Orca
A bot framework that is easy to reason about, easy to debug, and easy to use.
Classes | Macros | Typedefs | Enumerations | Functions
discord.h File Reference

File containing public functions and datatypes. More...

#include <stdbool.h>
#include "json-actor-boxed.h"
#include "logconf.h"
#include "specs-code/discord/all_opaque_struct.h"
#include "specs-code/discord/all_enums.h"
#include "specs-code/discord/all_structs.h"
#include "specs-code/discord/all_functions.h"
Include dependency graph for discord.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  discord_session
 
struct  discord_get_channel_messages_params
 
struct  discord_create_message_params
 
struct  discord_edit_message_params
 
struct  discord_list_guild_members_params
 

Macros

#define DISCORD_API_BASE_URL   "https://discord.com/api/v9"
 
#define DISCORD_GATEWAY_URL_SUFFIX   "?v=9&encoding=json"
 
#define DISCORD_VOICE_CONNECTIONS_URL_SUFFIX   "?v=4"
 
#define SNOWFLAKE_INCREMENT   12
 
#define SNOWFLAKE_PROCESS_ID   17
 
#define SNOWFLAKE_INTERNAL_WORKER_ID   22
 
#define SNOWFLAKE_TIMESTAMP   64
 
#define MAX_NAME_LEN   100 + 1
 
#define MAX_TOPIC_LEN   1024 + 1
 
#define MAX_DESCRIPTION_LEN   2048 + 1
 
#define MAX_USERNAME_LEN   32 + 1
 
#define MAX_DISCRIMINATOR_LEN   4 + 1
 
#define MAX_SHA256_LEN   1024 + 1
 
#define MAX_LOCALE_LEN   16 + 1
 
#define MAX_EMAIL_LEN   254 + 1
 
#define MAX_REGION_LEN   16 + 1
 
#define MAX_REASON_LEN   512 + 1
 
#define MAX_MESSAGE_LEN   4000 + 1
 
#define MAX_PAYLOAD_LEN   4096 + 1
 
#define EMBED_TITLE_LEN   256 + 1
 
#define EMBED_DESCRIPTION_LEN   2048 + 1
 
#define EMBED_MAX_FIELDS   25
 
#define EMBED_FIELD_NAME_LEN   256 + 1
 
#define EMBED_FIELD_VALUE_LEN   1024 + 1
 
#define EMBED_FOOTER_TEXT_LEN   2048 + 1
 
#define EMBED_AUTHOR_NAME_LEN   256 + 1
 
#define WEBHOOK_NAME_LEN   80 + 1
 

Typedefs

typedef uint64_t u64_unix_ms_t
 unix time in ms
 
typedef uint64_t u64_snowflake_t
 snowflake datatype
 
typedef void(* idle_cb) (struct discord *client, const struct discord_user *bot)
 Idle callback. More...
 
typedef void(* event_raw_cb) (struct discord *client, enum discord_gateway_events event, struct sized_buffer *sb_bot, struct sized_buffer *event_data)
 Raw Event callback. More...
 
typedef void(* guild_role_cb) (struct discord *client, const struct discord_user *bot, const u64_snowflake_t guild_id, const struct discord_permissions_role *role)
 Guild Role Create/Update callback. More...
 
typedef void(* guild_role_delete_cb) (struct discord *client, const struct discord_user *bot, const u64_snowflake_t guild_id, const u64_snowflake_t role_id)
 Guild Role Delete callback. More...
 
typedef void(* guild_member_cb) (struct discord *client, const struct discord_user *bot, const u64_snowflake_t guild_id, const struct discord_guild_member *member)
 Guild Member Add/Update callback. More...
 
typedef void(* guild_member_remove_cb) (struct discord *client, const struct discord_user *bot, const u64_snowflake_t guild_id, const struct discord_user *user)
 Guild Member Remove callback. More...
 
typedef void(* guild_ban_cb) (struct discord *client, const struct discord_user *bot, const u64_snowflake_t guild_id, const struct discord_user *user)
 Guild Ban Add/Remove callback. More...
 
typedef void(* message_cb) (struct discord *client, const struct discord_user *bot, const struct discord_message *message)
 Message Create/Update callback. More...
 
typedef void(* sb_message_cb) (struct discord *client, const struct discord_user *bot, struct sized_buffer *sb_bot, const struct discord_message *message, struct sized_buffer *msg_payload)
 
typedef void(* message_delete_cb) (struct discord *client, const struct discord_user *bot, const u64_snowflake_t id, const u64_snowflake_t channel_id, const u64_snowflake_t guild_id)
 Message Delete callback. More...
 
typedef void(* message_delete_bulk_cb) (struct discord *client, const struct discord_user *bot, const ja_u64 **ids, const u64_snowflake_t channel_id, const u64_snowflake_t guild_id)
 Message Delete Bulk callback. More...
 
typedef void(* channel_cb) (struct discord *client, const struct discord_user *bot, const struct discord_channel *channel)
 Channel Create/Update/Delete callback. More...
 
typedef void(* channel_pins_update_cb) (struct discord *client, const struct discord_user *bot, const u64_snowflake_t guild_id, const u64_snowflake_t channel_id, const u64_unix_ms_t last_pin_timestamp)
 Channel Pins Update callback. More...
 
typedef void(* message_reaction_add_cb) (struct discord *client, const struct discord_user *bot, const u64_snowflake_t user_id, const u64_snowflake_t channel_id, const u64_snowflake_t message_id, const u64_snowflake_t guild_id, const struct discord_guild_member *member, const struct discord_emoji *emoji)
 Message Reaction Add callback. More...
 
