mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-11 20:55:01 +00:00
Finish preliminary rework, ready to test
This commit is contained in:
parent
57893e7f76
commit
d0a1beb809
177 changed files with 854 additions and 707 deletions
|
@ -8,6 +8,7 @@ import { safeFindRelevantAuditLogEntry } from "../../../utils/safeFindRelevantAu
|
|||
import { LogType } from "../../../data/LogType";
|
||||
import { stripObjectToScalars, resolveUser, UnknownUser } from "../../../utils";
|
||||
import { Case } from "../../../data/entities/Case";
|
||||
import { GuildAuditLogs, User } from "discord.js";
|
||||
|
||||
/**
|
||||
* Create a BAN case automatically when a user is banned manually.
|
||||
|
@ -15,7 +16,8 @@ import { Case } from "../../../data/entities/Case";
|
|||
*/
|
||||
export const CreateBanCaseOnManualBanEvt = modActionsEvt({
|
||||
event: "guildBanAdd",
|
||||
async listener({ pluginData, args: { guild, user } }) {
|
||||
async listener({ pluginData, args: { ban } }) {
|
||||
const user = ban.user;
|
||||
if (isEventIgnored(pluginData, IgnoredEventType.Ban, user.id)) {
|
||||
clearIgnoredEvents(pluginData, IgnoredEventType.Ban, user.id);
|
||||
return;
|
||||
|
@ -23,7 +25,7 @@ export const CreateBanCaseOnManualBanEvt = modActionsEvt({
|
|||
|
||||
const relevantAuditLogEntry = await safeFindRelevantAuditLogEntry(
|
||||
pluginData,
|
||||
ErisConstants.AuditLogActions.MEMBER_BAN_ADD,
|
||||
GuildAuditLogs.Actions.MEMBER_BAN_ADD as number,
|
||||
user.id,
|
||||
);
|
||||
|
||||
|
@ -34,7 +36,7 @@ export const CreateBanCaseOnManualBanEvt = modActionsEvt({
|
|||
let reason = "";
|
||||
|
||||
if (relevantAuditLogEntry) {
|
||||
const modId = relevantAuditLogEntry.user.id;
|
||||
const modId = relevantAuditLogEntry.executor!.id;
|
||||
const auditLogId = relevantAuditLogEntry.id;
|
||||
|
||||
mod = await resolveUser(pluginData.client, modId);
|
||||
|
|
|
@ -9,6 +9,7 @@ import { LogType } from "../../../data/LogType";
|
|||
import { resolveUser, stripObjectToScalars, UnknownUser } from "../../../utils";
|
||||
import { safeFindRelevantAuditLogEntry } from "../../../utils/safeFindRelevantAuditLogEntry";
|
||||
import { Case } from "../../../data/entities/Case";
|
||||
import { GuildAuditLogs, User } from "discord.js";
|
||||
|
||||
/**
|
||||
* Create a KICK case automatically when a user is kicked manually.
|
||||
|
@ -24,7 +25,7 @@ export const CreateKickCaseOnManualKickEvt = modActionsEvt({
|
|||
|
||||
const kickAuditLogEntry = await safeFindRelevantAuditLogEntry(
|
||||
pluginData,
|
||||
ErisConstants.AuditLogActions.MEMBER_KICK,
|
||||
GuildAuditLogs.Actions.MEMBER_KICK as number,
|
||||
member.id,
|
||||
);
|
||||
|
||||
|
@ -40,7 +41,7 @@ export const CreateKickCaseOnManualKickEvt = modActionsEvt({
|
|||
`Tried to create duplicate case for audit log entry ${kickAuditLogEntry.id}, existing case id ${createdCase.id}`,
|
||||
);
|
||||
} else {
|
||||
mod = await resolveUser(pluginData.client, kickAuditLogEntry.user.id);
|
||||
mod = await resolveUser(pluginData.client, kickAuditLogEntry.executor!.id);
|
||||
|
||||
const config = mod instanceof UnknownUser ? pluginData.config.get() : await pluginData.config.getForUser(mod);
|
||||
|
||||
|
@ -48,7 +49,7 @@ export const CreateKickCaseOnManualKickEvt = modActionsEvt({
|
|||
const casesPlugin = pluginData.getPlugin(CasesPlugin);
|
||||
createdCase = await casesPlugin.createCase({
|
||||
userId: member.id,
|
||||
modId: kickAuditLogEntry.user.id,
|
||||
modId: mod.id,
|
||||
type: CaseTypes.Kick,
|
||||
auditLogId: kickAuditLogEntry.id,
|
||||
reason: kickAuditLogEntry.reason || undefined,
|
||||
|
|
|
@ -8,6 +8,7 @@ import { safeFindRelevantAuditLogEntry } from "../../../utils/safeFindRelevantAu
|
|||
import { stripObjectToScalars, resolveUser, UnknownUser } from "../../../utils";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { Case } from "../../../data/entities/Case";
|
||||
import { GuildAuditLogs, User } from "discord.js";
|
||||
|
||||
/**
|
||||
* Create an UNBAN case automatically when a user is unbanned manually.
|
||||
|
@ -15,7 +16,8 @@ import { Case } from "../../../data/entities/Case";
|
|||
*/
|
||||
export const CreateUnbanCaseOnManualUnbanEvt = modActionsEvt({
|
||||
event: "guildBanRemove",
|
||||
async listener({ pluginData, args: { guild, user } }) {
|
||||
async listener({ pluginData, args: { ban } }) {
|
||||
const user = ban.user;
|
||||
if (isEventIgnored(pluginData, IgnoredEventType.Unban, user.id)) {
|
||||
clearIgnoredEvents(pluginData, IgnoredEventType.Unban, user.id);
|
||||
return;
|
||||
|
@ -23,7 +25,7 @@ export const CreateUnbanCaseOnManualUnbanEvt = modActionsEvt({
|
|||
|
||||
const relevantAuditLogEntry = await safeFindRelevantAuditLogEntry(
|
||||
pluginData,
|
||||
ErisConstants.AuditLogActions.MEMBER_BAN_REMOVE,
|
||||
GuildAuditLogs.Actions.MEMBER_BAN_REMOVE as number,
|
||||
user.id,
|
||||
);
|
||||
|
||||
|
@ -33,7 +35,7 @@ export const CreateUnbanCaseOnManualUnbanEvt = modActionsEvt({
|
|||
let mod: User | UnknownUser | null = null;
|
||||
|
||||
if (relevantAuditLogEntry) {
|
||||
const modId = relevantAuditLogEntry.user.id;
|
||||
const modId = relevantAuditLogEntry.executor!.id;
|
||||
const auditLogId = relevantAuditLogEntry.id;
|
||||
|
||||
mod = await resolveUser(pluginData.client, modId);
|
||||
|
|
|
@ -4,13 +4,14 @@ import { LogType } from "../../../data/LogType";
|
|||
|
||||
import { resolveMember } from "../../../utils";
|
||||
import { hasDiscordPermissions } from "../../../utils/hasDiscordPermissions";
|
||||
import { TextChannel, Constants, Permissions } from "discord.js";
|
||||
|
||||
/**
|
||||
* Show an alert if a member with prior notes joins the server
|
||||
*/
|
||||
export const PostAlertOnMemberJoinEvt = modActionsEvt({
|
||||
event: "guildMemberAdd",
|
||||
async listener({ pluginData, args: { guild, member } }) {
|
||||
async listener({ pluginData, args: { member } }) {
|
||||
const config = pluginData.config.get();
|
||||
|
||||
if (!config.alert_on_rejoin) return;
|
||||
|
@ -38,15 +39,15 @@ export const PostAlertOnMemberJoinEvt = modActionsEvt({
|
|||
}
|
||||
|
||||
const botMember = await resolveMember(pluginData.client, pluginData.guild, pluginData.client.user!.id);
|
||||
const botPerms = alertChannel.permissionsOf(botMember ?? pluginData.client.user!.id);
|
||||
if (!hasDiscordPermissions(botPerms, Constants.Permissions.sendMessages)) {
|
||||
const botPerms = alertChannel.permissionsFor(botMember ?? pluginData.client.user!.id);
|
||||
if (!hasDiscordPermissions(botPerms, Permissions.FLAGS.SEND_MESSAGES)) {
|
||||
logs.log(LogType.BOT_ALERT, {
|
||||
body: `Missing "Send Messages" permissions for the \`alert_channel\` configured in \`mod_actions\`: \`${alertChannelId}\``,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
await alertChannel.createMessage(
|
||||
await alertChannel.send(
|
||||
`<@!${member.id}> (${member.user.username}#${member.user.discriminator} \`${member.id}\`) joined with ${actions.length} prior record(s)`,
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue