mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
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 { LogType } from "../data/LogType";
|
||||
import { TextChannel } from "eris";
|
||||
import { formatTemplateString } from "../utils";
|
||||
import { formatTemplateString, stripObjectToScalars } from "../utils";
|
||||
import DefaultLogMessages from "../data/DefaultLogMessages.json";
|
||||
import moment from "moment-timezone";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
|
||||
interface ILogChannel {
|
||||
include?: LogType[];
|
||||
|
@ -72,4 +73,19 @@ export class LogsPlugin extends Plugin {
|
|||
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