mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-03 14:38:49 +00:00
Add class for interactions
This commit is contained in:
1 parent
d0f1e940a5
commit
b96a73df6f
37 files changed
+1038
-1012
No files matched your search
@@ -1,20 +1,31 @@
|
||||
import { AutocompleteInteraction } from 'discord.js';
|
||||
import { Logger } from 'pino';
|
||||
import loggerModule from '../services/logger';
|
||||
import { ExtendedClient } from '../types/clientTypes';
|
||||
import { BaseAutocompleteInteraction } from '../types/interactionTypes';
|
||||
|
||||
export const handleAutocomplete = async (interaction: AutocompleteInteraction, executionId: string) => {
|
||||
export const handleAutocomplete = async (
|
||||
interaction: AutocompleteInteraction,
|
||||
client: ExtendedClient,
|
||||
executionId: string,
|
||||
interactionIdentifier: string
|
||||
) => {
|
||||
// TODO: Define TS Type for handlers, and require logger constant?
|
||||
const logger: Logger = loggerModule.child({
|
||||
source: 'interactionCutocompleteHandler.ts',
|
||||
source: 'interactionAutocompleteHandler.ts',
|
||||
module: 'handler',
|
||||
name: 'interactionAutocompleteHandler',
|
||||
executionId: executionId
|
||||
});
|
||||
|
||||
// TODO: Create TS Type for autocompleteModule
|
||||
const autocompleteModule = await import(`../interactions/autocomplete/${interaction.commandName}.js`);
|
||||
const { default: autocomplete } = autocompleteModule;
|
||||
const autocomplete: BaseAutocompleteInteraction = client.autocompleteInteractions!.get(
|
||||
interactionIdentifier
|
||||
) as BaseAutocompleteInteraction;
|
||||
if (!autocomplete) {
|
||||
logger.warn(`Interaction created but autocomplete '${interactionIdentifier}' was not found.`);
|
||||
return;
|
||||
}
|
||||
|
||||
logger.debug('Executing autocomplete interaction.');
|
||||
logger.debug(`Executing autocomplete interaction '${interactionIdentifier}'.`);
|
||||
await autocomplete.execute({ interaction, executionId });
|
||||
};
|
||||
Reference in new issue
Block a user