2020-07-27 01:53:14 +02:00
|
|
|
import humanizeDuration from "humanize-duration";
|
2021-06-06 23:51:32 +02:00
|
|
|
import moment from "moment-timezone";
|
|
|
|
import { LogType } from "../../../data/LogType";
|
2021-08-18 01:51:42 +03:00
|
|
|
import { memberToTemplateSafeMember } from "../../../utils/templateSafeObjects";
|
2021-06-06 23:51:32 +02:00
|
|
|
import { logsEvt } from "../types";
|
2021-08-18 01:51:42 +03:00
|
|
|
import { logMemberJoin } from "../logFunctions/logMemberJoin";
|
|
|
|
import { logMemberJoinWithPriorRecords } from "../logFunctions/logMemberJoinWithPriorRecords";
|
2020-07-27 01:53:14 +02:00
|
|
|
|
2020-10-01 01:43:38 +03:00
|
|
|
export const LogsGuildMemberAddEvt = logsEvt({
|
2020-07-27 01:53:14 +02:00
|
|
|
event: "guildMemberAdd",
|
|
|
|
|
|
|
|
async listener(meta) {
|
|
|
|
const pluginData = meta.pluginData;
|
|
|
|
const member = meta.args.member;
|
|
|
|
|
2021-08-18 01:51:42 +03:00
|
|
|
logMemberJoin(pluginData, {
|
|
|
|
member,
|
2020-07-27 01:53:14 +02:00
|
|
|
});
|
|
|
|
|
2021-08-18 02:01:56 +03:00
|
|
|
// TODO: Uncomment below once circular dependencies in Knub have been fixed
|
2020-07-27 01:53:14 +02:00
|
|
|
|
2021-08-18 02:01:56 +03:00
|
|
|
// const cases = (await pluginData.state.cases.with("notes").getByUserId(member.id)).filter(c => !c.is_hidden);
|
|
|
|
// cases.sort((a, b) => (a.created_at > b.created_at ? -1 : 1));
|
|
|
|
//
|
|
|
|
// if (cases.length) {
|
|
|
|
// const recentCaseLines: string[] = [];
|
|
|
|
// const recentCases = cases.slice(0, 2);
|
|
|
|
// const casesPlugin = pluginData.getPlugin(CasesPlugin);
|
|
|
|
// for (const theCase of recentCases) {
|
|
|
|
// recentCaseLines.push((await casesPlugin.getCaseSummary(theCase))!);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// let recentCaseSummary = recentCaseLines.join("\n");
|
|
|
|
// if (recentCases.length < cases.length) {
|
|
|
|
// const remaining = cases.length - recentCases.length;
|
|
|
|
// if (remaining === 1) {
|
|
|
|
// recentCaseSummary += `\n*+${remaining} case*`;
|
|
|
|
// } else {
|
|
|
|
// recentCaseSummary += `\n*+${remaining} cases*`;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// logMemberJoinWithPriorRecords(pluginData, {
|
|
|
|
// member,
|
|
|
|
// recentCaseSummary,
|
|
|
|
// });
|
|
|
|
// }
|
2020-07-27 01:53:14 +02:00
|
|
|
},
|
|
|
|
});
|