typedef void(* message_reaction_remove_cb) (struct discord *client, const struct discord_user *bot, const u64_snowflake_t user_id, const u64_snowflake_t channel_id, const u64_snowflake_t message_id, const u64_snowflake_t guild_id, const struct discord_emoji *emoji)
 Message Reaction Remove callback. More...
 
typedef void(* message_reaction_remove_all_cb) (struct discord *client, const struct discord_user *bot, const u64_snowflake_t channel_id, const u64_snowflake_t message_id, const u64_snowflake_t guild_id)
 Message Reaction Remove All callback. More...
 
typedef void(* message_reaction_remove_emoji_cb) (struct discord *client, const struct discord_user *bot, const u64_snowflake_t channel_id, const u64_snowflake_t message_id, const u64_snowflake_t guild_id, const struct discord_emoji *emoji)
 Message Reaction Remove Emoji callback. More...
 
typedef void(* voice_state_update_cb) (struct discord *client, const struct discord_user *bot, const struct discord_voice_state *voice_state)
 Voice State Update callback. More...
 
typedef void(* voice_server_update_cb) (struct discord *client, const struct discord_user *bot, const char *token, const u64_snowflake_t guild_id, const char *endpoint)
 Voice Server Update callback. More...
 

Enumerations

enum  discord_event_handling_mode { EVENT_IS_HANDLED, EVENT_WILL_BE_HANDLED_IN_MAIN_THREAD, EVENT_WILL_BE_HANDLED_IN_CHILD_THREAD }
 

Functions

void discord_global_init ()
 Initialize resources of globals used by discord.h.
 
void discord_global_cleanup ()
 Free resources of globals used by discord.h.
 
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 bot.config file. More...
 
void discord_cleanup (struct discord *client)
 Free a Discord Client handle. More...
 
void discord_add_intents (struct discord *client, enum discord_gateway_intents code)
 Subscribe to Discord Gateway events. More...
 
void discord_remove_intents (struct discord *client, enum discord_gateway_intents code)
 Unsubscribe from Discord Gateway events. More...
 
void discord_set_prefix (struct discord *client, char *prefix)
 Set a mandatory prefix before commands. More...
 
void discord_set_on_command (struct discord *client, char *command, message_cb callback)
 Set command/callback pair, the callback is triggered if someone types command in chat. More...
 
void discord_set_on_event_raw (struct discord *client, event_raw_cb callback)
 Set a callback that triggers on any event the client is subscribed to. More...
 
void discord_set_on_idle (struct discord *client, idle_cb callback)
 Set a callback that triggers at every event-loop iteration. More...
 
void discord_set_on_guild_role_create (struct discord *client, guild_role_cb callback)
 Set a callback that triggers when a guild role is created. More...
 
void discord_set_on_guild_role_update (struct discord *client, guild_role_cb callback)
 Set a callback that triggers when a guild role is updated. More...
 
void discord_set_on_guild_role_delete (struct discord *client, guild_role_delete_cb callback)
 Set a callback that triggers when a guild role is deleted. More...
 
void discord_set_on_guild_member_add (struct discord *client, guild_member_cb callback)
 Set a callback that triggers when a guild member is added. More...
 
void discord_set_on_guild_member_update (struct discord *client, guild_member_cb callback)
 Set a callback that triggers when a guild member is updated. More...
 
void discord_set_on_guild_member_remove (struct discord *client, guild_member_remove_cb callback)
 Set a callback that triggers when a guild member is removed. More...
 
void discord_set_on_guild_ban_add (struct discord *client, guild_ban_cb callback)
 Set a callback that triggers when a guild ban is added. More...
 
void discord_set_on_guild_ban_remove (struct discord *client, guild_ban_cb callback)
 Set a callback that triggers when a guild ban is removed. More...
 
void discord_set_on_channel_create (struct discord *client, channel_cb callback)
 Set a callback that triggers when a channel is created. More...
 
void discord_set_on_channel_update (struct discord *client, channel_cb callback)
 Set a callback that triggers when a channel is updated. More...
 
void discord_set_on_channel_delete (struct discord *client, channel_cb callback)
 Set a callback that triggers when a channel is deleted. More...
 
void discord_set_on_channel_pins_update (struct discord *client, channel_pins_update_cb callback)
 Set a callback that triggers when some channel pins are updated. More...
 
void discord_set_on_message_create (struct discord *client, message_cb callback)
 Set a callback that triggers when a message is created. More...
 
void discord_set_on_sb_message_create (struct discord *client, sb_message_cb callback)
 
void discord_set_on_message_update (struct discord *client, message_cb callback)
 Set a callback that triggers when a message is updated. More...
 
void discord_set_on_sb_message_update (struct discord *client, sb_message_cb callback)
 
void discord_set_on_message_delete (struct discord *client, message_delete_cb callback)
 Set a callback that triggers when a message is deleted. More...
 
void discord_set_on_message_delete_bulk (struct discord *client, message_delete_bulk_cb callback)
 
void discord_set_on_message_reaction_add (struct discord *client, message_reaction_add_cb callback)
 Set a callback that triggers when a message reaction is added. More...
 
void discord_set_on_message_reaction_remove (struct discord *client, message_reaction_remove_cb callback)
 Set a callback that triggers when a message reaction is removed. More...
 
