2018-12-05 21:34:43 +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, {
|
2018-12-06 01:30:35 +01:00
|
|
|
name: 'tag',
|
2018-12-05 21:34:43 +01:00
|
|
|
group: 'admin',
|
2018-12-06 01:30:35 +01:00
|
|
|
memberName: 'tag',
|
2018-12-05 21:34:43 +01:00
|
|
|
userPermissions: ['ADMINISTRATOR'],
|
2018-12-06 01:30:35 +01:00
|
|
|
description: `Custom auto response`,
|
2018-12-05 21:34:43 +01:00
|
|
|
args: [
|
|
|
|
{
|
|
|
|
key: 'trigger',
|
|
|
|
prompt: 'Disable or enable?',
|
|
|
|
type: 'string',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'response',
|
|
|
|
prompt: 'Disable or enable?',
|
|
|
|
type: 'string',
|
|
|
|
}
|
|
|
|
]
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async run(message, { trigger, response }) {
|
|
|
|
if(blacklist[message.author.id])
|
|
|
|
return message.channel.send("You are blacklisted")
|
|
|
|
|
|
|
|
trigger = trigger.toLowerCase();
|
|
|
|
response = response.toLowerCase()
|
2018-12-06 01:30:35 +01:00
|
|
|
do {
|
|
|
|
trigger = trigger.replace('--', ' ')
|
|
|
|
} while (trigger.includes('--'))
|
|
|
|
|
2018-12-05 21:34:43 +01:00
|
|
|
let customresponse = {}
|
|
|
|
let json = JSON.stringify(customresponse)
|
|
|
|
|
2018-12-06 01:30:35 +01:00
|
|
|
|
2018-12-05 23:31:03 +01:00
|
|
|
fs.readFile('./json/customresponse.json', 'utf8', function readFileCallback(err, data){
|
2018-12-05 21:34:43 +01:00
|
|
|
if (err){
|
|
|
|
console.log(err);
|
|
|
|
} else {
|
|
|
|
customresponse = JSON.parse(data); //now it an object
|
|
|
|
customresponse [message.guild.id] = { 'text': trigger, 'response': response }
|
|
|
|
json = JSON.stringify(customresponse); //convert it back to json
|
2018-12-05 23:31:03 +01:00
|
|
|
fs.writeFile('./json/customresponse.json', json, 'utf8', function(err) {
|
2018-12-05 21:34:43 +01:00
|
|
|
if(err) {
|
|
|
|
return console.log(err);
|
|
|
|
}
|
|
|
|
})}});
|
|
|
|
|
|
|
|
return message.say(`autoresponse have been set`);
|
|
|
|
}
|
|
|
|
};
|