From 56914a270a5dbb66f2cf87850adaf0ba99107a69 Mon Sep 17 00:00:00 2001 From: toast-ts <96593068+toast-ts@users.noreply.github.com> Date: Mon, 25 Sep 2023 18:01:46 +1000 Subject: [PATCH] Check if member has Role A then remove before adding Role B --- src/events/interactionCreate.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/events/interactionCreate.ts b/src/events/interactionCreate.ts index 1b04132..afdd58e 100644 --- a/src/events/interactionCreate.ts +++ b/src/events/interactionCreate.ts @@ -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})