From f8c7c8d40edc78cdf6a0663e80809cf3640e30a1 Mon Sep 17 00:00:00 2001 From: Ioannis Andreopoulos <39243722+johnandreopoulos@users.noreply.github.com> Date: Fri, 10 Nov 2023 22:58:08 +0200 Subject: [PATCH] Implement Discord command functionality for managing bot promotions --- .../botlist/commands/Bot Reviewers/promote.js | 50 +++++++++++++++++++ .../commands/Bot Reviewers/unpromote.js | 50 +++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 discord/botlist/commands/Bot Reviewers/promote.js create mode 100644 discord/botlist/commands/Bot Reviewers/unpromote.js diff --git a/discord/botlist/commands/Bot Reviewers/promote.js b/discord/botlist/commands/Bot Reviewers/promote.js new file mode 100644 index 0000000..3aae67d --- /dev/null +++ b/discord/botlist/commands/Bot Reviewers/promote.js @@ -0,0 +1,50 @@ +const roles = global.config.server.roles; + +module.exports = { + name: "promote", + category: "Bot Reviewers", + cooldown: 2, + usage: "promote ", + description: "Promote a bot", + run: async (client, message, args) => { + let guild = client.guilds.cache.get(config.server.id); + if (guild.members.cache.has(message.author.id)) { + if (guild.members.cache.get(message.author.id).roles.cache.has(roles.botReviewer)) { + var bot = message.mentions.users.first(); + + if (bot) { + var botUser = bot; + } else { + var botID = args[0]; + var botUser = client.users.cache.get(botID); + } + + if (!botUser) { + return message.channel.send(":x: | You have given an invalid bot id or mention."); + } + + const botData = await botsdata.findOne({ + botID: botUser.id + }); + + if (!botData) { + return message.channel.send(":x: | You have given an invalid bot id or mention."); + } + + if (botData.promote) { + return message.channel.send("This bot is already promoted."); + } + + await botsdata.findOneAndUpdate({ + botID: botUser.id + }, { + $set: { + promote: true + }, + }); + + message.channel.send("Bot has been promoted"); + } + } + }, +}; diff --git a/discord/botlist/commands/Bot Reviewers/unpromote.js b/discord/botlist/commands/Bot Reviewers/unpromote.js new file mode 100644 index 0000000..f6c636b --- /dev/null +++ b/discord/botlist/commands/Bot Reviewers/unpromote.js @@ -0,0 +1,50 @@ +const roles = global.config.server.roles; + +module.exports = { + name: "unpromote", + category: "Bot Reviewers", + cooldown: 2, + usage: "unpromote ", + description: "Unpromote a bot", + run: async (client, message, args) => { + let guild = client.guilds.cache.get(config.server.id); + if (guild.members.cache.has(message.author.id)) { + if (guild.members.cache.get(message.author.id).roles.cache.has(roles.botReviewer)) { + var bot = message.mentions.users.first(); + + if (bot) { + var botUser = bot; + } else { + var botID = args[0]; + var botUser = client.users.cache.get(botID); + } + + if (!botUser) { + return message.channel.send(":x: | You have given an invalid bot id or mention."); + } + + const botData = await botsdata.findOne({ + botID: botUser.id + }); + + if (!botData) { + return message.channel.send(":x: | You have given an invalid bot id or mention."); + } + + if (!botData.promote) { + return message.channel.send("This bot is not promoted."); + } + + await botsdata.findOneAndUpdate({ + botID: botUser.id + }, { + $set: { + promote: false + }, + }); + + message.channel.send("Bot has been unpromoted"); + } + } + }, +}; \ No newline at end of file