Permissions & Roles
Make your app safer with permissions and roles, protect sensitive commands that could be abused by non-staff members
Permissions
client.on("interactionCreate", async interaction => {
// We're only using CommandInteraction here, this can be changed
// if you're manipulating other types of interaction
if (!(interaction instanceof CommandInteraction)) return;
const member = await interaction.member;
const memberPermissions = await member?.getPermission();
if (interaction.data.name === "purge") {
if (!memberPermissions?.includes(Permissions.CanManageChats)) {
return void interaction.createMessage({
content: "You do not have the necessary permission."
});
}
// [Your message purging logic here]
}
});Roles
Last updated