aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-04-25 22:07:53 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-04-25 22:07:53 -0400
commit7264e7e2c9f9d55009dd40efc4e9aca418a7f137 (patch)
tree67c7e8606f64e9c3e3a93dca0a2686e210bf2614 /src
parent40f9581991e12082a2708fa8fdd454c080f67a4b (diff)
downloadtanzanite-7264e7e2c9f9d55009dd40efc4e9aca418a7f137.tar.gz
tanzanite-7264e7e2c9f9d55009dd40efc4e9aca418a7f137.tar.bz2
tanzanite-7264e7e2c9f9d55009dd40efc4e9aca418a7f137.zip
feat: hard coded button roles
Diffstat (limited to 'src')
-rw-r--r--src/listeners/interaction/interactionCreate.ts16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/listeners/interaction/interactionCreate.ts b/src/listeners/interaction/interactionCreate.ts
index f3b786c..e7a2944 100644
--- a/src/listeners/interaction/interactionCreate.ts
+++ b/src/listeners/interaction/interactionCreate.ts
@@ -23,7 +23,21 @@ export default class InteractionCreateListener extends BushListener {
const id = interaction.customId;
if (['paginate_', 'command_', 'confirmationPrompt_', 'appeal'].some((s) => id.startsWith(s))) return;
else if (id.startsWith('automod;')) void AutoMod.handleInteraction(interaction as BushButtonInteraction);
- else return await interaction.reply({ content: 'Buttons go brrr', ephemeral: true });
+ else if (id.startsWith('button-role;') && interaction.inCachedGuild()) {
+ const [, roleId] = id.split(';');
+ const role = interaction.guild.roles.cache.get(roleId);
+ if (!role) return interaction.reply({ content: `${util.emojis.error} That role does not exist.` });
+ const has = interaction.member.roles.cache.has(roleId);
+ if (has) {
+ const success = await interaction.member.roles.remove(roleId).catch(() => false);
+ if (success) return interaction.reply({ content: `${util.emojis.success} Removed ${role.name} from you.` });
+ else return interaction.reply({ content: `${util.emojis.error} Failed to remove ${role.name} from you.` });
+ } else {
+ const success = await interaction.member.roles.add(roleId).catch(() => false);
+ if (success) return interaction.reply({ content: `${util.emojis.success} Added ${role.name} to you.` });
+ else return interaction.reply({ content: `${util.emojis.error} Failed to add ${role.name} to you.` });
+ }
+ } else return await interaction.reply({ content: 'Buttons go brrr', ephemeral: true });
} else if (interaction.isSelectMenu()) {
if (interaction.customId.startsWith('command_')) return;
return await interaction.reply({