status and changes to Whois.ts

pull/1/head
Matthew 2024-10-24 20:40:08 -04:00
parent 0811bfbde9
commit 4fb3817702
Signed by: matthew
SSH Key Fingerprint: SHA256:piIXekA9q1p0ZGi4ogFbNY1embip5Ytbi3v8AZ8UYq4
2 changed files with 31 additions and 5 deletions

View File

@ -1,8 +1,9 @@
import DiscordInteractionCommand from "../../util/DiscordInteractionCommand"; import DiscordInteractionCommand from "../../util/DiscordInteractionCommand";
import { MemberModel } from "../../database/Member"; import { MemberModel } from "../../database/Member";
import Partner, {PartnerCommissionType, PartnerDepartment, PartnerModel, PartnerRoleType} from "../../database/Partner"; import Partner, { PartnerCommissionType, PartnerDepartment, PartnerModel, PartnerRoleType } from "../../database/Partner";
import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js"; import { ChatInputCommandInteraction, EmbedBuilder, GuildMember } from "discord.js";
import MemberUtil from "../../util/MemberUtil"; import MemberUtil from "../../util/MemberUtil";
import EmojiConfig from "../../util/EmojiConfig"
export default class Whois extends DiscordInteractionCommand { export default class Whois extends DiscordInteractionCommand {
constructor() { constructor() {
@ -26,14 +27,14 @@ export default class Whois extends DiscordInteractionCommand {
// if the partner exists, set the iconURL to the organizational logo // if the partner exists, set the iconURL to the organizational logo
const formattedName = MemberUtil.formatName(guildMember, partner); const formattedName = MemberUtil.formatName(guildMember, partner);
embed.setAuthor({ name: formattedName.text, iconURL: formattedName.iconURL }); 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 // set the thumbnail to the user's avatar
embed.setThumbnail(guildMember.user.displayAvatarURL()); embed.setThumbnail(guildMember.user.displayAvatarURL());
// initialize the description string // initialize the description string
let embedDescription = ''; let embedDescription = '';
if (partner) { 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`; if (partner.emailAddress) embedDescription += `**Email Address**: ${partner.emailAddress}\n`;
switch (partner.department) { switch (partner.department) {
case PartnerDepartment.ENGINEERING: case PartnerDepartment.ENGINEERING:
@ -74,6 +75,27 @@ export default class Whois extends DiscordInteractionCommand {
} }
embed.setColor(guildMember.displayColor); embed.setColor(guildMember.displayColor);
if (embedDescription?.length > 0) embed.setDescription(embedDescription); 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}` : ''}` }); embed.setFooter({ text: `Discord ID: ${guildMember.id}${databaseMember ? `Internal ID: ${databaseMember?._id}` : ''}` });
return await interaction.editReply({ embeds: [embed] }); return await interaction.editReply({ embeds: [embed] });

4
util/EmojiConfig.ts Normal file
View File

@ -0,0 +1,4 @@
export default class EmojiConfig {
public static LOC = "<:loc:607695848612167700>";
public static EMAIL = "<:email:699786452267040878>";
}