Add guild member join logging
This commit is contained in:
parent
687d507325
commit
af7902e7de
1 changed files with 18 additions and 2 deletions
|
@ -1,10 +1,11 @@
|
||||||
import { Plugin } from "knub";
|
import { decorators as d, Plugin } from "knub";
|
||||||
import { GuildServerLogs } from "../data/GuildServerLogs";
|
import { GuildServerLogs } from "../data/GuildServerLogs";
|
||||||
import { LogType } from "../data/LogType";
|
import { LogType } from "../data/LogType";
|
||||||
import { TextChannel } from "eris";
|
import { TextChannel } from "eris";
|
||||||
import { formatTemplateString } from "../utils";
|
import { formatTemplateString, stripObjectToScalars } from "../utils";
|
||||||
import DefaultLogMessages from "../data/DefaultLogMessages.json";
|
import DefaultLogMessages from "../data/DefaultLogMessages.json";
|
||||||
import moment from "moment-timezone";
|
import moment from "moment-timezone";
|
||||||
|
import humanizeDuration from "humanize-duration";
|
||||||
|
|
||||||
interface ILogChannel {
|
interface ILogChannel {
|
||||||
include?: LogType[];
|
include?: LogType[];
|
||||||
|
@ -72,4 +73,19 @@ export class LogsPlugin extends Plugin {
|
||||||
return formatted;
|
return formatted;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@d.event("guildMemberAdd")
|
||||||
|
onMemberJoin(_, member) {
|
||||||
|
const newThreshold = moment().valueOf() - 1000 * 60 * 60;
|
||||||
|
const accountAge = humanizeDuration(moment().valueOf() - member.createdAt, {
|
||||||
|
largest: 2,
|
||||||
|
round: true
|
||||||
|
});
|
||||||
|
|
||||||
|
this.log(LogType.MEMBER_JOIN, {
|
||||||
|
member: stripObjectToScalars(member, ["user"]),
|
||||||
|
new: member.createdAt >= newThreshold ? " :new:" : "",
|
||||||
|
account_age: accountAge
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue