NAME

Discord::Client::Model::Message - message snapshots and REST operations

SYNOPSIS

# Ignore bots and return the reply Future from a message handler.
$bot->on_message(sub {
    my ($message, $bot) = @_;
    return if $message->is_from_bot;
    return unless $message->content eq '!ping';
    return $message->reply('Pong!');
});

DESCRIPTION

A message snapshot with REST operations. Inherits construction and data access from Discord::Client::Model. Set message intents explicitly; enable Message Content in the Developer Portal for the example. Raw events remain available through "on" in Discord::Client.

METHODS

channel_id

Returns the channel ID or undef.

content

Returns the message content or undef if absent from the payload.

is_from_bot

Returns a boolean from the author's bot flag; false when absent.

author

Returns a Discord::Client::Model::User snapshot or undef. Performs no request.

channel

Returns an ID-only Discord::Client::Model::Channel reference or undef. It shares the Message's REST client and performs no request. Use its refresh to fetch channel details.

edit

edit(text_or_hash) returns a Future containing a new Message snapshot.

delete

Returns a Future resolving to undef after deletion.

reply

reply(text_or_hash) adds a message reference and returns a Future containing the new Message snapshot. Set allowed_mentions to control pings.

LICENSE

Apache License 2.0.