Concord - C Discord API library
A Discord API wrapper library written in C

Wrapper to the Discord REST API. More...

Collaboration diagram for REST API:

Modules

 Request's handling
 Store, manage and dispatch individual requests.
 

Files

file  discord-request.h
 Generic macros for initializing a discord_attributes.
 

Data Structures

struct  discord_rest
 The handle used for interfacing with Discord's REST API. More...
 

Functions

void discord_rest_init (struct discord_rest *rest, struct logconf *conf, const char token[])
 Initialize an REST handle. More...
 
void discord_rest_cleanup (struct discord_rest *rest)
 Free an REST handle. More...
 
CCORDcode discord_rest_run (struct discord_rest *rest, struct discord_attributes *req, struct ccord_szbuf *body, enum http_method method, char endpoint_fmt[],...)
 Perform a request to Discord. More...
 
void discord_rest_stop_buckets (struct discord_rest *rest)
 Stop all bucket's on-going, pending and timed-out requests. More...
 

Detailed Description

Wrapper to the Discord REST API.

Function Documentation

◆ discord_rest_init()

void discord_rest_init ( struct discord_rest rest,
struct logconf conf,
const char  token[] 
)

Initialize an REST handle.

Structure used for interfacing with the Discord's REST API

Parameters
restthe REST handle to be initialized
confpointer to discord logging module
tokenthe bot token

◆ discord_rest_cleanup()

void discord_rest_cleanup ( struct discord_rest rest)

Free an REST handle.

Parameters
restthe handle initialized with discord_rest_init()

◆ discord_rest_run()

CCORDcode discord_rest_run ( struct discord_rest rest,
struct discord_attributes req,
struct ccord_szbuf body,
enum http_method  method,
char  endpoint_fmt[],
  ... 
)

Perform a request to Discord.

This functions is a selector over discord_rest_run() or discord_rest_run_requestor()

Parameters
restthe handle initialized with discord_rest_init()
reqreturn object of request
bodythe body sent for methods that require (ex: post), leave as null if unecessary
methodthe method in opcode format of the request being sent
endpoint_fmtthe printf-like endpoint formatting string
Returns
CCORDcode value for how the operation went, CCORD_OK means nothing out of the ordinary
Note
if sync is set then this function will block the thread and perform it immediately

◆ discord_rest_stop_buckets()

void discord_rest_stop_buckets ( struct discord_rest rest)

Stop all bucket's on-going, pending and timed-out requests.

The requests will be moved over to client's 'queues->recycling' queue

Parameters
restthe handle initialized with discord_rest_init()