Guides and reference
DiscordPHP runs on ReactPHP: nearly every call returns a promise, and your bot lives inside an event loop. If promises and the event loop are new to you, read about them first. Everything below builds on them.
The DiscordPHP guide
Start with the guide's introduction, which covers requirements, installation and tips, then work through the topics.
Basics
Creating the client, its options, and running it.
Events
Listening for gateway events, the intents each one needs, and what your listener receives.
Repositories
Reading from the cache, fetching from Discord, and saving and deleting parts.
Parts
Guilds, channels, members, messages and users, and what you can do with each.
Message builder
Composing messages with embeds, files, mentions and components.
Message components
Buttons, select menus and text inputs, and handling their clicks.
Interactions
Slash commands, context menus and modals: registering them and responding.
Permissions
Reading and changing role and channel permissions.
Collection
Filtering, finding and mapping over repositories and other collections.
FAQ
Answers to the questions people ask most often in the Discord server.
Class references
Every class, method and property, generated from the source's documentation.
| Package | Reference | Also |
|---|---|---|
| DiscordPHP | discord-php.github.io/DiscordPHP | Deprecated API |
| DiscordPHP-Http | discord-php.github.io/DiscordPHP-Http | — |
| DiscordPHP-Voice | discord-php.github.io/DiscordPHP-Voice | — |
| Collection | discord-php.github.io/Collection | — |
The UML diagrams on this site show how the classes fit together, and which class sends each of Discord's routes.
Voice
DiscordPHP-Voice keeps its own guides, with diagrams, next to its code.
- Getting started — requirements,
libdavesetup, playing and recording - The DAVE protocol — end-to-end encryption, the MLS lifecycle and its opcodes
- The audio pipeline — how audio flows out and in, and the playback states
- Protocol reference — voice gateway opcodes and close codes
- Troubleshooting — missing libraries, permissions and playback problems
More from the project
- Examples — small bots you can run
- Wiki — community-written notes and how-tos
- Changelog — what changed in each release
- Releases — release notes on GitHub
- Upgrading to v7 — and to v6
- One-page docs — the earlier docs site, which still covers guild join requests and webhook events
- Contributing — how to send a change
Discord's documentation
- Developer documentation — the API DiscordPHP wraps
- Developer portal — create an application and a bot token
- Gateway — intents, connecting and sharding
- Rate limits — what DiscordPHP-Http's buckets follow
- OpenAPI description — the spec the route map is built from