Get started with Peachy now 🍑
PEACHYPEACHY
Utility

UserInfo

The `userinfo` command displays detailed information about a user in a Discord server. It can be triggered using the prefixes `P`, `p`, or the slash command `/`.

UserInfo Command

The userinfo command is a utility feature in a Discord bot that provides comprehensive information about a specified user, including their ID, roles, and join date.

Command Details

  • Name: userinfo
  • Aliases: user, whois
  • Category: Utility
  • Description: Displays information about a user.
  • Usage:
    • Prefix: P userinfo [@User], p userinfo [@User]
    • Slash: /userinfo [user]
  • Examples:
    • P userinfo @User
    • p userinfo @User
    • /userinfo @User
  • Cooldown: 3 seconds
  • Arguments: Required (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

  • Displays detailed user information in an embed, including user ID, display name, username, join date, bot status, server boost status, top role, and account creation date.
  • Sends an initial "searching" message with a loading emoji, then replaces it with an embed containing:
    • A thumbnail of the user's avatar.
    • Fields for user details, such as join duration and top role.
    • A footer showing the requester's display name and avatar.
    • A timestamp.
  • Includes interactive buttons to toggle between the main user info, avatar, and banner views.
  • Supports both prefix-based (P or p) and slash command (/) inputs.
  • Fetches the user's banner using client.users.fetch() and falls back to a default banner if none exists.
  • Buttons time out after 1 minute, becoming disabled, and only the command issuer can interact with them.
  • 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 formatted embeds for the main user info, avatar, and banner views.
  • client.users.fetch() to retrieve user data, including banner information.
  • guild.members.cache.get() and message.mentions to identify the target user.
  • ActionRowBuilder and ButtonBuilder from discord.js to create interactive buttons for switching views.
  • A message component collector to handle button interactions with a 1-minute timeout.
  • Language localization for messages and emojis via generalMessages.
  • Error handling for invalid user inputs and fetch failures.