From ba399e45b4d97dae06ca696d5a61f425391be64a Mon Sep 17 00:00:00 2001 From: Loic Bersier Date: Thu, 6 Dec 2018 04:36:44 +0100 Subject: [PATCH] Can now untag autoresponse --- commands/utility/unstag.js | 47 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 commands/utility/unstag.js diff --git a/commands/utility/unstag.js b/commands/utility/unstag.js new file mode 100644 index 0000000..3fc6db5 --- /dev/null +++ b/commands/utility/unstag.js @@ -0,0 +1,47 @@ +const { Command } = require('discord.js-commando'); +const blacklist = require('../../json/blacklist.json'); +const fs = require('fs'); +module.exports = class CustomResponseCommand extends Command { + constructor(client) { + super(client, { + name: 'untag', + aliases: ['rmcustomresponse'], + group: 'utility', + memberName: 'untag', + description: `remove custom autoresponse`, + args: [ + { + key: 'trigger', + prompt: 'What is the word to remove', + type: 'string', + } + ] + }); + } + + async run(message, { trigger, response }) { + if(blacklist[message.author.id]) + return message.channel.send("You are blacklisted") + + trigger = trigger.toLowerCase(); + + let customresponse = {} + let json = JSON.stringify(customresponse) + + + fs.readFile('DiscordBot/json/customresponse.json', 'utf8', function readFileCallback(err, data){ + if (err){ + console.log(err); + } else { + customresponse = JSON.parse(data); //now it an object + customresponse [trigger] = { 'response': '', 'server': '' } + json = JSON.stringify(customresponse); //convert it back to json + fs.writeFile('DiscordBot/json/customresponse.json', json, 'utf8', function(err) { + if(err) { + return console.log(err); + } + })}}); + + return message.say(`The following autoresponse have been deleted: ${trigger}`); + } +}; \ No newline at end of file