fix merge conflicts

master
Pax 2024-10-31 10:38:28 +04:00
parent 7ea009714b
commit 9c4a672734
2 changed files with 65 additions and 62 deletions

View File

@ -1,26 +1,22 @@
import DiscordInteractionCommand from '../../util/DiscordInteractionCommand'; import DiscordInteractionCommand from "../../util/DiscordInteractionCommand";
import { MemberModel } from '../../database/Member'; import { MemberModel } from "../../database/Member";
import Partner, { import Partner, {
PartnerCommissionType, PartnerCommissionType,
PartnerDepartment, PartnerDepartment,
PartnerModel, PartnerModel,
PartnerRoleType, PartnerRoleType,
} from '../../database/Partner'; } from "../../database/Partner";
import { import { ChatInputCommandInteraction, EmbedBuilder, GuildMember } from "discord.js";
ChatInputCommandInteraction, import MemberUtil from "../../util/MemberUtil";
EmbedBuilder, import EmojiConfig from "../../util/EmojiConfig";
GuildMember,
} from 'discord.js';
import MemberUtil from '../../util/MemberUtil';
import EmojiConfig from '../../util/EmojiConfig';
export default class Whois extends DiscordInteractionCommand { export default class Whois extends DiscordInteractionCommand {
constructor() { constructor() {
super('whois', 'Retrieves information about a user.'); super("whois", "Retrieves information about a user.");
this.builder.addUserOption((option) => this.builder.addUserOption((option) =>
option option
.setName('member') .setName("member")
.setDescription('The member to get information about.') .setDescription("The member to get information about.")
.setRequired(true) .setRequired(true)
); );
} }
@ -28,67 +24,58 @@ export default class Whois extends DiscordInteractionCommand {
public async execute(interaction: ChatInputCommandInteraction) { public async execute(interaction: ChatInputCommandInteraction) {
// defer our reply and perform database/external API operations/lookups // defer our reply and perform database/external API operations/lookups
await interaction.deferReply({ ephemeral: false }); await interaction.deferReply({ ephemeral: false });
const target = interaction.options.getUser('member', true); const target = interaction.options.getUser("member", true);
const guild = const guild = interaction.guild || interaction.client.guilds.cache.get(this.GUILD_ID);
interaction.guild || interaction.client.guilds.cache.get(this.GUILD_ID);
const guildMember = await guild?.members.fetch(target.id); const guildMember = await guild?.members.fetch(target.id);
const databaseMember = await MemberModel.findOne({ discordID: target.id }); const databaseMember = await MemberModel.findOne({ discordID: target.id });
const partner = await PartnerModel.findOne({ discordID: target.id }); const partner = await PartnerModel.findOne({ discordID: target.id });
// return an error if target was not located // return an error if target was not located
if (!guildMember) if (!guildMember)
return interaction.editReply({ return interaction.editReply({ content: `Member target ${target.id} was not located.` });
content: `Member target ${target.id} was not located.`,
});
// build our embed // build our embed
const embed = new EmbedBuilder(); const embed = new EmbedBuilder();
// if the role type is managerial, add a [k] to the end of the name // 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 the partner exists, set the iconURL to the organizational logo
const formattedName = MemberUtil.formatName(guildMember, partner); const formattedName = MemberUtil.formatName(guildMember, partner);
embed.setAuthor({ embed.setAuthor({ name: formattedName.text, iconURL: formattedName.iconURL });
name: formattedName.text,
iconURL: formattedName.iconURL,
});
// 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) {
// set the title to the partner's title if applicable // set the title to the partner's title if applicable
if (partner.title) if (partner.title) embedDescription += `## __${EmojiConfig.LOC} ${partner.title}__\n`;
embedDescription += `## __${EmojiConfig.LOC} ${partner.title}__\n`; embedDescription += "### Partner Information\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:
embedDescription += '**Department**: Dept. of Engineering\n'; embedDescription += "**Department**: Dept. of Engineering\n";
break; break;
case PartnerDepartment.OPERATIONS: case PartnerDepartment.OPERATIONS:
embedDescription += '**Department**: Dept. of Operations\n'; embedDescription += "**Department**: Dept. of Operations\n";
break; break;
case PartnerDepartment.INDEPENDENT_AGENCY: case PartnerDepartment.INDEPENDENT_AGENCY:
embedDescription += '**Department**: Independent Agency/Contractor\n'; embedDescription += "**Department**: Independent Agency/Contractor\n";
break; break;
} }
switch (partner.commissionType) { switch (partner.commissionType) {
case PartnerCommissionType.TENURE: case PartnerCommissionType.TENURE:
embedDescription += '**Commission Type**: Tenure\n'; embedDescription += "**Commission Type**: Tenure\n";
break; break;
case PartnerCommissionType.PROVISIONAL: case PartnerCommissionType.PROVISIONAL:
embedDescription += '**Commission Type**: Provisional\n'; embedDescription += "**Commission Type**: Provisional\n";
break; break;
case PartnerCommissionType.CONTRACTUAL: case PartnerCommissionType.CONTRACTUAL:
embedDescription += embedDescription += "**Commission Type**: Contractual/Independent/Collaborator\n";
'**Commission Type**: Contractual/Independent/Collaborator\n';
break; break;
case PartnerCommissionType.ACTING: case PartnerCommissionType.ACTING:
embedDescription += '**Commission Type**: Acting\n'; embedDescription += "**Commission Type**: Acting\n";
break; break;
case PartnerCommissionType.INTERIM: case PartnerCommissionType.INTERIM:
embedDescription += '**Commission Type**: Interim\n'; embedDescription += "**Commission Type**: Interim\n";
break; break;
case PartnerCommissionType.TRIAL: case PartnerCommissionType.TRIAL:
embedDescription += '**Commission Type**: Trial/Intern\n'; embedDescription += "**Commission Type**: Trial/Intern\n";
break; break;
} }
if (partner.directReport) { if (partner.directReport) {
@ -103,35 +90,26 @@ export default class Whois extends DiscordInteractionCommand {
if (guildMember.presence?.status) { if (guildMember.presence?.status) {
// TODO: this currently doesn't work for some reason // TODO: this currently doesn't work for some reason
switch (guildMember.presence.status) { switch (guildMember.presence.status) {
case 'online': case "online":
embed.addFields({ name: 'Status', value: 'Online', inline: true }); embed.addFields({ name: "Status", value: "Online", inline: true });
break; break;
case 'idle': case "idle":
embed.addFields({ name: 'Status', value: 'Idle', inline: true }); embed.addFields({ name: "Status", value: "Idle", inline: true });
break; break;
case 'dnd': case "dnd":
embed.addFields({ embed.addFields({ name: "Status", value: "Do Not Disturb", inline: true });
name: 'Status',
value: 'Do Not Disturb',
inline: true,
});
break; break;
case 'offline': case "offline" || "invisible":
embed.addFields({ name: 'Status', value: 'Offline', inline: true }); embed.addFields({ name: "Status", value: "Online", inline: true });
break;
case 'invisible':
embed.addFields({ name: 'Status', value: 'invisible', inline: true });
break; break;
default: default:
// TODO: decide what placeholder we should use for values that fall "out of range" // TODO: decide what placeholder we should use for values that fall "out of range"
embed.addFields({ name: 'Status', value: '', inline: true }); embed.addFields({ name: "Status", value: "", inline: true });
break; break;
} }
} }
embed.setFooter({ embed.setFooter({
text: `Discord ID: ${guildMember.id}${ text: `Discord ID: ${guildMember.id}${databaseMember ? `Internal ID: ${databaseMember?._id}` : ""}`,
databaseMember ? `Internal ID: ${databaseMember?._id}` : ''
}`,
}); });
return await interaction.editReply({ embeds: [embed] }); return await interaction.editReply({ embeds: [embed] });

View File

@ -1,11 +1,20 @@
{ {
"scripts": { "license": "AGPL-3.0-or-later",
"start": "npx tsc && node dist/index.js"
},
"devDependencies": { "devDependencies": {
"@eslint/js": "^9.13.0",
"@types/uuid": "^9.0.8", "@types/uuid": "^9.0.8",
"@typescript-eslint/eslint-plugin": "^8.11.0",
"@typescript-eslint/parser": "^8.11.0",
"eslint": "^9.13.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"globals": "^15.11.0",
"husky": "^9.1.6",
"lint-staged": "^15.2.10",
"prettier": "^3.3.3",
"ts-node": "^10.9.2", "ts-node": "^10.9.2",
"typescript": "^5.4.2" "typescript": "^5.4.2",
"typescript-eslint": "^8.11.0"
}, },
"dependencies": { "dependencies": {
"@typegoose/typegoose": "^12.2.0", "@typegoose/typegoose": "^12.2.0",
@ -14,5 +23,21 @@
"stripe": "^14.21.0", "stripe": "^14.21.0",
"typeorm": "^0.3.20", "typeorm": "^0.3.20",
"uuid": "^9.0.1" "uuid": "^9.0.1"
},
"scripts": {
"prepare": "husky",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"lint:fix": "eslint . --ext .js,.jsx,.ts,.tsx --fix",
"format": "prettier --write .",
"test": ""
},
"lint-staged": {
"*.{js,jsx,ts,tsx}": [
"eslint --fix",
"prettier --write"
],
"*.{json,css,scss,md}": [
"prettier --write"
]
} }
} }