mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-23 09:35:02 +00:00
Update backend/src/plugins/Automod/actions/crosspostMessage.ts
Co-authored-by: Almeida <almeidx@pm.me>
This commit is contained in:
parent
8c3d232eb9
commit
5b73253962
1 changed files with 12 additions and 15 deletions
|
@ -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);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue