#' A Function which is being used to update the client's presence
#' @export
#'
#' @param client The client object
#' @param presence The presence object (named list)
#' @section Resource:
#'
#' See https://discordapp.com/developers/docs/topics/gateway#update-status
#'
#' @section Warning:
#' Sending malformed payload will result in errors! don't panick :)
#'
#' @examples
#' \dontrun{update.presence(client, list(game=list(name="Hey!", type=0)))}
#' \dontrun{update.presence(client, list(game=list(name="Streaming!", type=1, url="https://twitch.tv/theonlyartz")))}
updates.presence <- function(client, presence) {
payload <- list(
op = 3,
d = presence
)
if (is.null(presence$afk)) payload$d$afk <- FALSE
if (is.null(presence$status)) payload$d$status <- "online"
if (is.null(presence$since)) payload$d$since <- NA
json <- toJSON(payload)
client$ws$send(json)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.