edit webhook default original

This commit is contained in:
ITOH
2021-05-04 18:34:27 +02:00
parent 9dbb0621ac
commit 4dc0e636e0
2 changed files with 6 additions and 3 deletions

View File

@@ -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<Message>(
"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 },
);

View File

@@ -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) =>