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