/[sudobot]/trunk/src/commands/settings/HelpCommand.ts
ViewVC logotype

Diff of /trunk/src/commands/settings/HelpCommand.ts

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 485 by rakin, Mon Jul 29 17:29:59 2024 UTC revision 486 by rakin, Mon Jul 29 17:30:28 2024 UTC
# Line 24  import Help from '../../utils/Help'; Line 24  import Help from '../../utils/Help';
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() {
# Line 44  export default class HelpCommand extends Line 45  export default class HelpCommand extends
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 pagination = new Pagination(getAllCommandData(), {
49                  embeds: [                  channel_id: message.channel!.id,
50                      new MessageEmbed({                  guild_id: message.guild!.id,
51                          title: 'Help',                  limit: 10,
52                          description: renderCommandList()                  user_id: message.member!.user.id,
53                      })                  timeout: 120_000,
54                  ],                  embedBuilder({ data, maxPages, currentPage }) {
55                        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`;
56    
57                        for (const { name, shortBrief } of data) {
58                            description += `**${name}**\n`;
59                            description += `${shortBrief}\n\n`;
60                        }
61    
62                        return new MessageEmbed({
63                            author: {
64                                iconURL: client.user?.displayAvatarURL(),
65                                name: "Help"
66                            },
67                            description,
68                            footer: {
69                                text: `Page ${currentPage} of ${maxPages}`
70                            }
71                        });
72                    },
73              });              });
74    
75                let reply = await message.reply(pagination.getMessageOptions(1));
76    
77                if (message instanceof CommandInteraction) {
78                    reply = <Message> await message.fetchReply();
79                }
80    
81                await pagination.start(reply!);
82    
83              return;              return;
84          }          }
85    

Legend:
Removed from v.485  
changed lines
  Added in v.486

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26