import { HaltExecution } from "@purrkit/router"; import { kitten } from "@/client"; import { upsertGuild } from "@stealth-developers/db"; import { upsertUser } from "@/lib"; const base = kitten.builder(); export const getUser = base .use(async (interaction) => { if (!interaction.guild) return {}; const user = await upsertUser(interaction.user, interaction.guild); if (!user) throw new HaltExecution("Failed to add you to the database. Please try again."); return { user }; }) .use(async (interaction) => { if (!interaction.guild) return {}; const actor = await upsertUser(interaction.user, interaction.guild); if (!actor) throw new HaltExecution("Failed to add you to the database. Please try again."); return { actor }; }) .use(async (interaction) => { if (!interaction.guild) return {}; const guild = await upsertGuild({ discordId: interaction.guild.id, icon: interaction.guild.iconURL(), name: interaction.guild.name, }); if (!guild) throw new HaltExecution("Failed to find your guild in the database. Please try again."); return { guild }; }); export const getBasicData = getUser;