DiscordrBot.Rdthis is the main class for the discord bot it handles all the incoming messages and events
new()DiscordrBot$new(token, intent = GUILD_MESSAGES)
tokenThe discord bot token
intentthe 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)
opone of the opcodes from the discord websocket https://discord.com/developers/docs/topics/opcodes-and-status-codes
callbacka function that would be called with the event data register event handlers
register_event_handler()DiscordrBot$register_event_handler(event_type, callback)
event_typeone of the events from the discord websocket https://discord.com/developers/docs/topics/gateway#commands-and-events
callbacka function that would be called with the event data send payload directly to the websocket
send_payload()DiscordrBot$send_payload(opcode, data)
opcodewebsocket OP CODE
datalist 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)
paththe path from the discord base api. general POST request to discord
discord_post_api()DiscordrBot$discord_post_api(path, body)
paththe path from the discord base api.
bodya 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)
deepWhether to make a deep clone.