forked from Supositware/Haha-Yes
Custom autoresponse
This commit is contained in:
parent
6080d91bcd
commit
50c73ddc0c
2 changed files with 13 additions and 11 deletions
|
@ -5,19 +5,19 @@ module.exports = class CustomResponseCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
super(client, {
|
super(client, {
|
||||||
name: 'tag',
|
name: 'tag',
|
||||||
group: 'admin',
|
aliases: ['customresponse'],
|
||||||
|
group: 'utility',
|
||||||
memberName: 'tag',
|
memberName: 'tag',
|
||||||
userPermissions: ['ADMINISTRATOR'],
|
|
||||||
description: `Custom auto response`,
|
description: `Custom auto response`,
|
||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
key: 'trigger',
|
key: 'trigger',
|
||||||
prompt: 'Disable or enable?',
|
prompt: 'The word that will trigger the autoresponse (use "--" instead of spaces)',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'response',
|
key: 'response',
|
||||||
prompt: 'Disable or enable?',
|
prompt: 'The response to the word ( you can use spaces here )',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -38,14 +38,14 @@ module.exports = class CustomResponseCommand extends Command {
|
||||||
let json = JSON.stringify(customresponse)
|
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){
|
if (err){
|
||||||
console.log(err);
|
console.log(err);
|
||||||
} else {
|
} else {
|
||||||
customresponse = JSON.parse(data); //now it an object
|
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
|
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) {
|
if(err) {
|
||||||
return console.log(err);
|
return console.log(err);
|
||||||
}
|
}
|
10
index.js
10
index.js
|
@ -97,10 +97,12 @@ client.registry
|
||||||
if(autoresponse[message.channel.id] == 'enable')
|
if(autoresponse[message.channel.id] == 'enable')
|
||||||
message.channel.send(responseObject[message_content]);
|
message.channel.send(responseObject[message_content]);
|
||||||
// User autoresponse
|
// User autoresponse
|
||||||
// } else if(customresponse[message.guild.id]['text']) {
|
} else if(customresponse[message_content]) {
|
||||||
// var autoresponse = new SelfReloadJSON('DiscordBot/json/autoresponse.json');
|
var autoresponse = new SelfReloadJSON('DiscordBot/json/autoresponse.json');
|
||||||
// if(autoresponse[message.channel.id] == 'enable')
|
if(autoresponse[message.channel.id] == 'enable') {
|
||||||
// message.channel.send(customresponse[message.guild.id]['response'])
|
if(customresponse[message_content].server == message.guild.id)
|
||||||
|
message.channel.send(customresponse[message_content].response)
|
||||||
|
}
|
||||||
// If it contain "like if" react with 👍
|
// If it contain "like if" react with 👍
|
||||||
} else if (message_content.includes("like if")) {
|
} else if (message_content.includes("like if")) {
|
||||||
var autoresponse = new SelfReloadJSON('DiscordBot/json/autoresponse.json');
|
var autoresponse = new SelfReloadJSON('DiscordBot/json/autoresponse.json');
|
||||||
|
|
Loading…
Reference in a new issue