PHP code example of cyberwolf-studio / discord-php

1. Go to this page and download the library: Download cyberwolf-studio/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/ */

    

cyberwolf-studio / discord-php example snippets


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

nction (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 CyberWolf\Discord\Discord;
use CyberWolf\Discord\Rest\Helpers\Channel\MessageBuilder;

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

composer