2018-12-06 04:36:44 +01:00
|
|
|
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`,
|
2018-12-07 19:58:26 +01:00
|
|
|
userPermissions: ['MANAGE_MESSAGES'],
|
2018-12-06 04:36:44 +01:00
|
|
|
args: [
|
|
|
|
{
|
|
|
|
key: 'trigger',
|
|
|
|
prompt: 'What is the word to remove',
|
|
|
|
type: 'string',
|
|
|
|
}
|
|
|
|
]
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-12-06 18:50:18 +01:00
|
|
|
async run(message, { trigger }) {
|
2018-12-06 04:36:44 +01:00
|
|
|
if(blacklist[message.author.id])
|
|
|
|
return message.channel.send("You are blacklisted")
|
|
|
|
|
|
|
|
trigger = trigger.toLowerCase();
|
|
|
|
|
|
|
|
let customresponse = {}
|
|
|
|
let json = JSON.stringify(customresponse)
|
|
|
|
|
|
|
|
|
2018-12-06 23:01:40 +01:00
|
|
|
fs.readFile(`./tag/${message.guild.id}.json`, 'utf8', function readFileCallback(err, data){
|
2018-12-06 04:36:44 +01:00
|
|
|
if (err){
|
|
|
|
console.log(err);
|
|
|
|
} else {
|
|
|
|
customresponse = JSON.parse(data); //now it an object
|
2018-12-07 00:26:19 +01:00
|
|
|
delete customresponse[trigger]
|
2018-12-06 04:36:44 +01:00
|
|
|
json = JSON.stringify(customresponse); //convert it back to json
|
2018-12-06 23:01:40 +01:00
|
|
|
fs.writeFile(`./tag/${message.guild.id}.json`, json, 'utf8', function(err) {
|
2018-12-06 04:36:44 +01:00
|
|
|
if(err) {
|
|
|
|
return console.log(err);
|
|
|
|
}
|
|
|
|
})}});
|
|
|
|
|
|
|
|
return message.say(`The following autoresponse have been deleted: ${trigger}`);
|
|
|
|
}
|
|
|
|
};
|