From 656bfc5ce19a07f7d058e2d8b856817cef93639d Mon Sep 17 00:00:00 2001 From: Supositware Date: Tue, 26 Feb 2019 00:23:54 +0100 Subject: [PATCH] command to censor/uncensor --- commands/owner/twitter/censor.js | 57 ++++++++++++++++++++++++++++++ commands/owner/twitter/uncensor.js | 57 ++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 commands/owner/twitter/censor.js create mode 100644 commands/owner/twitter/uncensor.js diff --git a/commands/owner/twitter/censor.js b/commands/owner/twitter/censor.js new file mode 100644 index 0000000..c66a79a --- /dev/null +++ b/commands/owner/twitter/censor.js @@ -0,0 +1,57 @@ +const { Command } = require('discord-akairo'); +const fs = require('fs'); + +class censorCommand extends Command { + constructor() { + super('censor', { + aliases: ['censor'], + category: 'owner', + ownerOnly: 'true', + args: [ + { + id: 'word', + type: 'string' + } + ], + description: { + content: 'Censor word for twitter', + usage: '[word]', + examples: ['nigger'] + } + }); + } + + async exec(message, args) { + let word = args.word; + + word = word.toLowerCase(); + + let words = []; + let json = JSON.stringify(words); + + fs.readFile('./json/twitter/censor.json', 'utf8', function readFileCallback(err, data) { + if (err) { + fs.writeFile('./json/twitter/censor.json', `["${word}"]`, function (err) { + 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 + fs.writeFile('./json/twitter/censor.json', json, 'utf8', function (err) { + if (err) { + return console.log(err); + } + }); + } + }); + + + return message.channel.send(`censored the word ${word}`); + } +} + +module.exports = censorCommand; \ No newline at end of file diff --git a/commands/owner/twitter/uncensor.js b/commands/owner/twitter/uncensor.js new file mode 100644 index 0000000..c17ea06 --- /dev/null +++ b/commands/owner/twitter/uncensor.js @@ -0,0 +1,57 @@ +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', + type: 'string' + } + ], + description: { + content: 'Unensor word for twitter', + usage: '[word]', + examples: ['shit'] + } + }); + } + + async exec(message, args) { + let word = args.word; + + word = word.toLowerCase(); + + let words = []; + let json = JSON.stringify(words); + + fs.readFile('./json/twitter/uncensor.json', 'utf8', function readFileCallback(err, data) { + if (err) { + fs.writeFile('./json/twitter/uncensor.json', `["${word}"]`, function (err) { + 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 + fs.writeFile('./json/twitter/uncensor.json', json, 'utf8', function (err) { + if (err) { + return console.log(err); + } + }); + } + }); + + + return message.channel.send(`Uncensored the word ${word}`); + } +} + +module.exports = uncensorCommand; \ No newline at end of file