revolution / discord-manager
Discord 管理器
5.1.1
2024-03-19 06:39 UTC
Requires
- php: ^8.1
- discord/interactions: ^2.2
- guzzlehttp/guzzle: ^7.5
- illuminate/http: ^10.0||^11.0
- illuminate/support: ^10.0||^11.0
- simplito/elliptic-php: ^1.0
Requires (Dev)
- mockery/mockery: ^1.3
- orchestra/testbench: ^8.0||^9.0
- phpunit/phpunit: ^10.0
- dev-master
- 5.1.1
- 5.1.0
- 5.0.1
- 5.0.0
- 4.x-dev
- 4.3.0
- 4.2.0
- 4.1.4
- 4.1.3
- 4.1.2
- 4.1.1
- 4.1.0
- 4.0.0
- 3.x-dev
- 3.0.0
- 2.x-dev
- 2.2.1
- 2.2.0
- 2.1.0
- 2.0.1
- 2.0.0
- 1.x-dev
- 1.6.0
- 1.5.1
- 1.5.0
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.1
- 1.3.0
- 1.2.1
- 1.2.0
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
This package is auto-updated.
Last update: 2024-08-29 05:24:22 UTC
README
注意 从 v5 版本开始,只提供 Interactions 命令。Interactions 命令是基于 webhooks 的,在 Laravel 中使用起来非常方便。 v4 仍然支持 Gateway API。
要求
- PHP >= 8.1
- Laravel >= 10.0
安装
composer require revolution/discord-manager
.env
DISCORD_BOT_TOKEN=
# APPLICATION ID
DISCORD_BOT=
# PUBLIC KEY
DISCORD_PUBLIC_KEY=
# GUILD ID
DISCORD_GUILD=
卸载
composer remove revolution/discord-manager
- 删除
config/discord_interactions.php
- 删除
app/Discord/
和其他文件。 - 删除
.env
中的DISCORD_*
交互
发布配置文件
php artisan vendor:publish --tag=discord-interactions-config
编辑 config/discord_interactions.php
在 Discord 的开发者门户中设置 INTERACTIONS ENDPOINT URL
https://example/discord/webhook
创建响应命令
php artisan discord:make:interaction HelloCommand
将命令注册到 Discord 服务器
php artisan discord:interactions:register
创建事件监听器
php artisan make:listener InteractionsListener
use Revolution\DiscordManager\Events\InteractionsWebhook; use Revolution\DiscordManager\Facades\DiscordManager; // /** * Handle the event. * * @param InteractionsWebhook $event * @return void */ public function handle(InteractionsWebhook $event) { DiscordManager::interaction($event->request); }
(仅 Laravel10) 更新 EventServiceProvider.php
use App\Listeners\InteractionsListener; use Revolution\DiscordManager\Events\InteractionsWebhook; // protected $listen = [ Registered::class => [ SendEmailVerificationNotification::class, ], InteractionsWebhook::class => [ InteractionsListener::class, ], ];
工作流程
- 来自 Discord 的 POST 请求到达 https://example/discord/webhook
- 验证签名
- InteractionsWebhookController
- DeferredResponse
- DispatchInteractionsEvent 终止中间件
- InteractionsWebhook 事件分发
- 在您的项目中创建 InteractionsListener。
- DiscordManager 调用
app/Discord/
中的某个命令。
授权协议
MIT