DiscordPHP Documentation

MessageRepository extends AbstractRepository
in package

Contains messages sent to a channel.

Tags
see
Message
see
Channel
since
4.0.0

Table of Contents

$cache  : CacheWrapper
$discrim  : string
The collection discriminator.
$cache  : CacheWrapper
$class  : mixed
{@inheritDoc}
$discrim  : string
The collection discriminator.
$endpoints  : array<string|int, mixed>
Endpoints for interacting with the Discord servers.
$factory  : Factory
The parts factory.
$http  : Http
The HTTP client.
$items  : array<string|int, mixed>
The items contained in the collection.
$vars  : array<string|int, mixed>
Variables that are related to the repository.
__construct()  : mixed
AbstractRepository constructor.
__debugInfo()  : array<string|int, mixed>
Returns an item that will be displayed for debugging.
__get()  : mixed
__serialize()  : array<string|int, mixed>
Returns the string representation of the collection.
__unserialize()  : void
Unserializes the collection.
clear()  : void
Clears the collection.
count()  : int
Counts the amount of objects in the collection.
create()  : Part
Builds a new, empty part.
delete()  : ExtendedPromiseInterface<string|int, Part>
Attempts to delete a part on the Discord servers.
fetch()  : ExtendedPromiseInterface<string|int, Part>
Gets a part from the repository or Discord servers.
fill()  : Collection
Fills an array of items into the collection.
filter()  : Collection
Runs a filter callback over the collection and returns a new collection based on the response of the callback.
find()  : mixed
Runs a filter callback over the collection and returns the first item where the callback returns `true` when given the item.
find()  : Part|null
Runs a filter callback over the repository and returns the first part where the callback returns `true` when given the part.
first()  : mixed
Returns the first element of the collection.
first()  : Part|null
Returns the first cached part.
for()  : static
Creates a collection for a class.
fresh()  : ExtendedPromiseInterface<string|int, Part>
Returns a part with fresh values.
freshen()  : ExtendedPromiseInterface<string|int, static>
Freshens the repository cache.
from()  : static
Creates a collection from an array.
get()  : mixed
Gets an item from the collection.
get()  : Part|null
Gets a part from the repository.
getIterator()  : Traversable
Returns an iterator for the collection.
has()  : bool
Checks if the array has multiple offsets.
isset()  : bool
If the collection has an offset.
jsonSerialize()  : array<string|int, mixed>
Serializes the object to a value that can be serialized natively by json_encode().
keys()  : array<string|int, int>|array<string|int, string>
Get the keys of the items.
last()  : mixed
Returns the last element of the collection.
last()  : Part|null
Returns the last cached part.
map()  : Collection
Runs a callback over the collection and creates a new collection.
merge()  : Collection
Merges another collection into this collection.
offsetExists()  : bool
If the collection has an offset.
offsetGet()  : mixed
Gets an item from the collection.
offsetSet()  : void
Sets an item into the collection.
offsetUnset()  : void
Unsets an index from the collection.
pull()  : mixed
Pulls an item from the collection.
pull()  : Part|mixed
Pulls a part from the repository.
push()  : Collection
Pushes items to the collection.
pushItem()  : Collection
Pushes a single item to the collection.
save()  : ExtendedPromiseInterface<string|int, Part>
Attempts to save a part to the Discord servers.
serialize()  : string
Returns the string representation of the collection.
set()  : mixed
Sets a value in the collection.
toArray()  : array<string|int, mixed>
Converts the collection to an array.
unserialize()  : void
Unserializes the collection.
cacheFreshen()  : ExtendedPromiseInterface<string|int, static>

Properties

$discrim read-only

The collection discriminator.

public string $discrim

The discriminator.

$class

{@inheritDoc}

protected mixed $class = \Discord\Parts\Channel\Message::class

$discrim

The collection discriminator.

protected string $discrim

$endpoints

Endpoints for interacting with the Discord servers.

