feat: polls

Added support for polls similar to discord.js v14 (including class, event).
Breaking change: Do not use and remove MessagePoll.
This commit is contained in:
Elysia
2024-10-27 10:45:29 +07:00
parent 4c39f68353
commit 966f25bb8d
21 changed files with 8898 additions and 395 deletions

View File

@@ -27,7 +27,7 @@ class InteractionResponses {
/**
* Options for a reply to an {@link Interaction}.
* @typedef {BaseMessageOptions} InteractionReplyOptions
* @typedef {BaseMessageOptionsWithPoll} InteractionReplyOptions
* @property {boolean} [ephemeral] Whether the reply should be ephemeral
* @property {boolean} [fetchReply] Whether to fetch the reply
* @property {MessageFlags} [flags] Which flags to set for the message.

View File

@@ -60,6 +60,28 @@ class TextBasedChannel {
return this.lastPinTimestamp ? new Date(this.lastPinTimestamp) : null;
}
/**
* Represents the data for a poll answer.
* @typedef {Object} PollAnswerData
* @property {string} text The text for the poll answer
* @property {EmojiIdentifierResolvable} [emoji] The emoji for the poll answer
*/
/**
* Represents the data for a poll.
* @typedef {Object} PollData
* @property {PollQuestionMedia} question The question for the poll
* @property {PollAnswerData[]} answers The answers for the poll
* @property {number} duration The duration in hours for the poll
* @property {boolean} allowMultiselect Whether the poll allows multiple answers
* @property {PollLayoutType} [layoutType] The layout type for the poll
*/
/**
* @external PollLayoutType
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/PollLayoutType}
*/
/**
* Base options provided when sending.
* @typedef {Object} BaseMessageOptions
@@ -75,7 +97,12 @@ class TextBasedChannel {
* @property {Array<(MessageActionRow|MessageActionRowOptions)>} [components]
* Action rows containing interactive components for the message (buttons, select menus)
* @property {MessageAttachment[]} [attachments] Attachments to send in the message
* @property {MessagePoll} [poll] A poll!
*/
/**
* The base message options for messages including a poll.
* @typedef {BaseMessageOptions} BaseMessageOptionsWithPoll
* @property {PollData} [poll] The poll to send with the message
*/
/**