feat: add getGuildRoles

This commit is contained in:
Miguel Nogueira 2022-08-23 04:51:21 +01:00
parent 5512d0045e
commit 3c36b299db
No known key found for this signature in database
GPG Key ID: 3C6A7E29AF26D370

View File

@ -158,6 +158,7 @@ class Discord
*
* @return object|bool Ban object if user is banned. Null
* @throws RequestException
* @see https://discord.com/developers/docs/resources/guild#ban-object
*/
public function getGuildBan(): object|bool
{
@ -172,4 +173,20 @@ class Discord
return ($ban->successful()) ? (object) $ban->json() : $ban->throwIf($ban->status() !== 404);
}
/**
* Retrieves list of Role objects
* @see https://discord.com/developers/docs/topics/permissions#role-object
* @return array List of role objects
*
* @throws RequestException
*/
public function getGuildRoles(): array {
return Http::withHeaders([
'Authorization' => 'Bot ' . config('services.discord.token')
])->get(config('services.discord.base_url') . "/guilds/{$this->workingGuild}/roles")
->throw()
->json();
}
}