void discord_set_on_message_reaction_remove_all (struct discord *client, message_reaction_remove_all_cb callback)
 Set a callback that triggers when all reaction from some message is removed. More...
 
void discord_set_on_message_reaction_remove_emoji (struct discord *client, message_reaction_remove_emoji_cb callback)
 Set a callback that triggers when all instances of a particular reaction from some message is removed. More...
 
void discord_set_on_ready (struct discord *client, idle_cb callback)
 Set a callback that triggers when the client is ready. More...
 
void discord_set_on_voice_state_update (struct discord *client, voice_state_update_cb callback)
 Set a callback that triggers when a voice state is updated. More...
 
void discord_set_on_voice_server_update (struct discord *client, voice_server_update_cb callback)
 Set a callback that triggers when a voice server is updated. More...
 
void discord_set_voice_cbs (struct discord *client, struct discord_voice_cbs *callbacks)
 Helper to quickly set voice callbacks. More...
 
void discord_set_blocking_event_handler (struct discord *client, enum discord_event_handling_mode(*f)(void *cxt))
 
void discord_run (struct discord *client)
 Start a connection to the Discord Gateway. More...
 
void * discord_set_data (struct discord *client, void *data)
 Keep some user arbitrary data, by associating it to the client. More...
 
void * discord_get_data (struct discord *client)
 Received user arbitrary data associated to the client. More...
 
void discord_replace_presence (struct discord *client, struct discord_gateway_status_update *presence)
 Replace the Client presence with a struct discord_gateway_status_update. More...
 
void discord_set_presence (struct discord *client, struct discord_gateway_activity *activity, char status[], bool afk)
 Modify the Client presence state. More...
 
ORCAcode discord_get_guild_audit_log (struct discord *client, const u64_snowflake_t guild_id, struct discord_get_guild_audit_log_params *params, struct discord_audit_log *p_audit_log)
 
ORCAcode discord_get_channel (struct discord *client, const u64_snowflake_t channel_id, struct discord_channel *p_channel)
 
ORCAcode discord_modify_channel (struct discord *client, const u64_snowflake_t channel_id, struct discord_modify_channel_params *params, struct discord_channel *p_channel)
 
ORCAcode discord_delete_channel (struct discord *client, const u64_snowflake_t channel_id, struct discord_channel *p_channel)
 
ORCAcode discord_get_channel_messages (struct discord *client, const u64_snowflake_t channel_id, struct discord_get_channel_messages_params *params, struct discord_message ***p_messages)
 
ORCAcode discord_get_channel_message (struct discord *client, const u64_snowflake_t channel_id, const u64_snowflake_t message_id, struct discord_message *p_message)
 
ORCAcode discord_create_message (struct discord *client, const u64_snowflake_t channel_id, struct discord_create_message_params *params, struct discord_message *p_message)
 
ORCAcode discord_crosspost_message (struct discord *client, const u64_snowflake_t channel_id, const u64_snowflake_t message_id, struct discord_message *p_message)
 
ORCAcode discord_create_reaction (struct discord *client, const u64_snowflake_t channel_id, const u64_snowflake_t message_id, const u64_snowflake_t emoji_id, const char emoji_name[])
 
ORCAcode discord_delete_own_reaction (struct discord *client, const u64_snowflake_t channel_id, const u64_snowflake_t message_id, const u64_snowflake_t emoji_id, const char emoji_name[])
 
ORCAcode discord_delete_user_reaction (struct discord *client, const u64_snowflake_t channel_id, const u64_snowflake_t message_id, const u64_snowflake_t user_id, const u64_snowflake_t emoji_id, const char emoji_name[])
 
ORCAcode discord_get_reactions (struct discord *client, u64_snowflake_t channel_id, u64_snowflake_t message_id, const u64_snowflake_t emoji_id, const char emoji_name[], struct discord_get_reactions_params *params, struct discord_user ***p_users)
 
ORCAcode discord_delete_all_reactions (struct discord *client, u64_snowflake_t channel_id, u64_snowflake_t message_id)
 
ORCAcode discord_delete_all_reactions_for_emoji (struct discord *client, const u64_snowflake_t channel_id, const u64_snowflake_t message_id, const u64_snowflake_t emoji_id, const char emoji_name[])
 
ORCAcode discord_edit_message (struct discord *client, const u64_snowflake_t channel_id, const u64_snowflake_t message_id, struct discord_edit_message_params *params, struct discord_message *p_message)
 
ORCAcode discord_delete_message (struct discord *client, u64_snowflake_t channel_id, u64_snowflake_t message_id)
 
ORCAcode discord_bulk_delete_messages (struct discord *client, u64_snowflake_t channel_id, u64_snowflake_t **messages)
 
ORCAcode discord_edit_channel_permissions (struct discord *client, const u64_snowflake_t channel_id, const u64_snowflake_t overwrite_id, struct discord_edit_channel_permissions_params *params)
 
ORCAcode discord_get_channel_invites (struct discord *client, const u64_snowflake_t channel_id, struct discord_invite ***p_invites)
 
ORCAcode discord_create_channel_invite (struct discord *client, const u64_snowflake_t channel_id, struct discord_create_channel_invite_params *params, struct discord_invite *p_invite)
 
ORCAcode discord_delete_channel_permission (struct discord *client, const u64_snowflake_t channel_id, const u64_snowflake_t overwrite_id)
 
ORCAcode discord_trigger_typing_indicator (struct discord *client, u64_snowflake_t channel_id)
 
