forien / discord-webhooks
使用Discord的webhook API构建和发送webhooks的简单包装器
0.1.0-beta
2018-04-09 22:42 UTC
Requires
- php: ~7.0
This package is not auto-updated.
Last update: 2024-09-25 01:13:20 UTC
README
使用Discord的webhook API构建和发送webhooks的简单包装器
允许简单的小型使用(单个Webhook对象到单个钩子(url))以及为多个渠道或多个Webhook对象的大规模派发器。
考虑到简单的最终用户面向对象方法(例如方法链)构建。
@todo README & 文档
// dispatcher manages building and sending webhooks $dispatch = \Forien\WebhookDispatcher::getInstance(); // to create new Webhook object you can use either: $webhook = $dispatch->createWebhook(); // or: $webhook = new \Forien\DiscordHelpers\Webhook(); $webhook->setContent('some basic text'); $embed = $webhook->addEmbed(); $embed->addAuthor(['name' => 'Forien', 'icon_url' => '/*...*/']); $embed->addField()->setName('name')->setValue('value'); $embed->addField()->setName('name2')->setValue('value2'); $embed->setColor('#cba'); // you can either add Hooks (Discord webhook urls) through either: $dispatch->addHook('https://...'); $dispatch->setHooks(['https://...', ...]) // you can send attach Webhook object to Dispatcher if you created it independly: $dispatch->addWebhook($webhook); // you can send all attached Webhook objects at once (every will be sent to every Hook): $dispatch->send() // you can also specify single webhook-hook: $dispatch->send($webhook, $hook);