diff --git a/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts b/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts index 8855ebeba9..55c92f093a 100644 --- a/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts +++ b/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts @@ -289,6 +289,10 @@ export class PaginatedMessage { /** * Sets the {@link PaginatedMessage.selectMenuPlaceholder} for this instance of {@link PaginatedMessage}. + * + * This applies only to the string select menu from the {@link PaginatedMessage.defaultActions} + * that offers "go to page" (we internally check the customId for this) + * * This will only apply to this one instance and no others. * @param placeholder The new placeholder to set * @returns The current instance of {@link PaginatedMessage} @@ -1277,6 +1281,7 @@ export class PaginatedMessage { if (isMessageStringSelectInteractionData(interaction)) { return new StringSelectMenuBuilder({ + ...interaction, ...(interaction.customId === '@sapphire/paginated-messages.goToPage' && { options: await Promise.all( this.pages.map(async (_, index) => { @@ -1290,8 +1295,7 @@ export class PaginatedMessage { }) ), placeholder: this.selectMenuPlaceholder - }), - ...interaction + }) }); } @@ -1528,6 +1532,7 @@ export class PaginatedMessage { { customId: '@sapphire/paginated-messages.goToPage', type: ComponentType.StringSelect, + options: [], run: ({ handler, interaction }) => interaction.isStringSelectMenu() && (handler.index = parseInt(interaction.values[0], 10)) }, { diff --git a/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessageTypes.ts b/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessageTypes.ts index 5edb0c0e09..6615b7af93 100644 --- a/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessageTypes.ts +++ b/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessageTypes.ts @@ -6,10 +6,12 @@ import type { ActionRowComponentOptions, ActionRowData, BaseMessageOptions, + BaseSelectMenuComponentData, ButtonInteraction, - ChannelSelectMenuComponentData, + ChannelType, CollectedInteraction, CommandInteraction, + ComponentType, EmbedBuilder, Guild, Interaction, @@ -19,19 +21,15 @@ import type { InteractionUpdateOptions, JSONEncodable, LinkButtonComponentData, - MentionableSelectMenuComponentData, Message, MessageActionRowComponentBuilder, MessageComponentInteraction, MessageEditOptions, MessageReplyOptions, ModalSubmitInteraction, - RoleSelectMenuComponentData, SelectMenuComponentOptionData, StageChannel, - StringSelectMenuComponentData, User, - UserSelectMenuComponentData, VoiceChannel, WebhookMessageEditOptions } from 'discord.js'; @@ -92,7 +90,11 @@ export type PaginatedMessageActionLink = LinkButtonComponentData; * } * ``` */ -export type PaginatedMessageActionStringMenu = StringSelectMenuComponentData & PaginatedMessageActionRun; +type PaginatedMessageActionStringMenu = PaginatedMessageActionRun & + BaseSelectMenuComponentData & { + type: ComponentType.StringSelect; + options: SelectMenuComponentOptionData[]; + }; /** * To utilize User Select Menus you can pass an object with the structure of {@link PaginatedMessageActionUserMenu} to {@link PaginatedMessage} actions. @@ -100,7 +102,7 @@ export type PaginatedMessageActionStringMenu = StringSelectMenuComponentData & P * ```typescript * const UserMenu: PaginatedMessageActionUserMenu = { * customId: 'CustomUserSelectMenu', - * type: ComponentType.ChannelSelect, + * type: ComponentType.UserSelect, * run: ({ interaction }) => { * if (interaction.isChannelSelectMenu()) { * console.log(interaction.values[0]) @@ -109,7 +111,11 @@ export type PaginatedMessageActionStringMenu = StringSelectMenuComponentData & P * } * ``` */ -export type PaginatedMessageActionUserMenu = UserSelectMenuComponentData & PaginatedMessageActionRun; +type PaginatedMessageActionUserMenu = PaginatedMessageActionRun & + BaseSelectMenuComponentData & { + type: ComponentType.UserSelect; + options?: never; + }; /** * To utilize Role Select Menus you can pass an object with the structure of {@link PaginatedMessageActionRoleMenu} to {@link PaginatedMessage} actions. @@ -126,7 +132,11 @@ export type PaginatedMessageActionUserMenu = UserSelectMenuComponentData & Pagin * } * ``` */ -export type PaginatedMessageActionRoleMenu = RoleSelectMenuComponentData & PaginatedMessageActionRun; +type PaginatedMessageActionRoleMenu = PaginatedMessageActionRun & + BaseSelectMenuComponentData & { + type: ComponentType.RoleSelect; + options?: never; + }; /** * To utilize Mentionable Select Menus you can pass an object with the structure of {@link PaginatedMessageActionMentionableMenu} to {@link PaginatedMessage} actions. @@ -143,7 +153,11 @@ export type PaginatedMessageActionRoleMenu = RoleSelectMenuComponentData & Pagin * } * ``` */ -export type PaginatedMessageActionMentionableMenu = MentionableSelectMenuComponentData & PaginatedMessageActionRun; +type PaginatedMessageActionMentionableMenu = PaginatedMessageActionRun & + BaseSelectMenuComponentData & { + type: ComponentType.MentionableSelect; + options?: never; + }; /** * To utilize Channel Select Menus you can pass an object with the structure of {@link PaginatedMessageActionChannelMenu} to {@link PaginatedMessage} actions. @@ -161,7 +175,12 @@ export type PaginatedMessageActionMentionableMenu = MentionableSelectMenuCompone * } * ``` */ -export type PaginatedMessageActionChannelMenu = ChannelSelectMenuComponentData & PaginatedMessageActionRun; +type PaginatedMessageActionChannelMenu = PaginatedMessageActionRun & + BaseSelectMenuComponentData & { + type: ComponentType.ChannelSelect; + channelTypes?: ChannelType[]; + options?: never; + }; /** * The context to be used in {@link PaginatedMessageActionButton}.