Get started with Peachy now 🍑
PEACHYPEACHY
Gambling

Slots

The `slots` command allows users to play a slot machine gambling game with animated spinning reels. It can be triggered using the prefixes `P`, `p`, or the slash command `/`.

Command Details

  • Name: slots
  • Aliases: slot, s
  • Category: Gambling
  • Description: Bet your money in the slot machine!
  • Usage: P slots <amount>, p slots <amount>, or /slots <amount>
  • Examples:
    • P slots 100
    • p slot 100
    • /slots 100
  • Cooldown: 2 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 slot machine gambling game with animated spinning reels.
  • Features 6 different slot symbols with varying payout multipliers (x1, x2, x3, x4, x5, x10).
  • 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.
  • Different win probabilities for blacklisted vs regular users.
  • Three-stage animated slot spinning with timed delays.
  • Progressive reel stopping animation (left to right).
  • Dynamic payout calculation based on matching symbols.
  • Win rates: x1 (24.5%), x2 (10%), x3 (5.5%), x4 (5%), x5 (3%), x10 (2%).
  • Visual feedback with win/lose result thumbnails.
  • Real-time balance updates with immediate database synchronization.
  • Formatted display of bet amounts and winnings.
  • Supports both prefix-based (P or p) 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.
  • Users.updateOne() for immediate database balance updates.
  • client.utils.getRandomNumber(1, 100) for outcome determination.
  • client.utils.formatNumber() to display formatted coin amounts.
  • client.utils.emojiToImage() for win/lose result thumbnails.
  • client.utils.getRandomElement() for random result emoji selection.
  • Six-tier slot symbol array with corresponding multiplier values.
  • Probability-based outcome generation with different rates for blacklisted users.
  • Three-stage animated embed updates with precise timing (1000ms, 700ms, 1000ms).
  • Non-matching slot generation algorithm to ensure losing combinations.
  • Balance management with pre-game deduction and post-game payout.
  • Language localization for all game messages and results.
  • Error handling for database operations and invalid amounts.
  • Visual enhancement with decorative borders and themed emojis.