mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-16 14:11:50 +00:00
Automod logging improvements
This commit is contained in:
parent
17aac769bb
commit
40af0f2359
4 changed files with 26 additions and 11 deletions
|
@ -59,5 +59,5 @@
|
||||||
|
|
||||||
"BOT_ALERT": "⚠ {tmplEval(body)}",
|
"BOT_ALERT": "⚠ {tmplEval(body)}",
|
||||||
"AUTOMOD_ALERT": "{text}",
|
"AUTOMOD_ALERT": "{text}",
|
||||||
"AUTOMOD_ACTION": "\uD83E\uDD16 Automod rule **{rule}** triggered by {userMention(user)}, actions taken: {actionsTaken}\n{matchSummary}"
|
"AUTOMOD_ACTION": "\uD83E\uDD16 Automod rule **{rule}** triggered by {userMention(user)}. Actions taken: **{actionsTaken}**\n{matchSummary}"
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import {
|
||||||
SECONDS,
|
SECONDS,
|
||||||
stripObjectToScalars,
|
stripObjectToScalars,
|
||||||
tNullable,
|
tNullable,
|
||||||
|
verboseChannelMention,
|
||||||
} from "../utils";
|
} from "../utils";
|
||||||
import { decorators as d } from "knub";
|
import { decorators as d } from "knub";
|
||||||
import { mergeConfig } from "knub/dist/configUtils";
|
import { mergeConfig } from "knub/dist/configUtils";
|
||||||
|
@ -1025,10 +1026,14 @@ export class AutomodPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||||
const archiveId = await this.archives.createFromSavedMessages(savedMessages, this.guild);
|
const archiveId = await this.archives.createFromSavedMessages(savedMessages, this.guild);
|
||||||
const baseUrl = this.knub.getGlobalConfig().url;
|
const baseUrl = this.knub.getGlobalConfig().url;
|
||||||
const archiveUrl = this.archives.getUrl(baseUrl, archiveId);
|
const archiveUrl = this.archives.getUrl(baseUrl, archiveId);
|
||||||
matchSummary = `Deleted messages: <${archiveUrl}>`;
|
matchSummary = `Matched messages: <${archiveUrl}>`;
|
||||||
} else if (matchedMessageIds.length === 1) {
|
} else if (matchedMessageIds.length === 1) {
|
||||||
const message = await this.savedMessages.find(matchedMessageIds[0]);
|
const message = await this.savedMessages.find(matchedMessageIds[0]);
|
||||||
matchSummary = `Deleted message:\n${messageSummary(message)}`;
|
const channel = this.guild.channels.get(message.channel_id);
|
||||||
|
const channelMention = channel ? verboseChannelMention(channel) : `\`#${message.channel_id}\``;
|
||||||
|
matchSummary = `Matched message in ${channelMention} (originally posted at **${
|
||||||
|
message.posted_at
|
||||||
|
}**):\n${messageSummary(message)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (matchResult.type === "username") {
|
if (matchResult.type === "username") {
|
||||||
|
|
|
@ -13,6 +13,9 @@ import {
|
||||||
stripObjectToScalars,
|
stripObjectToScalars,
|
||||||
UnknownUser,
|
UnknownUser,
|
||||||
useMediaUrls,
|
useMediaUrls,
|
||||||
|
verboseChannelMention,
|
||||||
|
verboseUserMention,
|
||||||
|
verboseUserName,
|
||||||
} from "../utils";
|
} from "../utils";
|
||||||
import DefaultLogMessages from "../data/DefaultLogMessages.json";
|
import DefaultLogMessages from "../data/DefaultLogMessages.json";
|
||||||
import moment from "moment-timezone";
|
import moment from "moment-timezone";
|
||||||
|
@ -193,17 +196,11 @@ export class LogsPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||||
|
|
||||||
const memberConfig = this.getMatchingConfig({ member, userId: user.id }) || ({} as any);
|
const memberConfig = this.getMatchingConfig({ member, userId: user.id }) || ({} as any);
|
||||||
|
|
||||||
if (memberConfig.ping_user) {
|
return memberConfig.ping_user ? verboseUserMention(user) : verboseUserName(user);
|
||||||
// Ping/mention the user
|
|
||||||
return `<@!${user.id}> (**${user.username}#${user.discriminator}**, \`${user.id}\`)`;
|
|
||||||
} else {
|
|
||||||
// No ping/mention
|
|
||||||
return `**${user.username}#${user.discriminator}** (\`${user.id}\`)`;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
channelMention: channel => {
|
channelMention: channel => {
|
||||||
if (!channel) return "";
|
if (!channel) return "";
|
||||||
return `<#${channel.id}> (**#${channel.name}**, \`${channel.id}\`)`;
|
return verboseChannelMention(channel);
|
||||||
},
|
},
|
||||||
messageSummary: (msg: SavedMessage) => {
|
messageSummary: (msg: SavedMessage) => {
|
||||||
if (!msg) return "";
|
if (!msg) return "";
|
||||||
|
|
13
src/utils.ts
13
src/utils.ts
|
@ -7,6 +7,7 @@ import {
|
||||||
Guild,
|
Guild,
|
||||||
GuildAuditLog,
|
GuildAuditLog,
|
||||||
GuildAuditLogEntry,
|
GuildAuditLogEntry,
|
||||||
|
GuildChannel,
|
||||||
Member,
|
Member,
|
||||||
MessageContent,
|
MessageContent,
|
||||||
TextableChannel,
|
TextableChannel,
|
||||||
|
@ -792,3 +793,15 @@ export function messageSummary(msg: SavedMessage) {
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function verboseUserMention(user: User | UnknownUser): string {
|
||||||
|
return `<@!${user.id}> (**${user.username}#${user.discriminator}**, \`${user.id}\`)`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function verboseUserName(user: User | UnknownUser): string {
|
||||||
|
return `**${user.username}#${user.discriminator}** (\`${user.id}\`)`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function verboseChannelMention(channel: GuildChannel): string {
|
||||||
|
return `<#${channel.id}> (**#${channel.name}**, \`${channel.id}\`)`;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue