78 lines
1.7 KiB
JavaScript
78 lines
1.7 KiB
JavaScript
const {
|
|
cardToString
|
|
} = require("../../utils/pokerEngine");
|
|
|
|
const {
|
|
getPokerService
|
|
} = require("../../utils/crumbPoker");
|
|
|
|
const {
|
|
POKER_CARD_RESPONSE_LIFETIME,
|
|
deferPokerReply,
|
|
editPokerError,
|
|
getPokerGameIdFromInteraction
|
|
} = require("../../utils/pokerDiscord");
|
|
|
|
|
|
module.exports = {
|
|
name:
|
|
"pokerCards",
|
|
|
|
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 cards =
|
|
await getPokerService()
|
|
.viewCards({
|
|
gameId,
|
|
userId:
|
|
interaction.user.id
|
|
});
|
|
|
|
await interaction.editReply({
|
|
content:
|
|
`🃏 Your cards: **${cards.map(cardToString).join(" ")}**`,
|
|
embeds: [],
|
|
components: []
|
|
});
|
|
|
|
setTimeout(
|
|
() => {
|
|
interaction
|
|
.deleteReply()
|
|
.catch(() => {});
|
|
},
|
|
POKER_CARD_RESPONSE_LIFETIME
|
|
);
|
|
|
|
return;
|
|
}
|
|
|
|
catch (error) {
|
|
return editPokerError(
|
|
interaction,
|
|
error
|
|
);
|
|
}
|
|
}
|
|
};
|