diff --git a/commands/admin/tag b/commands/admin/tag.js similarity index 73% rename from commands/admin/tag rename to commands/admin/tag.js index 692badff..e0f4519a 100644 --- a/commands/admin/tag +++ b/commands/admin/tag.js @@ -5,19 +5,19 @@ module.exports = class CustomResponseCommand extends Command { constructor(client) { super(client, { name: 'tag', - group: 'admin', + aliases: ['customresponse'], + group: 'utility', memberName: 'tag', - userPermissions: ['ADMINISTRATOR'], description: `Custom auto response`, args: [ { key: 'trigger', - prompt: 'Disable or enable?', + prompt: 'The word that will trigger the autoresponse (use "--" instead of spaces)', type: 'string', }, { key: 'response', - prompt: 'Disable or enable?', + prompt: 'The response to the word ( you can use spaces here )', type: 'string', } ] @@ -38,14 +38,14 @@ module.exports = class CustomResponseCommand extends Command { let json = JSON.stringify(customresponse) - fs.readFile('./json/customresponse.json', 'utf8', function readFileCallback(err, data){ + fs.readFile('DiscordBot/json/customresponse.json', 'utf8', function readFileCallback(err, data){ if (err){ console.log(err); } else { customresponse = JSON.parse(data); //now it an object - customresponse [message.guild.id] = { 'text': trigger, 'response': response } + customresponse [trigger] = { 'response': response, 'server': message.guild.id } json = JSON.stringify(customresponse); //convert it back to json - fs.writeFile('./json/customresponse.json', json, 'utf8', function(err) { + fs.writeFile('DiscordBot/json/customresponse.json', json, 'utf8', function(err) { if(err) { return console.log(err); } diff --git a/index.js b/index.js index ae85f0cb..3a780d3b 100644 --- a/index.js +++ b/index.js @@ -97,10 +97,12 @@ client.registry if(autoresponse[message.channel.id] == 'enable') message.channel.send(responseObject[message_content]); // User autoresponse -// } else if(customresponse[message.guild.id]['text']) { -// var autoresponse = new SelfReloadJSON('DiscordBot/json/autoresponse.json'); -// if(autoresponse[message.channel.id] == 'enable') -// message.channel.send(customresponse[message.guild.id]['response']) + } else if(customresponse[message_content]) { + var autoresponse = new SelfReloadJSON('DiscordBot/json/autoresponse.json'); + if(autoresponse[message.channel.id] == 'enable') { + if(customresponse[message_content].server == message.guild.id) + message.channel.send(customresponse[message_content].response) + } // If it contain "like if" react with 👍 } else if (message_content.includes("like if")) { var autoresponse = new SelfReloadJSON('DiscordBot/json/autoresponse.json');