Allow searching credit by name

This commit is contained in:
Dragon Fire
2020-06-20 09:15:47 -04:00
parent 953a8234b9
commit 30d79e2522
2 changed files with 24 additions and 9 deletions
+23 -8
View File
@@ -1,6 +1,7 @@
const Command = require('../../structures/Command');
const { Command: CommandoCommand } = require('discord.js-commando');
const { MessageEmbed } = require('discord.js');
const { embedURL } = require('../../util/Util');
const { trimArray, embedURL } = require('../../util/Util');
module.exports = class CreditCommand extends Command {
constructor(client) {
@@ -14,21 +15,35 @@ module.exports = class CreditCommand extends Command {
{
key: 'command',
prompt: 'Which command would you like to view the credits list of?',
type: 'command'
type: 'command|string'
}
]
});
}
run(msg, { command }) {
if (!command.credit) return msg.say('This command is credited to no one. It just appeared.');
const embed = new MessageEmbed()
.setTitle(command.name)
.setColor(0x7289DA)
.setDescription(command.credit.map(credit => {
if (command instanceof CommandoCommand) {
if (!command.credit) return msg.say('This command is credited to no one. It just appeared.');
const embed = new MessageEmbed()
.setTitle(command.name)
.setColor(0x7289DA)
.setDescription(command.credit.map(credit => {
if (!credit.reasonURL) return `${embedURL(credit.name, credit.url)} (${credit.reason})`;
return `${embedURL(credit.name, credit.url)} (${embedURL(credit.reason, credit.reasonURL)})`;
}).join('\n'));
return msg.embed(embed);
}
const commands = this.client.registry.commands
.filter(c => c.credit && c.credit.length && c.credit.find(cred => cred.name.includes(command.toLowerCase())))
.map(credit => {
if (!credit.reasonURL) return `${embedURL(credit.name, credit.url)} (${credit.reason})`;
return `${embedURL(credit.name, credit.url)} (${embedURL(credit.reason, credit.reasonURL)})`;
}).join('\n'));
});
if (!commands.length) return msg.say('Could not find any results.');
const embed = new MessageEmbed()
.setTitle(command.toLowerCase())
.setColor(0x7289DA)
.setDescription(trimArray(commands, 15).join(', '));
return msg.embed(embed);
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "116.34.1",
"version": "116.34.2",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {