Get started with Peachy now 🍑
PEACHYPEACHY
Utility

Avatar

The `avatar` command allows users to display a user's avatar in a Discord server. It can be triggered using the prefixes `P`, `p`, or the slash command `/`.

Command Details

  • Name: avatar
  • Aliases: av, pfp
  • Category: Utility
  • Description: Displays a user's avatar.
  • Usage: P avatar [@User], p avatar [@User], or /avatar [user]
  • Examples:
    • P avatar @User
    • p avatar @User
    • /avatar @User
  • Cooldown: 3 seconds
  • Arguments: Optional (user mention or ID)
  • Slash Command: Enabled
  • Permissions:
    • Bot: SendMessages, ViewChannel, EmbedLinks
    • User: None
  • Player Requirements: None (no voice, DJ, or active player required)

Functionality

  • If no user is mentioned, the command defaults to showing the avatar of the user who invoked it.
  • The command sends an initial "searching" message with a loading emoji, then replaces it with an embed containing:
    • The user's avatar image (1024x1024, PNG format, dynamic).
    • A title with customizable emojis.
    • A footer showing the requester's display name and avatar.
    • A timestamp.
  • Supports both prefix-based (P or p) and slash command (/) inputs.
  • If no valid user is found, an error message is displayed.

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.embed() to create a formatted embed.
  • mention.displayAvatarURL() to fetch the user's avatar.
  • Language localization for messages and emojis.
  • Error handling for cases where no user is mentioned.