Get started with Peachy now 🍑
PEACHYPEACHY
Profile

Birthday

The `birthday` command allows users to set, view, or reset their birthday and automatically calculates their zodiac sign. It can be triggered using the prefixes `P`, `p`, or the slash command `/`.

Command Details

  • Name: birthday
  • Aliases: bd
  • Category: Profile
  • Description: Set your profile birthday and zodiac sign
  • Usage: P birthday <date || reset || help>, p birthday <date || reset || help>, or /birthday <subcommand>
  • Examples:
    • P birthday 20-01
    • p bd reset
    • /birthday help
    • P birthday 03/15
  • Cooldown: 5 seconds
  • Arguments: date/subcommand (optional for viewing)
  • Slash Command: Enabled
  • Permissions:
    • Bot: SendMessages, ViewChannel, EmbedLinks
    • User: None
  • Player Requirements: None (no voice, DJ, or active player required)

Functionality

  • Comprehensive birthday and zodiac sign management system.
  • Set Birthday: Accepts multiple date formats (DD-MM, MM-DD, MM/DD, DD/MM).
  • Automatic Zodiac Calculation: Determines zodiac sign based on birth date.
  • Visual Zodiac Display: Shows zodiac emoji as embed thumbnail.
  • Reset Function: Clears both birthday and zodiac sign data.
  • Help Command: Displays usage examples and supported date formats.
  • View Current: Shows current birthday and zodiac sign when no arguments provided.
  • Multiple Date Format Support: Flexible date parsing using Moment.js.
  • Database Integration: Persistent storage of birthday and zodiac information.
  • Error Validation: Validates date formats and provides helpful error messages.
  • Formatted Display: Shows dates in DD-MMM format (e.g., "20-Jan").
  • 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:

  • moment() library for flexible date parsing and validation across multiple formats.
  • client.utils.getZodiacSign() to calculate zodiac signs based on day and month.
  • client.utils.emojiToImage() to convert zodiac emojis into embed thumbnails.
  • client.utils.formatCapitalize() for proper name formatting of zodiac signs.
  • Users.updateOne() with $set operator for updating birthday and zodiac data.
  • Array of supported date formats for comprehensive date parsing.
  • Switch statement for handling subcommands (help, reset, set, view).
  • Conditional zodiac emoji display based on user's current zodiac sign.
  • Language localization for all messages, errors, and success responses.
  • Error handling for invalid date formats with helpful format suggestions.
  • Database integration for persistent profile data storage and retrieval.