diff --git a/src/commands/whois.ts b/src/commands/whois.ts index 67c7513..8ef069d 100644 --- a/src/commands/whois.ts +++ b/src/commands/whois.ts @@ -23,8 +23,8 @@ export default { const matches = mentionRegex.exec(input); mentionRegex.lastIndex = 0; - const idToUse = matches ? matches.groups!.id : input; + const valueToUse = matches ? matches.groups!.id : input; - handleWhoIsInteraction(interaction, idToUse, !(await channelIsInStaffCategory(interaction.channel as GuildBasedChannel))); + handleWhoIsInteraction(interaction, valueToUse, !(await channelIsInStaffCategory(interaction.channel as GuildBasedChannel))); } }; \ No newline at end of file diff --git a/src/utils/whois.ts b/src/utils/whois.ts index 97c01aa..9756c74 100644 --- a/src/utils/whois.ts +++ b/src/utils/whois.ts @@ -1,15 +1,18 @@ import { CommandInteraction, MessageFlags } from 'discord.js'; -import { config } from '../config'; -import { Database } from '../shared/Database'; import { getE621Alts } from './alt-utils'; +import { resolveUser } from './discord-user-utils'; -export async function handleWhoIsInteraction(interaction: CommandInteraction, idToUse: string, ephemeral = false) { +export async function handleWhoIsInteraction(interaction: CommandInteraction, valueToUse: string, ephemeral = false) { if (ephemeral) await interaction.deferReply({ flags: [MessageFlags.Ephemeral] }); else await interaction.deferReply(); if (!interaction.guild) return interaction.editReply('This command must be used in a server'); - const content = await getE621Alts(idToUse, interaction.guild!); + const user = await resolveUser(interaction.client, valueToUse, interaction.guild); - interaction.editReply(`<@${idToUse}>'s e621 and discord account(s):\n${content}`); + if (!user) return interaction.editReply('User not found.'); + + const content = await getE621Alts(user.id, interaction.guild!); + + interaction.editReply(`<@${user.id}>'s e621 and discord account(s):\n${content}`); } \ No newline at end of file