Add the poll object to the message transformer (#3624)

Co-authored-by: Awesome Stickz <awesome@stickz.dev>
This commit is contained in:
Fleny
2024-05-26 20:49:05 +02:00
committed by GitHub
parent e33b44e5e5
commit 163cebdcd0
2 changed files with 6 additions and 1 deletions

View File

@@ -389,6 +389,7 @@ export interface Transformers {
thread: boolean
type: boolean
webhookId: boolean
poll: boolean
call: {
participants: boolean
endedTimestamp: boolean
@@ -997,6 +998,7 @@ export function createTransformers(options: Partial<Transformers>, opts?: Create
thread: opts?.defaultDesiredPropertiesValue ?? false,
type: opts?.defaultDesiredPropertiesValue ?? false,
webhookId: opts?.defaultDesiredPropertiesValue ?? false,
poll: opts?.defaultDesiredPropertiesValue ?? false,
call: {
participants: opts?.defaultDesiredPropertiesValue ?? false,
endedTimestamp: opts?.defaultDesiredPropertiesValue ?? false,

View File

@@ -9,7 +9,7 @@ import {
type StickerFormatTypes,
} from '@discordeno/types'
import { CHANNEL_MENTION_REGEX } from '../constants.js'
import { snowflakeToTimestamp, type Bot } from '../index.js'
import { snowflakeToTimestamp, type Bot, type Poll } from '../index.js'
import { MessageFlags } from '../typings.js'
import type { Attachment } from './attachment.js'
import type { Channel } from './channel.js'
@@ -271,6 +271,8 @@ export interface Message extends MessageBase {
thread?: Channel
/** If the message is generated by a webhook, this is the webhook's id */
webhookId?: bigint
/** A poll! */
poll?: Poll
/** The call associated with the message */
call?: MessageCall
}
@@ -386,6 +388,7 @@ export function transformMessage(bot: Bot, payload: DiscordMessage): Message {
if (props.thread && payload.thread) message.thread = bot.transformers.channel(bot, { channel: payload.thread, guildId })
if (props.type) message.type = payload.type
if (props.webhookId && payload.webhook_id) message.webhookId = bot.transformers.snowflake(payload.webhook_id)
if (props.poll && payload.poll) message.poll = bot.transformers.poll(bot, payload.poll)
if (props.call && payload.call) message.call = bot.transformers.messageCall(bot, payload.call)
return bot.transformers.customizers.message(bot, payload, message)