/ src / modules / commands / help.ts
help.ts
 1  import { commandHandler } from './../bot';
 2  import { Command } from '../commandHandler';
 3  
 4  import config from '.././config';
 5  import { DiscordLocale, __, __h_dc, discordLocales } from '../messages';
 6  import { EmbedBuilder, SlashCommandBuilder, Locale as DiscordsLocale } from 'discord.js';
 7  import { getLang } from '../db';
 8  
 9  export default {
10    data: new SlashCommandBuilder()
11      .setName('help')
12      .setDescription('Shows the help menu')
13      .setDescriptionLocalizations(__h_dc('Shows the help menu')),
14  
15    execute: async interaction => {
16      const locale = getLang(interaction);
17  
18      // const commandEmbed = new EmbedBuilder()
19      //   .setTitle(__({ phrase: 'Commands', locale }))
20      //   .setColor(config.COLOR);
21      // commandHandler.commands.forEach(command => {
22      //   let commandName = `**\`/${command.data.name}`;
23      //   command.data.options.forEach(option => {
24      //     if (option.toJSON().required) {
25      //       commandName += ` <${option.toJSON().name}>`;
26      //     } else {
27      //       commandName += ` [${option.toJSON().name}]`;
28      //     }
29      //   });
30      //   commandName += `\`**`;
31      //
32      //   const discordLocale = discordLocales.includes(locale as DiscordLocale) ? locale as unknown as DiscordLocale : 'en-US';
33      //
34      //   let commandDescription = command.data.description_localizations
35      //     ? command.data.description_localizations[discordLocale]
36      //     : command.data.description;
37      //
38      //   command.data.options.forEach(option => {
39      //     const name_localizations = option.toJSON().name_localizations;
40      //     const description_localizations = option.toJSON().description_localizations;
41      //     const name = name_localizations ? name_localizations[discordLocale] : option.toJSON().name;
42      //     const description = description_localizations ? description_localizations[discordLocale as DiscordsLocale] : option.toJSON().description
43      //     commandDescription += `\n\`${name}\`: ${description}`;
44      //   });
45      //
46      //   commandEmbed.addFields({ name: commandName, value: commandDescription! });
47      // });
48  
49      interaction.reply({
50        files: ['./img/discord-header.png'],
51        embeds: [
52          new EmbedBuilder()
53            .setColor(config.COLOR)
54            .setFooter({
55              // = Made and hosted by <author>.
56              // or
57              // = Made by <author> and hosted by <host>
58              text:
59                config.AUTHOR === config.HOSTER_NAME
60                  ? __({ phrase: 'Made and hosted by %s', locale }, config.AUTHOR)
61                  : __({ phrase: 'Made by %s and hosted by %s', locale }, config.AUTHOR, config.HOSTER_NAME),
62              iconURL: config.AUTHOR_LOGO_LINK
63            })
64            .setDescription(
65              __({ phrase: 'A Discord bot for automatic role assignment based on activities.\n', locale }) +
66              __({ phrase: 'Support/Suggestions: %s\n', locale }, 'https://discord.gg/3K9Yx4ufN7') +
67              __({ phrase: 'GitHub: %s\n', locale }, 'https://github.com/tippf3hlr/activity-roles/') +
68              __({ phrase: 'Contact: %s\n\n', locale }, '@tippfehlr | tippfehlr@gmail.com') +
69              __({
70                phrase:
71                  "Add an activity role with `/addactivityrole`. " +
72                  "By default, the bot will be removed when the user stops the activity.\n" +
73                  "If you set `permanent` to true, the bot will not remove the role.\n" +
74                  "`exact_activity_name` can be set to true if you get false-positives.\n",
75                locale
76              }) +
77              __({ phrase: "Set a status role with /setstatusrole!\n", locale }) +
78              __({ phrase: '**The bot will not remove any roles that were added manually.**', locale }) + "\n\n" +
79              __({ phrase: "I don’t use the bot myself. If you want to speed up development or help me pay for the server, please consider supporting me.", locale }) + "\n" +
80              "https://github.com/sponsors/tippfehlr\nhttps://ko-fi.com/Z8Z7SYDDJ"
81            ),
82          // commandEmbed
83        ]
84      });
85    }
86  } as Command;