LaravelPackages.net
Acme Inc.
Toggle sidebar
revolution/discord-manager

Discord Manager

17.036
3
5.3.0
About revolution/discord-manager

revolution/discord-manager is a Laravel package for discord manager. It currently has 3 GitHub stars and 17.036 downloads on Packagist (latest version 5.3.0). Install it with composer require revolution/discord-manager. Discover more Laravel packages by revolution or browse all Laravel packages to compare alternatives.

Last updated

Discord Manager

Note Since v5, only Interactions command is provided. Interactions command is webhook-based, it is easy to use in Laravel. v4 still support Gateway API.

Requirements

  • PHP >= 8.2
  • Laravel >= 11.0

Installation

composer require revolution/discord-manager

.env

DISCORD_BOT_TOKEN=

# APPLICATION ID
DISCORD_BOT=

# PUBLIC KEY
DISCORD_PUBLIC_KEY=

# GUILD ID
DISCORD_GUILD=

Uninstall

composer remove revolution/discord-manager
  • Delete config/discord_interactions.php
  • Delete app/Discord/ and other files.
  • Delete DISCORD_* in .env

Interactions

Publish config file

php artisan vendor:publish --tag=discord-interactions-config

Edit config/discord_interactions.php

Set INTERACTIONS ENDPOINT URL in Discord's developer portal.

https://example/discord/webhook

Create a command to respond

php artisan discord:make:interaction HelloCommand

Register commands to Discord server

You need to define and register the commands you actually use in config/discord_interactions.php.

php artisan discord:interactions:register

Create Event listener

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);
    }

Workflow

  1. POST request comes in from Discord to https://example/discord/webhook
  2. ValidateSignature
  3. InteractionsWebhookController
  4. DeferredResponse
  5. DispatchInteractionsEvent Terminable Middleware
  6. InteractionsWebhook Event dispatch
  7. InteractionsListener in your project.
  8. DiscordManager invokes one of the commands in app/Discord/.

Sample

https://github.com/kawax/discord-interactions

LICENSE

MIT

Star History Chart