68 lines
1.5 KiB
JavaScript
68 lines
1.5 KiB
JavaScript
const {
|
|
getPokerService
|
|
} = require("../../utils/crumbPoker");
|
|
|
|
const {
|
|
deferPokerReply,
|
|
editPokerError,
|
|
getPokerGameIdFromInteraction,
|
|
refreshPokerTableMessage
|
|
} = require("../../utils/pokerDiscord");
|
|
|
|
|
|
module.exports = {
|
|
name:
|
|
"pokerStart",
|
|
|
|
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 game =
|
|
await getPokerService()
|
|
.startTableHand({
|
|
gameId,
|
|
userId:
|
|
interaction.user.id
|
|
});
|
|
|
|
await refreshPokerTableMessage(
|
|
interaction.client,
|
|
game
|
|
);
|
|
|
|
return interaction.editReply({
|
|
content:
|
|
`✅ Hand **#${game.data.handNumber}** started. Cards have been dealt — use **🃏 Cards** to view your hand.`,
|
|
embeds: [],
|
|
components: []
|
|
});
|
|
}
|
|
|
|
catch (error) {
|
|
return editPokerError(
|
|
interaction,
|
|
error
|
|
);
|
|
}
|
|
}
|
|
};
|