NAME
Discord::Client::Model - Resource snapshots with optional REST operations
SYNOPSIS
use Discord::Client::Model;
# Wrap existing data without a request.
my $channel = Discord::Client::Model->wrap(
channel => {id => $channel_id}, rest => $rest,
);
# The Future yields a new Message snapshot.
my $sent = $channel->send({content => 'Hello', allowed_mentions => {parse => []}});
DESCRIPTION
Copied resource data with optional REST operations. Snapshots retain unknown fields and string IDs. They do not refresh or populate a cache automatically. Wrapping is synchronous and performs no request.
REST operations return Futures and propagate cancellation. Successful operations return new snapshots; existing objects do not change. Without a REST client, operations fail with state. The caller owns the REST client.
METHODS
wrap
Discord::Client::Model->wrap(type, hashref, rest => $rest) returns a Discord::Client::Model::Message, Discord::Client::Model::Channel, Discord::Client::Model::User or Discord::Client::Model::Guild. Types are message, channel, user and guild. Unknown types or invalid data throw. rest is optional for read-only access.
new
new(data => $hashref, rest => $rest) constructs a snapshot of the called class. Data must be JSON-encodable with a decimal-string ID. Invalid data throws. Normally use wrap or a subclass constructor.
id
Returns the resource ID as a string.
raw
Returns a copied data hashref.
get
get(field) returns a copied field value, or undef when absent.
rest
Returns the supplied REST client, or undef.
LICENSE
Apache License 2.0.