26#ifndef DISCORD_VERSION
31#define DISCORD_VERSION "10"
34#define DISCORD_API_BASE_URL "https://discord.com/api/v" DISCORD_VERSION
35#define DISCORD_GATEWAY_URL_SUFFIX "?v=" DISCORD_VERSION "&encoding=json"
41#include "discord_codecs.h"
43#include "discord-voice.h"
58#define DISCORD_MAX_NAME_LEN 4 * 100 + 1
59#define DISCORD_MAX_TOPIC_LEN 4 * 1024 + 1
60#define DISCORD_MAX_DESCRIPTION_LEN 4 * 2048 + 1
61#define DISCORD_MAX_USERNAME_LEN 4 * 32 + 1
62#define DISCORD_MAX_DISCRIMINATOR_LEN 4 + 1
63#define DISCORD_MAX_REASON_LEN 4 * 512 + 1
64#define DISCORD_MAX_MESSAGE_LEN 4 * 2000 + 1
65#define DISCORD_MAX_PAYLOAD_LEN 4 * 4096 + 1
71#define DISCORD_EMBED_TITLE_LEN 4 * 256 + 1
72#define DISCORD_EMBED_DESCRIPTION_LEN 4 * 4096 + 1
73#define DISCORD_EMBED_MAX_FIELDS 25
74#define DISCORD_EMBED_FIELD_NAME_LEN 4 * 256 + 1
75#define DISCORD_EMBED_FIELD_VALUE_LEN 4 * 1024 + 1
76#define DISCORD_EMBED_FOOTER_TEXT_LEN 4 * 2048 + 1
77#define DISCORD_EMBED_AUTHOR_NAME_LEN 4 * 256 + 1
83#define DISCORD_WEBHOOK_NAME_LEN 4 * 80 + 1
160#define discord_claim(client, data) (__discord_claim(client, data), data)
Application Command public functions and datatypes.
Caching of Discord resources.
Listen, react and trigger Discord Gateway events.
Generic macros for initializing a discord_response and return handles.
CCORDcode
Definition: error.h:12
CCORDcode discord_return_error(struct discord *client, const char error[], CCORDcode code)
Return a Concord's error.
const char * discord_strerror(CCORDcode code, struct discord *client)
Return the meaning of CCORDcode.
void discord_cleanup(struct discord *client)
Free a Discord Client handle.
CCORDcode discord_run(struct discord *client)
Start a connection to the Discord Gateway.
uint64_t discord_timestamp(struct discord *client)
Get the current timestamp (in milliseconds)
const struct discord_user * discord_get_self(struct discord *client)
Get the client's cached user.
void discord_unclaim(struct discord *client, const void *data)
Unclaim ownership of a resource provided by Concord.
struct discord * discord_clone(const struct discord *orig)
Clone a discord client.
void discord_shutdown(struct discord *client)
Gracefully shutdown an ongoing Discord connection.
struct logconf * discord_get_logconf(struct discord *client)
Retrieve client's logging module for configuration purposes.
void discord_reconnect(struct discord *client, bool resume)
Gracefully reconnects an ongoing Discord connection.
void * discord_get_data(struct discord *client)
Receive user arbitrary data stored with discord_set_data()
struct discord * discord_config_init(const char config_file[])
Create a Discord Client handle by a config.json file.
int discord_get_ping(struct discord *client)
Get the client WebSockets ping.
void * discord_set_data(struct discord *client, void *data)
Store user arbitrary data that can be retrieved by discord_get_data()
struct io_poller * discord_get_io_poller(struct discord *client)
get the io_poller used by the discord client
uint64_t discord_timestamp_us(struct discord *client)
Get the current timestamp (in microseconds)
struct ccord_szbuf_readonly discord_config_get_field(struct discord *client, char *const path[], unsigned depth)
Get the contents from the config file field.
struct discord * discord_init(const char token[])
Create a Discord Client handle by its token.
void __discord_claim(struct discord *client, const void *data)
unsigned discord_timer_ctl(struct discord *client, struct discord_timer *timer)
modifies or creates a timer
bool discord_timer_cancel(struct discord *client, unsigned id)
cancels a timer, this will delete the timer if DISCORD_TIMER_DELETE_AUTO is enabled
bool discord_timer_start(struct discord *client, unsigned id)
starts a timer
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
discord_timer_flags
flags used to change behaviour of timer
Definition: discord.h:353
void(* discord_ev_timer)(struct discord *client, struct discord_timer *ev)
callback to be used with struct discord_timer
Definition: discord.h:349
bool discord_timer_get(struct discord *client, unsigned id, struct discord_timer *timer)
get the data associated with the timer
bool discord_timer_stop(struct discord *client, unsigned id)
stops a timer
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
bool discord_timer_cancel_and_delete(struct discord *client, unsigned id)
cancels, and deletes a timer
bool discord_timer_delete(struct discord *client, unsigned id)
deletes a timer
@ DISCORD_TIMER_TICK
Definition: discord.h:365
@ DISCORD_TIMER_MILLISECONDS
Definition: discord.h:355
@ DISCORD_TIMER_INTERVAL_FIXED
Definition: discord.h:369
@ DISCORD_TIMER_DELETE_AUTO
Definition: discord.h:361
@ DISCORD_TIMER_CANCELED
Definition: discord.h:363
@ DISCORD_TIMER_DELETE
Definition: discord.h:359
@ DISCORD_TIMER_MICROSECONDS
Definition: discord.h:357
@ DISCORD_TIMER_GET
Definition: discord.h:367
Audit Log public functions and datatypes.
Auto Moderation public functions and datatypes.
Channel public functions and datatypes.
Emoji public functions and datatypes.
Gateway public functions and datatypes.
Guild public functions and datatypes.
Guild Scheduled Event public functions and datatypes.
Guild Template public functions and datatypes.
Invite public functions and datatypes.
OAuth2 public functions and datatypes.
Stage Instance public functions and datatypes.
Sticker public functions and datatypes.
User public functions and datatypes.
Voice public functions and datatypes.
Webhook public functions and datatypes.
Interaciton public functions and datatypes.
Read-only generic sized buffer.
Definition: types.h:55
struct used for modifying, and getting info about a timer
Definition: discord.h:373
discord_ev_timer on_status_changed
Definition: discord.h:382
void * data
Definition: discord.h:384
enum discord_timer_flags flags
Definition: discord.h:377
unsigned id
Definition: discord.h:375
int64_t interval
Definition: discord.h:388
discord_ev_timer on_tick
Definition: discord.h:379
int64_t repeat
Definition: discord.h:390
int64_t delay
Definition: discord.h:386
The Discord client handler.
Definition: discord-internal.h:1190
void * data
Definition: discord-internal.h:1236
char * token
Definition: discord-internal.h:1196
A stackful and modularized wrapper over the popular 'log.c' facilities.
Definition: logconf.h:217