mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-23 09:35:02 +00:00
initial
This commit is contained in:
parent
8dfa9aec2a
commit
e1499f64fc
2 changed files with 32 additions and 0 deletions
|
@ -7,6 +7,7 @@ import { ArchiveThreadAction } from "./archiveThread";
|
||||||
import { BanAction } from "./ban";
|
import { BanAction } from "./ban";
|
||||||
import { ChangeNicknameAction } from "./changeNickname";
|
import { ChangeNicknameAction } from "./changeNickname";
|
||||||
import { CleanAction } from "./clean";
|
import { CleanAction } from "./clean";
|
||||||
|
import { CrosspostMessageAction } from "./crosspostMessage";
|
||||||
import { KickAction } from "./kick";
|
import { KickAction } from "./kick";
|
||||||
import { LogAction } from "./log";
|
import { LogAction } from "./log";
|
||||||
import { MuteAction } from "./mute";
|
import { MuteAction } from "./mute";
|
||||||
|
@ -34,6 +35,7 @@ export const availableActions: Record<string, AutomodActionBlueprint<any>> = {
|
||||||
set_counter: SetCounterAction,
|
set_counter: SetCounterAction,
|
||||||
set_slowmode: SetSlowmodeAction,
|
set_slowmode: SetSlowmodeAction,
|
||||||
archive_thread: ArchiveThreadAction,
|
archive_thread: ArchiveThreadAction,
|
||||||
|
crosspost_message: CrosspostMessageAction,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const AvailableActions = t.type({
|
export const AvailableActions = t.type({
|
||||||
|
@ -53,4 +55,5 @@ export const AvailableActions = t.type({
|
||||||
set_counter: SetCounterAction.configType,
|
set_counter: SetCounterAction.configType,
|
||||||
set_slowmode: SetSlowmodeAction.configType,
|
set_slowmode: SetSlowmodeAction.configType,
|
||||||
archive_thread: ArchiveThreadAction.configType,
|
archive_thread: ArchiveThreadAction.configType,
|
||||||
|
crosspost_message: CrosspostMessageAction.configType,
|
||||||
});
|
});
|
||||||
|
|
29
backend/src/plugins/Automod/actions/crosspostMessage.ts
Normal file
29
backend/src/plugins/Automod/actions/crosspostMessage.ts
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
import { Message } from "discord.js";
|
||||||
|
import * as t from "io-ts";
|
||||||
|
import { ChannelTypeStrings } from "src/types";
|
||||||
|
import { automodAction } from "../helpers";
|
||||||
|
|
||||||
|
export const CrosspostMessageAction = automodAction({
|
||||||
|
configType: t.type({}),
|
||||||
|
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;
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
for (const msg of messages) {
|
||||||
|
await msg?.crosspost();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
Loading…
Add table
Add a link
Reference in a new issue