protected array<string|int, mixed> $endpoints = ['get' => \Discord\Http\Endpoint::CHANNEL_MESSAGE, 'update' => \Discord\Http\Endpoint::CHANNEL_MESSAGE, 'delete' => \Discord\Http\Endpoint::CHANNEL_MESSAGE]

Endpoints.

$items

The items contained in the collection.

protected array<string|int, mixed> $items

$vars

Variables that are related to the repository.

protected array<string|int, mixed> $vars = []

Variables.

Methods

__construct()

AbstractRepository constructor.

public __construct(Discord $discord[, array<string|int, mixed> $vars = [] ]) : mixed
Parameters
$discord : Discord
$vars : array<string|int, mixed> = []

An array of variables used for the endpoint.

Return values
mixed

__debugInfo()

Returns an item that will be displayed for debugging.

public __debugInfo() : array<string|int, mixed>
Return values
array<string|int, mixed>

__get()

public __get(string $key) : mixed
Parameters
$key : string
Return values
mixed

__serialize()

Returns the string representation of the collection.

public __serialize() : array<string|int, mixed>
Return values
array<string|int, mixed>

__unserialize()

Unserializes the collection.

public __unserialize(array<string|int, mixed> $data) : void
Parameters
$data : array<string|int, mixed>
Return values
void

clear()

Clears the collection.

public clear() : void
Return values
void

count()

Counts the amount of objects in the collection.

public count() : int
Return values
int

create()

Builds a new, empty part.

public create([array<string|int, mixed> $attributes = [] ][, bool $created = false ]) : Part
Parameters
$attributes : array<string|int, mixed> = []

The attributes for the new part.

$created : bool = false
Tags
throws
Exception
Return values
Part

The new part.

delete()

Attempts to delete a part on the Discord servers.

public delete(Part|string $part[, string|null $reason = null ]) : ExtendedPromiseInterface<string|int, Part>
Parameters
$part : Part|string

The part to delete.

$reason : string|null = null

Reason for Audit Log (if supported).

Tags
throws
Exception
Return values
ExtendedPromiseInterface<string|int, Part>

fetch()

Gets a part from the repository or Discord servers.

public fetch(string $id[, bool $fresh = false ]) : ExtendedPromiseInterface<string|int, Part>
Parameters
$id : string

The ID to search for.

$fresh : bool = false

Whether we should skip checking the cache.

Tags
throws
Exception
Return values
ExtendedPromiseInterface<string|int, Part>

fill()

Fills an array of items into the collection.

public fill(array<string|int, mixed> $items) : Collection
Parameters
$items : array<string|int, mixed>
Return values
Collection

filter()

Runs a filter callback over the collection and returns a new collection based on the response of the callback.

public filter(callable $callback) : Collection
Parameters
$callback : callable
Return values
Collection

find()

Runs a filter callback over the collection and returns the first item where the callback returns `true` when given the item.

public find(callable $callback) : mixed
Parameters
$callback : callable
Return values
mixed

null if no items returns true when called in the $callback.

find()

Runs a filter callback over the repository and returns the first part where the callback returns `true` when given the part.

public find() : Part|null
Return values
Part|null

null if no items returns true when called in the callback.

first()

Returns the first element of the collection.

public first() : mixed
Return values
mixed

for()

Creates a collection for a class.

public static for(string $class[, string $discrim = 'id' ]) : static
Parameters
$class : string
$discrim : string = 'id'
Return values
static

fresh()

Returns a part with fresh values.

public fresh(Part $part[, array<string|int, mixed> $queryparams = [] ]) : ExtendedPromiseInterface<string|int, Part>
Parameters
$part : Part

The part to get fresh values.

$queryparams : array<string|int, mixed> = []

Query string params to add to the request (no validation)

Tags
throws
Exception
Return values
ExtendedPromiseInterface<string|int, Part>

freshen()

Freshens the repository cache.

