From af3d618591b2539560e46566a179f1ae47f056ea Mon Sep 17 00:00:00 2001 From: loicbersier Date: Sun, 21 Oct 2018 20:46:57 +0200 Subject: [PATCH] Can disable autoresponse --- commands/admin/{autoresponse => autoresponse.js} | 6 +++--- index.js | 16 ++++++++++++++++ package.json | 1 + 3 files changed, 20 insertions(+), 3 deletions(-) rename commands/admin/{autoresponse => autoresponse.js} (89%) diff --git a/commands/admin/autoresponse b/commands/admin/autoresponse.js similarity index 89% rename from commands/admin/autoresponse rename to commands/admin/autoresponse.js index 89feb6bf..a497b1e0 100644 --- a/commands/admin/autoresponse +++ b/commands/admin/autoresponse.js @@ -8,11 +8,11 @@ module.exports = class sayCommand extends Command { group: 'admin', memberName: 'autoresponse', userPermissions: ['MANAGE_MESSAGES'], - description: `Repeat the text you send`, + description: `Can disable autoresponse in the channel`, args: [ { key: 'text', - prompt: 'What do you want me to say', + prompt: 'Disable or enable?', type: 'string', oneOf: ['disable', 'enable'], } @@ -40,6 +40,6 @@ module.exports = class sayCommand extends Command { } })}}); - message.say(text); + message.say(`Autoresponse have been ${text}d`); } }; \ No newline at end of file diff --git a/index.js b/index.js index 1517fa03..e18088af 100644 --- a/index.js +++ b/index.js @@ -5,6 +5,7 @@ const { token, prefix, statsChannel, ownerID, supportServer } = require('./confi const responseObject = require("./json/reply.json"); const reactObject = require("./json/react.json"); const imgResponseObject = require("./json/imgreply.json"); +var SelfReloadJSON = require('self-reload-json'); // Prefix and ownerID and invite to support server const client = new CommandoClient({ commandPrefix: prefix, @@ -80,18 +81,33 @@ client.registry if (message.author.bot) return; { // Reply with images as attachement if(imgResponseObject[message_content]) { + var autoresponse = new SelfReloadJSON('./json/autoresponse.json'); + if(autoresponse[message.channel.id] == 'disable') + return console.log('disable') message.channel.send({files: [imgResponseObject[message_content]]}); } // React only to the messages else if(reactObject[message_content]) { + var autoresponse = new SelfReloadJSON('./json/autoresponse.json'); + if(autoresponse[message.channel.id] == 'disable') + return console.log('disable') message.react(reactObject[message_content]); } // auto respond to messages else if(responseObject[message_content]) { + var autoresponse = new SelfReloadJSON('./json/autoresponse.json'); + if(autoresponse[message.channel.id] == 'disable') + return console.log('disable') message.channel.send(responseObject[message_content]); } else if (message_content.includes("like if")) { + var autoresponse = new SelfReloadJSON('./json/autoresponse.json'); + if(autoresponse[message.channel.id] == 'disable') + return console.log('disable') message.react("\u{1F44D}") } else if (message_content.includes("jeff")) { + var autoresponse = new SelfReloadJSON('./json/autoresponse.json'); + if(autoresponse[message.channel.id] == 'disable') + return console.log('disable') message.react("496028845967802378") } }}); diff --git a/package.json b/package.json index 7117938b..c426ba3d 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "discord.js-commando": "^0.10.0", "faceapp": "^0.4.4", "node-fetch": "^2.2.0", + "self-reload-json": "^0.4.0", "superagent": "^4.0.0-beta.5", "ytdl-core": "^0.26.1" }