mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-03 06:28:53 +00:00
feat!: Extract logic for autocomplete and component interactions
This commit is contained in:
1 parent
f16a18deb5
commit
1ec1281e98
29 files changed
+694
-442
No files matched your search
@@ -5,7 +5,7 @@ import path from 'node:path';
|
||||
import loggerModule from '../services/logger';
|
||||
import { RegisterClientCommandsParams } from '../types/utilTypes';
|
||||
|
||||
export const registerClientCommands = ({ client, executionId }: RegisterClientCommandsParams) => {
|
||||
export const registerClientCommands = async ({ client, executionId }: RegisterClientCommandsParams) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'registerClientCommands.js',
|
||||
module: 'register',
|
||||
@@ -30,10 +30,11 @@ export const registerClientCommands = ({ client, executionId }: RegisterClientCo
|
||||
delete require.cache[require.resolve(`../interactions/commands/${folder}/${file}`)];
|
||||
|
||||
// register command
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
const command = require(`../interactions/commands/${folder}/${file}`);
|
||||
client.commands.delete(command.data.name);
|
||||
client.commands.set(command.data.name, command);
|
||||
//const command = require(`../interactions/commands/${folder}/${file}`);
|
||||
const commandModule = await import(`../interactions/commands/${folder}/${file}`);
|
||||
|
||||
client.commands.delete(commandModule.default.data.name);
|
||||
client.commands.set(commandModule.default.data.name, commandModule.default);
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
logger.error(`Error registering command ${folder}/${file}: ${error.message}`);
|
||||
|
||||
Reference in new issue
Block a user