forked from engineering/crv2
status and changes to Whois.ts
parent
0811bfbde9
commit
4fb3817702
|
@ -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] });
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
export default class EmojiConfig {
|
||||
public static LOC = "<:loc:607695848612167700>";
|
||||
public static EMAIL = "<:email:699786452267040878>";
|
||||
}
|
Loading…
Reference in New Issue