From 754983ab08357c7d08836263c39eb057d812ef22 Mon Sep 17 00:00:00 2001 From: Matthew Date: Tue, 2 Apr 2024 16:39:36 -0400 Subject: [PATCH] formatting todo comment --- util/MemberUtil.ts | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/util/MemberUtil.ts b/util/MemberUtil.ts index 902c666..43704b1 100644 --- a/util/MemberUtil.ts +++ b/util/MemberUtil.ts @@ -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() + } + } + } }