From 5b73253962a8d4b03e952610b55aa104984f5565 Mon Sep 17 00:00:00 2001 From: metal Date: Wed, 8 Sep 2021 11:39:54 +0100 Subject: [PATCH] Update backend/src/plugins/Automod/actions/crosspostMessage.ts Co-authored-by: Almeida --- .../Automod/actions/crosspostMessage.ts | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/backend/src/plugins/Automod/actions/crosspostMessage.ts b/backend/src/plugins/Automod/actions/crosspostMessage.ts index bd079ee4..4b6b5c7c 100644 --- a/backend/src/plugins/Automod/actions/crosspostMessage.ts +++ b/backend/src/plugins/Automod/actions/crosspostMessage.ts @@ -9,22 +9,19 @@ export const CrosspostMessageAction = automodAction({ defaultConfig: {}, async apply({ pluginData, contexts, actionConfig }) { - const messages = await Promise.all( - contexts - .filter(c => c.message?.id) - .map(async c => { - const channel = pluginData.guild.channels.cache.get(c.message!.channel_id); - if (channel?.type === ChannelTypeStrings.NEWS && channel.isText()) { - // .isText() to fix the typings - const msg = await channel.messages.fetch(c.message!.id); - return msg && msg.crosspostable ? msg : null; - } - return null; - }), - ); + const messages = contexts + .filter(c => c.message?.id) + .map(c => { + const channel = pluginData.guild.channels.cache.get(c.message!.channel_id); + if (channel?.type === ChannelTypeStrings.NEWS && channel.isText()) { + // .isText() to fix the typings + return channel.messages.fetch(c.message!.id); + } + return null; + }); - for (const msg of messages) { - await msg?.crosspost().catch(noop); + for await (const msg of messages) { + if (msg?.crosspostable) await msg?.crosspost().catch(noop); } }, });