correct Ref for directReport in PartnerModel

dev
Matthew 2024-11-09 18:14:24 -05:00
parent dac548d82c
commit 58841b2830
Signed by: matthew
SSH Key Fingerprint: SHA256:piIXekA9q1p0ZGi4ogFbNY1embip5Ytbi3v8AZ8UYq4
2 changed files with 7 additions and 42 deletions

View File

@ -1,4 +1,4 @@
import { prop, getModelForClass } from "@typegoose/typegoose";
import { prop, getModelForClass, Ref } from "@typegoose/typegoose";
import Member from "./Member";
/* TODO
@ -60,9 +60,9 @@ export default class Partner implements SharedMemberAttributes {
@prop({ required: true })
public title: PartnerTitle | "Partner" | undefined;
@prop()
@prop({ ref: () => Partner })
//
public directReport: Partner | string | undefined;
public directReport?: Ref<Partner> | string | undefined;
@prop()
// this field dictates if the partner is able to perform developer commands, such as "eval"

View File

@ -8,13 +8,14 @@ import Partner, {
import Member, { MemberAdditionalAcknowledgement, MemberModel } from "../database/Member";
import { Client, GuildMember, User } from "discord.js";
import { guildID } from "../config.json";
import { Ref } from "@typegoose/typegoose";
export interface PartnerOptions {
roleType: PartnerRoleType;
commissionType: PartnerCommissionType;
department: PartnerDepartment;
title: PartnerTitle;
directReport: Partner | string;
directReport: Ref<Partner>;
}
export interface FormatNameOptions {
@ -25,7 +26,7 @@ export interface FormatNameOptions {
// TODO: Add the rest of the remaining role configurations
export const PartnerDiscordRoleMap = {
// Director of Engineering, Management, Staff, Technician, Core Team, Play Caller
"Director of Engineering": [
Engineering: [
"1077646568091570236",
"1077646956890951690",
"446104438969466890",
@ -34,7 +35,7 @@ export const PartnerDiscordRoleMap = {
"1014978134573064293",
],
// Director of Operations, Management, Staff, Moderator, Core Team, Play Caller
"Director of Operations": [
Operations: [
"1077647072163020840",
"1077646956890951690",
"446104438969466890",
@ -79,40 +80,4 @@ export default class MemberUtil {
{ $push: { additionalAcknowledgement: acknowledgement } }
);
}
// TODO: comments and extended formatting
public static formatName(
target: GuildMember | User,
partner?: Partner | null
): FormatNameOptions {
console.log(
`[MemberUtil] Formatting name for ${target.displayName} at url ${target instanceof GuildMember ? target.user.displayAvatarURL() : target.displayAvatarURL()}`
);
// if the role type is managerial, add a [k] to the end of the name
// if the partner exists, set the iconURL to the organizational logo
if (partner?.roleType == PartnerRoleType.MANAGERIAL) {
return {
text: `${target.displayName} [k]`,
iconURL: target.displayAvatarURL(),
};
} else if (partner?.commissionType == PartnerCommissionType.CONTRACTUAL) {
// if the commission type is contractual, add a [c] to the end of the name
return {
text: `${target.displayName} [c]`,
iconURL:
target instanceof GuildMember
? target.user.displayAvatarURL()
: target.displayAvatarURL(),
};
} else {
// otherwise, just set the author to the member's display name
return {
text: target.displayName,
iconURL:
target instanceof GuildMember
? target.user.displayAvatarURL()
: target.displayAvatarURL(),
};
}
}
}