forked from Supositware/Haha-Yes
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.
70 lines
2.1 KiB
JavaScript
70 lines
2.1 KiB
JavaScript
6 years ago
|
const { Command } = require('discord-akairo');
|
||
5 years ago
|
const Tag = require('../../models').Tag;
|
||
6 years ago
|
const fs = require('fs');
|
||
5 years ago
|
const { MessageEmbed } = require('discord.js');
|
||
6 years ago
|
|
||
5 years ago
|
|
||
5 years ago
|
class seetagCommand extends Command {
|
||
6 years ago
|
constructor() {
|
||
|
super('taglist', {
|
||
5 years ago
|
aliases: ['seetag', 'taglist', 'tags'],
|
||
6 years ago
|
category: 'utility',
|
||
|
channelRestriction: 'guild',
|
||
6 years ago
|
args: [
|
||
|
{
|
||
|
id: 'raw',
|
||
5 years ago
|
match: 'rest',
|
||
|
optional: true
|
||
5 years ago
|
},
|
||
|
{
|
||
5 years ago
|
id: 'all',
|
||
5 years ago
|
match: 'flag',
|
||
5 years ago
|
flag: '--all',
|
||
6 years ago
|
}
|
||
|
],
|
||
6 years ago
|
description: {
|
||
|
content: 'Show the list of tag for this server.',
|
||
|
usage: '',
|
||
|
examples: ['']
|
||
|
}
|
||
|
});
|
||
|
}
|
||
6 years ago
|
|
||
6 years ago
|
async exec(message, args) {
|
||
5 years ago
|
if (args.raw) {
|
||
|
let tagList = await Tag.findOne({attributes: ['trigger','response','ownerID'], where: {trigger: args.raw, serverID: message.guild.id}});
|
||
5 years ago
|
this.client.users.fetch(tagList.dataValues.ownerID)
|
||
|
.then(user => {
|
||
|
const TagEmbed = new MessageEmbed()
|
||
|
.setColor('#ff9900')
|
||
|
.setTitle(message.guild.name)
|
||
|
.addField('Trigger:', tagList['dataValues']['trigger'])
|
||
|
.addField('Response:', tagList['dataValues']['response'])
|
||
5 years ago
|
.addField('Creator:', `${user.username}#${user.discriminator} (${user.id})`);
|
||
5 years ago
|
|
||
|
return message.channel.send(TagEmbed);
|
||
|
});
|
||
|
} else if (args.all) {
|
||
5 years ago
|
let tagList = await Tag.findAll({attributes: ['trigger','response','ownerID'], where: {serverID: message.guild.id}});
|
||
5 years ago
|
var tagArray = [];
|
||
5 years ago
|
tagList.forEach(tag => {
|
||
5 years ago
|
tagArray.push(tag.dataValues);
|
||
5 years ago
|
});
|
||
5 years ago
|
fs.writeFile('/tmp/tagslist.txt',JSON.stringify(tagArray, null, 2), function(err) {
|
||
|
if (err) return console.error(err);
|
||
|
return message.channel.send('Here are your tags', {files: ['/tmp/tagslist.txt']});
|
||
|
});
|
||
5 years ago
|
} else {
|
||
|
let tagList = await Tag.findAll({attributes: ['trigger'], where: {serverID: message.guild.id}});
|
||
|
const tagString = tagList.map(t => t.trigger).join(', ') || 'No tags set.';
|
||
|
const TagEmbed = new MessageEmbed()
|
||
|
.setColor('#ff9900')
|
||
|
.setTitle('List of tags')
|
||
|
.setDescription(tagString)
|
||
|
.setFooter('Use this command with the name of the tag to see more info about it!');
|
||
|
|
||
|
return message.channel.send(TagEmbed);
|
||
5 years ago
|
}
|
||
6 years ago
|
}
|
||
6 years ago
|
}
|
||
5 years ago
|
module.exports = seetagCommand;
|