1
0
Fork 0
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.
Haha-Yes/commands/admin/tag

56 lines
2.0 KiB
Plaintext

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',
group: 'admin',
6 years ago
memberName: 'tag',
userPermissions: ['ADMINISTRATOR'],
6 years ago
description: `Custom auto response`,
args: [
{
key: 'trigger',
prompt: 'Disable or enable?',
type: 'string',
},
{
key: 'response',
prompt: 'Disable or enable?',
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('--'))
let customresponse = {}
let json = JSON.stringify(customresponse)
6 years ago
6 years ago
fs.readFile('./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 }
json = JSON.stringify(customresponse); //convert it back to json
6 years ago
fs.writeFile('./json/customresponse.json', json, 'utf8', function(err) {
if(err) {
return console.log(err);
}
})}});
return message.say(`autoresponse have been set`);
}
};