2019-02-26 00:23:54 +01:00
|
|
|
const { Command } = require('discord-akairo');
|
|
|
|
const fs = require('fs');
|
|
|
|
|
|
|
|
class uncensorCommand extends Command {
|
|
|
|
constructor() {
|
|
|
|
super('uncensor', {
|
|
|
|
aliases: ['uncensor'],
|
|
|
|
category: 'owner',
|
|
|
|
ownerOnly: 'true',
|
|
|
|
args: [
|
|
|
|
{
|
|
|
|
id: 'word',
|
2019-02-26 15:10:34 +01:00
|
|
|
type: 'string',
|
|
|
|
match: 'rest'
|
2019-02-26 00:23:54 +01:00
|
|
|
}
|
|
|
|
],
|
|
|
|
description: {
|
|
|
|
content: 'Unensor word for twitter',
|
|
|
|
usage: '[word]',
|
|
|
|
examples: ['shit']
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async exec(message, args) {
|
|
|
|
let word = args.word;
|
2019-02-26 15:24:28 +01:00
|
|
|
|
|
|
|
word = word.toLowerCase();
|
|
|
|
|
2019-02-26 00:23:54 +01:00
|
|
|
let words = [];
|
|
|
|
let json = JSON.stringify(words);
|
|
|
|
|
2019-02-28 17:35:53 +01:00
|
|
|
fs.readFile('./json/uncensor.json', 'utf8', function readFileCallback(err, data) {
|
2019-02-26 00:23:54 +01:00
|
|
|
if (err) {
|
2019-02-28 17:35:53 +01:00
|
|
|
fs.writeFile('./json/uncensor.json', `["${word}"]`, function (err) {
|
2019-02-26 00:23:54 +01:00
|
|
|
if (err) {
|
|
|
|
|
|
|
|
console.log(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
words = JSON.parse(data); //now it an object
|
|
|
|
words.push(word);
|
|
|
|
json = JSON.stringify(words); //convert it back to json
|
2019-02-28 17:35:53 +01:00
|
|
|
fs.writeFile('./json/uncensor.json', json, 'utf8', function (err) {
|
2019-02-26 00:23:54 +01:00
|
|
|
if (err) {
|
|
|
|
return console.log(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return message.channel.send(`Uncensored the word ${word}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = uncensorCommand;
|