forked from Supositware/Haha-Yes
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
2.0 KiB
Plaintext
65 lines
2.0 KiB
Plaintext
5 years ago
|
const { Command } = require('discord-akairo');
|
||
|
const TwitterBlacklist = require('../../models').TwitterBlacklist;
|
||
|
|
||
|
class TwitterBlacklistCommand extends Command {
|
||
|
constructor() {
|
||
|
super('TwitterBlacklist', {
|
||
|
aliases: ['TwitterBlacklist', 'twiBlacklist', 'tblacklist'],
|
||
|
category: 'owner',
|
||
|
ownerOnly: 'true',
|
||
|
userPermissions: ['MANAGE_MESSAGES'],
|
||
|
args: [
|
||
|
{
|
||
|
id: 'userID',
|
||
|
type: 'string',
|
||
|
prompt: {
|
||
|
start: 'Who do you want to blacklist?',
|
||
|
}
|
||
|
},
|
||
|
{
|
||
|
id: 'reason',
|
||
4 years ago
|
match: 'rest',
|
||
5 years ago
|
type: 'string',
|
||
|
default: 'no reasons provided',
|
||
|
prompt: {
|
||
|
start: 'What should the reason be?',
|
||
|
optional: true,
|
||
|
}
|
||
|
}
|
||
|
],
|
||
5 years ago
|
channel: 'guild',
|
||
5 years ago
|
description: {
|
||
5 years ago
|
content: 'Blacklist user from the twitter command',
|
||
|
usage: '[userID]',
|
||
|
examples: ['']
|
||
5 years ago
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
async exec(message, args) {
|
||
|
const blacklist = await TwitterBlacklist.findOne({where: {userID:args.userID}});
|
||
|
|
||
|
if (!blacklist) {
|
||
|
const body = {userID: args.userID, reason: args.reason};
|
||
|
TwitterBlacklist.create(body);
|
||
4 years ago
|
return message.channel.send(`The user with the following id have been blacklisted from the twitter command: ${args.userID}`);
|
||
5 years ago
|
} else {
|
||
|
message.channel.send('This user is already blacklisted, do you want to unblacklist him? y/n');
|
||
4 years ago
|
const filter = m => m.content && m.author.id === message.author.id;
|
||
5 years ago
|
message.channel.awaitMessages(filter, {time: 5000 * 1000, max: 1, errors: ['time'] })
|
||
|
.then(messages => {
|
||
|
let messageContent = messages.map(messages => messages.content);
|
||
4 years ago
|
if (messageContent[0] === 'y' || messageContent[0] === 'yes') {
|
||
5 years ago
|
TwitterBlacklist.destroy({where: {userID:args.userID}});
|
||
4 years ago
|
return message.channel.send(`The user with the following id have been unblacklisted from the twitter command: ${args.userID}`);
|
||
5 years ago
|
}
|
||
|
})
|
||
|
.catch(err => {
|
||
|
console.error(err);
|
||
|
return message.channel.send('Took too long to answer. didin\'t unblacklist anyone.');
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = TwitterBlacklistCommand;
|