|
|
@ -30,28 +30,33 @@ class autoresponseCommand extends Command {
|
|
|
|
let text = args.text;
|
|
|
|
let text = args.text;
|
|
|
|
let all = args.all;
|
|
|
|
let all = args.all;
|
|
|
|
|
|
|
|
|
|
|
|
let autoresponse = {}
|
|
|
|
let autoresponse = {};
|
|
|
|
let json = JSON.stringify(autoresponse)
|
|
|
|
let json = JSON.stringify(autoresponse);
|
|
|
|
|
|
|
|
|
|
|
|
if (all == 'all') {
|
|
|
|
if (all == 'all') {
|
|
|
|
const guild = this.client.guilds.get(message.guild.id);
|
|
|
|
const guild = this.client.guilds.get(message.guild.id);
|
|
|
|
|
|
|
|
|
|
|
|
fs.readFile('./json/autoresponse.json', 'utf8', function readFileCallback(err, data) {
|
|
|
|
fs.readFile('./json/autoresponse.json', 'utf8', function readFileCallback(err, data) {
|
|
|
|
if (err) {
|
|
|
|
if (err) {
|
|
|
|
|
|
|
|
fs.close();
|
|
|
|
console.log(err);
|
|
|
|
console.log(err);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
autoresponse = JSON.parse(data); //now it an object
|
|
|
|
autoresponse = JSON.parse(data); //now it an object
|
|
|
|
guild.channels.forEach(channel => autoresponse [channel] = text)
|
|
|
|
guild.channels.forEach(channel => autoresponse[channel] = text);
|
|
|
|
json = JSON.stringify(autoresponse); //convert it back to json
|
|
|
|
json = JSON.stringify(autoresponse); //convert it back to json
|
|
|
|
json = json.replace(/[<#>]/g, '')
|
|
|
|
json = json.replace(/[<#>]/g, '');
|
|
|
|
fs.writeFile('./json/autoresponse.json', json, 'utf8', function (err) {
|
|
|
|
fs.writeFile('./json/autoresponse.json', json, 'utf8', function (err) {
|
|
|
|
if (err) {
|
|
|
|
if (err) {
|
|
|
|
|
|
|
|
fs.close();
|
|
|
|
return console.log(err);
|
|
|
|
return console.log(err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})}});
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return message.channel.send('Auto response have been disable/enable on every channel')
|
|
|
|
fs.close();
|
|
|
|
|
|
|
|
return message.channel.send('Auto response have been disable/enable on every channel');
|
|
|
|
|
|
|
|
|
|
|
|
} else if (text == 'disable' || 'enable') {
|
|
|
|
} else if (text == 'disable' || 'enable') {
|
|
|
|
fs.readFile('./json/autoresponse.json', 'utf8', function readFileCallback(err, data) {
|
|
|
|
fs.readFile('./json/autoresponse.json', 'utf8', function readFileCallback(err, data) {
|
|
|
@ -59,14 +64,20 @@ class autoresponseCommand extends Command {
|
|
|
|
console.log(err);
|
|
|
|
console.log(err);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
autoresponse = JSON.parse(data); //now it an object
|
|
|
|
autoresponse = JSON.parse(data); //now it an object
|
|
|
|
autoresponse [message.channel.id] = text
|
|
|
|
autoresponse[message.channel.id] = text;
|
|
|
|
json = JSON.stringify(autoresponse); //convert it back to json
|
|
|
|
json = JSON.stringify(autoresponse); //convert it back to json
|
|
|
|
fs.writeFile('./json/autoresponse.json', json, 'utf8', function (err) {
|
|
|
|
fs.writeFile('./json/autoresponse.json', json, 'utf8', function (err) {
|
|
|
|
if (err) {
|
|
|
|
if (err) {
|
|
|
|
|
|
|
|
fs.close();
|
|
|
|
return console.log(err);
|
|
|
|
return console.log(err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})}})};
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fs.close();
|
|
|
|
return message.channel.send(`Autoresponse have been ${text}d`);
|
|
|
|
return message.channel.send(`Autoresponse have been ${text}d`);
|
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
module.exports = autoresponseCommand;
|
|
|
|
module.exports = autoresponseCommand;
|