mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
Add 'joined with prior records' log entry
This commit is contained in:
parent
bbb1acb998
commit
bf25342122
3 changed files with 20 additions and 4 deletions
|
@ -43,5 +43,7 @@
|
|||
|
||||
"CASE_CREATE": "✏ **{mod.username}#{mod.discriminator}** (`{mod.id}`) manually created new **{caseType}** case (#{caseNum})",
|
||||
|
||||
"MASSBAN": "⚒ **{mod.username}#{mod.discriminator}** massbanned {count} users"
|
||||
"MASSBAN": "⚒ **{mod.username}#{mod.discriminator}** massbanned {count} users",
|
||||
|
||||
"MEMBER_JOIN_WITH_PRIOR_RECORDS": "⚠ **{member.user.username}#{member.user.discriminator}** joined with prior records ({caseCount} case(s))"
|
||||
}
|
||||
|
|
|
@ -42,5 +42,7 @@ export enum LogType {
|
|||
MASSBAN,
|
||||
|
||||
MEMBER_TIMED_MUTE,
|
||||
MEMBER_TIMED_UNMUTE
|
||||
MEMBER_TIMED_UNMUTE,
|
||||
|
||||
MEMBER_JOIN_WITH_PRIOR_RECORDS
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import diff from "lodash.difference";
|
|||
import { GuildSavedMessages } from "../data/GuildSavedMessages";
|
||||
import { SavedMessage } from "../data/entities/SavedMessage";
|
||||
import { GuildArchives } from "../data/GuildArchives";
|
||||
import { GuildCases } from "../data/GuildCases";
|
||||
|
||||
interface ILogChannel {
|
||||
include?: string[];
|
||||
|
@ -36,11 +37,12 @@ const unknownUser = {
|
|||
};
|
||||
|
||||
export class LogsPlugin extends Plugin {
|
||||
public static pluginName = 'logs';
|
||||
public static pluginName = "logs";
|
||||
|
||||
protected guildLogs: GuildLogs;
|
||||
protected savedMessages: GuildSavedMessages;
|
||||
protected archives: GuildArchives;
|
||||
protected cases: GuildCases;
|
||||
|
||||
protected logListener;
|
||||
|
||||
|
@ -64,6 +66,7 @@ export class LogsPlugin extends Plugin {
|
|||
this.guildLogs = new GuildLogs(this.guildId);
|
||||
this.savedMessages = GuildSavedMessages.getInstance(this.guildId);
|
||||
this.archives = GuildArchives.getInstance(this.guildId);
|
||||
this.cases = GuildCases.getInstance(this.guildId);
|
||||
|
||||
this.logListener = ({ type, data }) => this.log(type, data);
|
||||
this.guildLogs.on("log", this.logListener);
|
||||
|
@ -118,7 +121,7 @@ export class LogsPlugin extends Plugin {
|
|||
}
|
||||
|
||||
@d.event("guildMemberAdd")
|
||||
onMemberJoin(_, member) {
|
||||
async onMemberJoin(_, member) {
|
||||
const newThreshold = moment().valueOf() - 1000 * 60 * 60;
|
||||
const accountAge = humanizeDuration(moment().valueOf() - member.createdAt, {
|
||||
largest: 2,
|
||||
|
@ -130,6 +133,15 @@ export class LogsPlugin extends Plugin {
|
|||
new: member.createdAt >= newThreshold ? " :new:" : "",
|
||||
account_age: accountAge
|
||||
});
|
||||
|
||||
const cases = (await this.cases.getByUserId(member.id)).filter(c => !c.is_hidden);
|
||||
|
||||
if (cases.length) {
|
||||
this.guildLogs.log(LogType.MEMBER_JOIN_WITH_PRIOR_RECORDS, {
|
||||
member: stripObjectToScalars(member, ["user"]),
|
||||
caseCount: cases.length
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@d.event("guildMemberRemove")
|
||||
|
|
Loading…
Add table
Reference in a new issue