Concord - C Discord API library
A Discord API wrapper library written in C
discord.h File Reference

Public functions and datatypes. More...

#include <inttypes.h>
#include <stdbool.h>
#include "error.h"
#include "types.h"
#include "concord-once.h"
#include "io_poller.h"
#include "discord_codecs.h"
#include "discord-response.h"
#include "audit_log.h"
#include "auto_moderation.h"
#include "invite.h"
#include "channel.h"
#include "emoji.h"
#include "guild.h"
#include "guild_scheduled_event.h"
#include "guild_template.h"
#include "stage_instance.h"
#include "sticker.h"
#include "user.h"
#include "voice.h"
#include "webhook.h"
#include "gateway.h"
#include "oauth2.h"
#include "application_command.h"
#include "interaction.h"
#include "discord-cache.h"
#include "discord-events.h"
Include dependency graph for discord.h:

Go to the source code of this file.

Data Structures

struct  discord_timer
 struct used for modifying, and getting info about a timer More...
 

Macros

#define DISCORD_VERSION   "10"
 The Discord API version to use. More...
 
#define DISCORD_API_BASE_URL   "https://discord.com/api/v" DISCORD_VERSION
 
#define DISCORD_GATEWAY_URL_SUFFIX   "?v=" DISCORD_VERSION "&encoding=json"
 
#define DISCORD_MAX_NAME_LEN   4 * 100 + 1
 
#define DISCORD_MAX_TOPIC_LEN   4 * 1024 + 1
 
#define DISCORD_MAX_DESCRIPTION_LEN   4 * 2048 + 1
 
#define DISCORD_MAX_USERNAME_LEN   4 * 32 + 1
 
#define DISCORD_MAX_DISCRIMINATOR_LEN   4 + 1
 
#define DISCORD_MAX_REASON_LEN   4 * 512 + 1
 
#define DISCORD_MAX_MESSAGE_LEN   4 * 2000 + 1
 
#define DISCORD_MAX_PAYLOAD_LEN   4 * 4096 + 1
 
#define DISCORD_EMBED_TITLE_LEN   4 * 256 + 1
 
#define DISCORD_EMBED_DESCRIPTION_LEN   4 * 4096 + 1
 
#define DISCORD_EMBED_MAX_FIELDS   25
 
#define DISCORD_EMBED_FIELD_NAME_LEN   4 * 256 + 1
 
#define DISCORD_EMBED_FIELD_VALUE_LEN   4 * 1024 + 1
 
#define DISCORD_EMBED_FOOTER_TEXT_LEN   4 * 2048 + 1
 
#define DISCORD_EMBED_AUTHOR_NAME_LEN   4 * 256 + 1
 
#define DISCORD_WEBHOOK_NAME_LEN   4 * 80 + 1
 
#define discord_claim(client, data)   (__discord_claim(client, data), data)
 Claim ownership of a resource provided by Concord. More...
 

Typedefs

typedef void(* discord_ev_timer) (struct discord *client, struct discord_timer *ev)
 callback to be used with struct discord_timer More...
 

Enumerations

enum  discord_timer_flags {
  DISCORD_TIMER_MILLISECONDS = 0 , DISCORD_TIMER_MICROSECONDS = 1 << 0 , DISCORD_TIMER_DELETE = 1 << 1 , DISCORD_TIMER_DELETE_AUTO = 1 << 2 ,
  DISCORD_TIMER_CANCELED = 1 << 3 , DISCORD_TIMER_TICK = 1 << 4 , DISCORD_TIMER_GET = 1 << 5 , DISCORD_TIMER_INTERVAL_FIXED = 1 << 6
}
 flags used to change behaviour of timer More...
 

Functions

CCORDcode discord_return_error (struct discord *client, const char error[], CCORDcode code)
 Return a Concord's error. More...
 
const char * discord_strerror (CCORDcode code, struct discord *client)
 Return the meaning of CCORDcode. More...
 
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...
 
struct discorddiscord_init (const char token[])
 Create a Discord Client handle by its token. More...
 
struct discorddiscord_config_init (const char config_file[])
 Create a Discord Client handle by a config.json file. 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 discorddiscord_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_userdiscord_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 logconfdiscord_get_logconf (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...
 
unsigned discord_timer_ctl (struct discord *client, struct discord_timer *timer)
 modifies or creates a timer More...
 
unsigned discord_timer (struct discord *client, discord_ev_timer on_tick_cb, discord_ev_timer on_status_changed_cb, void *data, int64_t delay)
 creates a one shot timer that automatically deletes itself upon completion More...
 
unsigned discord_timer_interval (struct discord *client, discord_ev_timer on_tick_cb, discord_ev_timer on_status_changed_cb, void *data, int64_t delay, int64_t interval, int64_t repeat)
 creates a repeating timer that automatically deletes itself upon completion More...
 
bool discord_timer_get (struct discord *client, unsigned id, struct discord_timer *timer)
 get the data associated with the timer More...
 
bool discord_timer_start (struct discord *client, unsigned id)
 starts a timer More...
 
bool discord_timer_stop (struct discord *client, unsigned id)
 stops a timer More...
 
bool discord_timer_cancel (struct discord *client, unsigned id)
 cancels a timer, this will delete the timer if DISCORD_TIMER_DELETE_AUTO is enabled More...
 
bool discord_timer_delete (struct discord *client, unsigned id)
 deletes a timer More...
 
bool discord_timer_cancel_and_delete (struct discord *client, unsigned id)
 cancels, and deletes a timer More...
 

Detailed Description

Public functions and datatypes.

Author
Cogmasters

These symbols are organized in a intuitive fashion to be easily matched to the official Discord API docs

See also
https://discord.com/developers/docs/intro

Macro Definition Documentation

◆ DISCORD_VERSION

#define DISCORD_VERSION   "10"

The Discord API version to use.

Warning
only change this if you know what you are doing!

◆ DISCORD_API_BASE_URL

#define DISCORD_API_BASE_URL   "https://discord.com/api/v" DISCORD_VERSION

◆ DISCORD_GATEWAY_URL_SUFFIX

#define DISCORD_GATEWAY_URL_SUFFIX   "?v=" DISCORD_VERSION "&encoding=json"