forked from Supositware/Haha-Yes
Auto response can be deactivated
This commit is contained in:
parent
05d036d6c5
commit
fff134bbb8
2 changed files with 58 additions and 0 deletions
47
commands/admin/autoresponse.js
Normal file
47
commands/admin/autoresponse.js
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
const { Command } = require('discord.js-commando');
|
||||||
|
const blacklist = require('../../json/blacklist.json');
|
||||||
|
const fs = require('fs');
|
||||||
|
const autoresponse = require('../../json/autoresponse.json')
|
||||||
|
|
||||||
|
module.exports = class sayCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'autoresponse',
|
||||||
|
group: 'admin',
|
||||||
|
memberName: 'autoresponse',
|
||||||
|
userPermissions: ['MANAGE_MESSAGES'],
|
||||||
|
description: `Repeat the text you send`,
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
key: 'text',
|
||||||
|
prompt: 'What do you want me to say',
|
||||||
|
type: 'string',
|
||||||
|
oneOf: ['disable', 'enable'],
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(message, { text }) {
|
||||||
|
if(blacklist[message.author.id])
|
||||||
|
return message.channel.send("You are blacklisted")
|
||||||
|
|
||||||
|
let test = {}
|
||||||
|
let json = JSON.stringify(test)
|
||||||
|
|
||||||
|
fs.readFile('json/autoresponse.json', 'utf8', function readFileCallback(err, data){
|
||||||
|
if (err){
|
||||||
|
console.log(err);
|
||||||
|
} else {
|
||||||
|
test = JSON.parse(data); //now it an object
|
||||||
|
test [message.channel.id] = text
|
||||||
|
json = JSON.stringify(test); //convert it back to json
|
||||||
|
fs.writeFile('json/autoresponse.json', json, 'utf8', function(err) {
|
||||||
|
if(err) {
|
||||||
|
return console.log(err);
|
||||||
|
}
|
||||||
|
})}});
|
||||||
|
|
||||||
|
message.say(text);
|
||||||
|
}
|
||||||
|
};
|
11
index.js
11
index.js
|
@ -5,6 +5,7 @@ const { token, prefix, statsChannel, ownerID, supportServer } = require('./confi
|
||||||
const responseObject = require("./json/reply.json");
|
const responseObject = require("./json/reply.json");
|
||||||
const reactObject = require("./json/react.json");
|
const reactObject = require("./json/react.json");
|
||||||
const imgResponseObject = require("./json/imgreply.json");
|
const imgResponseObject = require("./json/imgreply.json");
|
||||||
|
const autoresponse = require("./json/autoresponse.json");
|
||||||
|
|
||||||
// Prefix and ownerID and invite to support server
|
// Prefix and ownerID and invite to support server
|
||||||
const client = new CommandoClient({
|
const client = new CommandoClient({
|
||||||
|
@ -81,18 +82,28 @@ client.registry
|
||||||
if (message.author.bot) return; {
|
if (message.author.bot) return; {
|
||||||
// Reply with images as attachement
|
// Reply with images as attachement
|
||||||
if(imgResponseObject[message_content]) {
|
if(imgResponseObject[message_content]) {
|
||||||
|
if(autoresponse[message.channel.id] == 'disable')
|
||||||
|
return message.channel.send('test')
|
||||||
message.channel.send({files: [imgResponseObject[message_content]]});
|
message.channel.send({files: [imgResponseObject[message_content]]});
|
||||||
}
|
}
|
||||||
// React only to the messages
|
// React only to the messages
|
||||||
else if(reactObject[message_content]) {
|
else if(reactObject[message_content]) {
|
||||||
|
if(autoresponse[message.channel.id] == 'disable')
|
||||||
|
return message.channel.send('test')
|
||||||
message.react(reactObject[message_content]);
|
message.react(reactObject[message_content]);
|
||||||
}
|
}
|
||||||
// auto respond to messages
|
// auto respond to messages
|
||||||
else if(responseObject[message_content]) {
|
else if(responseObject[message_content]) {
|
||||||
|
if(autoresponse[message.channel.id] == 'disable')
|
||||||
|
return message.channel.send('test')
|
||||||
message.channel.send(responseObject[message_content]);
|
message.channel.send(responseObject[message_content]);
|
||||||
} else if (message_content.includes("like if")) {
|
} else if (message_content.includes("like if")) {
|
||||||
|
if(autoresponse[message.channel.id] == 'disable')
|
||||||
|
return message.channel.send('test')
|
||||||
message.react("\u{1F44D}")
|
message.react("\u{1F44D}")
|
||||||
} else if (message_content.includes("jeff")) {
|
} else if (message_content.includes("jeff")) {
|
||||||
|
if(autoresponse[message.channel.id] == 'disable')
|
||||||
|
return message.channel.send('test')
|
||||||
message.react("496028845967802378")
|
message.react("496028845967802378")
|
||||||
}
|
}
|
||||||
}});
|
}});
|
||||||
|
|
Loading…
Reference in a new issue