AnyEvent-Discord
view release on metacpan or search on metacpan
doc/AnyEvent-Discord.md view on Meta::CPAN
979899100101102103104105106107108109110111112113114115116117- 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
234235236237238239240241242243244245246247248249250251252253254method _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
477478479480481482483484485486487488489490491492493494495496497=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 )