This repository has been archived by the owner on Aug 28, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Unknown
committed
Dec 31, 2017
1 parent
24eea41
commit 266d64b
Showing
2 changed files
with
43 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,36 @@ | ||
const { Command } = require('klasa'); | ||
const { Guild } = require('discord.js'); | ||
|
||
module.exports = class extends Command { | ||
|
||
constructor(...args) { | ||
super(...args, { | ||
permLevel: 10, | ||
description: (msg) => msg.language.get('COMMAND_BLACKLIST_DESCRIPTION'), | ||
usage: '<User:user|Guild:guild> [...]', | ||
usageDelim: ' ' | ||
}); | ||
} | ||
|
||
async run(msg, usersAndGuilds) { | ||
usersAndGuilds = new Set(usersAndGuilds); | ||
const usersAdded = []; | ||
const usersRemoved = []; | ||
const guildsAdded = []; | ||
const guildsRemoved = []; | ||
|
||
for (const userOrGuild of usersAndGuilds) { | ||
const type = userOrGuild instanceof Guild ? 'guild' : 'user'; | ||
|
||
await this.client.configs.update(`${type}Blacklist`, userOrGuild.id, msg.guild); | ||
|
||
if (type === 'guild' && this.client.guildBlacklist.includes(userOrGuild.id)) guildsAdded.push(userOrGuild.name); | ||
else if (type === 'guild') guildsRemoved.push(userOrGuild.name); | ||
else if (type === 'user' && this.client.userBlacklist.includes(userOrGuild.id)) usersAdded.push(userOrGuild.username); | ||
else usersRemoved.push(userOrGuild.username); | ||
} | ||
|
||
return msg.sendMessage(msg.language.get('COMMAND_BLACKLIST_SUCCESS', usersAdded, usersRemoved, guildsAdded, guildsRemoved)); | ||
} | ||
|
||
}; |
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