public freshen([array<string|int, mixed> $queryparams = [] ]) : ExtendedPromiseInterface<string|int, static>
Parameters
$queryparams : array<string|int, mixed> = []

Query string params to add to the request (no validation)

Tags
throws
Exception
Return values
ExtendedPromiseInterface<string|int, static>

from()

Creates a collection from an array.

public static from([array<string|int, mixed> $items = [] ][, string $discrim = 'id' ][, string $class = null ]) : static
Parameters
$items : array<string|int, mixed> = []
$discrim : string = 'id'
$class : string = null
Return values
static

get()

Gets an item from the collection.

public get(string $discrim, mixed $key) : mixed
Parameters
$discrim : string
$key : mixed
Return values
mixed

get()

Gets a part from the repository.

public get(string $discrim, mixed $key) : Part|null
Parameters
$discrim : string
$key : mixed
Return values
Part|null

getIterator()

Returns an iterator for the collection.

public getIterator() : Traversable
Return values
Traversable

has()

Checks if the array has multiple offsets.

public has(array<string|int, mixed> ...$keys) : bool
Parameters
$keys : array<string|int, mixed>
Return values
bool

isset()

If the collection has an offset.

public isset(mixed $offset) : bool
Parameters
$offset : mixed
Return values
bool

jsonSerialize()

Serializes the object to a value that can be serialized natively by json_encode().

public jsonSerialize() : array<string|int, mixed>
Return values
array<string|int, mixed>

keys()

Get the keys of the items.

public keys() : array<string|int, int>|array<string|int, string>
Return values
array<string|int, int>|array<string|int, string>

last()

Returns the last element of the collection.

public last() : mixed
Return values
mixed

map()

Runs a callback over the collection and creates a new collection.

public map(callable $callback) : Collection
Parameters
$callback : callable
Return values
Collection

offsetExists()

If the collection has an offset.

public offsetExists(mixed $offset) : bool
Parameters
$offset : mixed
Return values
bool

offsetGet()

Gets an item from the collection.

public offsetGet(mixed $offset) : mixed
Parameters
$offset : mixed
Return values
mixed

offsetSet()

Sets an item into the collection.

public offsetSet(mixed $offset, mixed $value) : void
Parameters
$offset : mixed
$value : mixed
Return values
void

offsetUnset()

Unsets an index from the collection.

public offsetUnset(mixed $offset) : void
Parameters
$offset : mixed
Return values
void

pull()

Pulls an item from the collection.

public pull(mixed $key[, mixed $default = null ]) : mixed
Parameters
$key : mixed
$default : mixed = null
Return values
mixed

pull()

Pulls a part from the repository.

public pull(string|int $key, mixed $default) : Part|mixed
Parameters
$key : string|int
$default : mixed
Return values
Part|mixed

pushItem()

Pushes a single item to the collection.

public pushItem(mixed $item) : Collection
Parameters
$item : mixed
Return values
Collection

save()

Attempts to save a part to the Discord servers.

public save(Part $part[, string|null $reason = null ]) : ExtendedPromiseInterface<string|int, Part>
Parameters
$part : Part

The part to save.

$reason : string|null = null

Reason for Audit Log (if supported).

Tags
throws
Exception
Return values
ExtendedPromiseInterface<string|int, Part>

serialize()

Returns the string representation of the collection.

public serialize() : string
Return values
string

set()

Sets a value in the collection.

public set(mixed $offset, mixed $value) : mixed
Parameters
$offset : mixed
$value : mixed
Return values
mixed

toArray()

Converts the collection to an array.

public toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>

unserialize()

Unserializes the collection.

public unserialize(string $serialized) : void
Parameters
$serialized : string
Return values
void

cacheFreshen()

protected cacheFreshen(object $response) : ExtendedPromiseInterface<string|int, static>
Parameters
$response : object
Return values
ExtendedPromiseInterface<string|int, static>

Search results