24 |
import CommandOptions from '../../types/CommandOptions'; |
import CommandOptions from '../../types/CommandOptions'; |
25 |
import InteractionOptions from '../../types/InteractionOptions'; |
import InteractionOptions from '../../types/InteractionOptions'; |
26 |
import MessageEmbed from '../../client/MessageEmbed'; |
import MessageEmbed from '../../client/MessageEmbed'; |
27 |
import { renderCommandList, renderCommandMeta } from '../../services/CommandMetaDataManager'; |
import { getAllCommandData, renderCommandMeta } from '../../services/CommandMetaDataManager'; |
28 |
|
import Pagination from '../../utils/Pagination'; |
29 |
|
|
30 |
export default class HelpCommand extends BaseCommand { |
export default class HelpCommand extends BaseCommand { |
31 |
constructor() { |
constructor() { |
45 |
|
|
46 |
async run(client: DiscordClient, message: Message | CommandInteraction, options: CommandOptions | InteractionOptions) { |
async run(client: DiscordClient, message: Message | CommandInteraction, options: CommandOptions | InteractionOptions) { |
47 |
if ((options.isInteraction && !options.options.getString('command')) || (!options.isInteraction && options.args[0] === undefined)) { |
if ((options.isInteraction && !options.options.getString('command')) || (!options.isInteraction && options.args[0] === undefined)) { |
48 |
await message.reply({ |
const commandData = getAllCommandData(); |
49 |
embeds: [ |
const pagination = new Pagination(commandData, { |
50 |
new MessageEmbed({ |
channel_id: message.channel!.id, |
51 |
title: 'Help', |
guild_id: message.guild!.id, |
52 |
description: renderCommandList() |
limit: 10, |
53 |
}) |
user_id: message.member!.user.id, |
54 |
], |
timeout: 120_000, |
55 |
|
embedBuilder({ data, maxPages, currentPage }) { |
56 |
|
let description = `\`<...>\` means required argument and \`[...]\` means optional argument.\nRun \`${client.config.get('prefix')}help <CommandName>\` for more information about a specific command.\n\n`; |
57 |
|
|
58 |
|
for (const { name, shortBrief } of data) { |
59 |
|
description += `**${name}**\n`; |
60 |
|
description += `${shortBrief}\n\n`; |
61 |
|
} |
62 |
|
|
63 |
|
return new MessageEmbed({ |
64 |
|
author: { |
65 |
|
iconURL: client.user?.displayAvatarURL(), |
66 |
|
name: "Help" |
67 |
|
}, |
68 |
|
description, |
69 |
|
footer: { |
70 |
|
text: `Page ${currentPage} of ${maxPages} • ${commandData.length} commands total` |
71 |
|
} |
72 |
|
}); |
73 |
|
}, |
74 |
}); |
}); |
75 |
|
|
76 |
|
let reply = await message.reply(pagination.getMessageOptions(1)); |
77 |
|
|
78 |
|
if (message instanceof CommandInteraction) { |
79 |
|
reply = <Message> await message.fetchReply(); |
80 |
|
} |
81 |
|
|
82 |
|
await pagination.start(reply!); |
83 |
|
|
84 |
return; |
return; |
85 |
} |
} |
86 |
|
|
144 |
// ] |
// ] |
145 |
// }); |
// }); |
146 |
} |
} |
|
} |
|
147 |
|
} |