diff --git a/packages/core/src/structures.ts b/packages/core/src/structures.ts index e715c4f..9512260 100644 --- a/packages/core/src/structures.ts +++ b/packages/core/src/structures.ts @@ -11,7 +11,7 @@ export * from './structures/invite'; export * from './structures/members'; export * from './structures/message'; export * from './structures/message-reaction'; -export * from './structures/special/command-interaction-option-resolver'; +export * from './structures/special/interaction-options'; export * from './structures/special/permissions'; export * from './structures/presence'; export * from './structures/role'; diff --git a/packages/core/src/structures/interactions.ts b/packages/core/src/structures/interactions.ts index d39eeb5..3f55405 100644 --- a/packages/core/src/structures/interactions.ts +++ b/packages/core/src/structures/interactions.ts @@ -24,7 +24,7 @@ import { Member } from './members'; import { Message } from './message'; import { Permissions } from './special/permissions'; import { Webhook } from './webhook'; -import { CommandInteractionOptionResolver } from './special/command-interaction-option-resolver'; +import { InteractionOptions } from './special/interaction-options'; import { INTERACTION_ID_TOKEN, WEBHOOK_MESSAGE, @@ -329,7 +329,7 @@ export class AutoCompleteInteraction extends BaseInteraction implements Model { this.commandType = data.data!.type; this.commandGuildId = data.data!.guild_id; this.locale = super.locale!; - this.options = new CommandInteractionOptionResolver( + this.options = new InteractionOptions( data.data!.options ?? [] ); } @@ -340,7 +340,7 @@ export class AutoCompleteInteraction extends BaseInteraction implements Model { commandType: ApplicationCommandTypes; commandGuildId?: Snowflake; override locale: string; - options: CommandInteractionOptionResolver; + options: InteractionOptions; async respondWithChoices( choices: ApplicationCommandOptionChoice[] @@ -371,7 +371,7 @@ export class CommandInteraction extends BaseInteraction implements Model { this.commandName = data.data!.name; this.commandType = data.data!.type; this.commandGuildId = data.data!.guild_id; - this.options = new CommandInteractionOptionResolver( + this.options = new InteractionOptions( data.data!.options ?? [] ); @@ -436,7 +436,7 @@ export class CommandInteraction extends BaseInteraction implements Model { commandType: ApplicationCommandTypes; commandGuildId?: Snowflake; resolved: CommandInteractionDataResolved; - options: CommandInteractionOptionResolver; + options: InteractionOptions; override locale: string; } diff --git a/packages/core/src/structures/special/command-interaction-option-resolver.ts b/packages/core/src/structures/special/interaction-options.ts similarity index 94% rename from packages/core/src/structures/special/command-interaction-option-resolver.ts rename to packages/core/src/structures/special/interaction-options.ts index 14eac44..6637839 100644 --- a/packages/core/src/structures/special/command-interaction-option-resolver.ts +++ b/packages/core/src/structures/special/interaction-options.ts @@ -7,12 +7,11 @@ import { ApplicationCommandOptionTypes } from '@biscuitland/api-types'; /** * Utility class to get the resolved options for a command - * It is really typesafe * @example const option = ctx.options.getStringOption("name"); */ -export class CommandInteractionOptionResolver { - #subcommand?: string; - #group?: string; +export class InteractionOptions { + private _subcommand?: string; + private _group?: string; hoistedOptions: DiscordInteractionDataOption[]; resolved?: DiscordInteractionDataResolved; @@ -29,7 +28,7 @@ export class CommandInteractionOptionResolver { this.hoistedOptions[0]?.type === ApplicationCommandOptionTypes.SubCommandGroup ) { - this.#group = this.hoistedOptions[0].name; + this._group = this.hoistedOptions[0].name; this.hoistedOptions = this.hoistedOptions[0].options ?? []; } @@ -37,7 +36,7 @@ export class CommandInteractionOptionResolver { this.hoistedOptions[0]?.type === ApplicationCommandOptionTypes.SubCommand ) { - this.#subcommand = this.hoistedOptions[0].name; + this._subcommand = this.hoistedOptions[0].name; this.hoistedOptions = this.hoistedOptions[0].options ?? []; } @@ -249,20 +248,20 @@ export class CommandInteractionOptionResolver { getSubCommand( required = true ): [string | undefined, DiscordInteractionDataOption[]] { - if (required && !this.#subcommand) { + if (required && !this._subcommand) { throw new TypeError('Option marked as required was undefined'); } - return [this.#subcommand, this.hoistedOptions]; + return [this._subcommand, this.hoistedOptions]; } getSubCommandGroup( required = false ): [string | undefined, DiscordInteractionDataOption[]] { - if (required && !this.#group) { + if (required && !this._group) { throw new TypeError('Option marked as required was undefined'); } - return [this.#group, this.hoistedOptions]; + return [this._group, this.hoistedOptions]; } }