Language
The `language` command allows users to manage their language settings or view their current language in a Discord server. It can be triggered using the prefixes `P`, `p`, or the slash command `/`.
Language Command
The language
command is a utility feature in a Discord bot that allows users to view or set their preferred language.
Command Details
- Name:
language
- Aliases:
lang
- Category: Utility
- Description: Manages user language settings or displays the current language.
- Usage:
- Prefix:
P language [show|en|kh|help]
,p language [show|en|kh|help]
- Slash:
/language show
,/language help
- Prefix:
- Examples:
P language show
p language en
P language kh
/language help
- Cooldown: 3 seconds
- Arguments: Optional for prefix command (show, en, kh, help); required for slash command (subcommand: show or help)
- Slash Command: Enabled
- Permissions:
- Bot: SendMessages, ViewChannel
- User: None
- Player Requirements: None (no voice, DJ, or active player required)
Functionality
- Allows users to view their current language, set their language to English (
en
) or Khmer (kh
), or display command usage examples. - Supports the following subcommands:
show
(or no argument in prefix commands): Displays the user's current language.en
orkh
: Sets the user's language to English or Khmer, respectively.help
: Shows command usage examples and information.
- Sends an embed with:
- A title with customizable emojis.
- A description indicating the current language, language change confirmation, or help information.
- A thumbnail with the corresponding country flag emoji for the language.
- A footer showing the requester's display name and avatar.
- Updates the user's language preference in the database using the
Users
schema. - Supports both prefix-based (
P
orp
) and slash command (/
) inputs. - If no language is set, it displays "Unknown Language" or "Not set."
Code Overview
The command is built using a Command
class structure and handles both message-based and interaction-based (slash command) inputs. It uses:
Users.updateOne()
andUsers.findOne()
to manage and retrieve user language preferences in the database.client.embed()
to create a formatted embed.client.utils.emojiToImage()
to display country flag emojis as thumbnails.- Language localization for messages and emojis.
- A switch statement to handle subcommands (
en
,kh
,help
, or default forshow
).
Invites
The `invites` command allows users to display the total number of invite uses for a specified user in a Discord server. It can be triggered using the prefixes `P`, `p`, or the slash command `/`.
QR Code
The `qr` command displays a QR code for KHR or USD in a Discord server. It can be triggered using the prefixes `P`, `p`, or the slash command `/`.