feat: add removeGuildBan

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

View File

@ -134,6 +134,25 @@ 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.');
} }
/**
* @param string $reason The removal reason to provide Discord with (e.g. ban expired)
* @return null|bool Null on unnan, false if user is not banned
* @throws RequestException
*/
public function removeGuildBan(string $reason): null|bool {
if ($this->getGuildBan($this->user)) {
Http::withHeaders([
'Authorization' => 'Bot ' . config('services.discord.token'),
'X-Audit-Log-Reason' => $reason
])->delete(config('services.discord.base_url') . "/guilds/{$this->workingGuild}/bans/{$this->user->discord_user_id}")
->throw();
return null;
}
return false;
}
/** /**
* Gets (possible) ban for current user. * Gets (possible) ban for current user.
* *
@ -153,5 +172,4 @@ class Discord
return ($ban->successful()) ? (object) $ban->json() : $ban->throwIf($ban->status() !== 404); return ($ban->successful()) ? (object) $ban->json() : $ban->throwIf($ban->status() !== 404);
} }
} }