Pycord Documentation Guide
website·Indexed 33 days ago
https://guide.pycord.devA modern, feature-rich, and async-ready API wrapper for Discord written in Python. This guide covers bot creation, slash commands, UI components like buttons and modals, voice features, Cogs, and common practices for developing Discord bots.
What's inside Pycord
- Pycord is a modern, feature-rich, and async-ready API wrapper for Discord, providing an intuitive Python interface for developers to create Discord bots and applications.
Overview of Modal Dialogs in Pycord
Modal Dialogs (modals) provide a form-like structure for bots to receive input from users. They are particularly useful for receiving longer input without requiring the Message Content intent. Unlike other UI components, modals cannot be sent with messages; they must be invoked by an Application Command or another UI Component. A modal consists of a title, a custom ID, and up to 5discord.ui.InputTextcomponents.Overview of Discord Application Commands
Application Commands are a set of interaction features provided by Discord to improve user safety and privacy. Unlike prefix commands, they do not require the Message Content intent because Discord notifies the bot when a command is invoked rather than the bot reading every message.
There are three primary types of Application Commands:
- Slash Commands: Invoked using the
/prefix. They support fields for Members, Roles, Channels, Attachments, and Text. - User Commands: Context menu commands that appear when right-clicking/alt-clicking a user.
- Message Commands: Context menu commands that appear when right-clicking/alt-clicking a message.
- Slash Commands: Invoked using the
Follow Pycord guide header and formatting standards
When contributing to the guide, adhere to the following formatting rules:
- Header Hierarchy: Do not start a page with an
# H1header. Start with an introduction, then use## H2for main topics, and### H3for subtopics. - Grammar and Spelling: Ensure perfect spelling and grammar; a GitHub Action will flag spelling errors during pull requests.
- Paragraphs: Use two newlines to create a separate paragraph; a single newline keeps text within the same paragraph.
[Introduction text here] ## Main Topic Content here... ### Subtopic More specific content here...- Header Hierarchy: Do not start a page with an
Use Buttons for quick user responses
Buttons are Message Components used for quick responses to prompts (e.g., canceling or continuing an action) or for building interactive elements like calculators and games.Prepare a Pycord GSoC application template
A complete Pycord GSoC application should include the following sections:
- About You: Name, contact info, educational background, relevant experience (coding, open source, Discord bots), and motivation for joining Pycord/GSoC.
- Project Proposal: The specific project chosen, your understanding of the goals, and any unique approaches you propose.
- Technical Background: Known programming languages (especially Python), relevant technologies (databases, web frameworks), links to GitHub/personal projects, and previous open-source contributions.
- Availability: Weekly time commitment, known schedule conflicts, and your timezone.
Use Modal Dialogs for text input and forms
Modal Dialogs are Message Components used for text input and filling out forms (e.g., service sign-ups). They replace multi-step message processes by allowing users to fill multiple text fields in one interface. Modals are triggered either by an Application Command or by interacting with another UI Component (like a Button or Select Menu).Use Select Menus for list-based choices
Select Menus are Message Components that allow users to choose from a predefined list of options. They are ideal for selecting bot features or navigating pages of a help menu.Understand and configure Discord Intents in Pycord
Intents allow bot developers to subscribe to specific events in Discord (e.g., user joins or messages sent). This reduces unnecessary data traffic by allowing bots to opt-in only to the events they require. You can either enable all available intents or specify a subset.Understand why Pycord bots require hosting
Pycord bots must be hosted on a machine that runs constantly to maintain a connection with Discord. The bot sends 'heartbeats' (small packets) at set intervals to Discord to signal it is still active. If the process is terminated (e.g., by closing the IDE or shutting down the computer), heartbeats stop, and Discord will take the bot offline.Create a fully custom help command
To create a completely custom help system, subclass
commands.HelpCommand. You must override the following four methods to handle different help requests:send_bot_help(mapping): Triggered by<prefix>help.send_command_help(command): Triggered by<prefix>help <command>.send_group_help(group): Triggered by<prefix>help <group>.send_cog_help(cog): Triggered by<prefix>help <cog>.
Install Git on Linux
Git is typically available in most Linux distribution repositories. It can be installed via the distribution's built-in package manager or by downloading from the Git for Linux page.