1
0
Fork 0

fixed an issue where we could put anything in the autoresponse

akairo
Supositware 5 years ago
parent 9dee4389c4
commit 829f73d2c7

@ -27,9 +27,10 @@ class autoresponseCommand extends Command {
}
async exec(message, args) {
let text = args.text;
let all = args.all;
let text = args.text.toLowerCase();
let all = args.all.toLowerCase();
if (text.toLowerCase() == 'enable' || text.toLowerCase() == 'disable') {
let autoresponse = {};
let json = JSON.stringify(autoresponse);
@ -43,7 +44,7 @@ class autoresponseCommand extends Command {
} else {
autoresponse = JSON.parse(data); //now it an object
guild.channels.forEach(channel => autoresponse[channel] = text);
guild.channels.forEach(channel => autoresponse[channel] = text.toLowerCase());
json = JSON.stringify(autoresponse); //convert it back to json
json = json.replace(/[<#>]/g, '');
fs.writeFile('./json/autoresponse.json', json, 'utf8', function (err) {
@ -58,13 +59,13 @@ class autoresponseCommand extends Command {
return message.channel.send('Auto response have been disable/enable on every channel');
} else if (text == 'disable' || 'enable') {
} else if (text.toLowerCase() == 'disable' || 'enable') {
fs.readFile('./json/autoresponse.json', 'utf8', function readFileCallback(err, data) {
if (err) {
console.log(err);
} else {
autoresponse = JSON.parse(data); //now it an object
autoresponse[message.channel.id] = text;
autoresponse[message.channel.id] = text.toLowerCase();
json = JSON.stringify(autoresponse); //convert it back to json
fs.writeFile('./json/autoresponse.json', json, 'utf8', function (err) {
if (err) {
@ -77,7 +78,11 @@ class autoresponseCommand extends Command {
}
return message.channel.send(`Autoresponse have been ${text}d`);
return message.channel.send(`Autoresponse have been ${text.toLowerCase()}d`);
} else {
return message.channel.send('You didin\'t type a valid input');
}
}
}
module.exports = autoresponseCommand;
Loading…
Cancel
Save