8f096b9589
Checklist: - [x] Suivre les indications de `CONTRIBUTING.md` - [x] Référence aux tickets (par exemple `Closes #xyz`) Closes #1 Additional changes: - use of ChatInputCommandInteraction (part of v14) - fixed locales progress bars - updates dependencies - better handle of errors - support of modals - support of buttons Co-authored-by: Mylloon <kennel.anri@tutanota.com> Reviewed-on: https://git.kennel.ml/ConfrerieDuKassoulait/Botanique/pulls/44
36 lines
1 KiB
TypeScript
36 lines
1 KiB
TypeScript
import { readdir } from 'fs/promises';
|
|
import { removeExtension } from '../utils/misc';
|
|
import { Client } from 'discord.js';
|
|
|
|
export default async (client: Client) => {
|
|
// Dossier des modals
|
|
const modals_categories = (await readdir(__dirname))
|
|
.filter(element => !element.endsWith('.js') && !element.endsWith('.ts'));
|
|
|
|
await Promise.all(
|
|
// For each categorie
|
|
modals_categories.map(async modals_category => {
|
|
// Retrieve all the commands
|
|
const modal_files = await readdir(`${__dirname}/${modals_category}`);
|
|
|
|
// Add the category to the collection for the help command
|
|
client.modals.categories.set(
|
|
modals_category,
|
|
modal_files.map(removeExtension),
|
|
);
|
|
|
|
// Add the modal
|
|
return Promise.all(
|
|
modal_files.map(async modal_file => {
|
|
const modal = (
|
|
await import(`../modals/${modals_category}/${modal_file}`)
|
|
).default;
|
|
|
|
// Add it to the collection so the interaction will work
|
|
client.modals.list.set(modal.data.name, modal);
|
|
return modal.data;
|
|
}),
|
|
);
|
|
}),
|
|
);
|
|
};
|