Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions src/Types/Ban.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Ban
/**
* Time and Date when the ban expires.
*
* @var Carbon
* @var Carbon|null
*/
public $expires;

Expand Down Expand Up @@ -55,9 +55,23 @@ class Ban
*/
public function __construct($ban)
{
$this->expires = new Carbon($ban['expiration'], 'UTC');
// Expiration
if ($ban['expiration'] === null) {
$this->expires = null;
} else {
$this->expires = new Carbon($ban['expiration'], 'UTC');
}

// Time Added
$this->created = new Carbon($ban['timeAdded'], 'UTC');
$this->active = $ban['active'];

// Active
$this->active = $ban['active'];
if (!is_null($this->expires) && $this->active) {
if (!$this->expires->greaterThan(Carbon::now('UTC'))) {
$this->active = false;
}
}

$this->reason = $ban['reason'];
$this->adminName = $ban['adminName'];
Expand Down