const { getPokerService } = require("../../utils/crumbPoker"); const { deferPokerReply, editPokerError, getPokerGameIdFromInteraction, refreshPokerTableMessage } = require("../../utils/pokerDiscord"); module.exports = { name: "pokerCashOut", async execute( interaction ) { await deferPokerReply( interaction ); const gameId = getPokerGameIdFromInteraction( interaction ); if (!gameId) { return interaction.editReply({ content: "❌ This Poker table is no longer active.", embeds: [], components: [] }); } try { const result = await getPokerService() .cashOut({ gameId, userId: interaction.user.id }); await refreshPokerTableMessage( interaction.client, result.game ); return interaction.editReply({ content: `✅ Cashed out **${result.amount.toLocaleString()} Cookies** back to your vault.`, embeds: [], components: [] }); } catch (error) { return editPokerError( interaction, error ); } } };