moved to admin
This commit is contained in:
parent
72bf53d4e7
commit
b45201af39
2 changed files with 110 additions and 0 deletions
62
commands/admin/tag.js
Normal file
62
commands/admin/tag.js
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
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, {
|
||||||
|
name: 'tag',
|
||||||
|
aliases: ['customresponse'],
|
||||||
|
group: 'utility',
|
||||||
|
memberName: 'tag',
|
||||||
|
description: `Custom auto response`,
|
||||||
|
userPermissions: ['MANAGE_MESSAGES'],
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
key: 'trigger',
|
||||||
|
prompt: 'The word that will trigger the autoresponse (use "--" instead of spaces)',
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'response',
|
||||||
|
prompt: 'The response to the word ( you can use spaces here )',
|
||||||
|
type: 'string',
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(message, { trigger, response }) {
|
||||||
|
if(blacklist[message.author.id])
|
||||||
|
return message.channel.send("You are blacklisted")
|
||||||
|
|
||||||
|
trigger = trigger.toLowerCase();
|
||||||
|
do {
|
||||||
|
trigger = trigger.replace('--', ' ')
|
||||||
|
} while (trigger.includes('--'))
|
||||||
|
|
||||||
|
let customresponse = {}
|
||||||
|
let json = JSON.stringify(customresponse)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
fs.readFile(`./tag/${message.guild.id}.json`, 'utf8', function readFileCallback(err, data){
|
||||||
|
if (err){
|
||||||
|
fs.writeFile(`./tag/${message.guild.id}.json`, `{"${trigger}": {"response":"${response}","owner":"${message.author.id}"}}`, function (err) {
|
||||||
|
if (err){
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
customresponse = JSON.parse(data); //now it an object
|
||||||
|
customresponse.trigger = `response":${response},"owner":"${message.author.id}`
|
||||||
|
json = JSON.stringify(customresponse); //convert it back to json
|
||||||
|
fs.writeFile(`./tag/${message.guild.id}.json`, json, 'utf8', function(err) {
|
||||||
|
if(err) {
|
||||||
|
return console.log(err);
|
||||||
|
}
|
||||||
|
})}});
|
||||||
|
|
||||||
|
return message.say(`autoresponse have been set to ${trigger} : ${response}`);
|
||||||
|
}
|
||||||
|
};
|
48
commands/admin/untag.js
Normal file
48
commands/admin/untag.js
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
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, {
|
||||||
|
name: 'untag',
|
||||||
|
aliases: ['rmcustomresponse'],
|
||||||
|
group: 'admin',
|
||||||
|
memberName: 'untag',
|
||||||
|
description: `remove custom autoresponse`,
|
||||||
|
userPermissions: ['MANAGE_MESSAGES'],
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
key: 'trigger',
|
||||||
|
prompt: 'What is the word to remove',
|
||||||
|
type: 'string',
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(message, { trigger }) {
|
||||||
|
if(blacklist[message.author.id])
|
||||||
|
return message.channel.send("You are blacklisted")
|
||||||
|
|
||||||
|
trigger = trigger.toLowerCase();
|
||||||
|
|
||||||
|
let customresponse = {}
|
||||||
|
let json = JSON.stringify(customresponse)
|
||||||
|
|
||||||
|
|
||||||
|
fs.readFile(`./tag/${message.guild.id}.json`, 'utf8', function readFileCallback(err, data){
|
||||||
|
if (err){
|
||||||
|
console.log(err);
|
||||||
|
} else {
|
||||||
|
customresponse = JSON.parse(data); //now it an object
|
||||||
|
delete customresponse[trigger]
|
||||||
|
json = JSON.stringify(customresponse); //convert it back to json
|
||||||
|
fs.writeFile(`./tag/${message.guild.id}.json`, json, 'utf8', function(err) {
|
||||||
|
if(err) {
|
||||||
|
return console.log(err);
|
||||||
|
}
|
||||||
|
})}});
|
||||||
|
|
||||||
|
return message.say(`The following autoresponse have been deleted: ${trigger}`);
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in a new issue