PHP code example of fabrizio / laravel-restcord

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

    

fabrizio / laravel-restcord example snippets


'providers' => [
    ...
    LaravelRestcord\ServiceProvider::class,
]

$discord->guilds() // Guild[]

$guild->userCan(Permission::KICK_MEMBERS); // bool - uses permissions of the currently oauth'd user

$member = $guild->getMemberById($discordUserId); // \LaravelRestcord\Discord\Member
$member->roles(); // \LaravelRestcord\Discord\Role[]
$member->joinedAt(); // Carbon

use LaravelRestcord\Discord\HandlesBotAddedToGuild;
use Illuminate\Http\RedirectResponse;

class BotAddedToDiscordGuild
{
    use HandlesBotAddedToGuild;
    
    public function botAdded(Guild $guild) : RedirectResponse
    {
        // do something with the guild information the bot was added to
        
        return redirect('/to/this/page');
    }
}

    public function show(Guild $guild)
    {
        // Reference https://discordapi.com/permissions.html to determine
        // the permissions your bot needs
    
        $guild->sendUserToDiscordToAddBot($permissions);
    }

use LaravelRestcord\Discord\HandlesDiscordWebhooksBeingCreated;
use Illuminate\Http\RedirectResponse;

class Subscribe
{
    use HandlesDiscordWebhooksBeingCreated;
    
    public function webhookCreated(Webhook $webhook) : RedirectResponse
    {
        // $webhook->token();
        // Here you should save the token for use later when activating the webhook
        
        return redirect('/to/this/page');
    }
}

    public function show(Guild $guild)
    {
        // redirects the user to Discord's interface for selecting
        // a guild and channel for the webhook
        $guild->sendUserToDiscordToCreateWebhook();
    }