ORCAcode discord_follow_news_channel (struct discord *client, const u64_snowflake_t channel_id, struct discord_follow_news_channel_params *params, struct discord_channel *p_followed_channel)
 
ORCAcode discord_get_pinned_messages (struct discord *client, const u64_snowflake_t channel_id, struct discord_message ***p_messages)
 
ORCAcode discord_pin_message (struct discord *client, const u64_snowflake_t channel_id, const u64_snowflake_t message_id)
 
ORCAcode discord_unpin_message (struct discord *client, const u64_snowflake_t channel_id, const u64_snowflake_t message_id)
 
ORCAcode discord_group_dm_add_recipient (struct discord *client, const u64_snowflake_t channel_id, const u64_snowflake_t user_id, struct discord_group_dm_add_recipient_params *params)
 
ORCAcode discord_group_dm_remove_recipient (struct discord *client, const u64_snowflake_t channel_id, const u64_snowflake_t user_id)
 
ORCAcode discord_start_thread_with_message (struct discord *client, const u64_snowflake_t channel_id, const u64_snowflake_t message_id, struct discord_start_thread_with_message_params *params, struct discord_channel *p_channel)
 
ORCAcode discord_start_thread_without_message (struct discord *client, const u64_snowflake_t channel_id, struct discord_start_thread_without_message_params *params, struct discord_channel *p_channel)
 
ORCAcode discord_join_thread (struct discord *client, const u64_snowflake_t channel_id)
 
ORCAcode discord_add_thread_member (struct discord *client, const u64_snowflake_t channel_id, const u64_snowflake_t user_id)
 
ORCAcode discord_leave_thread (struct discord *client, const u64_snowflake_t channel_id)
 
ORCAcode discord_remove_thread_member (struct discord *client, const u64_snowflake_t channel_id, const u64_snowflake_t user_id)
 
ORCAcode discord_list_thread_members (struct discord *client, const u64_snowflake_t channel_id, struct discord_thread_member ***p_thread_members)
 
ORCAcode discord_list_active_threads (struct discord *client, const u64_snowflake_t channel_id, struct discord_thread_response_body *body)
 
ORCAcode discord_list_public_archived_threads (struct discord *client, const u64_snowflake_t channel_id, const u64_unix_ms_t before, const int limit, struct discord_thread_response_body *body)
 
ORCAcode discord_list_private_archived_threads (struct discord *client, const u64_snowflake_t channel_id, const u64_unix_ms_t before, const int limit, struct discord_thread_response_body *body)
 
ORCAcode discord_list_joined_private_archived_threads (struct discord *client, const u64_snowflake_t channel_id, const u64_unix_ms_t before, const int limit, struct discord_thread_response_body *body)
 
ORCAcode discord_list_guild_emojis (struct discord *client, const u64_snowflake_t guild_id, struct discord_emoji ***p_emojis)
 
ORCAcode discord_get_guild_emoji (struct discord *client, const u64_snowflake_t guild_id, const u64_snowflake_t emoji_id, struct discord_emoji *p_emoji)
 
ORCAcode discord_create_guild_emoji (struct discord *client, const u64_snowflake_t guild_id, struct discord_create_guild_emoji_params *params, struct discord_emoji *p_emoji)
 
ORCAcode discord_modify_guild_emoji (struct discord *client, const u64_snowflake_t guild_id, const u64_snowflake_t emoji_id, struct discord_modify_guild_emoji_params *params, struct discord_emoji *p_emoji)
 
ORCAcode discord_delete_guild_emoji (struct discord *client, const u64_snowflake_t guild_id, const u64_snowflake_t emoji_id)
 
ORCAcode discord_create_guild (struct discord *client, struct discord_create_guild_params *params, struct discord_guild *p_guild)
 
ORCAcode discord_get_guild (struct discord *client, const u64_snowflake_t guild_id, struct discord_guild *p_guild)
 
ORCAcode discord_get_guild_preview (struct discord *client, const u64_snowflake_t guild_id, struct discord_guild_preview *p_guild_preview)
 
ORCAcode discord_modify_guild (struct discord *client, const u64_snowflake_t guild_id, struct discord_modify_guild_params *params, struct discord_guild *p_guild)
 
ORCAcode discord_delete_guild (struct discord *client, const u64_snowflake_t guild_id)
 
ORCAcode discord_get_guild_channels (struct discord *client, const u64_snowflake_t guild_id, struct discord_channel ***p_channels)
 
ORCAcode discord_create_guild_channel (struct discord *client, const u64_snowflake_t guild_id, struct discord_create_guild_channel_params *params, struct discord_channel *p_channel)
 
ORCAcode discord_modify_guild_channel_positions (struct discord *client, const u64_snowflake_t guild_id, struct discord_modify_guild_channel_positions_params **params)
 
ORCAcode discord_get_guild_member (struct discord *client, u64_snowflake_t guild_id, u64_snowflake_t user_id, struct discord_guild_member *p_member)
 
ORCAcode discord_list_guild_members (struct discord *client, const u64_snowflake_t guild_id, struct discord_list_guild_members_params *params, struct discord_guild_member ***p_members)
 
ORCAcode discord_search_guild_members (struct discord *client, const u64_snowflake_t guild_id, struct discord_search_guild_members_params *params, struct discord_guild_member ***p_members)
 
ORCAcode discord_modify_guild_member (struct discord *client, const u64_snowflake_t guild_id, const u64_snowflake_t user_id, struct discord_modify_guild_member_params *params, struct discord_guild_member *p_member)
 
