Skip to content

Channels

Class  ·  Sharkord\Collections\Channels

Class Channels

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

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

// Look up by ID or name
$channel = $sharkord->channels->collection()->get(1);
$channel = $sharkord->channels->collection()->get('general');
// Iterate all cached channels
foreach ($sharkord->channels->collection() as $id => $channel) {
echo "{$channel->name}\n";
}
echo count($sharkord->channels->collection());

Channels constructor.

Parameters

ParameterTypeDescription
$sharkordSharkordReference to the main bot instance.

Retrieves a channel by ID or name.

Parameters

ParameterTypeDescription
$identifier`intstring`

Returns \Channel|null


Parameters

ParameterTypeDescription
$offsetmixed

Returns bool


Parameters

ParameterTypeDescription
$offsetmixed

Returns ?Channel


Parameters

ParameterTypeDescription
$offsetmixed
$valuemixed

Throws

  • \LogicException

Parameters

ParameterTypeDescription
$offsetmixed

Throws

  • \LogicException

Returns int


Returns \ArrayIterator<string,\Channel>