2019-10-06 20:29:50 +02:00
|
|
|
const { Command } = require('discord-akairo');
|
|
|
|
const userBlacklist = require('../../models').userBlacklist;
|
|
|
|
|
|
|
|
class blacklistCommand extends Command {
|
|
|
|
constructor() {
|
|
|
|
super('blacklist', {
|
|
|
|
aliases: ['blacklist'],
|
|
|
|
category: 'owner',
|
|
|
|
ownerOnly: 'true',
|
|
|
|
userPermissions: ['MANAGE_MESSAGES'],
|
|
|
|
args: [
|
|
|
|
{
|
|
|
|
id: 'userID',
|
|
|
|
type: 'string',
|
|
|
|
prompt: {
|
|
|
|
start: 'Who do you want to blacklist?',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
2020-03-19 23:24:31 +01:00
|
|
|
channel: 'guild',
|
2019-10-06 20:29:50 +02:00
|
|
|
description: {
|
2019-10-06 20:38:06 +02:00
|
|
|
content: 'Blacklist user from the bot',
|
|
|
|
usage: '[userID]',
|
|
|
|
examples: ['']
|
2019-10-06 20:29:50 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async exec(message, args) {
|
2019-12-28 21:06:07 +01:00
|
|
|
const blacklist = await userBlacklist.findOne({where: {userID:args.userID}});
|
2019-10-06 20:29:50 +02:00
|
|
|
|
|
|
|
if (!blacklist) {
|
|
|
|
const body = {userID: args.userID};
|
|
|
|
userBlacklist.create(body);
|
2020-05-08 01:26:09 +02:00
|
|
|
return message.channel.send(`The following ID have been blacklisted: ${args.userID}`);
|
2019-10-06 20:29:50 +02:00
|
|
|
} else {
|
|
|
|
message.channel.send('This user is already blacklisted, do you want to unblacklist him? y/n');
|
2020-05-02 00:10:44 +02:00
|
|
|
const filter = m => m.content && m.author.id === message.author.id;
|
2019-10-06 20:29:50 +02:00
|
|
|
message.channel.awaitMessages(filter, {time: 5000 * 1000, max: 1, errors: ['time'] })
|
|
|
|
.then(messages => {
|
2020-05-08 01:26:09 +02:00
|
|
|
console.log(messages);
|
2019-10-06 20:29:50 +02:00
|
|
|
let messageContent = messages.map(messages => messages.content);
|
2020-05-08 01:26:09 +02:00
|
|
|
console.log(messageContent);
|
|
|
|
if (messageContent[0] === 'y' || messageContent[0] === 'yes') {
|
2019-10-06 20:29:50 +02:00
|
|
|
userBlacklist.destroy({where: {userID:args.userID}});
|
2020-05-08 01:26:09 +02:00
|
|
|
return message.channel.send(`The following ID have been unblacklisted: ${args.userID}`);
|
2019-10-06 20:29:50 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
console.error(err);
|
|
|
|
return message.channel.send('Took too long to answer. didin\'t unblacklist anyone.');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = blacklistCommand;
|