mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-06-08 16:15:04 +00:00
Typed log functions + more
This commit is contained in:
parent
d2ac700143
commit
bed6589d48
166 changed files with 4021 additions and 869 deletions
35
backend/src/plugins/Logs/logFunctions/logMemberJoin.ts
Normal file
35
backend/src/plugins/Logs/logFunctions/logMemberJoin.ts
Normal file
|
@ -0,0 +1,35 @@
|
|||
import { GuildPluginData } from "knub";
|
||||
import { LogsPluginType } from "../types";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { log } from "../util/log";
|
||||
import { createTypedTemplateSafeValueContainer } from "../../../templateFormatter";
|
||||
import { GuildMember } from "discord.js";
|
||||
import { memberToTemplateSafeMember } from "../../../utils/templateSafeObjects";
|
||||
import moment from "moment-timezone";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
|
||||
interface LogMemberJoinData {
|
||||
member: GuildMember;
|
||||
}
|
||||
|
||||
export function logMemberJoin(pluginData: GuildPluginData<LogsPluginType>, data: LogMemberJoinData) {
|
||||
const newThreshold = moment.utc().valueOf() - 1000 * 60 * 60;
|
||||
const accountAge = humanizeDuration(moment.utc().valueOf() - data.member.user.createdTimestamp, {
|
||||
largest: 2,
|
||||
round: true,
|
||||
});
|
||||
|
||||
return log(
|
||||
pluginData,
|
||||
LogType.MEMBER_JOIN,
|
||||
createTypedTemplateSafeValueContainer({
|
||||
member: memberToTemplateSafeMember(data.member),
|
||||
new: data.member.user.createdTimestamp >= newThreshold ? " :new:" : "",
|
||||
account_age: accountAge,
|
||||
}),
|
||||
{
|
||||
userId: data.member.id,
|
||||
bot: data.member.user.bot,
|
||||
},
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue