can show only 1 tag at a time

This commit is contained in:
Supositware 2019-02-10 14:57:39 +01:00
parent 080499defd
commit 5cf4c02c9f

View file

@ -9,6 +9,12 @@ class taglistCommand extends Command {
aliases: ['taglist', 'tags'], aliases: ['taglist', 'tags'],
category: 'utility', category: 'utility',
channelRestriction: 'guild', channelRestriction: 'guild',
args: [
{
id: 'raw',
type: 'string',
}
],
description: { description: {
content: 'Show the list of tag for this server.', content: 'Show the list of tag for this server.',
usage: '', usage: '',
@ -17,7 +23,7 @@ class taglistCommand extends Command {
}); });
} }
async exec(message) { async exec(message, args) {
try { try {
var customresponse = reload(`../../tag/${message.guild.id}.json`); var customresponse = reload(`../../tag/${message.guild.id}.json`);
var count = Object.keys(customresponse).length; var count = Object.keys(customresponse).length;
@ -31,9 +37,20 @@ class taglistCommand extends Command {
return; return;
} }
let json = JSON.stringify(data); let json = JSON.parse(data);
if (args.raw) {
const tagEmbed = new MessageEmbed()
.setColor('#ff9900')
.setTitle(args.raw)
.setDescription(json[args.raw]);
return message.channel.send(tagEmbed);
}
json = JSON.stringify(data);
json = json.replace(/[{}'\\]+/g, ''); json = json.replace(/[{}'\\]+/g, '');
json = json.replace(/,+/g, '\n'); json = json.replace(/,+/g, '\n');
const tagEmbed = new MessageEmbed() const tagEmbed = new MessageEmbed()
.setColor('#ff9900') .setColor('#ff9900')
.setTitle('Tags list') .setTitle('Tags list')