What is Laracord?
Laracord is a micro-framework that provides a beautiful starting point for your next Discord bot.
Build functional, elegant bots harnessing the full power of Laravel alongside DiscordPHP.
Features
- Out of the box support for databases, caching, and many other Laravel features thanks to Laravel Zero.
- Instantly generate working bot commands and event listeners with 0 knowledge.
- Automatic handling of registering/updating/unregistering application slash commands.
- Generate asynchronous services/tasks that run parallel to the bot.
- Optional HTTP Server with native Laravel routing and Livewire support.
- Fully configurable and extendable.
- Beautiful console logging with timestamps.
- Fully documented and maintained.
Requirements
Laracord utilizes Composer for managing dependencies. Before using Laracord, please ensure you have Composer installed on your machine.
The following PHP extensions are also required:
- fileinfo
- sqlite3
- pdo_sqlite
- sodium (to build for production)
Creating a Project
Before creating your first Laracord project, make sure that your local machine has PHP and Composer installed.
After you have installed PHP and Composer, you may create a new Laracord project via Composer's create-project
command:
$ composer create-project laracord/laracord
$ cd laracord
Initial Configuration
In order to run the Bot, you will have to create an Application using the Discord Developer Portal and obtain a bot token.
By default, the Bot will also require you enable the necessary Intents.
These can be found and enabled in the developer portal under Settings > Bot > Privileged Gateway Intents
.
Once you obtain a bot token, you can configure it inside of .env
:
DISCORD_TOKEN=...
Booting Laracord
To boot your bot, simply run laracord
with no arguments passed:
$ php laracord
When booting Laracord using a bot token that is currently not in any servers, Laracord will automatically output an invite link in console for convenience.
Adding a Bot Admin
For convenience, Laracord comes with a console command to set a specified user as admin using their Discord ID:
$ php laracord bot:admin <id>
Tinker (REPL)
Laracord comes with full support for Tinker out of the box.
$ php laracord tinker
Additional Commands
To view all built-in console commands, you can run the list
command:
$ php laracord list