AnyEvent-Discord

 view release on metacpan or  search on metacpan

doc/AnyEvent-Discord.md  view on Meta::CPAN

97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
- off($event\_type, \\&handler?)
 
    Detach an event handler from a defined event type. If the handler does not
    exist for the event, no error will be returned. If no handler is provided, all
    handlers for the event type will be removed.
 
- connect()
 
    Start connecting to the Discord API and return immediately. In a new AnyEvent
    application, this would come before executing "AnyEvent->condvar->recv". This
    method will retrieve the available gateway endpoint, create a connection,
    identify itself, begin a heartbeat, and once complete, Discord will fire a
    'ready' event to the handler.
 
- send($channel\_id, $content)
 
    Send a message to the provided channel.
 
- typing($channel\_id)
 
    Starts the "typing..." indicator in the provided channel. This method issues the

lib/AnyEvent/Discord.pm  view on Meta::CPAN

234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
method _ws_send_payload(AnyEvent::Discord::Payload $payload) {
  unless ($self->_socket) {
    $self->_debug('Attempted to send payload to disconnected socket');
    return;
  }
  my $msg = $payload->as_json;
  $self->_trace('ws out: ' . $msg);
  $self->_socket->send($msg);
}
 
# Look up the gateway endpoint using the Discord API
method _lookup_gateway() {
  my $payload = $self->_discord_api('GET', 'gateway');
  die 'Invalid gateway returned by API' unless ($payload and $payload->{url} and $payload->{url} =~ /^wss/);
 
  # Add the requested version and encoding to the provided URL
  my $gateway = $payload->{url};
  $gateway .= '/' unless ($gateway =~/\/$/);
  $gateway .= '?v=6&encoding=json';
  return $gateway;
}

lib/AnyEvent/Discord.pm  view on Meta::CPAN

477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
=item off($event_type, \&handler?)
 
Detach an event handler from a defined event type. If the handler does not
exist for the event, no error will be returned. If no handler is provided, all
handlers for the event type will be removed.
 
=item connect()
 
Start connecting to the Discord API and return immediately. In a new AnyEvent
application, this would come before executing "AnyEvent->condvar->recv". This
method will retrieve the available gateway endpoint, create a connection,
identify itself, begin a heartbeat, and once complete, Discord will fire a
'ready' event to the handler.
 
=item send($channel_id, $content)
 
Send a message to the provided channel.
 
=item typing($channel_id)
 
Starts the "typing..." indicator in the provided channel. This method issues the



( run in 0.452 second using v1.01-cache-2.11-cpan-26ccb49234f )