mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-01 16:30:08 +00:00
Closes: #2482 Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com>
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import type { Bot } from "../../bot.ts";
|
|
import { Message } from "../../transformers/message.ts";
|
|
import { DiscordMessage } from "../../types/discord.ts";
|
|
import { BigString, InteractionCallbackData, InteractionResponseTypes } from "../../types/mod.ts";
|
|
|
|
/**
|
|
* Edits the original webhook message.
|
|
*
|
|
* @param bot - The bot instance to use to make the request.
|
|
* @param webhookId - The ID of the webhook to edit the original message of.
|
|
* @param token - The webhook token, used to edit the message.
|
|
* @param options - The parameters for the edit of the message.
|
|
* @returns An instance of the edited {@link Message}.
|
|
*
|
|
* @remarks
|
|
* Fires a _Message Update_ gateway event.
|
|
*
|
|
* @see {@link https://discord.com/developers/docs/resources/webhook#edit-webhook-message}
|
|
*/
|
|
export async function editOriginalWebhookMessage(
|
|
bot: Bot,
|
|
webhookId: BigString,
|
|
token: string,
|
|
options: InteractionCallbackData & { threadId?: BigString },
|
|
): Promise<Message> {
|
|
const result = await bot.rest.runMethod<DiscordMessage>(
|
|
bot.rest,
|
|
"PATCH",
|
|
bot.constants.routes.WEBHOOK_MESSAGE_ORIGINAL(webhookId, token, options),
|
|
{
|
|
...bot.transformers.reverse.interactionResponse(bot, {
|
|
type: InteractionResponseTypes.UpdateMessage,
|
|
data: options,
|
|
}).data,
|
|
file: options.file,
|
|
},
|
|
);
|
|
|
|
return bot.transformers.message(bot, result);
|
|
}
|