Bot discord | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Bot discord

So like I'm trying to create bot but I struck on roles. Let's say the server has 3 roles: admin, verifiedmember, and everyone. Admins have all roles. I want to make only admins to use a specific commands like "!mute". How to do that? I already know all ids for each role and member.

10th May 2020, 7:46 PM
Zahir Khodadin
Zahir Khodadin - avatar
4 Answers
+ 4
you could use if (!message.member.hasPermission("MUTE_MEMBERS")) { return message.reply( "❌ You can't use that." ); } Or just set up a verification system in your config file. That way you won't have to write that for each Moderator command. It'll be something like this exports.conf = { enabled: true, guildOnly: true, aliases: [], permLevel: "Administrator" };
11th May 2020, 12:26 AM
Jella
Jella - avatar
+ 1
Taken from https://anidiots.guide/understanding/roles : // assuming role.id is an actual ID of a valid role: if(message.member.roles.has(role.id)) { ... } else { ... }
10th May 2020, 10:40 PM
Schindlabua
Schindlabua - avatar
0
I use js
10th May 2020, 7:54 PM
Zahir Khodadin
Zahir Khodadin - avatar
0
the above code IS discordJS
27th Oct 2020, 9:16 PM
Isaac Whitaker
Isaac Whitaker - avatar