Custom autoresponse

This commit is contained in:
Loic Bersier 2018-12-06 04:18:21 +01:00
parent 6080d91bcd
commit 50c73ddc0c
2 changed files with 13 additions and 11 deletions

View file

@ -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);
}

View file

@ -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');