Store data about categories + comments
This commit is contained in:
parent
c39826ead3
commit
a8ce8faf06
2 changed files with 29 additions and 9 deletions
|
@ -2,6 +2,7 @@ import { REST } from '@discordjs/rest';
|
|||
import { Routes } from 'discord-api-types/v9';
|
||||
import { Client } from 'discord.js';
|
||||
import { readdir } from 'fs/promises';
|
||||
import { removeExtension } from '../utils/misc';
|
||||
|
||||
/** Load all the commands. */
|
||||
export default async (client: Client) => {
|
||||
|
@ -17,6 +18,12 @@ export default async (client: Client) => {
|
|||
// Retrieve all the commands
|
||||
const command_files = await readdir(`${__dirname}/${command_category}`);
|
||||
|
||||
// Add the category to the collection for the help command
|
||||
client.commands.categories.set(
|
||||
command_category,
|
||||
command_files.map(removeExtension),
|
||||
);
|
||||
|
||||
// Add the command
|
||||
return Promise.all(
|
||||
command_files.map(async command_file => {
|
||||
|
@ -25,7 +32,7 @@ export default async (client: Client) => {
|
|||
).default;
|
||||
|
||||
// Add it to the collection so the interaction will work
|
||||
client.commands.set(command.data(client).name, command);
|
||||
client.commands.list.set(command.data(client).name, command);
|
||||
|
||||
return command.data(client).toJSON();
|
||||
}),
|
||||
|
|
|
@ -16,13 +16,25 @@ declare module 'discord.js' {
|
|||
default_lang: string
|
||||
},
|
||||
/** Store all the slash commands */
|
||||
commands: Collection<
|
||||
commands: {
|
||||
categories: Collection<
|
||||
/** Category name */
|
||||
string,
|
||||
/** Name of the commands in the category */
|
||||
string[]
|
||||
>,
|
||||
list: Collection<
|
||||
/** Command name */
|
||||
string,
|
||||
/** Command itself */
|
||||
{
|
||||
/** Data about the command */
|
||||
data: SlashCommandBuilder,
|
||||
/** How the command interact */
|
||||
interaction: (interaction: CommandInteraction, client: Client) => unknown
|
||||
}
|
||||
>,
|
||||
}
|
||||
/** Store all the localizations */
|
||||
locales: Map<string, Map<string, string>>
|
||||
}
|
||||
|
@ -42,7 +54,8 @@ export default async () => {
|
|||
default_lang: process.env.DEFAULT_LANG ?? 'fr',
|
||||
};
|
||||
|
||||
client.commands = new Collection();
|
||||
client.commands.categories = new Collection();
|
||||
client.commands.list = new Collection();
|
||||
|
||||
console.log('Translations progression :');
|
||||
client.locales = await loadLocales(client.config.default_lang);
|
||||
|
|
Loading…
Reference in a new issue