2023-07-10 19:14:16 +00:00
|
|
|
import {
|
|
|
|
|
SlashCommandBuilder,
|
|
|
|
|
SlashCommandSubcommandBuilder,
|
|
|
|
|
SlashCommandSubcommandGroupBuilder,
|
|
|
|
|
} from 'discord.js';
|
2023-06-27 02:22:28 +00:00
|
|
|
import embedInfo from '../core/discord/embedInfo.js';
|
2023-05-21 16:50:05 +00:00
|
|
|
import {
|
2023-07-10 19:14:16 +00:00
|
|
|
COMMANDS_RAW,
|
2023-05-21 16:50:05 +00:00
|
|
|
CommandRegistry,
|
2023-06-25 02:32:56 +00:00
|
|
|
} from '../events/interactionCreate/index.js';
|
2023-04-26 14:23:42 +00:00
|
|
|
|
2023-07-10 19:14:16 +00:00
|
|
|
const RAW_PATH = `https://raw.githubusercontent.com/tresabhi/blitzkrieg/main/docs/`;
|
|
|
|
|
const DOCS: Record<string, string> = {
|
|
|
|
|
permissions: 'guide/permissions',
|
|
|
|
|
embeds: 'guide/embeds',
|
|
|
|
|
about: 'guide/about',
|
|
|
|
|
invite: 'guide/invite',
|
|
|
|
|
};
|
|
|
|
|
|
2023-07-05 01:15:18 +00:00
|
|
|
export const helpCommand: CommandRegistry = {
|
2023-04-26 23:43:43 +00:00
|
|
|
inProduction: true,
|
2023-07-10 19:14:16 +00:00
|
|
|
inDevelopment: true,
|
2023-04-26 14:23:42 +00:00
|
|
|
inPublic: true,
|
|
|
|
|
|
|
|
|
|
command: new SlashCommandBuilder()
|
2023-06-21 02:01:12 +00:00
|
|
|
.setName('help')
|
2023-07-10 19:14:16 +00:00
|
|
|
.setDescription('All the help you need about the bot')
|
|
|
|
|
.addSubcommand((option) =>
|
|
|
|
|
option
|
|
|
|
|
.setName('commands')
|
|
|
|
|
.setDescription('List of all commands and their descriptions'),
|
|
|
|
|
)
|
|
|
|
|
.addSubcommand((option) =>
|
|
|
|
|
option
|
|
|
|
|
.setName('permissions')
|
|
|
|
|
.setDescription('The permissions needed for the bot to function'),
|
|
|
|
|
)
|
|
|
|
|
.addSubcommand((option) =>
|
|
|
|
|
option.setName('about').setDescription('About the bot'),
|
|
|
|
|
)
|
|
|
|
|
.addSubcommand((option) =>
|
|
|
|
|
option.setName('embeds').setDescription('How embeds work'),
|
|
|
|
|
)
|
|
|
|
|
.addSubcommand((option) =>
|
|
|
|
|
option.setName('invite').setDescription('How to invite the bot'),
|
|
|
|
|
),
|
2023-04-26 14:23:42 +00:00
|
|
|
|
2023-06-27 01:43:30 +00:00
|
|
|
handler(interaction) {
|
2023-07-10 19:14:16 +00:00
|
|
|
const subcommand = interaction.options.getSubcommand();
|
|
|
|
|
|
|
|
|
|
if (subcommand === 'commands') {
|
|
|
|
|
return [
|
|
|
|
|
`# Commands\n\nBlitzkrieg offers the following commands:`,
|
|
|
|
|
embedInfo(
|
|
|
|
|
'',
|
|
|
|
|
COMMANDS_RAW.filter(
|
|
|
|
|
(registry) => registry.inPublic && registry.inProduction,
|
|
|
|
|
)
|
|
|
|
|
.map((registry) => {
|
|
|
|
|
const info = `- \`/${registry.command.name}\`: ${registry.command.description}`;
|
|
|
|
|
const subcommandGroups = registry.command.options.filter(
|
|
|
|
|
(option) =>
|
|
|
|
|
option instanceof SlashCommandSubcommandGroupBuilder,
|
|
|
|
|
) as SlashCommandSubcommandGroupBuilder[];
|
|
|
|
|
const subcommands = registry.command.options.filter(
|
|
|
|
|
(option) => option instanceof SlashCommandSubcommandBuilder,
|
|
|
|
|
) as SlashCommandSubcommandBuilder[];
|
|
|
|
|
|
|
|
|
|
const tree =
|
|
|
|
|
subcommandGroups.length > 0
|
|
|
|
|
? subcommandGroups
|
|
|
|
|
.map((subcommandGroup) => {
|
|
|
|
|
const info = ` - \`${subcommandGroup.name}\`: ${subcommandGroup.description}`;
|
|
|
|
|
const subcommands = subcommandGroup.options
|
|
|
|
|
.map(
|
|
|
|
|
(subcommand) =>
|
|
|
|
|
` - \`${subcommand.name}\`: ${subcommand.description}`,
|
|
|
|
|
)
|
|
|
|
|
.join('\n');
|
|
|
|
|
|
|
|
|
|
return `${info}${
|
|
|
|
|
subcommands ? `\n${subcommands}` : ''
|
|
|
|
|
}`;
|
|
|
|
|
})
|
|
|
|
|
.join('\n')
|
|
|
|
|
: subcommands
|
|
|
|
|
.map(
|
|
|
|
|
(subcommand) =>
|
|
|
|
|
` - \`${subcommand.name}\`: ${subcommand.description}`,
|
|
|
|
|
)
|
|
|
|
|
.join('\n');
|
|
|
|
|
|
|
|
|
|
return `${info}${tree ? `\n${tree}` : ''}`;
|
|
|
|
|
})
|
|
|
|
|
.join('\n'),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const url = `${RAW_PATH}${DOCS[subcommand]}.md`;
|
|
|
|
|
const content = fetch(url).then((response) => response.text());
|
|
|
|
|
|
|
|
|
|
return content;
|
2023-04-26 14:23:42 +00:00
|
|
|
},
|
2023-07-05 01:15:18 +00:00
|
|
|
};
|