-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Discord command functionality for managing bot promotions
- Loading branch information
1 parent
df1c237
commit f8c7c8d
Showing
2 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} | ||
}, | ||
}; |