From 0d32686ffd4fff834e62b18e45655baa50185316 Mon Sep 17 00:00:00 2001 From: AnxietyisReal <96593068+AnxietyisReal@users.noreply.github.com> Date: Wed, 3 May 2023 07:35:43 +1000 Subject: [PATCH] Prepare for button roles. --- src/config.json | 1 + src/events/interactionCreate.ts | 11 +++++++++++ src/typings/interfaces.d.ts | 1 + 3 files changed, 13 insertions(+) diff --git a/src/config.json b/src/config.json index 55d6147..c02d469 100644 --- a/src/config.json +++ b/src/config.json @@ -14,6 +14,7 @@ "registerCommands": true, "commands": true, "logs": true, + "buttonRoles": true, "automod": true, "mpstats": true, "autores": true diff --git a/src/events/interactionCreate.ts b/src/events/interactionCreate.ts index ea9371e..b95334a 100644 --- a/src/events/interactionCreate.ts +++ b/src/events/interactionCreate.ts @@ -16,6 +16,17 @@ export default { return interaction.reply('An error occurred while executing that command.'); } } + } else if (interaction.isButton()){ + if (interaction.customId.startsWith('reaction-') && client.config.botSwitches.buttonRoles){ + const RoleID = interaction.customId.replace('reaction-',''); + if (interaction.member.roles.cache.has(RoleID)){ + interaction.member.roles.remove(RoleID); + interaction.reply({content: `You have been removed from <@&${RoleID}>`, ephemeral: true}) + } else { + interaction.member.roles.add(RoleID); + interaction.reply({content: `You have been added to <@&${RoleID}>`, ephemeral: true}) + } + } else console.log(client.logTime(), `Button pressed at ${interaction.message.url}`); } } } diff --git a/src/typings/interfaces.d.ts b/src/typings/interfaces.d.ts index c76a5ac..4fa71fe 100644 --- a/src/typings/interfaces.d.ts +++ b/src/typings/interfaces.d.ts @@ -151,6 +151,7 @@ interface botSwitches { registerCommands: boolean, commands: boolean, logs: boolean, + buttonRoles: boolean, automod: boolean, mpstats: boolean, autores: boolean