diff --git a/src/blacklist/blacklist.utils.ts b/src/blacklist/blacklist.utils.ts index ec3fe167..e12734e2 100644 --- a/src/blacklist/blacklist.utils.ts +++ b/src/blacklist/blacklist.utils.ts @@ -33,11 +33,15 @@ export function createBlacklistEmbedFields({ characterName, discordId, reason, + lodestoneId, }: BlacklistDocument): APIEmbedField[] { const displayName = getDisplayName({ characterName, discordId }); + return [ { name: 'Player', value: displayName, inline: true }, { name: 'Reason', value: reason, inline: true }, - { name: '\u200b', value: '\u200b', inline: true }, + lodestoneId + ? { name: 'Lodestone ID', value: String(lodestoneId), inline: true } + : { name: '\u200b', value: '\u200b', inline: true }, ]; } diff --git a/src/blacklist/events/handlers/blacklist-updated.event-handler.ts b/src/blacklist/events/handlers/blacklist-updated.event-handler.ts index 223497e8..90ea20c7 100644 --- a/src/blacklist/events/handlers/blacklist-updated.event-handler.ts +++ b/src/blacklist/events/handlers/blacklist-updated.event-handler.ts @@ -1,6 +1,7 @@ import { EventsHandler, type IEventHandler } from '@nestjs/cqrs'; import { type APIEmbedField, EmbedBuilder } from 'discord.js'; import { titleCase } from 'title-case'; +import { createFields } from '../../../common/embed-helpers.js'; import { DiscordService } from '../../../discord/discord.service.js'; import { SettingsCollection } from '../../../firebase/collections/settings-collection.js'; import { getDisplayName } from '../../blacklist.utils.js'; @@ -28,13 +29,18 @@ class BlacklistUpdatedEventHandler const toFrom = type === 'added' ? 'to' : 'from'; - const fields: APIEmbedField[] = [ + const fields = createFields([ { name: 'User', value: titleCase(getDisplayName(entry)), inline: true, }, - ]; + { + name: 'Lodestone ID', + value: entry.lodestoneId?.toString(), + inline: true, + }, + ]); if (type === 'added') { fields.push({ name: 'Reason', value: entry.reason, inline: true }); diff --git a/src/blacklist/subcommands/add/blacklist-add.command-handler.ts b/src/blacklist/subcommands/add/blacklist-add.command-handler.ts index 85a55548..858261e3 100644 --- a/src/blacklist/subcommands/add/blacklist-add.command-handler.ts +++ b/src/blacklist/subcommands/add/blacklist-add.command-handler.ts @@ -20,12 +20,14 @@ class BlacklistAddCommandHandler const discordId = getDiscordId(interaction); const characterName = interaction.options.getString('character'); + const lodestoneId = interaction.options.getInteger('lodestone-id'); const reason = interaction.options.getString('reason', true); const props: BlacklistDocument = { discordId, characterName: characterName?.toLowerCase() ?? null, reason, + lodestoneId, }; const entry = await this.blacklistCollection.upsert(guildId, props); diff --git a/src/blacklist/subcommands/remove/blacklist-remove.command-handler.ts b/src/blacklist/subcommands/remove/blacklist-remove.command-handler.ts index dc9a4d91..b90adef0 100644 --- a/src/blacklist/subcommands/remove/blacklist-remove.command-handler.ts +++ b/src/blacklist/subcommands/remove/blacklist-remove.command-handler.ts @@ -19,10 +19,12 @@ class BlacklistRemoveCommandHandler const discordId = getDiscordId(interaction); const characterName = interaction.options.getString('character'); + const lodestoneId = interaction.options.getInteger('lodestone-id'); const entry = await this.blacklistCollection.remove(guildId, { discordId, characterName: characterName?.toLowerCase() ?? null, + lodestoneId, }); await interaction.editReply('Success!'); diff --git a/src/firebase/collections/blacklist-collection.ts b/src/firebase/collections/blacklist-collection.ts index 49289f7c..361374e4 100644 --- a/src/firebase/collections/blacklist-collection.ts +++ b/src/firebase/collections/blacklist-collection.ts @@ -69,7 +69,10 @@ class BlacklistCollection { */ public remove( guildId: string, - props: BlacklistDocumentKeys, + props: ExactType< + BlacklistDocument, + 'discordId' | 'characterName' | 'lodestoneId' + >, ): Promise { const pipeline$ = this.query$(guildId, props).pipe( mergeMap(async (result) => { diff --git a/src/firebase/models/blacklist.model.ts b/src/firebase/models/blacklist.model.ts index 2204c8c8..3528f835 100644 --- a/src/firebase/models/blacklist.model.ts +++ b/src/firebase/models/blacklist.model.ts @@ -2,4 +2,5 @@ export interface BlacklistDocument { characterName: string | null; discordId: string | null; reason: string; + lodestoneId: number | null; } diff --git a/src/slash-commands/commands/blacklist.ts b/src/slash-commands/commands/blacklist.ts index ae39f762..d0733a56 100644 --- a/src/slash-commands/commands/blacklist.ts +++ b/src/slash-commands/commands/blacklist.ts @@ -1,6 +1,7 @@ import { PermissionFlagsBits, SlashCommandBuilder, + type SlashCommandIntegerOption, type SlashCommandStringOption, SlashCommandSubcommandBuilder, type SlashCommandUserOption, @@ -26,6 +27,11 @@ const characterOption = (option: SlashCommandStringOption) => .setName('character') .setDescription('The character name incase no discord id is known'); +const lodestoneIdOption = (option: SlashCommandIntegerOption) => + option + .setName('lodestone-id') + .setDescription('The Lodestone ID of the character'); + const BlacklistAddSubCommand = new SlashCommandSubcommandBuilder() .setName('add') .setDescription('A list of players to keep an eye on') @@ -37,14 +43,16 @@ const BlacklistAddSubCommand = new SlashCommandSubcommandBuilder() ) .addUserOption(userOption) .addStringOption(discordIdOption) - .addStringOption(characterOption); + .addStringOption(characterOption) + .addIntegerOption(lodestoneIdOption); const BlacklistRemoveSubCommand = new SlashCommandSubcommandBuilder() .setName('remove') .setDescription('Remove a user from the blacklist') .addUserOption(userOption) .addStringOption(discordIdOption) - .addStringOption(characterOption); + .addStringOption(characterOption) + .addIntegerOption(lodestoneIdOption); const BlacklistDisplayCommand = new SlashCommandSubcommandBuilder() .setName('display')