| 1 | #!/usr/bin/env perl | ||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use v5.26; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use File::Spec; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | # Validate deployment settings before constructing the example client. | ||||||||||||||||||||||||||||
| 9 | my $guild_id = $ENV{TEST_GUILD_ID} | ||||||||||||||||||||||||||||
| 10 | 1 | ▶ | or die "TEST_GUILD_ID is required for guild command deployment\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | # Load one example's declarations without starting its Gateway connection. | ||||||||||||||||||||||||||||
| 13 | 1 | my ($example) = @ARGV; | |||||||||||||||||||||||||||
| 14 | 1 | ▶ | die "Usage: perl examples/sync-commands.pl EXAMPLE.pl\n" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 15 | unless @ARGV == 1; | ||||||||||||||||||||||||||||
| 16 | 1 | my $path = File::Spec->rel2abs($example); | |||||||||||||||||||||||||||
| 17 | 1 | ▶ | die "Example file does not exist\n" unless -f $path; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 18 | 1 | my $bot = do $path; | |||||||||||||||||||||||||||
| 19 | 1 | ▶ | die "Could not load example\n" | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($bot) and $bot->isa("Discord::Client")
MC/DC0%0/2
builtin::blessed($bot) and $bot->isa("Discord::Client")
builtin::blessed($bot)
$bot->isa("Discord::Client")
Truth table33%1/3
A and B
A= builtin::blessed($bot)B= $bot->isa("Discord::Client")
| |||||||||||||||||||||||||||||
| 20 | unless blessed($bot) && $bot->isa('Discord::Client'); | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | # Deployment replaces this application's commands in the selected test guild. | ||||||||||||||||||||||||||||
| 23 | 1 | my $deployed = eval { | |||||||||||||||||||||||||||
| 24 | 1 | $bot->commands->sync( scope => { guild_id => $guild_id } )->get; | |||||||||||||||||||||||||||
| 25 | 1 | 1; | |||||||||||||||||||||||||||
| 26 | }; | ||||||||||||||||||||||||||||
| 27 | 1 | my $deployment_error = $@; | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | # Close SDK resources even when deployment fails, preserving the original error. | ||||||||||||||||||||||||||||
| 30 | 1 | my $closed = eval { | |||||||||||||||||||||||||||
| 31 | 1 | $bot->close->get; | |||||||||||||||||||||||||||
| 32 | 1 | 1; | |||||||||||||||||||||||||||
| 33 | }; | ||||||||||||||||||||||||||||
| 34 | 1 | my $close_error = $@; | |||||||||||||||||||||||||||
| 35 | 1 | ▶ | die $deployment_error unless $deployed; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | 1 | ▶ | die $close_error unless $closed; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||