Skip to content

Commit

Permalink
Implement Discord command functionality for managing bot promotions
Browse files Browse the repository at this point in the history
  • Loading branch information
johnandreopoulos committed Nov 10, 2023
1 parent df1c237 commit f8c7c8d
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
50 changes: 50 additions & 0 deletions discord/botlist/commands/Bot Reviewers/promote.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const roles = global.config.server.roles;

module.exports = {
name: "promote",
category: "Bot Reviewers",
cooldown: 2,
usage: "promote <bot>",
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");
}
}
},
};
50 changes: 50 additions & 0 deletions discord/botlist/commands/Bot Reviewers/unpromote.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const roles = global.config.server.roles;

module.exports = {
name: "unpromote",
category: "Bot Reviewers",
cooldown: 2,
usage: "unpromote <bot>",
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");
}
}
},
};

0 comments on commit f8c7c8d

Please sign in to comment.