Bank
Balance
The `balance` command displays comprehensive financial information including wallet, bank, and total balance with formatted number display.
Command Details
- Name: balance
- Aliases: bal, money, coins
- Category: Bank
- Description: Check your current bank balance and wallet amount
- Usage:
P balance [@user],p balance [@user], or/balance [@user] - Examples:
P balancep bal @JohnDoe/balance @user
- Cooldown: 3 seconds
- Arguments: user (optional) - The user whose balance you want to check
- Slash Command: Enabled
- Permissions:
- Bot: SendMessages, ViewChannel, EmbedLinks
- User: None
- Player Requirements: None (no voice, DJ, or active player required)
Functionality
- Comprehensive Balance Display: Shows wallet, bank, and total balance in formatted, easy-to-read layout.
- Multi-User Support: Check your own balance or view other users' financial information.
- Formatted Number Display: Uses
client.utils.formatNumber()for readable large number formatting. - Wallet vs Bank Separation: Clearly distinguishes between cash on hand and banked money.
- Total Calculation: Automatically calculates and displays combined wallet and bank totals.
- User Profile Integration: Retrieves balance data from user database profiles.
- Privacy Considerations: May include privacy settings for balance visibility to other users.
- Real-Time Data: Displays current, up-to-date balance information from the database.
- Embed Formatting: Creates visually appealing embeds with coin emojis and financial styling.
- Error Handling: Provides appropriate messages for users not found or database errors.
- Self vs Others: Different messaging for checking your own balance versus viewing others'.
- Database Integration: Connects to user economy database for accurate balance retrieval.
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()for retrieving user financial data from the economy database.- Optional user parameter handling for checking both self and other users' balances.
client.utils.formatNumber()for displaying large numbers in readable formats (1,000 vs 1000).client.embed()creation with financial styling, coin emojis, and balance breakdowns.- User validation to ensure target users exist and have registered economy profiles.
- Error handling for database connection issues, missing users, or invalid balance data.
- Privacy logic for determining balance visibility between different users.
- Balance calculation combining wallet.coin and bank.coin values for total display.
- Conditional messaging for self-balance checks versus checking other users' finances.
- Integration with the bot's economy system for consistent financial data management.