mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-03 06:28:53 +00:00
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
import { AutocompleteInteraction } from 'discord.js';
|
|
import { Logger } from 'pino';
|
|
import { BaseAutocompleteInteraction } from '../classes/interactions';
|
|
import loggerModule from '../services/logger';
|
|
import { ExtendedClient } from '../types/clientTypes';
|
|
|
|
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({
|
|
module: 'handler',
|
|
name: 'interactionAutocompleteHandler',
|
|
executionId: executionId
|
|
});
|
|
|
|
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 '${interactionIdentifier}'.`);
|
|
await autocomplete.execute({ interaction, executionId });
|
|
};
|