nopjmp/discord-webhooks

一个简单的 Discord webhook 客户端库。

0.4.0 2024-04-20 21:11 UTC

This package is auto-updated.

Last update: 2024-09-20 22:59:04 UTC


README

Discord webhooks 是 Discord webhook API 的简单客户端。

动机

虽然这可能是 Discord webhook 系统的“又一个”库,但我还是想自己做一个。Discord 不支持 BitBucket 的 webhook 系统,且与 Slack 兼容的端点不会发送消息。

入门

您可以直接将 PHP 文件复制到您的项目中,或者 更推荐 使用 composer。

Composer 安装命令

composer require nopjmp/discord-webhooks

用法

使用起来相当简单。我将提供一个示例。

use \DiscordWebhooks\Client;
use \DiscordWebhooks\Embed;

$webhook = new Client('DISCORD_WEBHOOK_URL');
$embed = new Embed();

$embed->description('This is an embed');

$webhook->username('Bot')->message('Hello, Human!')->embed($embed)->send();

发送文件示例

$webhook->addFile("/path/to/file")
        ->addStringFile("Hello World!", "hello_world.txt")
        ->send();

许可证

该项目采用 MIT 许可。要阅读完整的许可证,请打开 LICENSE.md

贡献

拉取请求和问题都是开放的!