chore: merge branch dev
to main
#200
2 changed files with 36 additions and 10 deletions
|
@ -9,6 +9,7 @@ import {
|
|||
import "../../modules/string";
|
||||
import { getLocale, getLocalizations } from "../../utils/locales";
|
||||
import { getFilename } from "../../utils/misc";
|
||||
import { goodDescription, goodName } from "../../utils/commands/help";
|
||||
|
||||
export default {
|
||||
scope: () => [],
|
||||
|
@ -63,12 +64,16 @@ export default {
|
|||
// Add subcommands
|
||||
const all_commands: string[] = [];
|
||||
commands_name.forEach((command) => {
|
||||
const json = client.commands.list.get(command)?.data.toJSON();
|
||||
all_commands.push(command);
|
||||
const data = client.commands.list.get(command)?.data;
|
||||
const name = goodName(data!, interaction.locale);
|
||||
all_commands.push(name);
|
||||
|
||||
json?.options
|
||||
?.filter((option) => option.type === ApplicationCommandOptionType.Subcommand)
|
||||
.forEach((subcommand) => all_commands.push(command + " " + subcommand.name));
|
||||
data
|
||||
?.toJSON()
|
||||
.options?.filter((option) => option.type === ApplicationCommandOptionType.Subcommand)
|
||||
.forEach((subcommand) =>
|
||||
all_commands.push(name + " " + goodName(subcommand, interaction.locale)),
|
||||
);
|
||||
});
|
||||
|
||||
const commands = all_commands.reduce(
|
||||
|
@ -111,12 +116,10 @@ export default {
|
|||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setColor(Colors.Blurple)
|
||||
.setTitle("`/" + command.data.name + "`")
|
||||
.setTitle("`/" + goodName(command.data, interaction.locale) + "`")
|
||||
.setDescription(
|
||||
// Loads the description
|
||||
// according to the user's locals
|
||||
command.data.description_localizations?.[interaction.locale] ??
|
||||
command.data.description,
|
||||
// Loads the description according to the user's locals
|
||||
goodDescription(command.data, interaction.locale),
|
||||
),
|
||||
],
|
||||
});
|
||||
|
|
23
src/utils/commands/help.ts
Normal file
23
src/utils/commands/help.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
import { APIApplicationCommandSubcommandOption, Locale, SlashCommandBuilder } from "discord.js";
|
||||
|
||||
/**
|
||||
* Find the name of the command, trying to get the correct locale
|
||||
* @param data Command data
|
||||
* @param locale Locale wanted
|
||||
* @returns Command's name
|
||||
*/
|
||||
export const goodName = (
|
||||
data: SlashCommandBuilder | APIApplicationCommandSubcommandOption,
|
||||
locale: Locale,
|
||||
) => data.name_localizations?.[locale] ?? data.name;
|
||||
|
||||
/**
|
||||
* Find the description of the command, trying to get the correct locale
|
||||
* @param data Command data
|
||||
* @param locale Locale wanted
|
||||
* @returns Command's description
|
||||
*/
|
||||
export const goodDescription = (
|
||||
data: SlashCommandBuilder | APIApplicationCommandSubcommandOption,
|
||||
locale: Locale,
|
||||
) => data.description_localizations?.[locale] ?? data.description;
|
Loading…
Reference in a new issue