formatting todo comment

master
Matthew 2024-04-02 16:39:36 -04:00
parent 3e80cba3c1
commit 754983ab08
Signed by: matthew
SSH Key Fingerprint: SHA256:piIXekA9q1p0ZGi4ogFbNY1embip5Ytbi3v8AZ8UYq4
1 changed files with 28 additions and 1 deletions

View File

@ -6,7 +6,7 @@ import Partner, {
PartnerTitle
} from "../database/Partner";
import Member, { MemberAdditionalAcknowledgement, MemberModel } from "../database/Member";
import { Client } from "discord.js";
import { Client, GuildMember, User } from "discord.js";
import { guildID } from "../config.json";
export interface PartnerOptions {
@ -17,6 +17,11 @@ export interface PartnerOptions {
directReport: Partner | string;
}
export interface FormatNameOptions {
text: string;
iconURL: string;
}
// TODO: Add the rest of the remaining role configurations
export const PartnerDiscordRoleMap = {
// Director of Engineering, Management, Staff, Technician, Core Team, Play Caller
@ -53,4 +58,26 @@ export default class MemberUtil {
if (member.additionalAcknowledgement?.includes(acknowledgement)) throw new Error("This member already has this acknowledgement.")
return MemberModel.updateOne({ discordID: member.discordID }, { $push: { additionalAcknowledgement: acknowledgement } });
}
// TODO: comments and extended formatting
public static formatName(target: GuildMember | User, partner?: Partner | null): FormatNameOptions {
// 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: "https://static.libraryofcode.org/library_of_code_redeg.png"
}
} 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: "https://static.libraryofcode.org/library_of_code_redeg.png"
}
} else { // otherwise, just set the author to the member's display name
return {
text: target.displayName,
iconURL: target.displayAvatarURL()
}
}
}
}