AnyEvent-Discord
view release on metacpan or search on metacpan
lib/AnyEvent/Discord.pm view on Meta::CPAN
package AnyEvent::Discord;
use v5.14;
use Moops;
class AnyEvent::Discord 0.7 {
use Algorithm::Backoff::Exponential;
use AnyEvent::Discord::Payload;
use AnyEvent::WebSocket::Client;
use Data::Dumper;
use JSON qw(decode_json encode_json);
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Headers;
our $VERSION = '0.7';
has version => ( is => 'ro', isa => Str, default => $VERSION );
has token => ( is => 'rw', isa => Str, required => 1 );
has base_uri => ( is => 'rw', isa => Str, default => 'https://discordapp.com/api' );
lib/AnyEvent/Discord.pm view on Meta::CPAN
$self->_handle_internal_event('error', $@);
return;
}
$self->_debug('Connected to ' . $gateway);
$self->_socket($socket);
# If we send malformed content, bail out
$socket->on('parse_error', sub {
my ($c, $error) = @_;
$self->_debug(Data::Dumper::Dumper($error));
die $error;
});
# Handle reconnection
$socket->on('finish', sub {
my ($c) = @_;
$self->_debug('Received disconnect');
$self->_handle_internal_event('disconnected');
unless ($self->_force_disconnect()) {
my $seconds = $self->_backoff->failure();
( run in 0.471 second using v1.01-cache-2.11-cpan-a5abf4f5562 )