Get started with Peachy now πŸ‘
PEACHYPEACHY
Work

Rob

The rob command allows users to attempt stealing coins from another user, with a success rate based on the victim's coin balance. Includes cooldowns and penalties.

Command Details

  • Name: rob
  • Aliases: steal
  • Category: Work
  • Description: Attempt to rob another user for their coins.
  • Usage:
    • rob <user>
  • Examples:
    • rob @username - Attempts to rob the mentioned user.
  • Cooldown: 8 seconds (plus internal 3-minute robbery cooldown)
  • Arguments: Required (user mention or user ID)
  • Slash Command: Enabled
  • Permissions:
    • Bot: SendMessages, ViewChannel, EmbedLinks
    • User: None
  • Player Requirements:
    • Must not be a police officer (position = "police" and status = "approved").
    • Target must not be a police officer.
    • Target must have at least 100 coins.

Functionality

  • Validations:
    • Cannot rob yourself.
    • Both robber and victim must exist in the database.
    • Cannot rob if robber is a police officer.
    • Cannot rob a user who is a police officer.
    • Checks robbery cooldown (3 minutes). Shows remaining time if active.
    • Target must have at least 100 coins.
  • Success Chance:
    • Dynamic success rate based on victim's coin balance:
      • 500M+ β†’ 10%
      • 300M β†’ 20%
      • 200M β†’ 30%
      • 100M β†’ 40%
      • 50M β†’ 50%
      • 20M β†’ 60%
      • 10M β†’ 65%
      • 5M β†’ 70%
      • 1M β†’ 75%
      • Below 1M β†’ 80%
  • Stolen Amount:
    • 1% to 1.5% of victim's balance.
  • On Success:
    • Robber gains stolen amount.
    • Victim loses stolen amount.
    • Robber’s work.rob set to true and robAmount updated.
    • Cooldown applied (3 mins).
  • On Failure:
    • Robber loses 1% of their balance as penalty.
    • Robber’s work.rob set to true and robAmount updated.
    • Cooldown applied (3 mins).
  • Messages:
    • Success β†’ Embed with stolen amount and victim name.
    • Failure β†’ Embed with penalty amount and victim name.
    • Cooldown β†’ Embed with remaining time.

Code Overview

The command:

  • Uses Chance.js for probability calculations.
  • Uses moment for time formatting.
  • Updates database fields: balance.coin, work.rob, and work.robAmount.
  • Integrates cooldown system with client.utils.checkCooldown and updateCooldown.
  • Uses client.utils for:
    • Emojis and images
    • Number formatting
    • Embed construction
    • Random emoji selection for robbery visuals.

Example Success Embed