Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/commandstring/discordphp-bot-template
- Owner: CommandString
- License: mit
- Created: 2022-10-13T11:36:55.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-22T11:30:28.000Z (10 months ago)
- Last Synced: 2024-05-17T13:21:36.534Z (6 months ago)
- Topics: discord, discord-bot, discordphp, php, template
- Language: PHP
- Homepage:
- Size: 180 KB
- Stars: 13
- Watchers: 2
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
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