|
Concord - C Discord API library
A Discord API wrapper library written in C
|
Client functions and datatypes. More...
Modules | |
| Caching | |
| Caching API supported by Concord. | |
| Commands | |
| Requests made by the client to the Gateway socket. | |
| Events | |
| Events sent over the Gateway socket to the client. | |
| Data Wrap | |
| Helpers for wrapping Discord data types for easier management. | |
| Timer | |
| Schedule callbacks to be called in the future. | |
Data Structures | |
| struct | discord_config |
| The Discord configuration handler. More... | |
| struct | discord |
| The Discord client handler. More... | |
Macros | |
| #define | discord_claim(client, data) (__discord_claim(client, data), data) |
| Claim ownership of a resource provided by Concord. More... | |
| #define | ccord_global_init() |
| #define | ccord_global_cleanup() |
| #define | ccord_shutdown_async() discord_shutdown_all() |
| Backwards compatible alias for discord_shutdown_all() More... | |
| #define | discord_init discord_from_token |
| Backwards compatible alias for discord_from_token() More... | |
| #define | discord_config_init discord_from_json |
| Backwards compatible alias for discord_from_json() More... | |
Functions | |
| void | __discord_claim (struct discord *client, const void *data) |
| void | discord_unclaim (struct discord *client, const void *data) |
| Unclaim ownership of a resource provided by Concord. More... | |
| void | discord_shutdown_all (void) |
| Gracefully notify all Discord connections for shutting down. More... | |
| bool | discord_shutdown_all_ongoing (void) |
| Check if all Discord connections shutting down is in progress. More... | |
| struct discord * | discord_from_token (const char token[]) |
| Creates a Discord Client handle from a token. More... | |
| struct discord * | discord_from_json (const char config_file[]) |
Creates a Discord Client handle from a config.json file. More... | |
| struct discord * | discord_from_config (const struct discord_config *config) |
| Creates a Discord Client handle from a discord_config structure. More... | |
| struct ccord_szbuf_readonly | discord_config_get_field (struct discord *client, char *const path[], unsigned depth) |
| Get the contents from the config file field. More... | |
| struct discord * | discord_clone (const struct discord *orig) |
| Clone a discord client. More... | |
| void | discord_cleanup (struct discord *client) |
| Free a Discord Client handle. More... | |
| const struct discord_user * | discord_get_self (struct discord *client) |
| Get the client's cached user. More... | |
| CCORDcode | discord_run (struct discord *client) |
| Start a connection to the Discord Gateway. More... | |
| void | discord_shutdown (struct discord *client) |
| Gracefully shutdown an ongoing Discord connection. More... | |
| void | discord_reconnect (struct discord *client, bool resume) |
| Gracefully reconnects an ongoing Discord connection. More... | |
| void * | discord_set_data (struct discord *client, void *data) |
| Store user arbitrary data that can be retrieved by discord_get_data() More... | |
| void * | discord_get_data (struct discord *client) |
| Receive user arbitrary data stored with discord_set_data() More... | |
| int | discord_get_ping (struct discord *client) |
| Get the client WebSockets ping. More... | |
| uint64_t | discord_timestamp (struct discord *client) |
| Get the current timestamp (in milliseconds) More... | |
| uint64_t | discord_timestamp_us (struct discord *client) |
| Get the current timestamp (in microseconds) More... | |
| struct logmod * | discord_get_logmod (struct discord *client) |
| Retrieve client's logging module for configuration purposes. More... | |
| struct io_poller * | discord_get_io_poller (struct discord *client) |
| get the io_poller used by the discord client More... | |
Client functions and datatypes.
| #define discord_claim | ( | client, | |
| data | |||
| ) | (__discord_claim(client, data), data) |
Claim ownership of a resource provided by Concord.
| client | the client initialized with discord_from_token() |
| data | a resource provided by Concord |
data (for one-liners) | #define ccord_global_init | ( | ) |
| #define ccord_global_cleanup | ( | ) |
| #define ccord_shutdown_async | ( | ) | discord_shutdown_all() |
Backwards compatible alias for discord_shutdown_all()
| #define discord_init discord_from_token |
Backwards compatible alias for discord_from_token()
| #define discord_config_init discord_from_json |
Backwards compatible alias for discord_from_json()
| void __discord_claim | ( | struct discord * | client, |
| const void * | data | ||
| ) |
| void discord_unclaim | ( | struct discord * | client, |
| const void * | data | ||
| ) |
Unclaim ownership of a resource provided by Concord.
| client | the client initialized with discord_from_token() |
| data | a resource provided by Concord, that has been previously claimed with discord_claim() |
| void discord_shutdown_all | ( | void | ) |
Gracefully notify all Discord connections for shutting down.
| bool discord_shutdown_all_ongoing | ( | void | ) |
Check if all Discord connections shutting down is in progress.
| struct discord * discord_from_token | ( | const char | token[] | ) |
Creates a Discord Client handle from a token.
| token | the bot token |
| struct discord * discord_from_json | ( | const char | config_file[] | ) |
Creates a Discord Client handle from a config.json file.
| config_file | the config.json file name |
| struct discord * discord_from_config | ( | const struct discord_config * | config | ) |
Creates a Discord Client handle from a discord_config structure.
| config | the discord_config structure |
| struct ccord_szbuf_readonly discord_config_get_field | ( | struct discord * | client, |
| char *const | path[], | ||
| unsigned | depth | ||
| ) |
Get the contents from the config file field.
| client | the client created with discord_from_json() |
| path | the JSON key path |
| depth | the path depth |
Clone a discord client.
Should be called before entering a thread, to ensure each thread has its own client instance with unique buffers, url and headers
| orig | the original client created with discord_from_token() |
| void discord_cleanup | ( | struct discord * | client | ) |
Free a Discord Client handle.
| client | the client created with discord_from_token() |
| const struct discord_user * discord_get_self | ( | struct discord * | client | ) |
Get the client's cached user.
| client | the client created with discord_from_token() |
Start a connection to the Discord Gateway.
| client | the client created with discord_from_token() |
| void discord_shutdown | ( | struct discord * | client | ) |
Gracefully shutdown an ongoing Discord connection.
| client | the client created with discord_from_token() |
| void discord_reconnect | ( | struct discord * | client, |
| bool | resume | ||
| ) |
Gracefully reconnects an ongoing Discord connection.
| client | the client created with discord_from_token() |
| resume | true to attempt to resume to previous session, false restart a fresh session |
| void * discord_set_data | ( | struct discord * | client, |
| void * | data | ||
| ) |
Store user arbitrary data that can be retrieved by discord_get_data()
| client | the client created with discord_from_token() |
| data | user arbitrary data |
| void * discord_get_data | ( | struct discord * | client | ) |
Receive user arbitrary data stored with discord_set_data()
| client | the client created with discord_from_token() |
| int discord_get_ping | ( | struct discord * | client | ) |
Get the client WebSockets ping.
| client | the client created with discord_from_token() |
| uint64_t discord_timestamp | ( | struct discord * | client | ) |
Get the current timestamp (in milliseconds)
| client | the client created with discord_from_token() |
| uint64_t discord_timestamp_us | ( | struct discord * | client | ) |
Get the current timestamp (in microseconds)
| client | the client created with discord_from_token() |
Retrieve client's logging module for configuration purposes.
| client | the client created with discord_from_token() |
| struct io_poller * discord_get_io_poller | ( | struct discord * | client | ) |
get the io_poller used by the discord client
| client | the client created with discord_from_token() |