1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-12-27 20:35:38 -05:00

Check if member has Role A then remove before adding Role B

This commit is contained in:
toast-ts 2023-09-25 18:01:46 +10:00
parent 676fa61615
commit 56914a270a

View File

@ -18,15 +18,24 @@ export default {
}
}
} else if (interaction.isAutocomplete()){
const AC = client.commands.get(interaction.commandName);
try {
await AC.command.default.autocomplete(client, interaction)
await client.commands.get(interaction.commandName).command.default.autocomplete(client, interaction);
} catch (error){
return console.log('An error occurred while running autocomplete:\n', error)
}
} else if (interaction.isButton()){
if (interaction.customId.startsWith('reaction-') && client.config.botSwitches.buttonRoles){
const RoleID = interaction.customId.replace('reaction-','');
// Note: This is just a temporary "permanent" fix for the issue of people having both roles and less work for the mods.
let buttonRoleBlocked = 'Cannot have both roles! - Button Role';
if (interaction.member.roles.cache.has('1149139369433776269') && RoleID === '1149139583729160325') {
interaction.member.roles.add('1149139583729160325', buttonRoleBlocked);
interaction.member.roles.remove('1149139369433776269', buttonRoleBlocked);
} else if (interaction.member.roles.cache.has('1149139583729160325') && RoleID === '1149139369433776269') {
interaction.member.roles.add('1149139369433776269', buttonRoleBlocked);
interaction.member.roles.remove('1149139583729160325', buttonRoleBlocked);
}
if (interaction.member.roles.cache.has(RoleID)){
interaction.member.roles.remove(RoleID, 'Button Role');
interaction.reply({content: `You have been removed from <@&${RoleID}>`, ephemeral: true})