ryantxr/discord-webhook
Composer 安装命令:
composer require ryantxr/discord-webhook
包简介
Post messages to discord.
README 文档
README
This library provides a client for Discord Webhooks. With minimal code, you should be able to send a message to a Discord channel.
If you need to do more, like embeds and formatting, then you can do that too.
Motivation
I looked at other libraries and they have been around for a long time. Credit to them for supporting embeds and some neat functionality. However, I didn't see a way to just send a message with a single line of code. All I want to do is send a single text message to a channel.
This library is compatible with service containers.
Getting Started
You can either copy the PHP files directly into your project or preferable just use composer.
Composer require command
composer require ryantxr/discord-webhook
Features
- Minimal code to send a message
- Compatible with service containers
- Unit-Testing with PHPUnit
- Easy to use to any framework or even a plain php file
Usage
<?php use Ryantxr\Discord\Webhook\Client as Webhook; $webhook = new Webhook( 'YOUR_DISCORD_WEBHOOK_URL' ); $webhook->message('This is a message');
Embeds
Discord has ways to make more interesting posts using Embeds.
use Ryantxr\Discord\Webhook\Client as Webhook; use Ryantxr\Discord\Webhook\Embed; // Get this from some config $webhookConfig = [ 'url' => 'YOUR_DISCORD_WEBHOOK_URL', 'username' => 'funnybot', 'avatar' => 'https://pbs.twimg.com/media/C51iiP9UYAIPpWP.png', ]; $webhook = new Webhook( $webhookConfig ); $embed = new Embed('SOME_URL_YOU_WANT'); $embed->title('This is a title') ->author('Justin', 'https://authors-website.com', 'https://discordapp.com/assets/28174a34e77bb5e5310ced9f95cb480b.png') ->field('Field 1', 'Some cool text', true ) ->field('Field 2', 'Another cool text', true ) ->color(15158332) ; $webhook->send($embed, "A message goes here.");
Here's the official color list to colorize your embeds:
DEFAULT: 0, AQUA: 1752220, GREEN: 3066993, BLUE: 3447003, PURPLE: 10181046, GOLD: 15844367, ORANGE: 15105570, RED: 15158332, GREY: 9807270, DARKER_GREY: 8359053, NAVY: 3426654, DARK_AQUA: 1146986, DARK_GREEN: 2067276, DARK_BLUE: 2123412, DARK_PURPLE: 7419530, DARK_GOLD: 12745742, DARK_ORANGE: 11027200, DARK_RED: 10038562, DARK_GREY: 9936031, LIGHT_GREY: 12370112, DARK_NAVY: 2899536
ryantxr/discord-webhook 适用场景与选型建议
ryantxr/discord-webhook 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 66 次下载、GitHub Stars 达 4, 最近一次更新时间为 2021 年 07 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「webhook」 「discord」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ryantxr/discord-webhook 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ryantxr/discord-webhook 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ryantxr/discord-webhook 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A simple monolog handler for support Discord webhooks
Send Notification to discord channel Webhook using native FilamentPHP Notification Facade class
Inbox pattern process implementation for your Laravel Applications
A simple package to create tables in Discord messages.
GitHub Webhook Listener with plugin-based API for creating your own triggerered actions
统计信息
- 总下载量: 66
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-07-23