PHP code example of 0xwaleed / discorole
1. Go to this page and download the library: Download 0xwaleed/discorole 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/ */
0xwaleed / discorole example snippets
use DiscoRole\PermissionConstants;
$d = new \DiscoRole\DiscoRole(token: 'your bot token');
$guild = $d->getGuild('guild id here');
$member = $guild->getMember('member id here');
//if we want to check for specific role
if ($member->has('role id')) {
//do your logic
}
//if we want to traverse all member's roles and check if one of them
//has the these permissions
if ($member->has(PermissionContatns::MANAGE_MESSAGES | PermissionContatns::MANAGE_GUILD)) {
//do your logic
}
foreach ($member->roles as $role) {
$role->id;
$role->name;
$role->color;
...
}