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/untag.js

56 lines
1.6 KiB
JavaScript

5 years ago
const { Command } = require('discord-akairo');
const fs = require('fs');
class UnTagCommand extends Command {
constructor() {
super('untag', {
aliases: ['untag'],
category: 'admin',
split: 'none',
args: [
{
id: "trigger",
type: "string"
}
],
channelRestriction: 'guild',
description: {
content: 'Remove created custom autoresponse',
usage: '[trigger]',
examples: ['"do you know da wea"']
}
});
}
async exec(message, args) {
let trigger = args.trigger;
trigger = trigger.toLowerCase();
5 years ago
let customresponse = {}
let json = JSON.stringify(customresponse)
fs.readFile(`./tag/${message.guild.id}.json`, 'utf8', function readFileCallback(err, data) {
if (err) {
5 years ago
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) {
fs.close();
return console.log(err);
}
})
}
});
fs.close();
5 years ago
return message.channel.send(`The following autoresponse have been deleted: ${trigger}`);
5 years ago
}
}
module.exports = UnTagCommand;