Get started with Peachy now 🍑
PEACHYPEACHY
Relationship

View Relationship

The viewrelationship command displays a user's relationships (partner, bestie, brother, sister) with detailed views for specific types or an overview of all relationships. This command is available to all registered users.

Command Details

  • Name: viewrelationship
  • Aliases: vr, relationshipinfo
  • Category: Relationship
  • Description: View your relationships or someone else's
  • Usage: viewrelationship [type] [@user]
  • Examples:
    • viewrelationship
    • viewrelationship bestie @user
    • vr partner @user
  • Cooldown: 5 seconds
  • Arguments: Optional (type, user)
  • Slash Command: Enabled
  • Permissions:
    • Bot: SendMessages, ViewChannel, EmbedLinks
    • User: None
  • Player Requirements: Target user must be registered

Functionality

  • Retrieves the target user's relationship data from the Users schema.
  • Supports viewing specific relationship types (partner, bestie, brother, sister) or all relationships (all).
  • For partner, generates a visual canvas using generatePartnerCanvas and displays it as an attachment with partner details (user and date).
  • For bestie, brother, or sister, paginates the list (10 per page) with user mentions and relationship start dates.
  • For all, shows a summary embed with fields for each relationship type, listing users and dates or "None" if empty.
  • Validates the target user, ensuring they are registered and have relevant relationships.
  • Sends localized error messages for cases like unregistered users, no relationships, or canvas generation failures.
  • Uses client.util.paginate for paginated lists and embeds for consistent display.

Code Overview

The command:

  • Extends the Command class from ../../structures/index.js.
  • Imports Users schema and generatePartnerCanvas for partner visualization.
  • Uses the run method to parse type (all, partner, bestie, brother, sister) and target user from message or slash command inputs.
  • For partner, generates a canvas, attaches it as an AttachmentBuilder, and embeds partner details.
  • For bestie, brother, or sister, chunks the relationship list into pages using chunkArray and creates paginated embeds.
  • For all, formats all relationships into a single embed with separate fields.
  • Sends success or error messages using client.utils.sendSuccessMessage or client.utils.sendErrorMessage, with proper handling for interactions and message commands.