mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-17 15:15:02 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
792a65c26c
22 changed files with 265 additions and 68 deletions
7
.clabot
7
.clabot
|
@ -23,7 +23,12 @@
|
||||||
"iamshoXy",
|
"iamshoXy",
|
||||||
"Scraayp",
|
"Scraayp",
|
||||||
"app/dependabot",
|
"app/dependabot",
|
||||||
"zayKenyon"
|
"zayKenyon",
|
||||||
|
"rukogit",
|
||||||
|
"Obliie",
|
||||||
|
"brawaru",
|
||||||
|
"Benricheson101",
|
||||||
|
"hawkeye7662"
|
||||||
],
|
],
|
||||||
"message": "Thank you for contributing to Zeppelin! We require contributors to sign our Contributor License Agreement (CLA). To let us review and merge your code, please visit https://github.com/ZeppelinBot/CLA to sign the CLA!"
|
"message": "Thank you for contributing to Zeppelin! We require contributors to sign our Contributor License Agreement (CLA). To let us review and merge your code, please visit https://github.com/ZeppelinBot/CLA to sign the CLA!"
|
||||||
}
|
}
|
||||||
|
|
38
backend/package-lock.json
generated
38
backend/package-lock.json
generated
|
@ -17,7 +17,6 @@
|
||||||
"discord.js": "^14.14.1",
|
"discord.js": "^14.14.1",
|
||||||
"dotenv": "^4.0.0",
|
"dotenv": "^4.0.0",
|
||||||
"emoji-regex": "^8.0.0",
|
"emoji-regex": "^8.0.0",
|
||||||
"erlpack": "github:discord/erlpack",
|
|
||||||
"escape-string-regexp": "^1.0.5",
|
"escape-string-regexp": "^1.0.5",
|
||||||
"express": "^4.17.0",
|
"express": "^4.17.0",
|
||||||
"fp-ts": "^2.0.1",
|
"fp-ts": "^2.0.1",
|
||||||
|
@ -1573,14 +1572,6 @@
|
||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/bindings": {
|
|
||||||
"version": "1.5.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz",
|
|
||||||
"integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
|
|
||||||
"dependencies": {
|
|
||||||
"file-uri-to-path": "1.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/bit-twiddle": {
|
"node_modules/bit-twiddle": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/bit-twiddle/-/bit-twiddle-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/bit-twiddle/-/bit-twiddle-1.0.2.tgz",
|
||||||
|
@ -3487,16 +3478,6 @@
|
||||||
"resolved": "https://registry.npmjs.org/env-string/-/env-string-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/env-string/-/env-string-1.0.1.tgz",
|
||||||
"integrity": "sha512-/DhCJDf5DSFK32joQiWRpWrT0h7p3hVQfMKxiBb7Nt8C8IF8BYyPtclDnuGGLOoj16d/8udKeiE7JbkotDmorQ=="
|
"integrity": "sha512-/DhCJDf5DSFK32joQiWRpWrT0h7p3hVQfMKxiBb7Nt8C8IF8BYyPtclDnuGGLOoj16d/8udKeiE7JbkotDmorQ=="
|
||||||
},
|
},
|
||||||
"node_modules/erlpack": {
|
|
||||||
"version": "0.1.3",
|
|
||||||
"resolved": "git+ssh://git@github.com/discord/erlpack.git#cbe76be04c2210fc9cb6ff95910f0937c1011d04",
|
|
||||||
"hasInstallScript": true,
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"bindings": "^1.5.0",
|
|
||||||
"nan": "^2.15.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/es5-ext": {
|
"node_modules/es5-ext": {
|
||||||
"version": "0.10.62",
|
"version": "0.10.62",
|
||||||
"resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.62.tgz",
|
"resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.62.tgz",
|
||||||
|
@ -3945,10 +3926,21 @@
|
||||||
"url": "https://github.com/sponsors/sindresorhus"
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/file-uri-to-path": {
|
"node_modules/file-type": {
|
||||||
"version": "1.0.0",
|
"version": "18.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/file-type/-/file-type-18.5.0.tgz",
|
||||||
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw=="
|
"integrity": "sha512-yvpl5U868+V6PqXHMmsESpg6unQ5GfnPssl4dxdJudBrr9qy7Fddt7EVX1VLlddFfe8Gj9N7goCZH22FXuSQXQ==",
|
||||||
|
"dependencies": {
|
||||||
|
"readable-web-to-node-stream": "^3.0.2",
|
||||||
|
"strtok3": "^7.0.0",
|
||||||
|
"token-types": "^5.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.16"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sindresorhus/file-type?sponsor=1"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"node_modules/fill-range": {
|
"node_modules/fill-range": {
|
||||||
"version": "7.0.1",
|
"version": "7.0.1",
|
||||||
|
|
|
@ -38,7 +38,6 @@
|
||||||
"discord.js": "^14.14.1",
|
"discord.js": "^14.14.1",
|
||||||
"dotenv": "^4.0.0",
|
"dotenv": "^4.0.0",
|
||||||
"emoji-regex": "^8.0.0",
|
"emoji-regex": "^8.0.0",
|
||||||
"erlpack": "github:discord/erlpack",
|
|
||||||
"escape-string-regexp": "^1.0.5",
|
"escape-string-regexp": "^1.0.5",
|
||||||
"express": "^4.17.0",
|
"express": "^4.17.0",
|
||||||
"fp-ts": "^2.0.1",
|
"fp-ts": "^2.0.1",
|
||||||
|
|
|
@ -11,6 +11,7 @@ import { CleanAction } from "./clean";
|
||||||
import { KickAction } from "./kick";
|
import { KickAction } from "./kick";
|
||||||
import { LogAction } from "./log";
|
import { LogAction } from "./log";
|
||||||
import { MuteAction } from "./mute";
|
import { MuteAction } from "./mute";
|
||||||
|
import { PauseInvitesAction } from "./pauseInvites";
|
||||||
import { RemoveRolesAction } from "./removeRoles";
|
import { RemoveRolesAction } from "./removeRoles";
|
||||||
import { ReplyAction } from "./reply";
|
import { ReplyAction } from "./reply";
|
||||||
import { SetAntiraidLevelAction } from "./setAntiraidLevel";
|
import { SetAntiraidLevelAction } from "./setAntiraidLevel";
|
||||||
|
@ -38,6 +39,7 @@ export const availableActions: Record<string, AutomodActionBlueprint<any>> = {
|
||||||
start_thread: StartThreadAction,
|
start_thread: StartThreadAction,
|
||||||
archive_thread: ArchiveThreadAction,
|
archive_thread: ArchiveThreadAction,
|
||||||
change_perms: ChangePermsAction,
|
change_perms: ChangePermsAction,
|
||||||
|
pause_invites: PauseInvitesAction,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const AvailableActions = t.type({
|
export const AvailableActions = t.type({
|
||||||
|
@ -59,4 +61,5 @@ export const AvailableActions = t.type({
|
||||||
start_thread: StartThreadAction.configType,
|
start_thread: StartThreadAction.configType,
|
||||||
archive_thread: ArchiveThreadAction.configType,
|
archive_thread: ArchiveThreadAction.configType,
|
||||||
change_perms: ChangePermsAction.configType,
|
change_perms: ChangePermsAction.configType,
|
||||||
|
pause_invites: PauseInvitesAction.configType,
|
||||||
});
|
});
|
||||||
|
|
19
backend/src/plugins/Automod/actions/pauseInvites.ts
Normal file
19
backend/src/plugins/Automod/actions/pauseInvites.ts
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
import { GuildFeature } from "discord.js";
|
||||||
|
import * as t from "io-ts";
|
||||||
|
import { automodAction } from "../helpers";
|
||||||
|
|
||||||
|
export const PauseInvitesAction = automodAction({
|
||||||
|
configType: t.type({
|
||||||
|
paused: t.boolean,
|
||||||
|
}),
|
||||||
|
|
||||||
|
defaultConfig: {},
|
||||||
|
|
||||||
|
async apply({ pluginData, actionConfig }) {
|
||||||
|
const hasInvitesDisabled = pluginData.guild.features.includes(GuildFeature.InvitesDisabled);
|
||||||
|
|
||||||
|
if (actionConfig.paused !== hasInvitesDisabled) {
|
||||||
|
await pluginData.guild.disableInvites(actionConfig.paused);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
|
@ -5,13 +5,15 @@ import { AutomodContext, AutomodPluginType } from "../types";
|
||||||
|
|
||||||
export async function runAutomodOnAntiraidLevel(
|
export async function runAutomodOnAntiraidLevel(
|
||||||
pluginData: GuildPluginData<AutomodPluginType>,
|
pluginData: GuildPluginData<AutomodPluginType>,
|
||||||
level: string | null,
|
newLevel: string | null,
|
||||||
|
oldLevel: string | null,
|
||||||
user?: User,
|
user?: User,
|
||||||
) {
|
) {
|
||||||
const context: AutomodContext = {
|
const context: AutomodContext = {
|
||||||
timestamp: Date.now(),
|
timestamp: Date.now(),
|
||||||
antiraid: {
|
antiraid: {
|
||||||
level,
|
level: newLevel,
|
||||||
|
oldLevel,
|
||||||
},
|
},
|
||||||
user,
|
user,
|
||||||
};
|
};
|
||||||
|
|
10
backend/src/plugins/Automod/functions/applyCooldown.ts
Normal file
10
backend/src/plugins/Automod/functions/applyCooldown.ts
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
import { GuildPluginData } from "knub";
|
||||||
|
import { convertDelayStringToMS } from "../../../utils";
|
||||||
|
import { AutomodContext, AutomodPluginType, TRule } from "../types";
|
||||||
|
|
||||||
|
export function applyCooldown(pluginData: GuildPluginData<AutomodPluginType>, rule: TRule, context: AutomodContext) {
|
||||||
|
const cooldownKey = `${rule.name}-${context.user?.id}`;
|
||||||
|
|
||||||
|
const cooldownTime = convertDelayStringToMS(rule.cooldown, "s");
|
||||||
|
if (cooldownTime) pluginData.state.cooldownManager.setCooldown(cooldownKey, cooldownTime);
|
||||||
|
}
|
|
@ -1,24 +0,0 @@
|
||||||
import { GuildPluginData } from "knub";
|
|
||||||
import { convertDelayStringToMS } from "../../../utils";
|
|
||||||
import { AutomodContext, AutomodPluginType, TRule } from "../types";
|
|
||||||
|
|
||||||
export function checkAndUpdateCooldown(
|
|
||||||
pluginData: GuildPluginData<AutomodPluginType>,
|
|
||||||
rule: TRule,
|
|
||||||
context: AutomodContext,
|
|
||||||
) {
|
|
||||||
const cooldownKey = `${rule.name}-${context.user?.id}`;
|
|
||||||
|
|
||||||
if (cooldownKey) {
|
|
||||||
if (pluginData.state.cooldownManager.isOnCooldown(cooldownKey)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const cooldownTime = convertDelayStringToMS(rule.cooldown, "s");
|
|
||||||
if (cooldownTime) {
|
|
||||||
pluginData.state.cooldownManager.setCooldown(cooldownKey, cooldownTime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
8
backend/src/plugins/Automod/functions/checkCooldown.ts
Normal file
8
backend/src/plugins/Automod/functions/checkCooldown.ts
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
import { GuildPluginData } from "knub";
|
||||||
|
import { AutomodContext, AutomodPluginType, TRule } from "../types";
|
||||||
|
|
||||||
|
export function checkCooldown(pluginData: GuildPluginData<AutomodPluginType>, rule: TRule, context: AutomodContext) {
|
||||||
|
const cooldownKey = `${rule.name}-${context.user?.id}`;
|
||||||
|
|
||||||
|
return pluginData.state.cooldownManager.isOnCooldown(cooldownKey);
|
||||||
|
}
|
|
@ -7,7 +7,8 @@ import { CleanAction } from "../actions/clean";
|
||||||
import { AutomodTriggerMatchResult } from "../helpers";
|
import { AutomodTriggerMatchResult } from "../helpers";
|
||||||
import { availableTriggers } from "../triggers/availableTriggers";
|
import { availableTriggers } from "../triggers/availableTriggers";
|
||||||
import { AutomodContext, AutomodPluginType } from "../types";
|
import { AutomodContext, AutomodPluginType } from "../types";
|
||||||
import { checkAndUpdateCooldown } from "./checkAndUpdateCooldown";
|
import { applyCooldown } from "./applyCooldown";
|
||||||
|
import { checkCooldown } from "./checkCooldown";
|
||||||
|
|
||||||
export async function runAutomod(pluginData: GuildPluginData<AutomodPluginType>, context: AutomodContext) {
|
export async function runAutomod(pluginData: GuildPluginData<AutomodPluginType>, context: AutomodContext) {
|
||||||
const userId = context.user?.id || context.member?.id || context.message?.user_id;
|
const userId = context.user?.id || context.member?.id || context.message?.user_id;
|
||||||
|
@ -46,7 +47,7 @@ export async function runAutomod(pluginData: GuildPluginData<AutomodPluginType>,
|
||||||
}
|
}
|
||||||
if (!rule.affects_self && userId && userId === pluginData.client.user?.id) continue;
|
if (!rule.affects_self && userId && userId === pluginData.client.user?.id) continue;
|
||||||
|
|
||||||
if (rule.cooldown && checkAndUpdateCooldown(pluginData, rule, context)) {
|
if (rule.cooldown && checkCooldown(pluginData, rule, context)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +85,8 @@ export async function runAutomod(pluginData: GuildPluginData<AutomodPluginType>,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (matchResult) {
|
if (matchResult) {
|
||||||
|
if (rule.cooldown) applyCooldown(pluginData, rule, context);
|
||||||
|
|
||||||
contexts = [context, ...(matchResult.extraContexts || [])];
|
contexts = [context, ...(matchResult.extraContexts || [])];
|
||||||
|
|
||||||
for (const _context of contexts) {
|
for (const _context of contexts) {
|
||||||
|
|
|
@ -9,10 +9,11 @@ export async function setAntiraidLevel(
|
||||||
newLevel: string | null,
|
newLevel: string | null,
|
||||||
user?: User,
|
user?: User,
|
||||||
) {
|
) {
|
||||||
|
const oldLevel = pluginData.state.cachedAntiraidLevel;
|
||||||
pluginData.state.cachedAntiraidLevel = newLevel;
|
pluginData.state.cachedAntiraidLevel = newLevel;
|
||||||
await pluginData.state.antiraidLevels.set(newLevel);
|
await pluginData.state.antiraidLevels.set(newLevel);
|
||||||
|
|
||||||
runAutomodOnAntiraidLevel(pluginData, newLevel, user);
|
runAutomodOnAntiraidLevel(pluginData, newLevel, oldLevel, user);
|
||||||
|
|
||||||
const logs = pluginData.getPlugin(LogsPlugin);
|
const logs = pluginData.getPlugin(LogsPlugin);
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ interface AntiraidLevelTriggerResult {}
|
||||||
export const AntiraidLevelTrigger = automodTrigger<AntiraidLevelTriggerResult>()({
|
export const AntiraidLevelTrigger = automodTrigger<AntiraidLevelTriggerResult>()({
|
||||||
configType: t.type({
|
configType: t.type({
|
||||||
level: tNullable(t.string),
|
level: tNullable(t.string),
|
||||||
|
only_on_change: tNullable(t.boolean),
|
||||||
}),
|
}),
|
||||||
|
|
||||||
defaultConfig: {},
|
defaultConfig: {},
|
||||||
|
@ -20,6 +21,14 @@ export const AntiraidLevelTrigger = automodTrigger<AntiraidLevelTriggerResult>()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
triggerConfig.only_on_change &&
|
||||||
|
context.antiraid.oldLevel !== undefined &&
|
||||||
|
context.antiraid.level === context.antiraid.oldLevel
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
extra: {},
|
extra: {},
|
||||||
};
|
};
|
||||||
|
|
|
@ -54,7 +54,7 @@ export const MatchWordsTrigger = automodTrigger<MatchResultType>()({
|
||||||
const looseMatchingThreshold = Math.min(Math.max(trigger.loose_matching_threshold, 1), 64);
|
const looseMatchingThreshold = Math.min(Math.max(trigger.loose_matching_threshold, 1), 64);
|
||||||
const patterns = trigger.words.map((word) => {
|
const patterns = trigger.words.map((word) => {
|
||||||
let pattern = trigger.loose_matching
|
let pattern = trigger.loose_matching
|
||||||
? [...word].map((c) => escapeStringRegexp(c)).join(`(?:\\s*|.{0,${looseMatchingThreshold})`)
|
? [...word].map((c) => escapeStringRegexp(c)).join(`(?:\\s*|.{0,${looseMatchingThreshold}})`)
|
||||||
: escapeStringRegexp(word);
|
: escapeStringRegexp(word);
|
||||||
|
|
||||||
if (trigger.only_full_words) {
|
if (trigger.only_full_words) {
|
||||||
|
|
|
@ -130,6 +130,7 @@ export interface AutomodContext {
|
||||||
};
|
};
|
||||||
antiraid?: {
|
antiraid?: {
|
||||||
level: string | null;
|
level: string | null;
|
||||||
|
oldLevel?: string | null;
|
||||||
};
|
};
|
||||||
threadChange?: {
|
threadChange?: {
|
||||||
created?: ThreadChannel;
|
created?: ThreadChannel;
|
||||||
|
|
|
@ -57,9 +57,10 @@ export async function clearMute(
|
||||||
await member.timeout(null);
|
await member.timeout(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pluginData.getPlugin(LogsPlugin).logMemberMuteExpired({ member });
|
||||||
} catch {
|
} catch {
|
||||||
pluginData.getPlugin(LogsPlugin).logBotAlert({
|
pluginData.getPlugin(LogsPlugin).logBotAlert({
|
||||||
body: `Failed to remove mute role from ${verboseUserMention(member.user)}`,
|
body: `Failed to clear mute from ${verboseUserMention(member.user)}`,
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|
|
@ -3,7 +3,6 @@ import { GuildLogs } from "../../data/GuildLogs";
|
||||||
import { GuildPersistedData } from "../../data/GuildPersistedData";
|
import { GuildPersistedData } from "../../data/GuildPersistedData";
|
||||||
import { makeIoTsConfigParser } from "../../pluginUtils";
|
import { makeIoTsConfigParser } from "../../pluginUtils";
|
||||||
import { trimPluginDescription } from "../../utils";
|
import { trimPluginDescription } from "../../utils";
|
||||||
import { GuildMemberCachePlugin } from "../GuildMemberCache/GuildMemberCachePlugin";
|
|
||||||
import { LogsPlugin } from "../Logs/LogsPlugin";
|
import { LogsPlugin } from "../Logs/LogsPlugin";
|
||||||
import { RoleManagerPlugin } from "../RoleManager/RoleManagerPlugin";
|
import { RoleManagerPlugin } from "../RoleManager/RoleManagerPlugin";
|
||||||
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
|
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
|
||||||
|
@ -31,7 +30,7 @@ export const PersistPlugin = zeppelinGuildPlugin<PersistPluginType>()({
|
||||||
configSchema: ConfigSchema,
|
configSchema: ConfigSchema,
|
||||||
},
|
},
|
||||||
|
|
||||||
dependencies: () => [LogsPlugin, RoleManagerPlugin, GuildMemberCachePlugin],
|
dependencies: () => [LogsPlugin, RoleManagerPlugin],
|
||||||
configParser: makeIoTsConfigParser(ConfigSchema),
|
configParser: makeIoTsConfigParser(ConfigSchema),
|
||||||
defaultOptions,
|
defaultOptions,
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { PersistedData } from "../../../data/entities/PersistedData";
|
import { PersistedData } from "../../../data/entities/PersistedData";
|
||||||
import { GuildMemberCachePlugin } from "../../GuildMemberCache/GuildMemberCachePlugin";
|
|
||||||
import { persistEvt } from "../types";
|
import { persistEvt } from "../types";
|
||||||
|
|
||||||
export const StoreDataEvt = persistEvt({
|
export const StoreDataEvt = persistEvt({
|
||||||
|
@ -9,8 +8,11 @@ export const StoreDataEvt = persistEvt({
|
||||||
const config = await pluginData.config.getForUser(member.user);
|
const config = await pluginData.config.getForUser(member.user);
|
||||||
const persistData: Partial<PersistedData> = {};
|
const persistData: Partial<PersistedData> = {};
|
||||||
|
|
||||||
|
// FIXME: New caching thing, or fix deadlocks with this plugin
|
||||||
if (member.partial) {
|
if (member.partial) {
|
||||||
|
return;
|
||||||
// Djs hasn't cached member data => use db cache
|
// Djs hasn't cached member data => use db cache
|
||||||
|
/*
|
||||||
const data = await pluginData.getPlugin(GuildMemberCachePlugin).getCachedMemberData(member.id);
|
const data = await pluginData.getPlugin(GuildMemberCachePlugin).getCachedMemberData(member.id);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return;
|
return;
|
||||||
|
@ -22,7 +24,7 @@ export const StoreDataEvt = persistEvt({
|
||||||
}
|
}
|
||||||
if (config.persist_nicknames && data.nickname) {
|
if (config.persist_nicknames && data.nickname) {
|
||||||
persistData.nickname = data.nickname;
|
persistData.nickname = data.nickname;
|
||||||
}
|
}*/
|
||||||
} else {
|
} else {
|
||||||
// Djs has cached member data => use that
|
// Djs has cached member data => use that
|
||||||
const memberRoles = Array.from(member.roles.cache.keys());
|
const memberRoles = Array.from(member.roles.cache.keys());
|
||||||
|
|
|
@ -86,6 +86,12 @@ export async function applyReactionRoleReactionsToMessage(
|
||||||
body: `Error ${e.code} while applying reaction role reactions to ${channelId}/${messageId}: ${e.message}`,
|
body: `Error ${e.code} while applying reaction role reactions to ${channelId}/${messageId}: ${e.message}`,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
} else if (e.code === 30010) {
|
||||||
|
errors.push(`Maximum number of reactions reached (20)`);
|
||||||
|
logs.logBotAlert({
|
||||||
|
body: `Error ${e.code} while applying reaction role reactions to ${channelId}/${messageId}: ${e.message}`,
|
||||||
|
});
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ import { CustomEventsPlugin } from "./CustomEvents/CustomEventsPlugin";
|
||||||
import { GuildAccessMonitorPlugin } from "./GuildAccessMonitor/GuildAccessMonitorPlugin";
|
import { GuildAccessMonitorPlugin } from "./GuildAccessMonitor/GuildAccessMonitorPlugin";
|
||||||
import { GuildConfigReloaderPlugin } from "./GuildConfigReloader/GuildConfigReloaderPlugin";
|
import { GuildConfigReloaderPlugin } from "./GuildConfigReloader/GuildConfigReloaderPlugin";
|
||||||
import { GuildInfoSaverPlugin } from "./GuildInfoSaver/GuildInfoSaverPlugin";
|
import { GuildInfoSaverPlugin } from "./GuildInfoSaver/GuildInfoSaverPlugin";
|
||||||
import { GuildMemberCachePlugin } from "./GuildMemberCache/GuildMemberCachePlugin";
|
|
||||||
import { InternalPosterPlugin } from "./InternalPoster/InternalPosterPlugin";
|
import { InternalPosterPlugin } from "./InternalPoster/InternalPosterPlugin";
|
||||||
import { LocateUserPlugin } from "./LocateUser/LocateUserPlugin";
|
import { LocateUserPlugin } from "./LocateUser/LocateUserPlugin";
|
||||||
import { LogsPlugin } from "./Logs/LogsPlugin";
|
import { LogsPlugin } from "./Logs/LogsPlugin";
|
||||||
|
@ -54,7 +53,7 @@ export const guildPlugins: Array<ZeppelinGuildPluginBlueprint<any>> = [
|
||||||
PostPlugin,
|
PostPlugin,
|
||||||
ReactionRolesPlugin,
|
ReactionRolesPlugin,
|
||||||
MessageSaverPlugin,
|
MessageSaverPlugin,
|
||||||
GuildMemberCachePlugin,
|
// GuildMemberCachePlugin, // FIXME: New caching thing, or fix deadlocks with this plugin
|
||||||
ModActionsPlugin,
|
ModActionsPlugin,
|
||||||
NameHistoryPlugin,
|
NameHistoryPlugin,
|
||||||
RemindersPlugin,
|
RemindersPlugin,
|
||||||
|
@ -93,7 +92,7 @@ export const baseGuildPlugins: Array<ZeppelinGuildPluginBlueprint<any>> = [
|
||||||
GuildInfoSaverPlugin,
|
GuildInfoSaverPlugin,
|
||||||
MessageSaverPlugin,
|
MessageSaverPlugin,
|
||||||
NameHistoryPlugin,
|
NameHistoryPlugin,
|
||||||
GuildMemberCachePlugin,
|
// GuildMemberCachePlugin, // FIXME: New caching thing, or fix deadlocks with this plugin
|
||||||
CasesPlugin,
|
CasesPlugin,
|
||||||
MutesPlugin,
|
MutesPlugin,
|
||||||
TimeAndDatePlugin,
|
TimeAndDatePlugin,
|
||||||
|
|
|
@ -135,7 +135,7 @@ export interface TDeepPartialProps<P extends t.Props>
|
||||||
{
|
{
|
||||||
[K in keyof P]?: TDeepPartial<t.OutputOf<P[K]>>;
|
[K in keyof P]?: TDeepPartial<t.OutputOf<P[K]>>;
|
||||||
}
|
}
|
||||||
> { }
|
> {}
|
||||||
|
|
||||||
export function tDeepPartial<T>(type: T): TDeepPartial<T> {
|
export function tDeepPartial<T>(type: T): TDeepPartial<T> {
|
||||||
if (type instanceof t.InterfaceType || type instanceof t.PartialType) {
|
if (type instanceof t.InterfaceType || type instanceof t.PartialType) {
|
||||||
|
@ -220,7 +220,7 @@ export interface PartialDictionaryC<D extends t.Mixed, C extends t.Mixed>
|
||||||
[K in t.OutputOf<D>]?: t.OutputOf<C>;
|
[K in t.OutputOf<D>]?: t.OutputOf<C>;
|
||||||
},
|
},
|
||||||
unknown
|
unknown
|
||||||
> { }
|
> {}
|
||||||
|
|
||||||
export const tPartialDictionary = <D extends t.Mixed, C extends t.Mixed>(
|
export const tPartialDictionary = <D extends t.Mixed, C extends t.Mixed>(
|
||||||
domain: D,
|
domain: D,
|
||||||
|
@ -652,7 +652,13 @@ export function getUrlsInString(str: string, onlyUnique = false): MatchedURL[] {
|
||||||
return urls;
|
return urls;
|
||||||
}
|
}
|
||||||
|
|
||||||
const hostnameParts = matchUrl.hostname.split(".");
|
let hostname = matchUrl.hostname.toLowerCase();
|
||||||
|
|
||||||
|
if (hostname.length > 3) {
|
||||||
|
hostname = hostname.replace(/[^a-z]+$/, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
const hostnameParts = hostname.split(".");
|
||||||
const tld = hostnameParts[hostnameParts.length - 1];
|
const tld = hostnameParts[hostnameParts.length - 1];
|
||||||
if (tlds.includes(tld)) {
|
if (tlds.includes(tld)) {
|
||||||
urls.push(matchUrl);
|
urls.push(matchUrl);
|
||||||
|
@ -1617,4 +1623,4 @@ export function renderUsername(username: string, discriminator: string): string
|
||||||
|
|
||||||
export function renderUserUsername(user: User | UnknownUser): string {
|
export function renderUserUsername(user: User | UnknownUser): string {
|
||||||
return renderUsername(user.username, user.discriminator);
|
return renderUsername(user.username, user.discriminator);
|
||||||
}
|
}
|
||||||
|
|
156
dashboard/src/components/docs/Moderation.vue
Normal file
156
dashboard/src/components/docs/Moderation.vue
Normal file
|
@ -0,0 +1,156 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<header>
|
||||||
|
<h1>Moderation</h1>
|
||||||
|
<p>
|
||||||
|
Moderation in Zeppelin is multi-layered. On top of typical actions such
|
||||||
|
as warning, muting, kicking, and banning, Zeppelin allows moderators to
|
||||||
|
utilise flags; create alerts; set thresholds; and act as others.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
This guide explains the options available in the
|
||||||
|
<router-link to="/docs/plugins/modactions"> Mod actions</router-link>
|
||||||
|
plugin. To best use this guide, read the default configuration of the
|
||||||
|
Mod actions plugin alongside this. This plugin does
|
||||||
|
<strong>not</strong> cover muting members, please see the
|
||||||
|
<router-link to="/docs/plugins/mutes">Mutes</router-link>
|
||||||
|
plugin for that.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Please ensure you understand how
|
||||||
|
<router-link to="/docs/plugins/plugin-configuration">plugin
|
||||||
|
configuration</router-link> and
|
||||||
|
<router-link to="/docs/configuration/permissions">plugin
|
||||||
|
permissions</router-link> work before reading this guide since
|
||||||
|
the configs defined here rely on these concepts.
|
||||||
|
</p>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<h2>Moderation Commands</h2>
|
||||||
|
<p>
|
||||||
|
So that your moderators may use Zeppelin moderation, you must define the
|
||||||
|
moderator role id in the config, assign it a level (50), and enable the
|
||||||
|
Mod actions plugin.
|
||||||
|
<CodeBlock code-lang="yaml" trim="start">
|
||||||
|
levels:
|
||||||
|
"PRETEND-ROLE-ID": 50 # Mod
|
||||||
|
|
||||||
|
plugins:
|
||||||
|
mod_actions: {}
|
||||||
|
</CodeBlock>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Each moderation command has a permission attached to it, so if your
|
||||||
|
server has a hierarchical structure then you will be able to scope
|
||||||
|
these permissions by referencing the plugins permissions page.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<h2>Sanction Notifications</h2>
|
||||||
|
<p>These config options define how Zeppelin will interact with the
|
||||||
|
members it sanctions (warns, kicks, bans).</p>
|
||||||
|
|
||||||
|
<h3>DM Values</h3>
|
||||||
|
<p>
|
||||||
|
The values <code>dm_on_warn</code>, <code>dm_on_kick</code>, and
|
||||||
|
<code>dm_on_ban</code> determine whether a member will be notified of
|
||||||
|
their sanctions through DMs. Ignoring privacy settings, setting these to
|
||||||
|
<code>true</code> will notify the member. Temporary banning uses the
|
||||||
|
ban configuration.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<h3>Channel Values</h3>
|
||||||
|
<p>
|
||||||
|
An alternative way to notify members about sanctions is through
|
||||||
|
mentioning them in a message sent in a channel. To enable this feature,
|
||||||
|
set <code>message_on_warn</code>, <code>message_on_kick</code>, and
|
||||||
|
and <code>message_on_ban</code> to true, then assign a
|
||||||
|
<code>message_channel</code>.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<h3>Notifying messages</h3>
|
||||||
|
<p>
|
||||||
|
This is how you control the exact wording the member receives. You can
|
||||||
|
adjust the wording per sanction type. These variables are
|
||||||
|
<code>warn_message</code>, <code>kick_message</code>, and
|
||||||
|
<code>ban_message</code>. Please remember that YAML supports mutli-line
|
||||||
|
strings, this is how you can write newlines in your messages. Notably,
|
||||||
|
temporarily banning a member permits the inclusion of the
|
||||||
|
<code>banTime</code> variable through <code>tempban_message</code>.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<h3>Summary Example</h3>
|
||||||
|
<p>
|
||||||
|
Employing what we have learnt so far, we can write a configuration that:
|
||||||
|
<ul>
|
||||||
|
<li>Alerts members of their warns in a channel, instead of DMs.</li>
|
||||||
|
<li>Alerts members of kicks and bans in their DMs.</li>
|
||||||
|
<li>Makes use of multi-line strings to prepare a tidy message.</li>
|
||||||
|
<li>Includes the remaining ban time if a ban was temporary.</li>
|
||||||
|
</ul>
|
||||||
|
<CodeBlock code-lang="yaml" trim="start">
|
||||||
|
plugins:
|
||||||
|
mod_actions:
|
||||||
|
config:
|
||||||
|
dm_on_warn: false
|
||||||
|
message_on_warn: true
|
||||||
|
message_channel: "PRETEND-CHANNEL-ID"
|
||||||
|
|
||||||
|
dm_on_kick: true
|
||||||
|
|
||||||
|
dm_on_ban: true
|
||||||
|
tempban_message: |-
|
||||||
|
Dear {user.username},
|
||||||
|
|
||||||
|
As a result of {reason}, you have been banned from {guildName}
|
||||||
|
for {banTime}. We welcome you back provided you do not do this
|
||||||
|
again.
|
||||||
|
</CodeBlock>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<h2>Alerts</h2>
|
||||||
|
<p>
|
||||||
|
Alerts are a nifty way for moderators to be notified of members trying to
|
||||||
|
evade sanctions by promptly leaving and rejoining your server. To enable
|
||||||
|
this feature, assign a channel in <code>alert_channel</code> and enable
|
||||||
|
<code>alert_on_rejoin</code>.
|
||||||
|
</p>
|
||||||
|
<CodeBlock code-lang="yaml" trim="start">
|
||||||
|
plugins:
|
||||||
|
mod_actions:
|
||||||
|
config:
|
||||||
|
alert_on_rejoin: true
|
||||||
|
alert_channel: "PRETEND-CHANNEL-ID"
|
||||||
|
</CodeBlock>
|
||||||
|
|
||||||
|
<h2>Thresholds</h2>
|
||||||
|
<p>
|
||||||
|
Thresholds alert moderators if a member is about to exceed a
|
||||||
|
predetermined number of cases, prompting moderators to consider whether
|
||||||
|
alternative (harsher) action could be taken. To enable thresholds,
|
||||||
|
assign the threshold as <code>warn_notify_threshold</code>, adjust the
|
||||||
|
message under <code>warn_notify_message</code>, and enable
|
||||||
|
<code>warn_notify_enabled</code>.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Write your config cleverly, check the default values for
|
||||||
|
<code>warn_notify_threshold</code> and <code>warn_notify_message</code>,
|
||||||
|
if these are acceptable then all you need to do is enable
|
||||||
|
<code>warn_notify_enabled</code>.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<h2>Ban Message Deletion</h2>
|
||||||
|
<p>
|
||||||
|
When a member is banned, Zeppelin automatically deletes the last day of
|
||||||
|
message history. You can extend this through the
|
||||||
|
<code>ban_delete_message_days</code> option.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import CodeBlock from "./CodeBlock.vue";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: { CodeBlock },
|
||||||
|
};
|
||||||
|
</script>
|
|
@ -51,7 +51,7 @@ export const router = new VueRouter({
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "setup-guides/moderation",
|
path: "setup-guides/moderation",
|
||||||
component: () => import("./components/docs/WorkInProgress.vue"),
|
component: () => import("./components/docs/Moderation.vue"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "setup-guides/counters",
|
path: "setup-guides/counters",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue