From b5099a005efbef607372149a57dac043a19fa634 Mon Sep 17 00:00:00 2001 From: MARCROCK22 <57925328+MARCROCK22@users.noreply.github.com> Date: Thu, 9 May 2024 14:35:34 -0400 Subject: [PATCH] fix: options resolver --- src/client/oninteractioncreate.ts | 2 +- src/index.ts | 2 +- src/structures/Interaction.ts | 19 +++++++++++-------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/client/oninteractioncreate.ts b/src/client/oninteractioncreate.ts index ef3d9d6..6aded2f 100644 --- a/src/client/oninteractioncreate.ts +++ b/src/client/oninteractioncreate.ts @@ -41,7 +41,7 @@ export async function onInteractionCreate( body.guild_id, body.data.resolved as ContextOptionsResolved, ); - const interaction = new AutocompleteInteraction(self, body, __reply); + const interaction = new AutocompleteInteraction(self, body, optionsResolver, __reply); const command = optionsResolver.getAutocomplete(); // idc, is a YOU problem diff --git a/src/index.ts b/src/index.ts index fdbc1b3..e6f81d1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,7 +9,7 @@ import { } from './client/base'; import type { ClientNameEvents, EventContext } from './events'; import { isCloudfareWorker } from './common'; -export { Logger, PermissionStrings } from './common'; +export { Logger, PermissionStrings, Watcher } from './common'; // export { Collection, LimitedCollection } from './collection'; // diff --git a/src/structures/Interaction.ts b/src/structures/Interaction.ts index e9c706a..5655041 100644 --- a/src/structures/Interaction.ts +++ b/src/structures/Interaction.ts @@ -216,7 +216,7 @@ export class BaseInteraction< static from(client: UsingClient, gateway: GatewayInteractionCreateDispatchData, __reply?: __InternalReplyFunction) { switch (gateway.type) { case InteractionType.ApplicationCommandAutocomplete: - return new AutocompleteInteraction(client, gateway, __reply); + return new AutocompleteInteraction(client, gateway, undefined, __reply); // biome-ignore lint/suspicious/noFallthroughSwitchClause: bad interaction between biome and ts-server case InteractionType.ApplicationCommand: switch (gateway.data.type) { @@ -299,16 +299,19 @@ export class AutocompleteInteraction extend constructor( client: UsingClient, interaction: APIApplicationCommandAutocompleteInteraction, + resolver?: OptionResolver, protected __reply?: __InternalReplyFunction, ) { super(client, interaction); - this.options = new OptionResolver( - client, - interaction.data.options, - undefined, - interaction.guild_id, - interaction.data.resolved as ContextOptionsResolved, - ); + this.options = + resolver ?? + new OptionResolver( + client, + interaction.data.options, + undefined, + interaction.guild_id, + interaction.data.resolved as ContextOptionsResolved, + ); } getInput() {