From 943bf322e0c0267c9c4c59bd6e13f85152adb0c0 Mon Sep 17 00:00:00 2001 From: O3H Date: Tue, 23 Jul 2024 00:27:02 +0100 Subject: [PATCH] alliance discordInvite should be in partial --- bot/events/interactionCreate.ts | 16 ++++++---------- bot/events/messageCreate.ts | 10 +++++----- bot/objects/AllianceModal.ts | 9 +++++---- bot/types.ts | 2 +- 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/bot/events/interactionCreate.ts b/bot/events/interactionCreate.ts index 96dd42ca..053834f5 100644 --- a/bot/events/interactionCreate.ts +++ b/bot/events/interactionCreate.ts @@ -29,7 +29,7 @@ export default { name: 'interactionCreate', async execute(interaction: BaseInteraction) { const client: ExtendedClient = interaction.client - const username = interaction.user.username + const username = interaction.user.displayName let cmdName: string = null if (interaction.isCommand()) @@ -39,17 +39,13 @@ export default { const cmd = client.slashCommands.get(cmdName) if (!cmd) return - console.log(`${username} used command: '${cmdName}'`) + console.log(`[${username}] Interaction triggered: '${cmdName}'`) return await cmd.run(client, interaction).catch(console.error) } if (interaction.isUserContextMenuCommand()) { - console.log(`${username} triggered a context menu action.`) - - if (cmdName == "Link User") { - console.log('Attempting to link a player') - return await showLinkModal(interaction) - } + console.log(`[${username}] Context menu action triggered: '${cmdName}'`) + if (cmdName == "Link User") return await showLinkModal(interaction) } if (interaction.isModalSubmit()) { @@ -66,12 +62,12 @@ export default { const alliance = modal.asObject(interaction) //#region Send alliance embed preview. - const preview = new CustomEmbed(client, `(${alliance.mapName}) Alliance Preview | ${alliance.allianceName}`) + const preview = new CustomEmbed(client, `(${alliance.map}) Alliance Preview | ${alliance.allianceName}`) .setColor(Colors.DarkBlue) .setThumbnail(alliance.imageURL ? alliance.imageURL : 'attachment://aurora.png') .addButton('creation_extra', 'Extra') .addButton('creation_finish', 'Finish', ButtonStyle.Success) - .addField("Leader(s)", alliance.leaders.length > 0 ? alliance.leaders : "None", true) + .addField("Leader(s)", alliance.leaderName.length > 0 ? alliance.leaderName : "None", true) if (alliance.discordInvite != "No discord invite has been set for this alliance") preview.setURL(alliance.discordInvite) diff --git a/bot/events/messageCreate.ts b/bot/events/messageCreate.ts index f4806ba3..e79ec459 100644 --- a/bot/events/messageCreate.ts +++ b/bot/events/messageCreate.ts @@ -20,7 +20,7 @@ async function runCmd(msg: Message, sliceAmt: number, cmdsKey: string) { const commands = (msg.client as any)[cmdsKey] as Collection const command = commands.get(commandName) || commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName)) - if (!command) return console.log(`Could not find command '${commandName}'`) + if (!command) return console.log(`[${msg.author.displayName}] Could not find command '${commandName}'`) const channel = msg.channel if (channel.type == ChannelType.GuildText) { @@ -67,10 +67,10 @@ export default { if (prefix(message, "/")) return runCmd(message, 1, 'auroraCommands') - if (prefix(message, "a/")) - return runCmd(message, 2, 'auroraCommands') + // if (prefix(message, "a/")) + // return runCmd(message, 2, 'auroraCommands') - if (prefix(message, "n/")) - return runCmd(message, 2, 'novaCommands') + //if (prefix(message, "n/")) + //return runCmd(message, 2, 'novaCommands') } } \ No newline at end of file diff --git a/bot/objects/AllianceModal.ts b/bot/objects/AllianceModal.ts index 02f7c9d1..b0f5ecfa 100644 --- a/bot/objects/AllianceModal.ts +++ b/bot/objects/AllianceModal.ts @@ -71,11 +71,12 @@ class AllianceModal extends ModalBuilder { } asObject = (interaction: ModalSubmitInteraction) => { - const obj: any = { - mapName: this.alliance.map, + const obj: DBAlliance & { map?: string } = { + map: this.alliance.map, allianceName: this.alliance.allianceName, + type: this.alliance.type || "normal", nations: fieldVal(interaction, 'nations').replaceAll(' ', '').split(','), - leaders: fieldVal(interaction, 'leaders') + leaderName: fieldVal(interaction, 'leaders') } const fullName = fieldVal(interaction, 'full_name') @@ -83,7 +84,7 @@ class AllianceModal extends ModalBuilder { const flag = fieldVal(interaction, 'flag') if (fullName) obj.fullName = fullName - if (discord) obj.discord = discord + if (discord) obj.discordInvite = discord if (flag) obj.imageURL = flag return obj diff --git a/bot/types.ts b/bot/types.ts index e072e914..01ac9b26 100644 --- a/bot/types.ts +++ b/bot/types.ts @@ -88,12 +88,12 @@ export type AllianceType = 'sub' | 'mega' | 'normal' export type DBAlliance = { allianceName: string leaderName: string - discordInvite: string type: AllianceType nations: string[] } & Partial<{ fullName: string imageURL: string + discordInvite: string colours: { fill: string outline: string