add rolebutton

This commit is contained in:
VALOU3336
2024-03-01 12:05:29 +01:00
parent 7ff8c0237f
commit 2b9c5efa33
20 changed files with 189 additions and 30 deletions
+30
View File
@@ -0,0 +1,30 @@
const {Events } = require("discord.js")
module.exports = {
name: Events.InteractionCreate,
async execute(interaction, client) {
const botId = client.user.id;
const customId = interaction.customId;
if (!customId.startsWith('rolebuttons_')) return;
const roleId = customId.split('_')[1];
const role = interaction.guild.roles.cache.get(roleId);
if (!role) {
return;
}
const member = interaction.member;
if (!member) {
return;
}
if (member.roles.cache.has(role.id)) {
await member.roles.remove(role);
await interaction.reply({ content: `Le rôle ${role.name} a été retiré.`, ephemeral: true });
} else {
await member.roles.add(role);
await interaction.reply({ content: `Le rôle ${role.name} a été ajouté.`, ephemeral: true });
}
},
};