mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-25 18:25:03 +00:00
Merge ddf685a5a2
into 3cf08e5a49
This commit is contained in:
commit
15677c848f
2 changed files with 29 additions and 0 deletions
|
@ -7,6 +7,7 @@ import { ArchiveThreadAction } from "./archiveThread";
|
|||
import { BanAction } from "./ban";
|
||||
import { ChangeNicknameAction } from "./changeNickname";
|
||||
import { CleanAction } from "./clean";
|
||||
import { CrosspostMessageAction } from "./crosspostMessage";
|
||||
import { KickAction } from "./kick";
|
||||
import { LogAction } from "./log";
|
||||
import { MuteAction } from "./mute";
|
||||
|
@ -36,6 +37,7 @@ export const availableActions: Record<string, AutomodActionBlueprint<any>> = {
|
|||
set_slowmode: SetSlowmodeAction,
|
||||
start_thread: StartThreadAction,
|
||||
archive_thread: ArchiveThreadAction,
|
||||
crosspost_message: CrosspostMessageAction,
|
||||
};
|
||||
|
||||
export const AvailableActions = t.type({
|
||||
|
@ -56,4 +58,5 @@ export const AvailableActions = t.type({
|
|||
set_slowmode: SetSlowmodeAction.configType,
|
||||
start_thread: StartThreadAction.configType,
|
||||
archive_thread: ArchiveThreadAction.configType,
|
||||
crosspost_message: CrosspostMessageAction.configType,
|
||||
});
|
||||
|
|
26
backend/src/plugins/Automod/actions/crosspostMessage.ts
Normal file
26
backend/src/plugins/Automod/actions/crosspostMessage.ts
Normal file
|
@ -0,0 +1,26 @@
|
|||
import * as t from "io-ts";
|
||||
import { ChannelTypeStrings } from "../../../types";
|
||||
import { noop } from "../../../utils";
|
||||
import { automodAction } from "../helpers";
|
||||
|
||||
export const CrosspostMessageAction = automodAction({
|
||||
configType: t.type({}),
|
||||
defaultConfig: {},
|
||||
|
||||
async apply({ pluginData, contexts }) {
|
||||
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 await (const msg of messages) {
|
||||
if (msg?.crosspostable) await msg?.crosspost().catch(noop);
|
||||
}
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue