Download the PHP package reysa/discord-api without Composer
On this page you can find all versions of the php package reysa/discord-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download reysa/discord-api
More information about reysa/discord-api
Files in reysa/discord-api
Package discord-api
Short Description Full-coverage Discord HTTP API client for Laravel -- call Discord's REST API through simple static PHP methods instead of raw HTTP calls.
License MIT
Informations about the package discord-api
Reysa Discord API
Call Discord's HTTP API from Laravel through simple static method calls instead of hand-rolling
Guzzle/Http:: requests, headers, and URLs yourself:
v2 covers essentially every endpoint Discord officially documents for bots — Guilds, Channels, Messages, Users, Webhooks, Emojis, Stickers, Invites, Application Commands & Interactions, Audit Log, Auto Moderation, Scheduled Events, Stage Instances, Soundboard, Polls, Voice, Monetization, and OAuth2. Not covered: the Gateway (WebSocket real-time events) and the Discord Social SDK/Lobby endpoints — different protocol/product, outside the scope of an HTTP client wrapper.
Official Discord API documentation: https://discord.com/developers/docs/intro
Table of contents
- What's new in v2
- Requirements
- Installation
- Configuration
- Quick usage example
- Full API coverage
- Browsable docs & live testing (Swagger)
- API reference (core helpers)
- Versioning & roadmap
- Contributing
- License
What's new in v2
- Full endpoint coverage — ~218 methods across 21 resource categories (up from 15 helpers in v1), generated directly from Discord's official docs source so paths/params match exactly. See Full API coverage for the breakdown.
- Interactive documentation — a Swagger UI you can run locally that documents every method as the actual PHP call you write, with real example payloads, and lets you fire live test requests against your own bot. See Browsable docs & live testing.
- Docker test harness —
docker compose up, no local PHP/Composer setup needed to try the package against a real Discord server. - Breaking change:
giveRole()/removeRole()now returnResponse[]keyed by role ID instead of a singleResponse— see their reference entries for why. - Every v1 method still works exactly as it did (same names, same arguments) except that one documented change.
Requirements
Check composer.json for exact constraints, but the package is designed to work with:
- PHP:
>= 8.2 - Laravel:
7.xup to13.x(viailluminate/support^7.0|^8.0|^9.0|^10.0|^11.0|^12.0|^13.0). Onlyilluminate/support(config, HTTP client, facades) is required — no framework internals this package depends on have changed across that range, so newer Laravel majors will typically keep working without a package update; the constraint just gets widened once released.
Installation
Install the package via Composer:
composer require reysa/discord-api
Laravel’s package auto-discovery will automatically register the service provider and facade.
You can also find the package on Packagist:
https://packagist.org/packages/reysa/discord-api
Configuration
Publish the config file:
php artisan vendor:publish --tag=discord-api-config
This will create config/discord-api.php in your Laravel application:
removeRole(string $userId, array $roleIds): Response[]
Remove one or multiple roles from a member.
$roleIdsworks the same way as ingiveRole— oneDELETErequest per role ID.- Returns an array of
Responseobjects keyed by role ID.
// Remove a single role
$results = DAPI::removeRole($userId, [123456789012345678]);
// Remove multiple roles
$results = DAPI::removeRole($userId, [
123456789012345678,
234567890123456789,
]);
setName(string $userId, string $name): Response
Set the member's nickname in the configured guild.
DAPI::setName($userId, 'New Nickname');
sendMessageToUser(string $userId, string $message): Response|false
Send a direct message (plain text) to a user.
- Internally:
- Creates a DM channel with the user.
- Sends the message to that channel.
- Returns
falseif creating the DM channel fails.
$result = DAPI::sendMessageToUser($userId, 'Hello in your DMs!');
if ($result === false) {
// handle failure
}
sendEmbedMessageToUser(string $userId, array $payload): Response|false
Send a rich embed (or any valid Discord message payload) to a user via DM.
$payloadis sent as-is to the Discord API.- Example payload:
['embeds' => [...]] - Returns
falseif DM channel creation fails.
$payload = [
'content' => 'Optional text',
'embeds' => [
[
'title' => 'Hello!',
'description' => 'This is an embed message',
'color' => 0x7289DA,
],
],
];
DAPI::sendEmbedMessageToUser($userId, $payload);
sendMessageToChannel(string $channelId, array $payload): Response
Send a message to a specific channel.
$payloadcan be:['content' => 'plain text']- or a more complex structure (embeds, components, etc.).
DAPI::sendMessageToChannel('123456789012345678', [
'content' => 'Hello channel!',
]);
getChannelMessage(string $channelId, string $messageId): Response
Retrieve a single message from a given channel.
$message = DAPI::getChannelMessage($channelId, $messageId);
getChannelMessages(string $channelId): Response
Retrieve recent messages from a given channel.
$messages = DAPI::getChannelMessages($channelId);
editChannelEmbedMessage(string $channelId, string $messageId, array $embeds): Response
Edit an existing message’s embeds in a channel.
DAPI::editChannelEmbedMessage($channelId, $messageId, [
[
'title' => 'Updated title',
'description' => 'Updated description',
],
]);
Versioning & Roadmap
- Scope: Full coverage of Discord's documented bot-usable HTTP REST API. Request bodies are
passed through as-is (no validation), matching the original package's philosophy — see the
Discord docs or the Swagger UI (
docker compose up,http://localhost:8081) for exact payload shapes per endpoint. - Not covered: Gateway/WebSocket events, Discord Social SDK (Lobby) endpoints.
- Planned: Typed request/response DTOs and higher-level helpers on top of the raw wrappers.
Contributing
Issues and pull requests are welcome.
- Feel free to open an issue with:
- API endpoints you’d like to see supported
- Bug reports
- Ideas for improving developer experience (DX)
License
This project is open-source software licensed under the MIT license.
See the LICENSE file for details.