1. Go to this page and download the library: Download tempcord/framework library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tempcord / framework example snippets
namespace App\Commands;
use Tempcord\Attributes\Command;
use CyberWolf\Discord\Gateway\Events\InteractionCreate;
#[Command(name: 'hello', description: 'Say hello!')]
class HelloCommand
{
public function __invoke(InteractionCreate $interaction): void
{
$interaction->respondWithMessage([
'content' => 'Hello, World! 👋'
]);
}
}
#[Command(
name: 'ping',
description: 'Check bot latency'
)]
class PingCommand
{
public function __invoke(InteractionCreate $interaction): void
{
$interaction->respondWithMessage([
'content' => 'Pong! 🏓'
]);
}
}
use Tempcord\Attributes\Event;
use CyberWolf\Discord\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(description: 'Target user')]
User $user
): void {
// Handle user info command
}
}
bash
# 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
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.