From 163cebdcd0349f30fdcdb80f50d62166c36ba964 Mon Sep 17 00:00:00 2001 From: Fleny Date: Sun, 26 May 2024 20:49:05 +0200 Subject: [PATCH] Add the poll object to the message transformer (#3624) Co-authored-by: Awesome Stickz --- packages/bot/src/transformers.ts | 2 ++ packages/bot/src/transformers/message.ts | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/bot/src/transformers.ts b/packages/bot/src/transformers.ts index 20f9b7f35..f5d23099c 100644 --- a/packages/bot/src/transformers.ts +++ b/packages/bot/src/transformers.ts @@ -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, 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, diff --git a/packages/bot/src/transformers/message.ts b/packages/bot/src/transformers/message.ts index 9b0affbc1..d0c09fc71 100644 --- a/packages/bot/src/transformers/message.ts +++ b/packages/bot/src/transformers/message.ts @@ -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)