import { roblox } from "@/roblox/client"; import type { RobloxUserId } from "@/roblox/types"; import { hasManagerPermissions } from "@/utils/permissions"; import { processRobloxUserInteraction } from "@/utils/robloxUser"; import { ApplicationCommandType, type Client, ContextMenuCommandBuilder, type GuildMember, type MessageContextMenuCommandInteraction, } from "discord.js"; const commandData = new ContextMenuCommandBuilder() .setName("Get Roblox Account") .setType(ApplicationCommandType.User); async function execute( _client: Client, interaction: MessageContextMenuCommandInteraction, ) { const isModerator = await hasManagerPermissions( interaction.member as GuildMember, ); await interaction.deferReply(); const target = interaction.targetId; const [linkedRes, linkedErr] = await roblox.getLinkedAccount(target); if (linkedErr) { const message = linkedErr.error; if (message === "User not found") { await interaction.editReply( "No linked Roblox account found for that user.", ); return; } await interaction.editReply( `There was an error fetching the linked account: ${linkedErr.error}`, ); return; } const id: RobloxUserId = linkedRes.robloxID; await processRobloxUserInteraction(interaction, id, isModerator); } export default { data: commandData, execute, };