mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Allow searching credit by name
This commit is contained in:
@@ -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
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "116.34.1",
|
||||
"version": "116.34.2",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user