ORCAcode discord_add_guild_member (struct discord *client, const u64_snowflake_t guild_id, const u64_snowflake_t user_id, struct discord_add_guild_member_params *params, struct discord_guild_member *p_member)
 
ORCAcode discord_modify_current_user_nick (struct discord *client, const u64_snowflake_t guild_id, const char nick[])
 
ORCAcode discord_add_guild_member_role (struct discord *client, const u64_snowflake_t guild_id, const u64_snowflake_t user_id, const u64_snowflake_t role_id)
 
ORCAcode discord_remove_guild_member_role (struct discord *client, const u64_snowflake_t guild_id, const u64_snowflake_t user_id, const u64_snowflake_t role_id)
 
ORCAcode discord_remove_guild_member (struct discord *client, const u64_snowflake_t guild_id, const u64_snowflake_t user_id)
 
ORCAcode discord_get_guild_bans (struct discord *client, const u64_snowflake_t guild_id, struct discord_guild_ban ***p_bans)
 
ORCAcode discord_get_guild_ban (struct discord *client, const u64_snowflake_t guild_id, const u64_snowflake_t user_id, struct discord_guild_ban *p_ban)
 
ORCAcode discord_create_guild_ban (struct discord *client, const u64_snowflake_t guild_id, const u64_snowflake_t user_id, int delete_message_days, const char reason[])
 
ORCAcode discord_remove_guild_ban (struct discord *client, const u64_snowflake_t guild_id, const u64_snowflake_t user_id, const char reason[])
 
ORCAcode discord_get_guild_roles (struct discord *client, const u64_snowflake_t guild_id, struct discord_permissions_role ***p_roles)
 
ORCAcode discord_create_guild_role (struct discord *client, const u64_snowflake_t guild_id, struct discord_create_guild_role_params *params, struct discord_permissions_role *p_role)
 
ORCAcode discord_modify_guild_role_positions (struct discord *client, const u64_snowflake_t guild_id, struct discord_modify_guild_role_positions_params **params, struct discord_permissions_role ***p_roles)
 
ORCAcode discord_modify_guild_role (struct discord *client, const u64_snowflake_t guild_id, const u64_snowflake_t role_id, struct discord_modify_guild_role_params *params, struct discord_permissions_role *p_role)
 
ORCAcode discord_delete_guild_role (struct discord *client, const u64_snowflake_t guild_id, const u64_snowflake_t role_id)
 
ORCAcode discord_get_invite (struct discord *client, char *invite_code, struct discord_get_invite_params *params, struct discord_invite *p_invite)
 
ORCAcode discord_delete_invite (struct discord *client, char *invite_code, struct discord_invite *p_invite)
 
ORCAcode discord_get_user (struct discord *client, const u64_snowflake_t user_id, struct discord_user *p_user)
 
ORCAcode discord_modify_current_user (struct discord *client, struct discord_modify_current_user_params *params, struct discord_user *p_user)
 
ORCAcode discord_get_current_user (struct discord *client, struct discord_user *p_user)
 
ORCAcode sb_discord_get_current_user (struct discord *client, struct sized_buffer *p_sb_user)
 
ORCAcode discord_get_current_user_guilds (struct discord *client, struct discord_guild ***p_guilds)
 
ORCAcode discord_leave_guild (struct discord *client, const u64_snowflake_t guild_id)
 
ORCAcode discord_create_dm (struct discord *client, const u64_snowflake_t recipient_id, struct discord_channel *p_dm_channel)
 
ORCAcode discord_create_group_dm (struct discord *client, struct discord_create_group_dm_params *params, struct discord_channel *p_dm_channel)
 
ORCAcode discord_get_user_connections (struct discord *client, struct discord_connection ***p_connections)
 
ORCAcode discord_list_voice_regions (struct discord *client, struct discord_voice_region ***p_voice_regions)
 
ORCAcode discord_get_gateway (struct discord *client, struct discord_session *p_session)
 
ORCAcode discord_get_gateway_bot (struct discord *client, struct discord_session *p_session)
 
void discord_embed_set_thumbnail (struct discord_embed *embed, char url[], char proxy_url[], int height, int width)
 
void discord_embed_set_image (struct discord_embed *embed, char url[], char proxy_url[], int height, int width)
 
void discord_embed_set_video (struct discord_embed *embed, char url[], char proxy_url[], int height, int width)
 
void discord_embed_set_footer (struct discord_embed *embed, char text[], char icon_url[], char proxy_icon_url[])
 
void discord_embed_set_provider (struct discord_embed *embed, char name[], char url[])
 
void discord_embed_set_author (struct discord_embed *embed, char name[], char url[], char icon_url[], char proxy_icon_url[])
 
void discord_embed_add_field (struct discord_embed *embed, char name[], char value[], bool Inline)
 
void discord_overwrite_append (struct discord_channel_overwrite ***permission_overwrites, u64_snowflake_t id, int type, enum discord_permissions_bitwise_flags allow, enum discord_permissions_bitwise_flags deny)
 
ORCAcode discord_get_channel_at_pos (struct discord *client, const u64_snowflake_t guild_id, const enum discord_channel_types type, const size_t position, struct discord_channel *p_channel)
 
ORCAcode discord_delete_messages_by_author_id (struct discord *client, u64_snowflake_t channel_id, u64_snowflake_t author_id)
 
