| 1 | package Discord::Client::Model::Message; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use v5.26; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use parent 'Discord::Client::Model'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 3 | our $VERSION = '0.003'; | |||||||||||||||||||||||||||
| 9 | 13 | ▶ | sub channel_id { $_[0]->get('channel_id') } | ||||||||||||||||||||||||||
|
Subroutine
channel_id: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 10 | 7 | ▶ | sub content { $_[0]->get('content') } | ||||||||||||||||||||||||||
|
Subroutine
content: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 3 | ▶ | sub is_from_bot { | ||||||||||||||||||||||||||
|
Subroutine
is_from_bot: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 13 | 3 | my ($self) = @_; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | # Missing author metadata does not imply a bot; callers decide whether to ignore it. | ||||||||||||||||||||||||||||
| 16 | 3 | my $author = $self->get('author'); | |||||||||||||||||||||||||||
| 17 | 3 | ▶ | return ref($author) eq 'HASH' && $author->{bot} ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $author eq "HASH" and $author->{"bot"}
MC/DC50%1/2
ref $author eq "HASH" and $author->{"bot"}
ref $author eq "HASH"
$author->{"bot"}
Truth table66%2/3
A and B
A= ref $author eq "HASH"B= $author->{"bot"}
| |||||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 1 | ▶ | sub author { | ||||||||||||||||||||||||||
|
Subroutine
author: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 21 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | # Wrap the embedded user without another request or a cache dependency. | ||||||||||||||||||||||||||||
| 24 | 1 | my $author = $self->get('author'); | |||||||||||||||||||||||||||
| 25 | 1 | ▶ | return undef unless ref($author) eq 'HASH'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | 1 | return Discord::Client::Model->wrap( user => $author, rest => $self->rest ); | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 2 | ▶ | sub channel { | ||||||||||||||||||||||||||
|
Subroutine
channel: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 30 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | # A channel reference permits sending without a cache or a preliminary fetch. | ||||||||||||||||||||||||||||
| 33 | 2 | ▶ | return undef unless defined $self->channel_id; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | 2 | return Discord::Client::Model->wrap( | |||||||||||||||||||||||||||
| 35 | channel => { id => $self->channel_id }, | ||||||||||||||||||||||||||||
| 36 | rest => $self->rest, | ||||||||||||||||||||||||||||
| 37 | ); | ||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 1 | ▶ | sub edit { | ||||||||||||||||||||||||||
|
Subroutine
edit: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 41 | 1 | my ( $self, $body ) = @_; | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | # Edits return a new snapshot; this message remains the originally observed version. | ||||||||||||||||||||||||||||
| 44 | 1 | my $request = $self->_call( edit_message => $self->channel_id, $self->id, $body ); | |||||||||||||||||||||||||||
| 45 | 1 | return $self->_model_future( message => $request ); | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 1 | ▶ | sub delete { | ||||||||||||||||||||||||||
|
Subroutine
delete: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 49 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||
| 50 | 1 | return $self->_call( delete_message => $self->channel_id, $self->id ); | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 3 | ▶ | sub reply { | ||||||||||||||||||||||||||
|
Subroutine
reply: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||
| 54 | 3 | my ( $self, $body ) = @_; | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | # Copy caller data before adding the source message reference. | ||||||||||||||||||||||||||||
| 57 | 3 | ▶ | $body = { content => "$body" } if defined($body) && !ref($body); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $body and not ref $body
MC/DC50%1/2
defined $body and not ref $body
defined $body
not ref $body
Truth table66%2/3
A and not(B)
A= defined $bodyB= not ref $body
| |||||||||||||||||||||||||||||
| 58 | 3 | ▶ | if ( ref($body) eq 'HASH' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | 3 | $body = { %$body, message_reference => { message_id => $self->id, channel_id => $self->channel_id }, }; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | 3 | my $request = $self->_call( create_message => $self->channel_id, $body ); | |||||||||||||||||||||||||||
| 62 | 3 | return $self->_model_future( message => $request ); | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 3 | 1; | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | __END__ | ||||||||||||||||||||||||||||