This commit is contained in:
Loic Bersier 2018-12-05 19:22:04 +01:00
parent 14526f731b
commit 20c83db125

View file

@ -36,7 +36,7 @@ module.exports = class AutoresponseCommand extends Command {
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('DiscordBot/json/autoresponse.json', 'utf8', function readFileCallback(err, data){
if (err){ if (err){
console.log(err); console.log(err);
} else { } else {
@ -44,7 +44,7 @@ module.exports = class AutoresponseCommand extends Command {
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('DiscordBot/json/autoresponse.json', json, 'utf8', function(err) {
if(err) { if(err) {
return console.log(err); return console.log(err);
} }
@ -52,14 +52,14 @@ module.exports = class AutoresponseCommand extends Command {
return message.say('Auto response have been disable/enable on every channel') return message.say('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('DiscordBot/json/autoresponse.json', 'utf8', function readFileCallback(err, data){
if (err){ if (err){
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('DiscordBot/json/autoresponse.json', json, 'utf8', function(err) {
if(err) { if(err) {
return console.log(err); return console.log(err);
} }