From 42ceeb5da069427ddcb80ae0dbfe0233ff6ab694 Mon Sep 17 00:00:00 2001 From: Loic Bersier Date: Fri, 7 Dec 2018 01:45:40 +0100 Subject: [PATCH] added a command to list all tag --- commands/utility/taglist.js | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 commands/utility/taglist.js diff --git a/commands/utility/taglist.js b/commands/utility/taglist.js new file mode 100644 index 00000000..c7d24042 --- /dev/null +++ b/commands/utility/taglist.js @@ -0,0 +1,39 @@ +const { Command } = require('discord.js-commando'); +const blacklist = require('../../json/blacklist.json'); +const Discord = require('discord.js'); +const SelfReloadJSON = require('self-reload-json'); +const fs = require('fs'); +module.exports = class taglistCommand extends Command { + constructor(client) { + super(client, { + name: 'taglist', + group: 'utility', + memberName: 'taglist', + description: `List all the tag` + }); + } + + async run(message) { + if(blacklist[message.author.id]) + return message.channel.send("You are blacklisted") + + let customresponse = new SelfReloadJSON(`./tag/${message.guild.id}.json`); + let count = Object.keys(customresponse).length + + fs.readFile(`./tag/${message.guild.id}.json`, 'utf8', function readFileCallback(err, data){ + if (err) + console.log(err); + let json = JSON.stringify(data) + json = json.replace(/[{}"\\]+/g, '') + json = json.replace(',', '\n') + const tagEmbed = new Discord.RichEmbed() + .setColor("#ff9900") + .setTitle('Tags list') + .setDescription(`Trigger:Response\n\n${json}`) + .setFooter(`You have ${count} tags on this server`) + + message.say(tagEmbed); + + }); + } +}; \ No newline at end of file