feat: add getGuildBan
This commit is contained in:
parent
b23b32dc4c
commit
43a19fc11f
@ -134,5 +134,24 @@ class Discord
|
|||||||
throw new AccountNotLinkedException('Specified website user has not linked their Discord account yet.');
|
throw new AccountNotLinkedException('Specified website user has not linked their Discord account yet.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets (possible) ban for current user.
|
||||||
|
*
|
||||||
|
* @return object|bool Ban object if user is banned. Null
|
||||||
|
* @throws RequestException
|
||||||
|
*/
|
||||||
|
public function getGuildBan(): object|bool
|
||||||
|
{
|
||||||
|
$ban = Http::withHeaders([
|
||||||
|
'Authorization' => 'Bot ' . config('services.discord.token')
|
||||||
|
])->get(config('services.discord.base_url') . "/guilds/{$this->workingGuild}/bans/{$this->user->discord_user_id}");
|
||||||
|
|
||||||
|
if ($ban->status() == 404) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ($ban->successful()) ? (object) $ban->json() : $ban->throwIf($ban->status() !== 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user