From a13219573d92173d4ec4cb962ef95a895a7d8d91 Mon Sep 17 00:00:00 2001 From: Braeden Sowinski Date: Tue, 19 Jul 2022 15:10:14 -0700 Subject: [PATCH] remove income function --- commands/remove-income.js | 61 +++++++++++++++++++++++++++++++++++++++ commands/set-income.js | 7 ++++- 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 commands/remove-income.js diff --git a/commands/remove-income.js b/commands/remove-income.js new file mode 100644 index 0000000..ff1857b --- /dev/null +++ b/commands/remove-income.js @@ -0,0 +1,61 @@ +const { MessageEmbed, Guild } = require('discord.js'); + +module.exports = { + name: "remove-income", + description: "remove an income role", + usage: "[role] [amount daily]", + permissions: { + channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"], + member: ["MANAGE_GUILD"], + }, + SlashCommand: { + options: [ + { + name: "role", + description: "role for this income", + value: "role", + type: 8, + required: true, + } + ], + /** + * + * @param {require("../structures/QuarksBot")} client + * @param {import("discord.js").MessageCreate} message + * @param {string[]} args + * @param {*} param3 + */ + run: async (client, interaction, args, { GuildDB }) => { + if (GuildDB.customChannelStatus==true&&!GuildDB.allowedChannels.includes(interaction.channel_id)) { + return interaction.send(`You are not allowed to use the bot in this channel.`); + } + + const searchIndex = roles.findIndex((role) => role.role==args[0].value); + if (searchIndex == -1) { + let embed = new MessageEmbed() + .setTitle('Role not found') + .setColor("RED"); + + return interaction.send({ embeds: [embed] }); + } else { + client.dbo.collection("guilds").updateOne({"server.serverID":Guild.serverID}, {$pull: {"server.incomeRoles": args[0].value}}, function(err, res) { + if (err) { + client.log(err); + let embed = new MessageEmbed() + .setTitle(err) + .setColor("RED"); + + return interaction.send({ embeds: [embed] }); + } + }); + } + + let successEmbed = new MessageEmbed() + .setTitle('Success') + .setDescription(`Successfully remoed <@&${args[0].value}> from income roles.`) + .setColor('GREEN'); + + return interaction.send({ embeds: [successEmbed] }); + }, + }, +} \ No newline at end of file diff --git a/commands/set-income.js b/commands/set-income.js index 2c492c2..a3c2b71 100644 --- a/commands/set-income.js +++ b/commands/set-income.js @@ -76,7 +76,12 @@ module.exports = { }); } - return interaction.send(`Set <@&${args[0].value}>'s income to $${args[1].value}`); + let successEmbed = new MessageEmbed() + .setTitle('Success') + .setDescription(`Set <@&${args[0].value}>'s income to $${args[1].value}`) + .setColor('GREEN'); + + return interaction.send({ embeds: [successEmbed] }); }, }, } \ No newline at end of file