feat: simplified commands help

This commit is contained in:
TresAbhi committed 2023-07-11 18:44:32 +00:00
1 parent 463af106be
commit 6c8f5ca478
2 files changed
+10 -53

No files matched your search

+9 -52
View File
@@ -1,9 +1,4 @@
import {
SlashCommandBuilder,
SlashCommandSubcommandBuilder,
SlashCommandSubcommandGroupBuilder,
} from 'discord.js';
import embedInfo from '../core/discord/embedInfo.js';
import { SlashCommandBuilder } from 'discord.js';
import {
COMMANDS_RAW,
CommandRegistry,
@@ -49,52 +44,14 @@ export const helpCommand: CommandRegistry = {
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'),
),
];
return `# Commands\n\nBlitzkrieg offers the following commands:\n\n${COMMANDS_RAW.filter(
(registry) => registry.inPublic && registry.inProduction,
)
.map(
(registry) =>
`- \`/${registry.command.name}\`: ${registry.command.description}`,
)
.join('\n')}`;
}
const url = `${RAW_PATH}${DOCS[subcommand]}.md`;
+1 -1
View File
@@ -5,7 +5,7 @@ import { RouteRegistry } from '../server.js';
export const todayRoute: RouteRegistry = {
route: '/today',
inProduction: true,
inDevelopment: false,
inDevelopment: true,
async handler(req) {
const player = resolvePlayerFromRequest(req);