Gambling
Blackjack
The `blackjack` command allows users to play a card game where they try to get closer to 21 than the dealer without going over. It can be triggered using the prefixes `P`, `p`, or the slash command `/`.
Command Details
- Name: blackjack
- Aliases: bj
- Category: Gambling
- Description: Bet an amount and try to get closer to 21
- Usage:
P blackjack <amount>
,p blackjack <amount>
, or/blackjack <amount>
- Examples:
P blackjack 100
p blackjack 100
/blackjack 100
- Cooldown: 3 seconds
- Arguments: amount (required)
- Slash Command: Enabled
- Permissions:
- Bot: SendMessages, ViewChannel, EmbedLinks
- User: None
- Player Requirements: None (no voice, DJ, or active player required)
Functionality
- Classic blackjack card game where players try to get as close to 21 as possible without busting.
- Shows a loading message while setting up the game.
- Validates that users aren't already in active games (KlaKlouk or MultiTransfer).
- Accepts betting amounts with special keywords like "all" or "half".
- Maximum bet limit of 250,000 coins per game.
- Features animated card dealing with a 2.8-second GIF introduction.
- Interactive gameplay with Hit and Stand buttons.
- Real-time card value calculations with proper Ace handling.
- Dealer follows standard blackjack rules (hits until 17 or higher).
- Automatic game resolution with win/lose/tie outcomes.
- Balance updates based on game results (win = 2x bet, tie = refund, lose = forfeit).
- 60-second timeout for inactive players.
- Supports both prefix-based (
P
orp
) and slash command (/
) inputs.
Code Overview
The command is built using a Command
class structure and handles both message-based and interaction-based (slash command) inputs. It uses:
client.utils.getUser()
to fetch and validate user data from the database.bjUtil.randCard()
to generate random cards from a 52-card deck.bjUtil.cardValue()
to calculate hand values with proper Ace logic.bjUtil.generateEmbed()
to create formatted game state displays.client.utils.fullOptionButton()
to create interactive Hit/Stand buttons.createMessageComponentCollector()
for handling button interactions.- Active games tracking using a
Map
to prevent concurrent games. - Animated card dealing with timed embed updates.
- Balance management with immediate deduction and result-based payouts.
- Error handling for database operations and user validation.
- Language localization for all game messages and interactions.
Wallpaper
The `wallpaper` command allows users to browse and view wallpapers for PC or phone in a Discord server. It can be triggered using the slash command `/` or prefix commands.
Coinflip
The `coinflip` command allows users to flip a coin and bet on either Peach or Goma side. It can be triggered using the prefixes `P`, `p`, or the slash command `/`.