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 18:49:05 +00:00
committed by GitHub
co-authored by Awesome Stickz
parent e33b44e5e5
commit 163cebdcd0
2 changed files with 6 additions and 1 deletions
+2
View File
@@ -389,6 +389,7 @@ export interface Transformers {
thread: boolean thread: boolean
type: boolean type: boolean
webhookId: boolean webhookId: boolean
poll: boolean
call: { call: {
participants: boolean participants: boolean
endedTimestamp: boolean endedTimestamp: boolean
@@ -997,6 +998,7 @@ export function createTransformers(options: Partial<Transformers>, opts?: Create
thread: opts?.defaultDesiredPropertiesValue ?? false, thread: opts?.defaultDesiredPropertiesValue ?? false,
type: opts?.defaultDesiredPropertiesValue ?? false, type: opts?.defaultDesiredPropertiesValue ?? false,
webhookId: opts?.defaultDesiredPropertiesValue ?? false, webhookId: opts?.defaultDesiredPropertiesValue ?? false,
poll: opts?.defaultDesiredPropertiesValue ?? false,
call: { call: {
participants: opts?.defaultDesiredPropertiesValue ?? false, participants: opts?.defaultDesiredPropertiesValue ?? false,
endedTimestamp: opts?.defaultDesiredPropertiesValue ?? false, endedTimestamp: opts?.defaultDesiredPropertiesValue ?? false,
+4 -1
View File
@@ -9,7 +9,7 @@ import {
type StickerFormatTypes, type StickerFormatTypes,
} from '@discordeno/types' } from '@discordeno/types'
import { CHANNEL_MENTION_REGEX } from '../constants.js' 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 { MessageFlags } from '../typings.js'
import type { Attachment } from './attachment.js' import type { Attachment } from './attachment.js'
import type { Channel } from './channel.js' import type { Channel } from './channel.js'
@@ -271,6 +271,8 @@ export interface Message extends MessageBase {
thread?: Channel thread?: Channel
/** If the message is generated by a webhook, this is the webhook's id */ /** If the message is generated by a webhook, this is the webhook's id */
webhookId?: bigint webhookId?: bigint
/** A poll! */
poll?: Poll
/** The call associated with the message */ /** The call associated with the message */
call?: MessageCall 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.thread && payload.thread) message.thread = bot.transformers.channel(bot, { channel: payload.thread, guildId })
if (props.type) message.type = payload.type if (props.type) message.type = payload.type
if (props.webhookId && payload.webhook_id) message.webhookId = bot.transformers.snowflake(payload.webhook_id) 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) if (props.call && payload.call) message.call = bot.transformers.messageCall(bot, payload.call)
return bot.transformers.customizers.message(bot, payload, message) return bot.transformers.customizers.message(bot, payload, message)