feat: add removeGuildBan
This commit is contained in:
parent
43a19fc11f
commit
5512d0045e
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user