ORCAcode discord_disconnect_guild_member (struct discord *client, const u64_snowflake_t guild_id, const u64_snowflake_t user_id, struct discord_guild_member *p_member)
 

Detailed Description

File containing public functions and datatypes.

Author
cee-studio
Date
18 Jun 2021 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

Typedef Documentation

◆ channel_cb

typedef void(* channel_cb) (struct discord *client, const struct discord_user *bot, const struct discord_channel *channel)

◆ channel_pins_update_cb

typedef void(* channel_pins_update_cb) (struct discord *client, const struct discord_user *bot, const u64_snowflake_t guild_id, const u64_snowflake_t channel_id, const u64_unix_ms_t last_pin_timestamp)

◆ event_raw_cb

typedef void(* event_raw_cb) (struct discord *client, enum discord_gateway_events event, struct sized_buffer *sb_bot, struct sized_buffer *event_data)

Raw Event callback.

If activated, this callback is triggered on any event. It is executed after every other callback has been checked.

See also
discord_set_on_raw_event()

◆ guild_ban_cb

typedef void(* guild_ban_cb) (struct discord *client, const struct discord_user *bot, const u64_snowflake_t guild_id, const struct discord_user *user)

◆ guild_member_cb

typedef void(* guild_member_cb) (struct discord *client, const struct discord_user *bot, const u64_snowflake_t guild_id, const struct discord_guild_member *member)

◆ guild_member_remove_cb

typedef void(* guild_member_remove_cb) (struct discord *client, const struct discord_user *bot, const u64_snowflake_t guild_id, const struct discord_user *user)

◆ guild_role_cb

typedef void(* guild_role_cb) (struct discord *client, const struct discord_user *bot, const u64_snowflake_t guild_id, const struct discord_permissions_role *role)

◆ guild_role_delete_cb

typedef void(* guild_role_delete_cb) (struct discord *client, const struct discord_user *bot, const u64_snowflake_t guild_id, const u64_snowflake_t role_id)

◆ idle_cb

typedef void(* idle_cb) (struct discord *client, const struct discord_user *bot)

Idle callback.

Runs on every WebSockets loop iteration, no trigger required

See also
discord_set_on_idle()

◆ message_cb

typedef void(* message_cb) (struct discord *client, const struct discord_user *bot, const struct discord_message *message)

◆ message_delete_bulk_cb

typedef void(* message_delete_bulk_cb) (struct discord *client, const struct discord_user *bot, const ja_u64 **ids, const u64_snowflake_t channel_id, const u64_snowflake_t guild_id)

Message Delete Bulk callback.

See also
https://discord.com/developers/docs/topics/gateway#messages
discord_set_on_message_delete_bulk()

◆ message_delete_cb

typedef void(* message_delete_cb) (struct discord *client, const struct discord_user *bot, const u64_snowflake_t id, const u64_snowflake_t channel_id, const u64_snowflake_t guild_id)

◆ message_reaction_add_cb

typedef void(* message_reaction_add_cb) (struct discord *client, const struct discord_user *bot, const u64_snowflake_t user_id, const u64_snowflake_t channel_id, const u64_snowflake_t message_id, const u64_snowflake_t guild_id, const struct discord_guild_member *member, const struct discord_emoji *emoji)

◆ message_reaction_remove_all_cb

typedef void(* message_reaction_remove_all_cb) (struct discord *client, const struct discord_user *bot, const u64_snowflake_t channel_id, const u64_snowflake_t message_id, const u64_snowflake_t guild_id)

◆ message_reaction_remove_cb

typedef void(* message_reaction_remove_cb) (struct discord *client, const struct discord_user *bot, const u64_snowflake_t user_id, const u64_snowflake_t channel_id, const u64_snowflake_t message_id, const u64_snowflake_t guild_id, const struct discord_emoji *emoji)

◆ message_reaction_remove_emoji_cb

typedef void(* message_reaction_remove_emoji_cb) (struct discord *client, const struct discord_user *bot, const u64_snowflake_t channel_id, const u64_snowflake_t message_id, const u64_snowflake_t guild_id, const struct discord_emoji *emoji)

◆ voice_server_update_cb

typedef void(* voice_server_update_cb) (struct discord *client, const struct discord_user *bot, const char *token, const u64_snowflake_t guild_id, const char *endpoint)

◆ voice_state_update_cb

typedef void(* voice_state_update_cb) (struct discord *client, const struct discord_user *bot, const struct discord_voice_state *voice_state)

Enumeration Type Documentation

◆ discord_event_handling_mode

Enumerator
EVENT_IS_HANDLED 

this event has been handled

EVENT_WILL_BE_HANDLED_IN_MAIN_THREAD 

handle this event in main thread

EVENT_WILL_BE_HANDLED_IN_CHILD_THREAD 

handle this event in a child thread

Function Documentation

◆ discord_add_intents()

void discord_add_intents ( struct discord client,
enum discord_gateway_intents  code 
)

Subscribe to Discord Gateway events.

Parameters
clientthe client created with discord_init()
codethe intents opcode, can be set as a bitmask operation (ex: A | B | C)
See also
https://discord.com/developers/docs/topics/gateway#gateway-intents

◆ discord_cleanup()

void discord_cleanup ( struct discord client)

Free a Discord Client handle.

Parameters
clientthe client created with discord_init()

◆ discord_config_init()

struct discord* discord_config_init ( const char  config_file[])

Create a Discord Client handle by a bot.config file.

Parameters
config_filethe bot.config file name
Returns
the newly created Discord Client handle

