2020-02-24 14:31:52 +01:00
|
|
|
const { Command } = require('discord-akairo');
|
|
|
|
const whitelistWord = require('../../models').whitelistWord;
|
|
|
|
|
|
|
|
class whitelistWordCommand extends Command {
|
|
|
|
constructor() {
|
|
|
|
super('whitelistWord', {
|
2020-02-24 14:34:04 +01:00
|
|
|
aliases: ['whitelistWord', 'unwhitelistword'],
|
2020-02-24 14:31:52 +01:00
|
|
|
category: 'admin',
|
|
|
|
userPermissions: ['MANAGE_MESSAGES'],
|
|
|
|
clientPermissions: ['MANAGE_MESSAGES', 'SEND_MESSAGES'],
|
|
|
|
args: [
|
|
|
|
{
|
|
|
|
id: 'word',
|
|
|
|
type: 'string',
|
|
|
|
match: 'rest'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'remove',
|
|
|
|
match: 'flag',
|
|
|
|
flag: '--remove'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'removeall',
|
|
|
|
match: 'flag',
|
|
|
|
flag: '--removeall'
|
|
|
|
}
|
|
|
|
],
|
|
|
|
channelRestriction: 'guild',
|
|
|
|
description: {
|
2020-02-24 14:34:04 +01:00
|
|
|
content: 'Whitelist word so it is not affected by the banned word, unwhitelistword alias and --removeaall to remove every banned whitelisted word',
|
|
|
|
usage: '[word to whitelist]',
|
|
|
|
examples: ['sexuality']
|
2020-02-24 14:31:52 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async exec(message, args) {
|
|
|
|
if (!args.word) args.word = '';
|
|
|
|
args.word = args.word.replace(/[\u0250-\ue007]/g, '');
|
|
|
|
const WhitelistWord = await whitelistWord.findOne({where: {word: args.word.toLowerCase(), serverID: message.guild.id}});
|
|
|
|
|
2020-02-24 14:34:04 +01:00
|
|
|
if (message.util.parsed.alias == 'unwhitelistword') {
|
2020-02-24 14:31:52 +01:00
|
|
|
if (args.removeall) {
|
|
|
|
whitelistWord.destroy({where: {serverID: message.guild.id}});
|
|
|
|
return message.channel.send('The whitelisted words has been reset.');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (WhitelistWord) {
|
|
|
|
whitelistWord.destroy({where: {word: args.word.toLowerCase(), serverID: message.guild.id}});
|
|
|
|
return message.channel.send(`The word ${args.word.toLowerCase()} is no longer whitelisted`);
|
|
|
|
} else {
|
|
|
|
return message.channel.send('There was no word to whiteliste');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!args.word) return message.channel.send('Please specify a word to whiteliste!');
|
|
|
|
|
|
|
|
if (!WhitelistWord) {
|
|
|
|
const body = {word: args.word.toLowerCase(), serverID: message.guild.id};
|
|
|
|
await whitelistWord.create(body);
|
|
|
|
return message.channel.send(`The word ${args.word.toLowerCase()} has been whitelisted`);
|
|
|
|
} else {
|
|
|
|
message.channel.send('This word is already whitelisted');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = whitelistWordCommand;
|