change: validate components at start

This commit is contained in:
ITOH
2021-05-31 19:48:31 +02:00
parent 71df32b684
commit 04c093bbff

View File

@@ -47,6 +47,10 @@ export async function sendMessage(channelId: bigint, content: string | CreateMes
throw new Error(Errors.MESSAGE_MAX_LENGTH);
}
if (content.components?.length) {
validateComponents(content.components);
}
if (content.allowedMentions) {
if (content.allowedMentions.users?.length) {
if (content.allowedMentions.parse?.includes(DiscordAllowedMentionsTypes.UserMentions)) {
@@ -69,10 +73,6 @@ export async function sendMessage(channelId: bigint, content: string | CreateMes
}
}
if (content.components?.length) {
validateComponents(content.components);
}
const result = await rest.runMethod<Message>(
"post",
endpoints.CHANNEL_MESSAGES(channelId),