fix: snakelize request body

This commit is contained in:
ITOH
2021-05-31 19:48:13 +02:00
parent 220ea9ebb8
commit 83b7a708e7
12 changed files with 54 additions and 46 deletions
@@ -5,6 +5,7 @@ import type { DiscordenoEditWebhookMessage } from "../../../types/discordeno/edi
import { Errors } from "../../../types/discordeno/errors.ts";
import { DiscordAllowedMentionsTypes } from "../../../types/messages/allowed_mentions_types.ts";
import { endpoints } from "../../../util/constants.ts";
import { snakelize, validateComponents } from "../../../util/utils.ts";
/** To edit your response to a slash command. If a messageId is not provided it will default to editing the original response. */
export async function editSlashResponse(token: string, options: DiscordenoEditWebhookMessage) {
@@ -12,6 +13,10 @@ export async function editSlashResponse(token: string, options: DiscordenoEditWe
throw Error(Errors.MESSAGE_MAX_LENGTH);
}
if (options.components?.length) {
validateComponents(options.components);
}
if (options.embeds && options.embeds.length > 10) {
options.embeds.splice(10);
}
@@ -43,7 +48,7 @@ export async function editSlashResponse(token: string, options: DiscordenoEditWe
options.messageId
? endpoints.WEBHOOK_MESSAGE(applicationId, token, options.messageId)
: endpoints.INTERACTION_ORIGINAL_ID_TOKEN(applicationId, token),
options
snakelize(options)
);
// If the original message was edited, this will not return a message