PHP code example of tempcord / discord-php

1. Go to this page and download the library: Download tempcord/discord-php 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 / discord-php example snippets


use Tempcord\Discord\Bitwise\Bitwise;
use Tempcord\Discord\Constants\Events;
use Tempcord\Discord\Discord;
use Tempcord\Discord\Enums\Intent;
use Tempcord\Discord\Gateway\Events\MessageCreate;
use Tempcord\Discord\Rest\Helpers\Channel\MessageBuilder;

TE, function (MessageCreate $message) use ($discord) {
    if ($message->content === '!ping') {
        $discord->rest->channel->createMessage(
            $message->channel_id,
            (new MessageBuilder())
                ->setContent('pong!')
        );
    }
});

$discord->gateway->open(); // Nothing after this line is executed

use Tempcord\Discord\Discord;
use Tempcord\Discord\Rest\Helpers\Channel\MessageBuilder;

Message(
    'channel-id',
    (new MessageBuilder())
        ->setContent('Hi there!')
);

composer