AnyEvent-Discord-Client
view release on metacpan or search on metacpan
lib/AnyEvent/Discord/Client.pm view on Meta::CPAN
use warnings;
use strict;
our $VERSION = '0.000002';
$VERSION = eval $VERSION;
use AnyEvent::WebSocket::Client;
use LWP::UserAgent;
use JSON;
use URI;
use HTTP::Request;
use HTTP::Headers;
use AnyEvent::HTTP;
my $debug = 0;
sub new {
my ($class, %args) = @_;
my $self = {
token => delete($args{token}),
lib/AnyEvent/Discord/Client.pm view on Meta::CPAN
}
sub add_commands {
my ($self, %commands) = @_;
$self->{commands}{$_} = $commands{$_} for keys %commands;
}
sub api_sync {
my ($self, $method, $path, $data) = @_;
my $resp = $self->{ua}->request(HTTP::Request->new(
uc($method),
$self->{api_root} . $path,
HTTP::Headers->new(
Authorization => "Bot $self->{token}",
User_Agent => $self->{api_useragent},
($data ? (Content_Type => "application/json") : ()),
(
!defined $data ? ()
: ref $data ? ("Content_Type" => "application/json")
: ("Content_Type" => "application/x-www-form-urlencoded")
( run in 0.230 second using v1.01-cache-2.11-cpan-de7293f3b23 )