From cda60fbec0215fb5cd8dd311b1c55301f82b171d Mon Sep 17 00:00:00 2001 From: Braeden Sowinski Date: Tue, 13 Jun 2023 14:28:54 -0700 Subject: [PATCH] handle remove income role --- commands/config.js | 26 ++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/commands/config.js b/commands/config.js index e893861..4aa540d 100644 --- a/commands/config.js +++ b/commands/config.js @@ -745,6 +745,32 @@ module.exports = { } }, + RemoveIncomeRole: { + run: async (client, interaction, GuildDB) => { + if (!interaction.customId.endsWith(interaction.member.user.id)) { + return ButtonInteraction.reply({ + content: "This button is not for you", + flags: (1 << 6) + }) + } + let action = ''; + let roleId = interaction.customId.split('-')[2]; + if (interaction.customId.split('-')[1]=='yes') { + action = 'removed'; + let income = GuildDB.incemeRoles.find((i) => i.role == roleId); + client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$pull: {"server.incomeRoles": income}}, function(err, res) { + if (err) return client.sendInternalError(interaction, err); + }); + } else if (interaction.customId.split('-')[1]=='no') action = 'kept'; + + const successEmbed = new EmbedBuilder() + .setColor(client.config.Colors.Green) + .setDescription(`**Successfully ${action} <@&${roleId}> as an income role.**`) + + return interaction.update({ embeds: [successEmbed], components: [] }); + } + } + ResetSettings: { run: async (client, interaction, GuildDB) => { if (!interaction.customId.endsWith(interaction.member.user.id)) { diff --git a/package.json b/package.json index 08c29ff..6ff42f5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dayz-armbands", - "version": "7.1.1", + "version": "7.2.0", "description": "A General Purpose Discord Bot for DayZ Servers.", "main": "index.js", "nodemonConfig": {