import { getAccountInfo, getClanAccountInfo } from '@blitzkit/core'; import { teal } from '@radix-ui/colors'; import { Glow } from '../components/AllStatsOverview/components/HeroStat/components/Glow'; import { CommandWrapper } from '../components/CommandWrapper'; import { linkBlitzAndDiscord } from '../core/db/linkBlitzAndDiscord'; import { addUsernameChoices } from '../core/discord/addUsernameChoices'; import { autocompleteUsername } from '../core/discord/autocompleteUsername'; import { createLocalizedCommand } from '../core/discord/createLocalizedCommand'; import { embedInfo } from '../core/discord/embedInfo'; import { resolvePlayerFromCommand } from '../core/discord/resolvePlayerFromCommand'; import { translator } from '../core/localization/translator'; import { CommandRegistry } from '../events/interactionCreate'; import { theme } from '../stitches.config'; export const verifyCommand = new Promise((resolve) => { resolve({ command: createLocalizedCommand('link').addStringOption((option) => addUsernameChoices(option).setRequired(true), ), async handler(interaction) { const { strings } = translator(interaction.locale); const { id, region } = await resolvePlayerFromCommand(interaction); const discordId = BigInt(interaction.user.id); const accountInfo = await getAccountInfo(region, id); const clanAccountInfo = await getClanAccountInfo(region, id, ['clan']); await linkBlitzAndDiscord(discordId, id); return [
avatar
{interaction.user.displayName} @{interaction.user.username}
accounts linked {strings.bot.commands.link.body.accounts_linked}
{clanAccountInfo?.clan ? ( clan emblem ) : null}
{accountInfo.nickname} {clanAccountInfo?.clan ? `[${clanAccountInfo?.clan?.tag}] • ` : ''} {strings.common.regions.normal[region]}
, embedInfo( strings.bot.commands.link.embed.title, strings.bot.commands.link.embed.description, ), ]; }, autocomplete: autocompleteUsername, }); });