◆ discord_get_data()

void* discord_get_data ( struct discord client)

Received user arbitrary data associated to the client.

Parameters
clientthe client created with discord_init()
Returns
the arbitrary user data address
Warning
the user should provide his own locking mechanism to protect his data from race conditions
See also
discord_set_data()

◆ discord_init()

struct discord* discord_init ( const char  token[])

Create a Discord Client handle by its token.

Parameters
tokenthe bot token
Returns
the newly created Discord Client handle

◆ discord_remove_intents()

void discord_remove_intents ( struct discord client,
enum discord_gateway_intents  code 
)

Unsubscribe from Discord Gateway events.

Parameters
clientthe client created with discord_init()
codethe intents opcode, can be set as a bitmask operation (ex: A | B | C)
See also
https://discord.com/developers/docs/topics/gateway#gateway-intents

◆ discord_replace_presence()

void discord_replace_presence ( struct discord client,
struct discord_gateway_status_update presence 
)

Replace the Client presence with a struct discord_gateway_status_update.

Parameters
clientthe client created with discord_init()
presencethe presence to replace the client's
Note
discord_set_presence() is a more comprehensible alternative
See also
discord_set_presence()

◆ discord_run()

void discord_run ( struct discord client)

Start a connection to the Discord Gateway.

Parameters
clientthe client created with discord_init()

◆ discord_set_data()

void* discord_set_data ( struct discord client,
void *  data 
)

Keep some user arbitrary data, by associating it to the client.

Parameters
clientthe client created with discord_init()
datauser arbitrary data to be accessed via discord_get_data()
Returns
the arbitrary user data address
Warning
the user should provide his own locking mechanism to protect his data from race conditions
See also
discord_get_data()

◆ discord_set_on_channel_create()

void discord_set_on_channel_create ( struct discord client,
channel_cb  callback 
)

Set a callback that triggers when a channel is created.

Parameters
clientthe client created with discord_init()
callbackthe callback that will be executed
Note
this function will automatically set intent(s) to make the callback triggerable

◆ discord_set_on_channel_delete()

void discord_set_on_channel_delete ( struct discord client,
channel_cb  callback 
)

Set a callback that triggers when a channel is deleted.

Parameters
clientthe client created with discord_init()
callbackthe callback that will be executed
Note
this function will automatically set intent(s) to make the callback triggerable

◆ discord_set_on_channel_pins_update()

void discord_set_on_channel_pins_update ( struct discord client,
channel_pins_update_cb  callback 
)

Set a callback that triggers when some channel pins are updated.

Parameters
clientthe client created with discord_init()
callbackthe callback that will be executed
Note
this function will automatically set intent(s) to make the callback triggerable

◆ discord_set_on_channel_update()

void discord_set_on_channel_update ( struct discord client,
channel_cb  callback 
)

Set a callback that triggers when a channel is updated.

Parameters
clientthe client created with discord_init()
callbackthe callback that will be executed
Note
this function will automatically set intent(s) to make the callback triggerable

◆ discord_set_on_command()

void discord_set_on_command ( struct discord client,
char *  command,
message_cb  callback 
)

Set command/callback pair, the callback is triggered if someone types command in chat.

Parameters
clientthe client created with discord_init()
commandthe command to trigger the callback
callbackthe callback that will be executed
Note
The command and any subjacent empty space is left out of discord_message::content
See also
discord_set_prefix() for changing a command prefix

◆ discord_set_on_event_raw()

void discord_set_on_event_raw ( struct discord client,
event_raw_cb  callback 
)

Set a callback that triggers on any event the client is subscribed to.

Note
the callback will be executed last, after every other has been checked
this gives the raw JSON payload associated with the event
Parameters
clientthe client created with discord_init()
callbackthe callback that will be executed

◆ discord_set_on_guild_ban_add()

void discord_set_on_guild_ban_add ( struct discord client,
guild_ban_cb  callback 
)

Set a callback that triggers when a guild ban is added.

Parameters
clientthe client created with discord_init()
callbackthe callback that will be executed
Note
this function will automatically set intent(s) to make the callback triggerable

◆ discord_set_on_guild_ban_remove()

void discord_set_on_guild_ban_remove ( struct discord client,
guild_ban_cb  callback 
)

Set a callback that triggers when a guild ban is removed.

Parameters
clientthe client created with discord_init()
callbackthe callback that will be executed
Note
this function will automatically set intent(s) to make the callback triggerable

◆ discord_set_on_guild_member_add()

void discord_set_on_guild_member_add ( struct discord client,
guild_member_cb  callback 
)

Set a callback that triggers when a guild member is added.

Parameters
clientthe client created with discord_init()
callbackthe callback that will be executed
Note
this function will automatically set intent(s) to make the callback triggerable

◆ discord_set_on_guild_member_remove()

void discord_set_on_guild_member_remove ( struct discord client,
guild_member_remove_cb  callback 
)

Set a callback that triggers when a guild member is removed.

Parameters
clientthe client created with discord_init()
callbackthe callback that will be executed
Note
this function will automatically set intent(s) to make the callback triggerable

◆ discord_set_on_guild_member_update()

void discord_set_on_guild_member_update ( struct discord client,
guild_member_cb  callback 
)

Set a callback that triggers when a guild member is updated.

Parameters
clientthe client created with discord_init()
callbackthe callback that will be executed
Note
this function will automatically set intent(s) to make the callback triggerable

◆ discord_set_on_guild_role_create()

