From 0f02125b0f1c8738523e24cbc279c58b8417b97b Mon Sep 17 00:00:00 2001 From: metal Date: Fri, 27 Aug 2021 15:37:44 +0000 Subject: [PATCH] add createChunkedEmbedMessage util --- backend/src/utils.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/backend/src/utils.ts b/backend/src/utils.ts index 8a7f7c55..97e0bdbb 100644 --- a/backend/src/utils.ts +++ b/backend/src/utils.ts @@ -1012,6 +1012,18 @@ export async function createChunkedMessage( } } +export async function createChunkedEmbedMessage( + channel: TextChannel | ThreadChannel | User, + messageEmbeds: MessageEmbed[], + allowedMentions?: MessageMentionOptions, + maxChunkLength = 10, +) { + const chunks = chunkArray(messageEmbeds, maxChunkLength); + for (const chunk of chunks) { + await channel.send({ embeds: chunk, allowedMentions }); + } +} + /** * Downloads the file from the given URL to a temporary file, with retry support */