PHPackages                             revolution/discord-manager - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. revolution/discord-manager

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

revolution/discord-manager
==========================

Discord Manager

5.3.0(2mo ago)317.0k1MITPHPPHP ^8.3CI passing

Since Dec 21Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/invokable/discord-manager)[ Packagist](https://packagist.org/packages/revolution/discord-manager)[ GitHub Sponsors](https://github.com/invokable)[ RSS](/packages/revolution-discord-manager/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (6)Dependencies (6)Versions (53)Used By (1)

Laravel Discord Manager
=======================

[](#laravel-discord-manager)

[![Ask DeepWiki](https://camo.githubusercontent.com/0f5ae213ac378635adeb5d7f13cef055ad2f7d9a47b36de7b1c67dbe09f609ca/68747470733a2f2f6465657077696b692e636f6d2f62616467652e737667)](https://deepwiki.com/invokable/discord-manager)

> **Note** As of v5, only the Interactions command is provided, which is webhook based and therefore easy to use with Laravel. All features using WebSockets have been removed.

Overview
--------

[](#overview)

Discord Manager is a Laravel package that provides seamless integration with Discord's Interactions API using webhook-based architecture. This package allows you to create and manage Discord slash commands, handle user interactions, and respond to Discord events directly from your Laravel application.

### Key Features

[](#key-features)

- **Webhook-based Architecture**: Secure and efficient handling of Discord interactions through webhooks
- **Slash Commands Support**: Create and register both guild-specific and global Discord slash commands
- **Laravel Integration**: Native Laravel service provider with configuration publishing and Artisan commands
- **Automatic Command Discovery**: Automatically loads and registers interaction commands from your application
- **Flexible Response System**: Support for immediate responses, deferred responses, and followup messages
- **Component Support**: Built-in support for Discord UI components like buttons, select menus, and modals
- **Event-driven**: Integrates with Laravel's event system for handling Discord interactions

### How It Works

[](#how-it-works)

The package operates by receiving webhook requests from Discord when users interact with your bot's commands. These requests are validated, processed through middleware, and dispatched to your custom command handlers. The workflow ensures secure communication with Discord while providing a familiar Laravel development experience.

### See also

[](#see-also)

- [Socialite for Discord](https://github.com/invokable/socialite-discord)
- [Laravel Notification for Discord(Webhook)](https://github.com/invokable/laravel-notification-discord-webhook)

Requirements
------------

[](#requirements)

- PHP &gt;= 8.3
- Laravel &gt;= 12.0

Installation
------------

[](#installation)

### Step 1: Install the Package

[](#step-1-install-the-package)

```
composer require revolution/discord-manager
```

### Step 2: Discord Application Setup

[](#step-2-discord-application-setup)

Before configuring the package, you need to create a Discord application and bot:

1. Go to the [Discord Developer Portal](https://discord.com/developers/applications)
2. Click "New Application" and give it a name
3. Navigate to the "Bot" section and click "Add Bot"
4. Copy the bot token for `DISCORD_BOT_TOKEN`
5. Go to "General Information" and copy the Application ID for `DISCORD_BOT`
6. Copy the Public Key for `DISCORD_PUBLIC_KEY`
7. For guild-specific commands, copy your Discord server's Guild ID for `DISCORD_GUILD`

### Step 3: Environment Configuration

[](#step-3-environment-configuration)

Add the following variables to your `.env` file:

```
# Bot token from Discord Developer Portal > Bot section
DISCORD_BOT_TOKEN=your_bot_token_here

# Application ID from Discord Developer Portal > General Information
DISCORD_BOT=your_application_id_here

# Public Key from Discord Developer Portal > General Information
DISCORD_PUBLIC_KEY=your_public_key_here

# Guild ID (Server ID) for guild-specific commands (optional)
DISCORD_GUILD=your_guild_id_here

# Optional: Discord API version (defaults to 10)
DISCORD_API_VERSION=10
```

### Step 4: Publish Configuration

[](#step-4-publish-configuration)

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

This creates `config/discord_interactions.php` where you can define your commands and customize settings.

### Uninstall

[](#uninstall)

```
composer remove revolution/discord-manager
```

- Delete `config/discord_interactions.php`
- Delete `app/Discord/` and other files.
- Delete `DISCORD_*` in `.env`

Configuration
-------------

[](#configuration)

### Command Configuration

[](#command-configuration)

Edit `config/discord_interactions.php` to define your Discord commands:

```
return [
    // Guild-specific commands (only available in specified servers)
    'guild' => [
        [
            'name' => 'hello',
            'description' => 'Say hello to a user',
            'type' => CommandType::CHAT_INPUT,
            'guild_id' => env('DISCORD_GUILD'),
            'options' => [
                [
                    'name' => 'user',
                    'description' => 'User to greet',
                    'type' => CommandOptionType::USER,
                    'required' => true,
                ],
            ],
        ],
    ],

    // Global commands (available in all servers)
    'global' => [
        [
            'name' => 'ping',
            'description' => 'Check if the bot is responding',
            'type' => CommandType::CHAT_INPUT,
        ],
    ],

    // Other configuration options
    'commands' => app_path('Discord/Interactions'), // Path to command classes
    'token' => env('DISCORD_BOT_TOKEN'),
    'bot' => env('DISCORD_BOT'),
    'public_key' => env('DISCORD_PUBLIC_KEY'),
    'path' => 'discord/webhook', // Webhook endpoint path
    'route' => 'discord.webhook', // Route name
    'middleware' => 'throttle', // Additional middleware
];
```

### Discord Developer Portal Setup

[](#discord-developer-portal-setup)

Set the **Interactions Endpoint URL** in your Discord application:

1. Go to [Discord Developer Portal](https://discord.com/developers/applications)
2. Select your application
3. Navigate to "General Information"
4. Set the Interactions Endpoint URL to: `https://yourdomain.com/discord/webhook`

Usage
-----

[](#usage)

### Quick Start

[](#quick-start)

Here's a complete example to get you started:

#### 1. Create a Command

[](#1-create-a-command)

```
php artisan discord:make:interaction HelloCommand
```

This creates `app/Discord/Interactions/HelloCommand.php`:

```