void discord_set_on_guild_role_create ( struct discord client,
guild_role_cb  callback 
)

Set a callback that triggers when a guild role is created.

Parameters
clientthe client created with discord_init()
callbackthe callback that will be executed
Note
this function will automatically set intent(s) to make the callback triggerable

◆ discord_set_on_guild_role_delete()

void discord_set_on_guild_role_delete ( struct discord client,
guild_role_delete_cb  callback 
)

Set a callback that triggers when a guild role is deleted.

Parameters
clientthe client created with discord_init()
callbackthe callback that will be executed
Note
this function will automatically set intent(s) to make the callback triggerable

◆ discord_set_on_guild_role_update()

void discord_set_on_guild_role_update ( struct discord client,
guild_role_cb  callback 
)

Set a callback that triggers when a guild role is updated.

Parameters
clientthe client created with discord_init()
callbackthe callback that will be executed
Note
this function will automatically set intent(s) to make the callback triggerable

◆ discord_set_on_idle()

void discord_set_on_idle ( struct discord client,
idle_cb  callback 
)

Set a callback that triggers at every event-loop iteration.

Parameters
clientthe client created with discord_init()
callbackthe callback that will be executed

◆ discord_set_on_message_create()

void discord_set_on_message_create ( struct discord client,
message_cb  callback 
)

Set a callback that triggers when a message is created.

Parameters
clientthe client created with discord_init()
callbackthe callback that will be executed
Note
this function will automatically set intent(s) to make the callback triggerable

◆ discord_set_on_message_delete()

void discord_set_on_message_delete ( struct discord client,
message_delete_cb  callback 
)

Set a callback that triggers when a message is deleted.

Parameters
clientthe client created with discord_init()
callbackthe callback that will be executed
Note
this function will automatically set intent(s) to make the callback triggerable

◆ discord_set_on_message_reaction_add()

void discord_set_on_message_reaction_add ( struct discord client,
message_reaction_add_cb  callback 
)

Set a callback that triggers when a message reaction is added.

Parameters
clientthe client created with discord_init()
callbackthe callback that will be executed
Note
this function will automatically set intent(s) to make the callback triggerable

◆ discord_set_on_message_reaction_remove()

void discord_set_on_message_reaction_remove ( struct discord client,
message_reaction_remove_cb  callback 
)

Set a callback that triggers when a message reaction is removed.

Parameters
clientthe client created with discord_init()
callbackthe callback that will be executed
Note
this function will automatically set intent(s) to make the callback triggerable

◆ discord_set_on_message_reaction_remove_all()

void discord_set_on_message_reaction_remove_all ( struct discord client,
message_reaction_remove_all_cb  callback 
)

Set a callback that triggers when all reaction from some message is removed.

Parameters
clientthe client created with discord_init()
callbackthe callback that will be executed
Note
this function will automatically set intent(s) to make the callback triggerable

◆ discord_set_on_message_reaction_remove_emoji()

void discord_set_on_message_reaction_remove_emoji ( struct discord client,
message_reaction_remove_emoji_cb  callback 
)

Set a callback that triggers when all instances of a particular reaction from some message is removed.

Parameters
clientthe client created with discord_init()
callbackthe callback that will be executed
Note
this function will automatically set intent(s) to make the callback triggerable

◆ discord_set_on_message_update()

void discord_set_on_message_update ( struct discord client,
message_cb  callback 
)

Set a callback that triggers when a message is updated.

Parameters
clientthe client created with discord_init()
callbackthe callback that will be executed
Note
this function will automatically set intent(s) to make the callback triggerable

◆ discord_set_on_ready()

void discord_set_on_ready ( struct discord client,
idle_cb  callback 
)

Set a callback that triggers when the client is ready.

Parameters
clientthe client created with discord_init()
callbackthe callback that will be executed
Note
this function will automatically set intent(s) to make the callback triggerable

◆ discord_set_on_voice_server_update()

void discord_set_on_voice_server_update ( struct discord client,
voice_server_update_cb  callback 
)

Set a callback that triggers when a voice server is updated.

Parameters
clientthe client created with discord_init()
callbackthe callback that will be executed
Note
this function will automatically set intent(s) to make the callback triggerable

◆ discord_set_on_voice_state_update()

void discord_set_on_voice_state_update ( struct discord client,
voice_state_update_cb  callback 
)

Set a callback that triggers when a voice state is updated.

Parameters
clientthe client created with discord_init()
callbackthe callback that will be executed
Note
this function will automatically set intent(s) to make the callback triggerable

◆ discord_set_prefix()

void discord_set_prefix ( struct discord client,
char *  prefix 
)

Set a mandatory prefix before commands.

Example: If 'help' is a command and '!' prefix is set, the command will only be validated if '!help' is sent

Parameters
clientthe client created with discord_init()
prefixthe prefix that should accompany any command
See also
discord_set_on_command()

◆ discord_set_presence()

void discord_set_presence ( struct discord client,
struct discord_gateway_activity activity,
char  status[],
bool  afk 
)

Modify the Client presence state.

Parameters
clientthe client created with discord_init()
activitythe user current activities
statuseither "idle","dnd","online", or "offline"
afkTRUE or FALSE

◆ discord_set_voice_cbs()

void discord_set_voice_cbs ( struct discord client,
struct discord_voice_cbs callbacks 
)

Helper to quickly set voice callbacks.

Parameters
clientthe client created with discord_init()
callbacksthe voice callbacks that will be executed