Fun
Wallpaper
The `wallpaper` command allows users to browse and view wallpapers for PC or phone in a Discord server. It can be triggered using the slash command `/` or prefix commands.
Command Details
- Name: wallpaper
- Aliases: wp
- Category: Fun
- Description: Displays a paginated list of wallpapers, allowing users to select categories and view specific wallpaper details.
- Usage:
P wallpaper [category]
,p wallpaper [category]
, or/wallpaper
- Examples:
P wallpaper
p wallpaper nature
/wallpaper
- Cooldown: 5 seconds
- Arguments: Optional (category name)
- Slash Command: Enabled
- Permissions:
- Bot: SendMessages, ViewChannel, EmbedLinks
- User: None
- Player Requirements: None (no voice, DJ, or active player required)
Functionality
- Displays wallpapers from a JSON file (
wallpapers.json
), grouped by unique categories (e.g., nature, abstract). - Defaults to the first category if none is specified; users can optionally provide a category as an argument.
- Shows up to 5 wallpapers per page in an embed, with each wallpaper listed by name and emoji.
- Includes interactive components:
- A dropdown menu to switch between wallpaper categories.
- A dropdown menu to select a specific wallpaper within the current category.
- Previous/next buttons to navigate through individual wallpapers when one is selected.
- Selecting a wallpaper displays its details (ID, description, category, and image) in a new embed.
- Supports pagination for browsing multiple pages of wallpapers.
- Uses a 5-minute collector to handle user interactions, disabling buttons after timeout.
- Sends an initial embed with a list of wallpapers and updates dynamically based on user selections.
- Supports both prefix-based (
P
orp
) and slash command (/
) inputs.
Code Overview
The command is built using a Command
class structure and handles both message-based and interaction-based inputs. It uses:
Wallpapers
JSON file to store wallpaper data (name, type, emoji, ID, description, image URL).StringSelectMenuBuilder
andActionRowBuilder
fromdiscord.js
for interactive dropdown menus.client.embed()
to create formatted embeds for wallpaper lists and details.- A custom
paginateWallpapers
function to handle pagination and interaction logic. - Language localization for messages and titles (via
language.locales
). - A message component collector to manage user interactions (category selection, wallpaper selection, navigation).
- Error handling for invalid wallpaper selections or missing message objects.
Quote
The `quote` command sends a random motivational or general quote in a Discord server. It can be triggered using the slash command `/` or prefix commands.
Blackjack
The `blackjack` command allows users to play a card game where they try to get closer to 21 than the dealer without going over. It can be triggered using the prefixes `P`, `p`, or the slash command `/`.