From 4fb3817702fb9e9cc2124846c3e522838fa094c0 Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 24 Oct 2024 20:40:08 -0400 Subject: [PATCH] status and changes to Whois.ts --- discord/commands/Whois.ts | 32 +++++++++++++++++++++++++++----- util/EmojiConfig.ts | 4 ++++ 2 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 util/EmojiConfig.ts diff --git a/discord/commands/Whois.ts b/discord/commands/Whois.ts index e182799..33d1148 100644 --- a/discord/commands/Whois.ts +++ b/discord/commands/Whois.ts @@ -1,8 +1,9 @@ import DiscordInteractionCommand from "../../util/DiscordInteractionCommand"; import { MemberModel } from "../../database/Member"; -import Partner, {PartnerCommissionType, PartnerDepartment, PartnerModel, PartnerRoleType} from "../../database/Partner"; -import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js"; +import Partner, { PartnerCommissionType, PartnerDepartment, PartnerModel, PartnerRoleType } from "../../database/Partner"; +import { ChatInputCommandInteraction, EmbedBuilder, GuildMember } from "discord.js"; import MemberUtil from "../../util/MemberUtil"; +import EmojiConfig from "../../util/EmojiConfig" export default class Whois extends DiscordInteractionCommand { constructor() { @@ -26,14 +27,14 @@ export default class Whois extends DiscordInteractionCommand { // if the partner exists, set the iconURL to the organizational logo const formattedName = MemberUtil.formatName(guildMember, partner); embed.setAuthor({ name: formattedName.text, iconURL: formattedName.iconURL }); - // set the title to the partner's title if applicable - if (partner?.title) embed.setTitle(partner.title); // set the thumbnail to the user's avatar embed.setThumbnail(guildMember.user.displayAvatarURL()); // initialize the description string let embedDescription = ''; if (partner) { - embedDescription += "__**Partner Information**__\n"; + // set the title to the partner's title if applicable + if (partner.title) embedDescription += `## __${EmojiConfig.LOC} ${partner.title}__\n`; + embedDescription += "### Partner Information\n"; if (partner.emailAddress) embedDescription += `**Email Address**: ${partner.emailAddress}\n`; switch (partner.department) { case PartnerDepartment.ENGINEERING: @@ -74,6 +75,27 @@ export default class Whois extends DiscordInteractionCommand { } embed.setColor(guildMember.displayColor); if (embedDescription?.length > 0) embed.setDescription(embedDescription); + // add status to embed + if (guildMember.presence?.status) { // TODO: this currently doesn't work for some reason + switch (guildMember.presence.status) { + case "online": + embed.addFields({ name: "Status", value: "Online", inline: true }); + break; + case "idle": + embed.addFields({ name: "Status", value: "Idle", inline: true }); + break; + case "dnd": + embed.addFields({ name: "Status", value: "Do Not Disturb", inline: true }); + break; + case "offline" || "invisible": + embed.addFields({ name: "Status", value: "Online", inline: true }); + break; + default: + // TODO: decide what placeholder we should use for values that fall "out of range" + embed.addFields({ name: "Status", value: "", inline: true }); + break; + } + } embed.setFooter({ text: `Discord ID: ${guildMember.id}${databaseMember ? `Internal ID: ${databaseMember?._id}` : ''}` }); return await interaction.editReply({ embeds: [embed] }); diff --git a/util/EmojiConfig.ts b/util/EmojiConfig.ts new file mode 100644 index 0000000..ae400de --- /dev/null +++ b/util/EmojiConfig.ts @@ -0,0 +1,4 @@ +export default class EmojiConfig { + public static LOC = "<:loc:607695848612167700>"; + public static EMAIL = "<:email:699786452267040878>"; +}