forked from Supositware/Haha-Yes
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
2.1 KiB
JavaScript
56 lines
2.1 KiB
JavaScript
6 years ago
|
const { Command } = require('discord.js-commando');
|
||
|
const blacklist = require('../../json/blacklist.json');
|
||
|
const fs = require('fs');
|
||
|
module.exports = class CustomResponseCommand extends Command {
|
||
|
constructor(client) {
|
||
|
super(client, {
|
||
6 years ago
|
name: 'tag',
|
||
6 years ago
|
aliases: ['customresponse'],
|
||
|
group: 'utility',
|
||
6 years ago
|
memberName: 'tag',
|
||
|
description: `Custom auto response`,
|
||
6 years ago
|
args: [
|
||
|
{
|
||
|
key: 'trigger',
|
||
6 years ago
|
prompt: 'The word that will trigger the autoresponse (use "--" instead of spaces)',
|
||
6 years ago
|
type: 'string',
|
||
|
},
|
||
|
{
|
||
|
key: 'response',
|
||
6 years ago
|
prompt: 'The response to the word ( you can use spaces here )',
|
||
6 years ago
|
type: 'string',
|
||
|
}
|
||
|
]
|
||
|
});
|
||
|
}
|
||
|
|
||
|
async run(message, { trigger, response }) {
|
||
|
if(blacklist[message.author.id])
|
||
|
return message.channel.send("You are blacklisted")
|
||
|
|
||
|
trigger = trigger.toLowerCase();
|
||
|
response = response.toLowerCase()
|
||
6 years ago
|
do {
|
||
|
trigger = trigger.replace('--', ' ')
|
||
|
} while (trigger.includes('--'))
|
||
|
|
||
6 years ago
|
let customresponse = {}
|
||
|
let json = JSON.stringify(customresponse)
|
||
|
|
||
6 years ago
|
|
||
6 years ago
|
fs.readFile('DiscordBot/json/customresponse.json', 'utf8', function readFileCallback(err, data){
|
||
6 years ago
|
if (err){
|
||
|
console.log(err);
|
||
|
} else {
|
||
|
customresponse = JSON.parse(data); //now it an object
|
||
6 years ago
|
customresponse [trigger] = { 'response': response, 'server': message.guild.id }
|
||
6 years ago
|
json = JSON.stringify(customresponse); //convert it back to json
|
||
6 years ago
|
fs.writeFile('DiscordBot/json/customresponse.json', json, 'utf8', function(err) {
|
||
6 years ago
|
if(err) {
|
||
|
return console.log(err);
|
||
|
}
|
||
|
})}});
|
||
|
|
||
6 years ago
|
return message.say(`autoresponse have been set to ${trigger} : ${response}`);
|
||
6 years ago
|
}
|
||
|
};
|