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: {},
|
defaultConfig: {},
|
||||||
|
|
||||||
async apply({ pluginData, contexts, actionConfig }) {
|
async apply({ pluginData, contexts, actionConfig }) {
|
||||||
const messages = await Promise.all(
|
const messages = contexts
|
||||||
contexts
|
|
||||||
.filter(c => c.message?.id)
|
.filter(c => c.message?.id)
|
||||||
.map(async c => {
|
.map(c => {
|
||||||
const channel = pluginData.guild.channels.cache.get(c.message!.channel_id);
|
const channel = pluginData.guild.channels.cache.get(c.message!.channel_id);
|
||||||
if (channel?.type === ChannelTypeStrings.NEWS && channel.isText()) {
|
if (channel?.type === ChannelTypeStrings.NEWS && channel.isText()) {
|
||||||
// .isText() to fix the typings
|
// .isText() to fix the typings
|
||||||
const msg = await channel.messages.fetch(c.message!.id);
|
return channel.messages.fetch(c.message!.id);
|
||||||
return msg && msg.crosspostable ? msg : null;
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}),
|
});
|
||||||
);
|
|
||||||
|
|
||||||
for (const msg of messages) {
|
for await (const msg of messages) {
|
||||||
await msg?.crosspost().catch(noop);
|
if (msg?.crosspostable) await msg?.crosspost().catch(noop);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue