Compare commits

..

7 Commits

8 changed files with 59 additions and 8 deletions

View File

@ -1,9 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DiscordProjectSettings">
<option name="show" value="ASK" />
<option name="description" value="" />
</component>
<component name="ProjectRootManager">
<output url="file://$PROJECT_DIR$/out" />
</component>

View File

@ -62,7 +62,12 @@ export default class Partner implements SharedMemberAttributes {
public title: PartnerTitle | "Partner" | undefined;
@prop()
//
public directReport: Partner | string | undefined;
@prop()
// this field dictates if the partner is able to perform developer commands, such as "eval"
public canPerformDevCommands: boolean | undefined;
}
export const PartnerModel = getModelForClass(Partner);

View File

@ -0,0 +1,13 @@
import DiscordInteractionCommand from "../../util/DiscordInteractionCommand";
import { ChatInputCommandInteraction } from "discord.js";
export default class Ping extends DiscordInteractionCommand {
constructor() {
super("partner", "Manipulates partner information.");
}
public async execute(interaction: ChatInputCommandInteraction): Promise<void> {
if (interaction.options?.getSubcommand(true) === "add") {
}
}
}

View File

@ -0,0 +1,25 @@
import DiscordInteractionCommand, { DiscordInteractionCommandSkeleton } from "../../util/DiscordInteractionCommand";
import { guildID } from "../../config.json";
import { ChatInputCommandInteraction, SlashCommandBuilder } from "discord.js";
import { MemberModel } from "../../database/Member";
import { PartnerModel } from "../../database/Partner";
export default class PartnerAdd implements DiscordInteractionCommandSkeleton {
public GUILD_ID: string;
public name: string;
public description: string
public builder: SlashCommandBuilder;
constructor() {
this.name = "partner";
this.description = "Creates a new partner entry.";
this.builder = new SlashCommandBuilder();
this.GUILD_ID = guildID;
}
public async execute(interaction: ChatInputCommandInteraction) {
const member = MemberModel.findOne({ discordID: interaction.user.id });
if (!member) return interaction.reply({ content: "The specified partner does not have a base member entry.", ephemeral: true });
if (!(await PartnerModel.findOne({discordID: interaction.user.id}))) return interaction.reply({ content: "The specified partner already has a partner entry.", ephemeral: true });
}
}

View File

@ -73,7 +73,7 @@ export default class Whois extends DiscordInteractionCommand {
}
}
embed.setColor(guildMember.displayColor);
embed.setDescription(embedDescription);
if (embedDescription?.length > 0) embed.setDescription(embedDescription);
embed.setFooter({ text: `Discord ID: ${guildMember.id}${databaseMember ? `Internal ID: ${databaseMember?._id}` : ''}` });
return await interaction.editReply({ embeds: [embed] });

View File

@ -1,2 +1,3 @@
export { default as Partner } from "./Partner";
export { default as Ping } from "./Ping";
export { default as Whois } from "./Whois";

View File

@ -1,12 +1,20 @@
import { SlashCommandBuilder, ChatInputCommandInteraction } from "discord.js";
import { guildID } from "../config.json";
export default abstract class DiscordInteractionCommand {
export interface DiscordInteractionCommandSkeleton {
GUILD_ID: string;
builder?: SlashCommandBuilder;
description: string;
execute: (interaction: ChatInputCommandInteraction) => Error | Promise<void | any>;
name: string;
}
export default abstract class DiscordInteractionCommand implements DiscordInteractionCommandSkeleton {
public name: string;
public description: string;
public builder: SlashCommandBuilder;
protected GUILD_ID: string;
public GUILD_ID: string;
protected constructor(name: string, description: string) {
this.name = name;

View File

@ -64,19 +64,22 @@ export default class MemberUtil {
// 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) {
console.log(`[MemberUtil] Formatting name for ${target.displayName}`)
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
console.log(`[MemberUtil] Formatting name for ${target.displayName}`)
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
console.log(`[MemberUtil] Formatting name for ${target.displayName} at url ${target instanceof GuildMember ? target.user.displayAvatarURL() : target.displayAvatarURL()}`);
return {
text: target.displayName,
iconURL: target.displayAvatarURL()
iconURL: target instanceof GuildMember ? target.user.displayAvatarURL() : target.displayAvatarURL()
}
}
}