From b31aef9999cf9b9f5189490db6fb19f9f0ab1a49 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Tue, 26 Jul 2022 23:41:29 +0200 Subject: [PATCH] move client to module folder --- src/modules/client.ts | 41 +++++++++++++++++++++++++++++++++++++++++ src/utils/client.ts | 39 +-------------------------------------- 2 files changed, 42 insertions(+), 38 deletions(-) create mode 100644 src/modules/client.ts diff --git a/src/modules/client.ts b/src/modules/client.ts new file mode 100644 index 0000000..8d0aa0e --- /dev/null +++ b/src/modules/client.ts @@ -0,0 +1,41 @@ +import { Collection } from 'discord.js'; +import { SlashCommandBuilder } from '@discordjs/builders'; + +export {}; + +declare module 'discord.js' { + // eslint-disable-next-line no-shadow + export interface Client { + /** Store the configuration */ + config: { + /** Bot version */ + version: string, + /** Bot token from env variable */ + token_discord: string | undefined, + /** Default lang used */ + default_lang: string + }, + /** Store all the slash commands */ + 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> + } +} diff --git a/src/utils/client.ts b/src/utils/client.ts index cb68532..182ebf1 100644 --- a/src/utils/client.ts +++ b/src/utils/client.ts @@ -1,44 +1,7 @@ import { Client, Collection, Intents } from 'discord.js'; import { readFileSync } from 'fs'; -import { SlashCommandBuilder } from '@discordjs/builders'; import { loadLocales } from './locales'; - -declare module 'discord.js' { - // eslint-disable-next-line no-shadow - export interface Client { - /** Store the configuration */ - config: { - /** Bot version */ - version: string, - /** Bot token from env variable */ - token_discord: string | undefined, - /** Default lang used */ - default_lang: string - }, - /** Store all the slash commands */ - 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> - } -} +import '../modules/client'; /** Creation of the client and definition of its properties. */ export default async () => {