Get started with Peachy now 🍑
PEACHYPEACHY
Social

Facebook

The facebook command allows users to manage their Facebook profile details, including setting a name or link, viewing their own or another user's details, or accessing help information. This command is available to all registered users.

Command Details

  • Name: facebook
  • Aliases: fb
  • Category: Profile
  • Description: Manage your Facebook profile
  • Usage:
    • facebook
    • facebook @mention
    • facebook name <YourFacebookName>
    • facebook link <YourFacebookLink>
    • facebook help
  • Examples:
    • facebook - Shows your current Facebook details
    • facebook @mention - Shows the mentioned user's Facebook details
    • facebook name MyFBName - Sets your Facebook name
    • facebook link https://facebook.com/MyProfile - Sets your Facebook link
    • facebook help - Shows command usage examples
  • Cooldown: 5 seconds
  • Arguments: Optional (subcommand, name, link, or user mention)
  • Slash Command: Enabled
  • Permissions:
    • Bot: SendMessages, ViewChannel, EmbedLinks
    • User: None
  • Player Requirements: User must be registered for profile updates or viewing

Functionality

  • Supports subcommands: name to set a Facebook name, link to set a Facebook link, help to display usage examples, and default behavior to view profile details.
  • For name, validates the input (max 21 characters) and updates the user's social.facebook.name in the Users schema.
  • For link, validates the input as a valid URL and updates the user's social.facebook.link in the Users schema.
  • For help, displays a detailed embed with command usage and examples.
  • For default (no subcommand), shows the target's Facebook name and link (if set) or a "Not set" message.
  • Retrieves user data from the Users schema and supports viewing another user's profile via mention.
  • Sends localized embeds for success, errors, or help, with proper formatting for names and clickable links.
  • Validates inputs, ensuring valid names, URLs, and registered users, with appropriate error messages.

Code Overview

The command:

  • Extends the Command class from ../../structures/index.js.
  • Imports Users schema for profile data management.
  • Uses the run method to handle both message and slash command inputs, parsing subcommands and arguments.
  • Supports subcommands (name, link, help) and default behavior for viewing profiles.
  • Validates inputs: checks name length (≤21 characters) and URL format using a regex pattern.
  • Updates the database with Users.updateOne for name and link changes.
  • Creates embeds with client.embed() for consistent display, including clickable links and localized messages.
  • Uses client.utils.sendErrorMessage and client.utils.oops for error handling, ensuring user-friendly feedback.