import { getAccountInfo, getClanAccountInfo, linkBlitzAndDiscord, } from '@blitzkit/core'; import { teal } from '@radix-ui/colors'; import { Glow } from '../components/AllStatsOverview/components/HeroStat/components/Glow'; import { CommandWrapper } from '../components/CommandWrapper'; 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 { t, translate } = 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 {t`bot.commands.link.body.accounts_linked`}
{clanAccountInfo?.clan ? ( clan emblem ) : null}
{accountInfo.nickname} {clanAccountInfo?.clan ? `[${clanAccountInfo?.clan?.tag}] • ` : ''} {translate(`common.regions.normal.${region}`)}
, embedInfo( t`bot.commands.link.embed.title`, t`bot.commands.link.embed.description`, ), ]; }, autocomplete: autocompleteUsername, }); });