| 1 | 1 | ▶ | use v5.26; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 2 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use Discord::Client::HTTPInteractions; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | # Verify signed HTTP requests without a Bot token or Gateway connection. | ||
| 7 | 1 | my $service = Discord::Client::HTTPInteractions->new( public_key => $ENV{DISCORD_PUBLIC_KEY}, ); | |
| 8 | |||
| 9 | # Send the reply directly in the HTTP response. | ||
| 10 | $service->command( | ||
| 11 | ping => ( | ||
| 12 | description => 'Replies with Pong', | ||
| 13 | 1 | ▶ | handler => sub { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 14 | 1 | my ($interaction) = @_; | |
| 15 | |||
| 16 | # Return the reply Future so delivery failures remain visible to the dispatcher. | ||
| 17 | 1 | return $interaction->reply('Pong!'); | |
| 18 | }, | ||
| 19 | 1 | ), | |
| 20 | ); | ||
| 21 | |||
| 22 | # Return the application for a PSGI host to serve. | ||
| 23 | 1 | $service->psgi_app; | |