tempcord/framework

A modern, elegant PHP framework for building Discord bots with ease

dev-master 2025-09-12 18:02 UTC

This package is auto-updated.

Last update: 2025-09-12 18:02:32 UTC


README

Version License PHP Version Build Status

Description

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/tempcord boilerplate to quickly create new Discord bot applications. This repository contains the core framework - for building applications, use composer create-project tempcord/tempcord your-bot-name.

Features

  • 🚀 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

Installation

Prerequisites

Step 1: Create New Application

Use the Tempcord application boilerplate to create a new Discord bot project:

composer create-project tempcord/tempcord my-discord-bot
cd my-discord-bot

Step 2: Configure Your Bot

Copy the example environment file and configure your bot:

cp .env.example .env

Edit the .env file with your Discord bot credentials:

DISCORD_TOKEN=your_bot_token_here

Step 3: Install Dependencies

composer install

Step 4: Create Your First Command

The 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! 👋'
        ]);
    }
}

Usage

Running Your Bot

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 register

Creating Commands

Commands 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! 🏓'
        ]);
    }
}

Handling Events

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 Options and Subcommands

#[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
    }
}

Contributing

We welcome contributions! Please see CONTRIBUTING.md for details on how to contribute to Tempcord.

Development Setup

  1. Fork the repository
  2. Clone your fork: git clone https://github.com/your-username/framework.git
  3. Install dependencies: composer install
  4. Create a feature branch: git checkout -b feature/amazing-feature
  5. Make your changes and add tests
  6. Run the test suite: composer test
  7. Commit your changes: git commit -m 'Add amazing feature'
  8. Push to your branch: git push origin feature/amazing-feature
  9. Open a Pull Request

Reporting Issues

When reporting issues, please include:

  • PHP version
  • Framework version
  • Steps to reproduce
  • Expected vs actual behavior
  • Error messages or logs

Feature Requests

We're always looking for ways to improve Tempcord. Feel free to:

  • Open an issue with the enhancement label
  • Discuss your ideas in our community channels
  • Submit a pull request with your implementation

License

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.