| 1 | package Discord::Client::Intents; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 15 | ▶ | use v5.26; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 15 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 15 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 15 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 15 | our $VERSION = '0.002'; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | # Keep Discord bit positions explicit, including gaps reserved by the protocol. | ||||||||||||||||||||||||||||
| 11 | 15 | my %BITS = ( | |||||||||||||||||||||||||||
| 12 | GUILDS => 1 << 0, | ||||||||||||||||||||||||||||
| 13 | GUILD_MEMBERS => 1 << 1, | ||||||||||||||||||||||||||||
| 14 | GUILD_MODERATION => 1 << 2, | ||||||||||||||||||||||||||||
| 15 | GUILD_EXPRESSIONS => 1 << 3, | ||||||||||||||||||||||||||||
| 16 | GUILD_INTEGRATIONS => 1 << 4, | ||||||||||||||||||||||||||||
| 17 | GUILD_WEBHOOKS => 1 << 5, | ||||||||||||||||||||||||||||
| 18 | GUILD_INVITES => 1 << 6, | ||||||||||||||||||||||||||||
| 19 | GUILD_VOICE_STATES => 1 << 7, | ||||||||||||||||||||||||||||
| 20 | GUILD_PRESENCES => 1 << 8, | ||||||||||||||||||||||||||||
| 21 | GUILD_MESSAGES => 1 << 9, | ||||||||||||||||||||||||||||
| 22 | GUILD_MESSAGE_REACTIONS => 1 << 10, | ||||||||||||||||||||||||||||
| 23 | GUILD_MESSAGE_TYPING => 1 << 11, | ||||||||||||||||||||||||||||
| 24 | DIRECT_MESSAGES => 1 << 12, | ||||||||||||||||||||||||||||
| 25 | DIRECT_MESSAGE_REACTIONS => 1 << 13, | ||||||||||||||||||||||||||||
| 26 | DIRECT_MESSAGE_TYPING => 1 << 14, | ||||||||||||||||||||||||||||
| 27 | MESSAGE_CONTENT => 1 << 15, | ||||||||||||||||||||||||||||
| 28 | GUILD_SCHEDULED_EVENTS => 1 << 16, | ||||||||||||||||||||||||||||
| 29 | AUTO_MODERATION_CONFIGURATION => 1 << 20, | ||||||||||||||||||||||||||||
| 30 | AUTO_MODERATION_EXECUTION => 1 << 21, | ||||||||||||||||||||||||||||
| 31 | GUILD_MESSAGE_POLLS => 1 << 24, | ||||||||||||||||||||||||||||
| 32 | DIRECT_MESSAGE_POLLS => 1 << 25, | ||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 59 | ▶ | sub bits { | ||||||||||||||||||||||||||
|
Subroutine
bits: called CC=5 SCAR=16.6
Pod
documented
| |||||||||||||||||||||||||||||
| 36 | 59 | my ( $class, @names ) = @_; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | # Validate names before combining their bits; repeated names remain idempotent. | ||||||||||||||||||||||||||||
| 39 | 59 | my $value = 0; | |||||||||||||||||||||||||||
| 40 | 59 | for my $name (@names) { | |||||||||||||||||||||||||||
| 41 | 67 | ▶ | croak 'intent name must be a string' if !defined($name) || ref($name); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $name or ref $name
MC/DC0%0/2
not defined $name or ref $name
not defined $name
ref $name
Truth table33%1/3
not(A) or B
A= not defined $nameB= ref $name
| |||||||||||||||||||||||||||||
| 42 | 67 | ▶ | croak "unknown Discord intent: $name" if !exists $BITS{$name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 65 | $value |= $BITS{$name}; | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | 57 | return $value; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 0 | ▶ | sub names { return sort keys %BITS } | ||||||||||||||||||||||||||
|
Subroutine
names: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 15 | 1; | |||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | __END__ | ||||||||||||||||||||||||||||