Tempcord is a modern, elegant PHP framework designed specifically for building Discord bots with ease. Built on top of the powerful Tempest Console framework and Ragnarok Fenrir Discord library, Tempcord provides a clean, attribute-based approach to creating sophisticated Discord bots with minimal boilerplate code.
The framework leverages PHP 8.3+ features and modern development practices to deliver a robust foundation for Discord bot development, featuring automatic command registration, event handling, and seamless integration with Discord's API.
Getting Started: Use the
tempcord/tempcordboilerplate to quickly create new Discord bot applications. This repository contains the core framework - for building applications, usecomposer create-project tempcord/tempcord your-bot-name.
- π Modern PHP 8.3+ - Leverages the latest PHP features and syntax
- π― Attribute-Based Commands - Define Discord commands using PHP attributes
- π‘ Event-Driven Architecture - Handle Discord events with clean, organized handlers
- π§ Auto-Discovery - Automatic command and event registration
- ποΈ Dependency Injection - Built-in container for clean architecture
- π Console Integration - Rich console output and logging capabilities
- π Extensible - Easy to extend with custom functionality
- π‘οΈ Type Safety - Full type hints and strict typing throughout
- π Logging Support - Comprehensive logging with multiple channels
- β‘ Performance Optimized - Efficient command and event handling
- PHP 8.3 or higher
- Composer
- A Discord Bot Token (from Discord Developer Portal)
Use the Tempcord application boilerplate to create a new Discord bot project:
composer create-project tempcord/tempcord my-discord-bot
cd my-discord-botCopy the example environment file and configure your bot:
cp .env.example .envEdit the .env file with your Discord bot credentials:
DISCORD_TOKEN=your_bot_token_herecomposer installThe boilerplate includes example commands. Create a new command in any folder, for example inside app/Commands/:
<?php
namespace App\Commands;
use Tempcord\Attributes\Command;
use Ragnarok\Fenrir\Gateway\Events\InteractionCreate;
#[Command(name: 'hello', description: 'Say hello!')]
class HelloCommand
{
public function __invoke(InteractionCreate $interaction): void
{
$interaction->respondWithMessage([
'content' => 'Hello, World! π'
]);
}
}Use the built-in console commands to manage your bot:
# Boot the bot
php tempcord boot
# Boot and register commands with Discord
php tempcord boot --register
# Register commands only (without starting the bot)
php tempcord registerCommands are defined using the #[Command] attribute:
#[Command(
name: 'ping',
description: 'Check bot latency'
)]
class PingCommand
{
public function __invoke(InteractionCreate $interaction): void
{
$interaction->respondWithMessage([
'content' => 'Pong! π'
]);
}
}Create event handlers using the #[Event] attribute:
use Tempcord\Attributes\Event;
use Ragnarok\Fenrir\Gateway\Events\MessageCreate;
#[Event(name: 'message_create')]
class MessageHandler
{
public function __invoke(MessageCreate $message): void
{
// Handle message events
if ($message->content === '!hello') {
// Respond to the message
}
}
}#[Command(name: 'user', description: 'User management commands')]
class UserCommand
{
#[Subcommand(name: 'info', description: 'Get user information')]
public function info(
#[Option(name: 'user', description: 'Target user', required: true)]
User $user
): void {
// Handle user info command
}
}We welcome contributions! Please see CONTRIBUTING.md for details on how to contribute to Tempcord.
- Fork the repository
- Clone your fork:
git clone https://github.com/your-username/framework.git - Install dependencies:
composer install - Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and add tests
- Run the test suite:
composer test - Commit your changes:
git commit -m 'Add amazing feature' - Push to your branch:
git push origin feature/amazing-feature - Open a Pull Request
When reporting issues, please include:
- PHP version
- Framework version
- Steps to reproduce
- Expected vs actual behavior
- Error messages or logs
We're always looking for ways to improve Tempcord. Feel free to:
- Open an issue with the
enhancementlabel - Discuss your ideas in our community channels
- Submit a pull request with your implementation
This project is licensed under the MIT License - see the LICENSE file for details.
Built with β€οΈ by CyberWolf.Studio team. using Tempest
For more information, visit our documentation or join our Discord community.