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 toolkit•3y 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 docs•3y 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øŭł
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øŭł
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 docs•3y 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øŭł
SourceBin
Error
Instantly share your code with the world.
Dãrķ Søŭł
The error in terminal
Dãrķ Søŭł
SourceBin
Demote Command
Instantly share your code with the world.
Dãrķ Søŭł
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/luna•3y ago
you dont have permissions to add or remove the role
Dãrķ Søŭł
I do I have administrator
Vigintillion
Vigintillion•3y 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øŭł
it has administrator as well
Vigintillion
Vigintillion•3y ago
Make sure to check that the bot’s role is above the roles you’re adding
treble/luna
treble/luna•3y ago
that means nothing if the role it tries to add is higher than the bots highest role, it wont work
Dãrķ Søŭł
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 docs•3y 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øŭł
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/luna•3y ago
not possible with reply use what i said above you still have to reply though
Dãrķ Søŭł
above it says how to find or get a channel
treble/luna
treble/luna•3y ago
it does indeed
Dãrķ Søŭł
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 docs•3y ago
method TextChannel#send() Sends a message to this channel.
Dãrķ Søŭł
thank you!

Did you find this page helpful?