Get started with Peachy now 🍑
PEACHYPEACHY
Fun

Guess

The `guess` command generates a visual representation of the relationship between two users in a Discord server using a "ship" image. It can be triggered using the slash command `/` or prefix commands.

Command Details

  • Name: guess
  • Aliases: None
  • Category: Fun
  • Description: Creates a "ship" image to guess the relationship between two users.
  • Usage: P guess <user1> <user2>, p guess <user1> <user2>, or /guess [target] [partner]
  • Examples:
    • P guess @User1 @User2
    • p guess @User1 @User2
    • /guess @User1 @User2
  • Cooldown: 5 seconds
  • Arguments: Required (two user mentions or IDs)
  • Slash Command: Enabled
  • Permissions:
    • Bot: SendMessages, ViewChannel, EmbedLinks
    • User: None
  • Player Requirements: None (no voice, DJ, or active player required)

Functionality

  • The command accepts two users as input (via mentions, IDs, or slash command options).
  • If invoked via slash command, users are selected from target and partner options; for prefix commands, it uses mentions or defaults to the invoker as the second user if only one is provided.
  • Validates that:
    • Both users are valid (sends error: "Please mention two valid users." if not).
    • The two users are not the same (sends error: "You cannot guess a relationship with the same user.").
  • Generates a "ship" image using the canvafy.Ship library, combining:
    • Avatars of both users (PNG, static format).
    • A background image (https://i.imgur.com/WRQ9JgJ.jpg).
    • A border color (#FFCFCF) and overlay opacity (0.7).
  • Sends the generated image as an attachment named ship-[user1]-[user2].png.
  • Displays an initial "Thinking..." message for better UX during image generation.
  • Handles errors gracefully, sending a user-friendly error message and logging the issue.

Code Overview

The command is built using a Command class structure and handles both message-based and interaction-based (slash command) inputs. It uses:

  • canvafy.Ship to generate the relationship image with user avatars.
  • client.embed() to create error embeds with a danger color.
  • User fetching via mentions, IDs, or slash command options.
  • Error handling for invalid users, same-user inputs, or image generation failures.
  • Language localization support (via the language parameter, though not fully utilized in the provided code).