diff --git a/lib/routes/Channels.ts b/lib/routes/Channels.ts index 07d13780..fc7a9f88 100644 --- a/lib/routes/Channels.ts +++ b/lib/routes/Channels.ts @@ -178,10 +178,7 @@ export default class Channels { method: "POST", path: Routes.CHANNEL_MESSAGES(channelID), json: { - // HACK: currently, allowed_mentions cannot be sent along with a poll. Due to how this previously worked, allowed mentions was ALWAYS sent. - // We check if poll is not present (or if allowedMentions IS present, for future proofing), and don't send allowed_mentions - // ^ If fixed make sure to remove the note from the "poll" property in the CreateMessageOptions interface - allowed_mentions: options.poll === undefined || options.allowedMentions ? this.#manager.client.util.formatAllowedMentions(options.allowedMentions) : undefined, + allowed_mentions: this.#manager.client.util.formatAllowedMentions(options.allowedMentions), attachments: options.attachments, components: options.components ? this.#manager.client.util.componentsToRaw(options.components) : undefined, content: options.content, diff --git a/lib/routes/Webhooks.ts b/lib/routes/Webhooks.ts index 37fa279d..d638da2f 100644 --- a/lib/routes/Webhooks.ts +++ b/lib/routes/Webhooks.ts @@ -129,12 +129,12 @@ export default class Webhooks { * @caching This method **does not** cache its result. */ async editMessage(webhookID: string, token: string, messageID: string, options: EditWebhookMessageOptions): Promise> { - const files = options.files; + const files = options.files ?? undefined; if (options.files) { delete options.files; } const query = new URLSearchParams(); - if (options.threadID !== undefined) { + if (options.threadID) { query.set("thread_id", options.threadID); } return this.#manager.authRequest({ @@ -205,6 +205,7 @@ export default class Webhooks { content: options.content, embeds: options.embeds ? this.#manager.client.util.embedsToRaw(options.embeds) : undefined, flags: options.flags, + poll: options.poll, thread_name: options.threadName, tts: options.tts, username: options.username diff --git a/lib/types/channels.d.ts b/lib/types/channels.d.ts index f3ca0f84..45a151d2 100644 --- a/lib/types/channels.d.ts +++ b/lib/types/channels.d.ts @@ -309,11 +309,8 @@ export interface CreateMessageOptions { /** Reply to a message. */ messageReference?: MessageReference; /** - * A poll to send. - * @note As of [3/22/24](https://github.com/discord/discord-api-docs/pull/6746): - * * content, components, and many other fields cannot be sent alongside a poll. - * * * This means we cannot set `allowedMentions`. If in the future `content` can be sent alongside a poll, allowedMentions will not be set automatically, and must be set manually. - * * Messages with a poll cannot be edited. + * A poll to send. Messages with a poll cannot be edited. + * @note As of [4/18/24](https://github.com/discord/discord-api-docs/pull/6746#issuecomment-2064810908), `attachments` cannot be sent with polls. */ poll?: MessagePollOptions; /** The IDs of up to 3 stickers from the current guild to send. */ diff --git a/lib/types/webhooks.d.ts b/lib/types/webhooks.d.ts index 716921ac..2fef1e8e 100644 --- a/lib/types/webhooks.d.ts +++ b/lib/types/webhooks.d.ts @@ -2,6 +2,7 @@ import type { CreateMessageOptions, RawChannel } from "./channels"; import type { RawGuild } from "./guilds"; import type { RawUser } from "./users"; +import type { Nullable } from "./misc"; import type { WebhookTypes } from "../Constants"; export interface RawWebhook {