Skip to content

Commit 665bf14

Browse files
TAEMBOJiralite
andauthoredSep 17, 2024··
types(MessageEditOptions): Omit poll (#10509)
fix: creating poll from message edit Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
1 parent 99136d6 commit 665bf14

File tree

5 files changed

+27
-7
lines changed

5 files changed

+27
-7
lines changed
 

‎packages/discord.js/src/structures/Webhook.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class Webhook {
126126

127127
/**
128128
* Options that can be passed into send.
129-
* @typedef {BaseMessageOptions} WebhookMessageCreateOptions
129+
* @typedef {BaseMessageOptionsWithPoll} WebhookMessageCreateOptions
130130
* @property {boolean} [tts=false] Whether the message should be spoken aloud
131131
* @property {MessageFlags} [flags] Which flags to set for the message.
132132
* <info>Only the {@link MessageFlags.SuppressEmbeds} flag can be set.</info>

‎packages/discord.js/src/structures/interfaces/InteractionResponses.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class InteractionResponses {
3636

3737
/**
3838
* Options for a reply to a {@link BaseInteraction}.
39-
* @typedef {BaseMessageOptions} InteractionReplyOptions
39+
* @typedef {BaseMessageOptionsWithPoll} InteractionReplyOptions
4040
* @property {boolean} [tts=false] Whether the message should be spoken aloud
4141
* @property {boolean} [ephemeral] Whether the reply should be ephemeral
4242
* @property {boolean} [fetchReply] Whether to fetch the reply

‎packages/discord.js/src/structures/interfaces/TextBasedChannel.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ class TextBasedChannel {
8080
* The files to send with the message.
8181
* @property {Array<(ActionRowBuilder|ActionRow|APIActionRowComponent)>} [components]
8282
* Action rows containing interactive components for the message (buttons, select menus)
83+
*/
84+
85+
/**
86+
* The base message options for messages including a poll.
87+
* @typedef {BaseMessageOptions} BaseMessageOptionsWithPoll
8388
* @property {PollData} [poll] The poll to send with the message
8489
*/
8590

@@ -93,7 +98,7 @@ class TextBasedChannel {
9398

9499
/**
95100
* The options for sending a message.
96-
* @typedef {BaseMessageOptions} BaseMessageCreateOptions
101+
* @typedef {BaseMessageOptionsWithPoll} BaseMessageCreateOptions
97102
* @property {boolean} [tts=false] Whether the message should be spoken aloud
98103
* @property {string} [nonce] The nonce for the message
99104
* <info>This property is required if `enforceNonce` set to `true`.</info>

‎packages/discord.js/typings/index.d.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -6291,7 +6291,7 @@ export interface InteractionDeferReplyOptions {
62916291

62926292
export interface InteractionDeferUpdateOptions extends Omit<InteractionDeferReplyOptions, 'ephemeral'> {}
62936293

6294-
export interface InteractionReplyOptions extends BaseMessageOptions {
6294+
export interface InteractionReplyOptions extends BaseMessageOptionsWithPoll {
62956295
tts?: boolean;
62966296
ephemeral?: boolean;
62976297
fetchReply?: boolean;
@@ -6459,10 +6459,13 @@ export interface BaseMessageOptions {
64596459
| ActionRowData<MessageActionRowComponentData | MessageActionRowComponentBuilder>
64606460
| APIActionRowComponent<APIMessageActionRowComponent>
64616461
)[];
6462+
}
6463+
6464+
export interface BaseMessageOptionsWithPoll extends BaseMessageOptions {
64626465
poll?: PollData;
64636466
}
64646467

6465-
export interface MessageCreateOptions extends BaseMessageOptions {
6468+
export interface MessageCreateOptions extends BaseMessageOptionsWithPoll {
64666469
tts?: boolean;
64676470
nonce?: string | number;
64686471
enforceNonce?: boolean;
@@ -6475,7 +6478,7 @@ export interface MessageCreateOptions extends BaseMessageOptions {
64756478
}
64766479

64776480
export interface GuildForumThreadMessageCreateOptions
6478-
extends Omit<BaseMessageOptions, 'poll'>,
6481+
extends BaseMessageOptions,
64796482
Pick<MessageCreateOptions, 'flags' | 'stickers'> {}
64806483

64816484
export interface MessageEditAttachmentData {
@@ -6981,7 +6984,9 @@ export interface WebhookMessageEditOptions extends Omit<MessageEditOptions, 'fla
69816984
threadId?: Snowflake;
69826985
}
69836986

6984-
export interface InteractionEditReplyOptions extends WebhookMessageEditOptions {
6987+
export interface InteractionEditReplyOptions
6988+
extends WebhookMessageEditOptions,
6989+
Pick<BaseMessageOptionsWithPoll, 'poll'> {
69856990
message?: MessageResolvable | '@original';
69866991
}
69876992

‎packages/discord.js/typings/index.test-d.ts

+10
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ import {
210210
ApplicationEmojiManager,
211211
StickerPack,
212212
SendableChannels,
213+
PollData,
213214
} from '.';
214215
import { expectAssignable, expectDeprecated, expectNotAssignable, expectNotType, expectType } from 'tsd';
215216
import type { ContextMenuCommandBuilder, SlashCommandBuilder } from '@discordjs/builders';
@@ -2576,6 +2577,8 @@ await textChannel.send({
25762577
});
25772578

25782579
declare const poll: Poll;
2580+
declare const message: Message;
2581+
declare const pollData: PollData;
25792582
{
25802583
expectType<Message>(await poll.end());
25812584

@@ -2589,6 +2592,13 @@ declare const poll: Poll;
25892592
messageId: snowflake,
25902593
answerId: 1,
25912594
});
2595+
2596+
await message.edit({
2597+
// @ts-expect-error
2598+
poll: pollData,
2599+
});
2600+
2601+
await chatInputInteraction.editReply({ poll: pollData });
25922602
}
25932603

25942604
expectType<Collection<Snowflake, StickerPack>>(await client.fetchStickerPacks());

0 commit comments

Comments
 (0)
Please sign in to comment.