From 741fcd51a521fb188306cbde3f017f7dbc150c71 Mon Sep 17 00:00:00 2001 From: Loic Bersier Date: Thu, 6 Dec 2018 19:42:05 +0100 Subject: [PATCH] fixed tag --- commands/utility/tag.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/commands/utility/tag.js b/commands/utility/tag.js index f7fb364..b920c14 100644 --- a/commands/utility/tag.js +++ b/commands/utility/tag.js @@ -42,16 +42,13 @@ module.exports = class CustomResponseCommand extends Command { fs.readFile(`DiscordBot/tag/${message.guild.id}.json`, 'utf8', function readFileCallback(err, data){ if (err){ - console.log(err); - } else { - customresponse = JSON.parse(data); //now it an object - if (customresponse == '{}') { - fs.writeFile(`DiscordBot/tag/${message.guild.id}.json`, '{}', function (err) { + fs.writeFile(`DiscordBot/tag/${message.guild.id}.json`, `{"${trigger}":"${response}"}`, function (err) { if (err){ console.log(err); } }) - } + } else { + customresponse = JSON.parse(data); //now it an object customresponse [trigger] = response json = JSON.stringify(customresponse); //convert it back to json fs.writeFile(`DiscordBot/tag/${message.guild.id}.json`, json, 'utf8', function(err) {