Get started with Peachy now 🍑
PEACHYPEACHY
Utility

ServerInfo

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

ServerInfo Command

The serverinfo command is a utility feature in a Discord bot that provides comprehensive information about the server, including member status, channels, and more.

Command Details

  • Name: serverinfo
  • Aliases: guildinfo, server, sv
  • Category: Utility
  • Description: Displays information about the server.
  • Usage:
    • Prefix: P serverinfo, p serverinfo
    • Slash: /serverinfo
  • Examples:
    • P serverinfo
    • p serverinfo
    • /serverinfo
  • Cooldown: 3 seconds
  • Arguments: None
  • Slash Command: Enabled
  • Permissions:
    • Bot: SendMessages, ViewChannel, EmbedLinks
    • User: None
  • Player Requirements: None (no voice, DJ, or active player required)

Functionality

  • Displays detailed server information in an embed, including server ID, name, owner, verification level, channel counts, member statuses, boost info, roles, emojis, stickers, total members, and creation date.
  • Sends an initial "searching" message with a loading emoji, then replaces it with an embed containing:
    • A thumbnail of the server icon.
    • The server banner as the embed image (or a default banner if none exists).
    • Fields for server details, such as online/offline member counts, offline members for 7 and 30 days, and boost status.
    • A footer showing the requester's display name and avatar.
    • A timestamp.
  • Includes interactive buttons to toggle between the main server info, server icon, and server banner views.
  • Supports both prefix-based (P or p) and slash command (/) inputs.
  • Buttons time out after 1 minute, becoming disabled, and only the command issuer can interact with them.

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 server info, icon, and banner views.
  • guild.members.fetch() to retrieve member data for status counts (online, idle, dnd, offline).
  • guild.iconURL() and guild.bannerURL() to fetch server icon and banner images.
  • 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.
  • Error handling for button interactions (restricting to the command issuer) and fallback for missing banner/icon.