justinkluever/discord-webhook-builder
Composer 安装命令:
composer require justinkluever/discord-webhook-builder
包简介
a simple and fluent builder for discord webhook messages with embeds or components v2
关键字:
README 文档
README
A simple discord webhook builder.
This package only provides a fluent way of building the payload, you still have to send it yourself currently.
Note
Components that are not supported by the simple discord webhook endpoint may be missing or limited currently as they where not the primary goal of this package
you can install it via composer:
composer require justinkluever/discord-webhook-builder
Usage
Using this package should be simple:
use JustinKluever\DiscordWebhookBuilder\Components\TextDisplay; use JustinKluever\DiscordWebhookBuilder\Enums\Support\MessageFlag; use JustinKluever\DiscordWebhookBuilder\Support\Webhook\Embed; use JustinKluever\DiscordWebhookBuilder\Webhook; // Components V2 $webhook = Webhook::make() ->flag(MessageFlag::IS_COMPONENTS_V2) // Required for Components V2 by Discord ->component( TextDisplay::make('This is a Text Display!'), ); // Classic Webhooks $webhook = Webhook::make() ->content('Embed Test webhook') ->embed( Embed::make()->description('This is a Embed description'), )
After creating your webhook payload you can use your preferred way of POSTing:
// Laravel HTTP Client use Illuminate\Support\Facades\Http; Http::post('https://discord.com/api/webhooks/...', $webhook); // The Webhook builder implements Stringable for ease of use // Guzzle $client->post('https://discord.com/api/webhooks/...', [ 'json' => $webhook ]); // cURL $ch = curl_init('https://discord.com/api/webhooks/...'); curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $webhook); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch);
For more details on how to use specific Components check the Source or look at Discord's Documentation:
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-13