Demote Command doesn't work.

So I have a demote slash command and when someone runs the command I want to check if they actually have the role to run the command so if they dont have it denies it. But for one reason the if statement doesn't work
25 Replies
d.js toolkit
d.js toolkit17mo ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
d.js docs
d.js docs17mo ago
To help you we need more information: - What are you trying to do? - What is your code? - What errors and debug logs do you have?
Dãrķ Søŭł
Dãrķ SøŭłOP17mo ago
I am trying to make a demote command for my staff manager bot. I will provide the command as file. I will explain the error after I send the command file
Dãrķ Søŭł
Dãrķ SøŭłOP17mo ago
so basically when I try to debug it and I remove the staff manager role from me so I can get denied it works just fine, but when I put back my role to try again to see that the bot will actually demote the person it doesn't work
d.js docs
d.js docs17mo ago
To share long code snippets use a service like gist, sourcebin, starbin, or similar instead of posting them as large code blocks.
Dãrķ Søŭł
Dãrķ SøŭłOP17mo ago
SourceBin
Error
Instantly share your code with the world.
Dãrķ Søŭł
Dãrķ SøŭłOP17mo ago
The error in terminal
Dãrķ Søŭł
Dãrķ SøŭłOP17mo ago
SourceBin
Demote Command
Instantly share your code with the world.
Dãrķ Søŭł
Dãrķ SøŭłOP17mo ago
the command code so why the if works when I dont have the role and it continues with the else statement but when I have the role the if statement doesn't work?
treble/luna
treble/luna17mo ago
you dont have permissions to add or remove the role
Dãrķ Søŭł
Dãrķ SøŭłOP17mo ago
I do I have administrator
Vigintillion
Vigintillion17mo ago
Add a try catch to it or a .catch() to check if missing permissions or add an if statement at the start to check for permission The bot doesnt have permission
Dãrķ Søŭł
Dãrķ SøŭłOP17mo ago
it has administrator as well
Vigintillion
Vigintillion17mo ago
Make sure to check that the bot’s role is above the roles you’re adding
treble/luna
treble/luna17mo ago
that means nothing if the role it tries to add is higher than the bots highest role, it wont work
Dãrķ Søŭł
Dãrķ SøŭłOP17mo ago
I just moved the role on top of the list, let me try again it works thank you also how can I make the bot to send an embed to a specific channel? and not in the channel the command was runned
d.js docs
d.js docs17mo ago
const channel = client.channels.cache.get("222086648706498562");
const channel = guild.channels.cache.find(channel => channel.name === "general");
const channel = client.channels.cache.get("222086648706498562");
const channel = guild.channels.cache.find(channel => channel.name === "general");
- Caches in discord.js are Collections which extend the native Map structure. - learn more
Dãrķ Søŭł
Dãrķ SøŭłOP17mo ago
I know how to do that, I don't know how to send the embed in different channel from the one the user send it I use interaction.reply?
treble/luna
treble/luna17mo ago
not possible with reply use what i said above you still have to reply though
Dãrķ Søŭł
Dãrķ SøŭłOP17mo ago
above it says how to find or get a channel
treble/luna
treble/luna17mo ago
it does indeed
Dãrķ Søŭł
Dãrķ SøŭłOP17mo ago
it doesn't say how to send the embed to the channel, I have the channel already or I am dumb and I can't understand it
d.js docs
d.js docs17mo ago
method TextChannel#send() Sends a message to this channel.
Dãrķ Søŭł
Dãrķ SøŭłOP17mo ago
thank you!
Want results from more Discord servers?
Add your server