Skip to content

Users

Class  ·  Sharkord\Collections\Users

Class Users

An array-accessible, iterable cache of User objects keyed by user ID (string).

Supports lookup by both integer ID and display name via get().

// Look up by ID or name
$user = $sharkord->users->collection()->get(42);
$user = $sharkord->users->collection()->get('Buzz');
// Iterate all cached users
foreach ($sharkord->users->collection() as $id => $user) {
echo "{$user->name}\n";
}
echo count($sharkord->users->collection());

Users constructor.

Parameters

ParameterTypeDescription
$sharkordSharkordReference to the main bot instance.

Retrieves a user by ID or display name.

Parameters

ParameterTypeDescription
$identifier`intstring`

Returns \User|null


Parameters

ParameterTypeDescription
$offsetmixed

Returns bool


Parameters

ParameterTypeDescription
$offsetmixed

Returns ?User


Parameters

ParameterTypeDescription
$offsetmixed
$valuemixed

Throws

  • \LogicException

Parameters

ParameterTypeDescription
$offsetmixed

Throws

  • \LogicException

Returns int


Returns \ArrayIterator<string,\User>