3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-17 15:15:02 +00:00

Merge remote-tracking branch 'origin/master' into iots_to_zod

This commit is contained in:
Dragory 2024-01-27 14:12:06 +02:00
commit 59c5176cbd
No known key found for this signature in database
39 changed files with 1420 additions and 2208 deletions

View file

@ -10,6 +10,7 @@ import { CleanAction } from "./clean";
import { KickAction } from "./kick";
import { LogAction } from "./log";
import { MuteAction } from "./mute";
import { PauseInvitesAction } from "./pauseInvites";
import { RemoveRolesAction } from "./removeRoles";
import { ReplyAction } from "./reply";
import { SetAntiraidLevelAction } from "./setAntiraidLevel";
@ -37,4 +38,5 @@ export const availableActions = {
start_thread: StartThreadAction,
archive_thread: ArchiveThreadAction,
change_perms: ChangePermsAction,
pause_invites: PauseInvitesAction,
} satisfies Record<string, AutomodActionBlueprint<any>>;

View file

@ -0,0 +1,17 @@
import { GuildFeature } from "discord.js";
import z from "zod";
import { automodAction } from "../helpers";
export const PauseInvitesAction = automodAction({
configSchema: z.strictObject({
paused: z.boolean(),
}),
async apply({ pluginData, actionConfig }) {
const hasInvitesDisabled = pluginData.guild.features.includes(GuildFeature.InvitesDisabled);
if (actionConfig.paused !== hasInvitesDisabled) {
await pluginData.guild.disableInvites(actionConfig.paused);
}
},
});

View file

@ -10,14 +10,17 @@ export const SetSlowmodeAction = automodAction({
duration: zDelayString.nullable().default("10s"),
}),
async apply({ pluginData, actionConfig }) {
async apply({ pluginData, actionConfig, contexts }) {
const slowmodeMs = Math.max(actionConfig.duration ? convertDelayStringToMS(actionConfig.duration)! : 0, 0);
for (const channelId of actionConfig.channels) {
const channels: Snowflake[] = actionConfig.channels ?? [];
if (channels.length === 0) {
channels.push(...contexts.filter((c) => c.message?.channel_id).map((c) => c.message!.channel_id));
}
for (const channelId of channels) {
const channel = pluginData.guild.channels.cache.get(channelId as Snowflake);
// Only text channels and text channels within categories support slowmodes
if (!channel || (!channel.isTextBased() && channel.type !== ChannelType.GuildCategory)) {
if (!channel?.isTextBased() && channel?.type !== ChannelType.GuildCategory) {
continue;
}