this is the main class for the discord bot it handles all the incoming messages and events
new()
DiscordrBot$new(token, intent = GUILD_MESSAGES)
token
The discord bot token
intent
the intent(s) that the bot should access. Discordr defines constant for the possible intents Closes websocket connection Start the bot
finalize()
DiscordrBot$finalize()
start()
starts the bot and enters in an infinite later loop if in a interactive session returns as the later event loop will be run while R is idle
DiscordrBot$start()
register_op_handler()
register op handler
DiscordrBot$register_op_handler(op, callback)
op
one of the opcodes from the discord websocket https://discord.com/developers/docs/topics/opcodes-and-status-codes
callback
a function that would be called with the event data register event handlers
register_event_handler()
DiscordrBot$register_event_handler(event_type, callback)
event_type
one of the events from the discord websocket https://discord.com/developers/docs/topics/gateway#commands-and-events
callback
a function that would be called with the event data send payload directly to the websocket
send_payload()
DiscordrBot$send_payload(opcode, data)
opcode
websocket OP CODE
data
list that represents data to be sent in payload return the endpoint of Websocket connections general GET request to discord
get_ws_endpoint()
DiscordrBot$get_ws_endpoint()
discord_get_api()
DiscordrBot$discord_get_api(path)
path
the path from the discord base api. general POST request to discord
discord_post_api()
DiscordrBot$discord_post_api(path, body)
path
the path from the discord base api.
body
a list that will the body of the http request. It will automatically encoded in json create a new websocket and connect to it switcher for op code Switch according to received events hello is the first message sent by discord on the websocket need to setup heartbeat and intent connect to discord sending intents and The session is invalid for discord need to reconnect again resumes previous sessions after they are interrupted reconnect socket if asked by discord save the ready event
clone()
The objects of this class are cloneable with this method.
DiscordrBot$clone(deep = FALSE)
deep
Whether to make a deep clone.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.