justinkluever/discord-webhook-builder 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固