Get started with Peachy now 🍑
PEACHYPEACHY
Social

Instagram

The instagram command allows users to manage their Instagram 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: instagram
  • Aliases: ig
  • Category: Profile
  • Description: Manage your Instagram profile
  • Usage:
    • instagram
    • instagram @mention
    • instagram name <YourInstagramName>
    • instagram link <YourInstagramLink>
    • instagram help
  • Examples:
    • instagram - Shows your current Instagram details
    • instagram @mention - Shows the mentioned user's Instagram details
    • instagram name MyIGName - Sets your Instagram name
    • instagram link https://instagram.com/MyProfile - Sets your Instagram link
    • instagram 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 an Instagram name, link to set an Instagram 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.instagram.name in the Users schema.
  • For link, validates the input as a valid URL using a regex pattern and updates the user's social.instagram.link in the Users schema.
  • For help, displays a detailed embed with command usage and examples.
  • For default (no subcommand), shows the target's Instagram 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.