Cannot figure out how to apply permissions to commands #7572
-
This is the code from the discordjs.guide, but I just can't get this to work. I've spent about 4 hours messing around with it but I'm just not sure: a) how to get a command's ID I'm following the command structure created here (https://discordjs.guide/creating-your-bot/command-handling.html#reading-command-files). Here's what my main.js looks like: https://pastebin.com/rz6BRs5R Help would be greatly appreciated, thank you! (also, is there a discord or something I can join? I haven't been able to find one) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
await guild.commands.fetch() to fetch all the commands, afterwards you can use const myKickCommandID = (await guild.commands.fetch()).find(command => command.name === "kick")?.id
after you've gotten a singular command, it's exactly like the guide, you call .permissions.add to it read the
this requires you to already have commands registered and you run this code once to add the permissions, maybe on the ready event and then after setting the permissions you can remove it right after.
Yes! Invite: https://discord.gg/djs |
Beta Was this translation helpful? Give feedback.
to fetch all the commands, afterwards you can use
find
to find the command via it'sname
and now you have a singular specific command available to you
now just accessing
command.id
would give you the idto apply that entirely it would be
after you've gotten a singular command, it's exactly like the guide, you call .permissions.add to it read the
docs
for more information on thisthis requires you to already have commands registered and you run thi…