From 4dc0e636e098dc31a3fa5ddc8b20d0c35ac3eb1f Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Tue, 4 May 2021 18:34:27 +0200 Subject: [PATCH] edit webhook default original --- src/helpers/webhooks/edit_webhook_message.ts | 7 ++++--- src/util/constants.ts | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/helpers/webhooks/edit_webhook_message.ts b/src/helpers/webhooks/edit_webhook_message.ts index d49ca7dfb..f1565263b 100644 --- a/src/helpers/webhooks/edit_webhook_message.ts +++ b/src/helpers/webhooks/edit_webhook_message.ts @@ -9,8 +9,7 @@ import { endpoints } from "../../util/constants.ts"; export async function editWebhookMessage( webhookId: bigint, webhookToken: string, - messageId: bigint, - options: EditWebhookMessage, + options: EditWebhookMessage & { messageId?: bigint }, ) { if (options.content && options.content.length > 2000) { throw Error(Errors.MESSAGE_MAX_LENGTH); @@ -62,7 +61,9 @@ export async function editWebhookMessage( const result = await rest.runMethod( "patch", - endpoints.WEBHOOK_MESSAGE(webhookId, webhookToken, messageId), + options.messageId + ? endpoints.WEBHOOK_MESSAGE(webhookId, webhookToken, options.messageId) + : endpoints.WEBHOOK_MESSAGE_ORIGINAL(webhookId, webhookToken), { ...options, allowedMentions: options.allowedMentions }, ); diff --git a/src/util/constants.ts b/src/util/constants.ts index 132f802f7..24f86e828 100644 --- a/src/util/constants.ts +++ b/src/util/constants.ts @@ -138,6 +138,8 @@ export const endpoints = { `${baseEndpoints.BASE_URL}/webhooks/${webhookId}`, WEBHOOK_MESSAGE: (webhookId: bigint, token: string, messageId: bigint) => `${baseEndpoints.BASE_URL}/webhooks/${webhookId}/${token}/messages/${messageId}`, + WEBHOOK_MESSAGE_ORIGINAL: (webhookId: bigint, token: string) => + `${baseEndpoints.BASE_URL}/webhooks/${webhookId}/${token}/messages/@original`, WEBHOOK_SLACK: (webhookId: bigint, token: string) => `${baseEndpoints.BASE_URL}/webhooks/${webhookId}/${token}/slack`, WEBHOOK_GITHUB: (webhookId: bigint, token: string) =>