Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/commandstring/discordphp-bot-template

An unofficial way to structure a discordPHP bot.
https://github.com/commandstring/discordphp-bot-template

discord discord-bot discordphp php template

Last synced: 1 day ago
JSON representation

An unofficial way to structure a discordPHP bot.

Awesome Lists containing this project

README

        

# DiscordPHP Bot Template

An unofficial way to structure a discordPHP bot.

# Table of Contents

* [Installation](#installation)
* [Important Resources](#important-resources)
* [Configuration](#configuration)
* [Slash Commands](#slash-commands)
* [Events](#events)
* [Disabling Commands and Events](#disabling-commands-and-events)
* [Extending The Template](#extending-the-template)
* [Bootstrap Sequence](#bootstrap-sequence)
* [Environment Variables](#environment-variables)

# Installation

```
composer create-project commandstring/dphp-bot
```

# Important Resources #

[DiscordPHP Class Reference](https://discord-php.github.io/DiscordPHP/guide/)

[DiscordPHP Documentation](https://discord-php.github.io/DiscordPHP/)

[DiscordPHP Discord Server](https://discord.gg/kM7wrJUYU9)
*Only ask questions relevant to DiscordPHP's own wrapper, not on how to use this.*

[Developer Hub](https://discord.gg/TgrcSkuDtQ) *Issues about this template can be asked here*

# Configuration

Copy the `.env.example` file to `.env` and add your bot token.

# Slash Commands

Create a class that implements `Core\Commands\CommandHandler` and attach the `Core\Commands\Command` attribute to it.

```php
respondWithMessage(messageWithContent('Ping :ping_pong:'), true);
}

public function autocomplete(Interaction $interaction): void
{
}

public function getConfig(): CommandBuilder
{
return (new CommandBuilder())
->setName('ping')
->setDescription('Ping the bot');
}
}
```

Once you start the bot, it will automatically register the command with Discord.
And if you make any changes to the config, it will update the command on the fly.

# Events

Create a class that implements any of the interfaces found inside of `Core\Events`.
Implement the interface that matches your desired event.

```php