dscrd
Discord C library
Data Structures | Macros | Typedefs | Enumerations | Functions
dscrd.h File Reference
#include <stdint.h>
#include <stdbool.h>
Include dependency graph for dscrd.h:

Go to the source code of this file.

Data Structures

struct  DiscordActivity_s
 Activity object (game) More...
 
struct  DiscordUser_s
 Discord user. More...
 
struct  DiscordClient_s
 Discord session. More...
 
struct  DscrdAuth_s
 
struct  DiscordGuild_s
 Discord guild. More...
 
struct  DiscordChannel_s
 Discord channel. More...
 
struct  DiscordChannelList_s
 
struct  DscrdFile_s
 Discord file wrapper. More...
 
struct  DiscordMessage_s
 
struct  Webhook_s
 Webhook structure. More...
 
struct  WebhookList_s
 WebhookList structure. More...
 
struct  GatewayResp_s
 

Macros

#define DISCORD_API   6
 
#define ID(X)   X ## "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
 
#define TOKEN_TO_STR(X)   (X == Bearer) ? "Bearer" : (X == Bot) ? "Bot" : (X == User) ? "User" : ""
 
#define DiscordClient_open_auth(X)   DiscordClient_open((X)->type, (X)->token)
 
#define DSCRD_FILE_NULL   ((DscrdFile *) "dummy")
 Use this if you want to reset avatar (needed to distinguish from not changing avatar) More...
 

Typedefs

typedef enum dscrd_type_e dscrd_type
 Discord datatypes. More...
 
typedef enum permissions_e permissions
 Permissions also described at https://discordapp.com/developers/docs/topics/permissions. More...
 
typedef struct DiscordActivity_s DiscordActivity
 Activity object (game) More...
 
typedef struct DiscordUser_s DiscordUser
 Discord user. More...
 
typedef enum token_type_e token_type
 
typedef struct DiscordClient_s DiscordClient
 Discord session. More...
 
typedef struct DscrdAuth_s DscrdAuth
 
typedef struct DiscordGuild_s DiscordGuild
 Discord guild. More...
 
typedef struct DiscordChannel_s DiscordChannel
 Discord channel. More...
 
typedef struct DiscordChannelList_s DiscordChannelList
 
typedef struct DscrdFile_s DscrdFile
 Discord file wrapper. More...
 
typedef struct DiscordMessage_s DiscordMessage
 
typedef struct Webhook_s Webhook
 Webhook structure. More...
 
typedef struct WebhookList_s WebhookList
 WebhookList structure. More...
 
typedef struct GatewayResp_s GatewayResp
 

Enumerations

enum  http_method {
  HTTP_POST, HTTP_GET, HTTP_PUT, HTTP_DELETE,
  HTTP_HEAD, HTTP_OPTIONS, HTTP_PATCH
}
 HTTP Methods. More...
 
enum  dscrd_type_e {
  DSCRD_TYPE_FIRST, DSCRD_GUILD, DSCRD_CHANNEL, DSCRD_USER,
  DSCRD_WEBHOOK, DSCRD_CLIENT, DSCRD_REST_RESP, DSCRD_FILE,
  DSCRD_MESSAGE, DSCRD_TYPE_LAST, DSCRD_TYPE_LIST = 256
}
 Discord datatypes. More...
 
enum  dscrd_verification_level {
  NONE, LOW, MEDIUM, HIGH,
  VERY_HIGH
}
 
enum  permissions_e {
  CREATE_INSTANT_INVITE = 0x00000001, KICK_MEMBERS = 0x00000002, BAN_MEMBERS = 0x00000004, ADMINISTRATOR = 0x00000008,
  MANAGE_CHANNELS = 0x00000010, MANAGE_GUILD = 0x00000020, ADD_REACTIONS = 0x00000040, VIEW_AUDIT_LOG = 0x00000080,
  VIEW_CHANNEL = 0x00000400, SEND_MESSAGES = 0x00000800, SEND_TTS_MESSAGES = 0x00001000, MANAGE_MESSAGES = 0x00002000,
  EMBED_LINKS = 0x00004000, ATTACH_FILES = 0x00008000, READ_MESSAGE_HISTORY = 0x00010000, MENTION_EVERYONE = 0x00020000,
  USE_EXTERNAL_EMOJIS = 0x00040000, CONNECT = 0x00100000, SPEAK = 0x00200000, MUTE_MEMBERS = 0x00400000,
  DEAFEN_MEMBERS = 0x00800000, MOVE_MEMBERS = 0x01000000, USE_VAD = 0x02000000, PRIORITY_SPEAKER = 0x00000100,
  CHANGE_NICKNAME = 0x04000000, MANAGE_NICKNAMES = 0x08000000, MANAGE_ROLES = 0x10000000, MANAGE_WEBHOOKS = 0x20000000,
  MANAGE_EMOJI = 0x40000000
}
 Permissions also described at https://discordapp.com/developers/docs/topics/permissions. More...
 
enum  activity_types { ACTIVITY_GAME, ACTIVITY_STREAMING, ACTIVITY_LISTENING }
 Activity types. More...
 
enum  dscrd_user_status {
  STATUS_ONLINE, STATUS_DND, STATUS_IDLE, STATUS_INVISIBLE,
  STATUS_OFFLINE
}
 User status. More...
 
enum  token_type_e { Bearer, Bot, User, Anonymous }
 
enum  gateway_flags { LAZYLOAD_GUILDS = 1, GATEWAY_FLAGS_LAST = 2 }
 
enum  channel_types {
  GUILD_TEXT, DM, GUILD_VOICE, GROUP_DM,
  GUILD_CATEGORY
}
 Channel types. More...
 
enum  message_types {
  DEFAULT, RECIPIENT_ADD, RECIPIENT_REMOVE, CALL,
  CHANNEL_NAME_CHANGE, CHANNEL_ICON_CHANGE, CHANNEL_PINNED_MESSAGE, GUILD_MEMBER_JOIN
}
 
enum  gateway_callback_resp { CALLBACK_OK, CALLBACK_ABORT }
 

Functions

int dscrd_has_gateway (void)
 
const char * dscrd_error (void)
 
const char * dscrd_error_long (void)
 
void dscrd_overwrite_api (int api)
 
int dscrd_initialize (void)
 
int dscrd_terminate (void)
 
DiscordUserDiscordUser_me (struct DiscordClient_s *client)
 
DiscordUserDiscordUser_get (struct DiscordClient_s *client, char *user_id)
 
void DiscordUser_destroy (DiscordUser *user)
 
DiscordClientDiscordClient_open (token_type type, const char *token)
 
void DiscordClient_close (DiscordClient *d)
 
int DiscordClient_gateway (DiscordClient *client, int flags)
 
int DiscordClient_set_status (DiscordClient *client, enum dscrd_user_status status)
 
int DiscordClient_set_game (DiscordClient *client, DiscordActivity *activity)
 
int dscrdd_auth (DscrdAuth *auth, const char *app_name)
 
DiscordGuildDiscordGuild_get (DiscordClient *client, char *guild_id)
 
DiscordGuildDiscordGuild_by_name (DiscordClient *client, char *guild_name)
 
DiscordGuild ** DiscordGuilds_get (DiscordClient *client)
 
void DiscordGuilds_destroy (DiscordGuild **guilds)
 
void DiscordGuild_destroy (DiscordGuild *guild)
 
DiscordChannelDiscordChannel_get (DiscordClient *client, char *channel_id)
 
DiscordChannelDiscordChannel_get_fast (DiscordClient *client, char *channel_id)
 
int DiscordChannel_modify (DiscordChannel *channel,...)
 
DiscordChannelDiscordChannel_by_name (DiscordGuild *guild, char *channel_name)
 
int DiscordChannel_send_message_simple (DiscordChannel *channel, const char *message)
 
DiscordChannelListDiscordChannels_in_guild (DiscordGuild *guild)
 
DiscordChannelDiscordChannelList_pop (DiscordChannelList *list, int i)
 
void DiscordChannelList_destroy (DiscordChannelList *channels)
 
void DiscordChannel_destroy (DiscordChannel *channel)
 
DscrdFileDscrdFile_get (const char *filename)
 
DscrdFileDscrdFile_get_mime (const char *filename, const char *mime_type)
 
void DscrdFile_destroy (DscrdFile *file)
 
int DiscordMessage_callback_all (DiscordClient *client, int(*callback)(DiscordMessage *))
 TODO. More...
 
int DiscordMessage_callback_mentions (DiscordClient *client, int(*callback)(DiscordMessage *))
 
int DiscordMessage_delete_id (DiscordClient *client, const char *channel_id, const char *message_id)
 Delete message after channel and message id. More...
 
int DiscordMessage_delete (DiscordMessage *message)
 Delete specified message. More...
 
DiscordMessageDiscordMessage_new_simple (DiscordChannel *channel, const char *message)
 new message (returns back) More...
 
void DiscordMessage_destroy (DiscordMessage *msg)
 
DiscordMessageDiscordMessage_get (DiscordChannel *channel, char *message_id)
 
WebhookWebhook_get (DiscordClient *client, char *id)
 
WebhookWebhook_get_no_auth (char *id, char *token)
 
WebhookWebhook_get_no_auth_url (const char *url)
 
WebhookWebhook_create (DiscordChannel *channel, char *name, DscrdFile *avatar)
 
void Webhook_destroy (Webhook *webhook)
 
int Webhook_execute (Webhook *webhook, const char *message, const char *username, const char *avatar_url)
 
int Webhook_execute_simple (Webhook *webhook, const char *message)
 
int Webhook_delete (Webhook *webhook)
 
int Webhook_modify (Webhook *webhook, const char *name, DscrdFile *avatar)
 
int Webhook_move (Webhook *webhook, DiscordChannel *channel)
 
WebhookListWebhooks_in_channel (DiscordClient *client, DiscordChannel *channel)
 
WebhookListWebhooks_in_guild (DiscordClient *client, DiscordGuild *guild)
 
void WebhookList_destroy (WebhookList *list)
 
struct DiscordGuild_s ** DiscordClient_lazy_guilds (DiscordClient *client)
 
int DiscordGateway_callback (DiscordClient *client, char *event, int(*func)(GatewayResp *), void *userdata)
 

Macro Definition Documentation

◆ DISCORD_API

#define DISCORD_API   6

Discord API version library was compiled for

◆ DiscordClient_open_auth

#define DiscordClient_open_auth (   X)    DiscordClient_open((X)->type, (X)->token)

Same as DiscordClient_open but takes DscrdAuth as an argument. It's a macro.

Parameters
Xpointer to DscrdAuth
Returns
DiscordClient* on success
NULL on failure
See also
DiscordClient_open dscrdd_auth

◆ DSCRD_FILE_NULL

#define DSCRD_FILE_NULL   ((DscrdFile *) "dummy")

Use this if you want to reset avatar (needed to distinguish from not changing avatar)

◆ ID

#define ID (   X)    X ## "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"

◆ TOKEN_TO_STR

#define TOKEN_TO_STR (   X)    (X == Bearer) ? "Bearer" : (X == Bot) ? "Bot" : (X == User) ? "User" : ""

Typedef Documentation

◆ DiscordActivity

Activity object (game)

Note
Bots are only able to send name, type, and optionally url.
See also
DiscordActivity_s for detailed element documentation

◆ DiscordChannel

Discord channel.

See also
DiscordChannel_s for detailed element documentation.
Todo:
detailed element documentation

◆ DiscordChannelList

◆ DiscordClient

Discord session.

You should not access any values except DiscordClient::me / DiscordClient::user and DiscordClient::api

See also
DiscordClient_s for detailed element documentation.
DiscordClient_open for getting such session.

◆ DiscordGuild

typedef struct DiscordGuild_s DiscordGuild

Discord guild.

See also
DiscordGuild_s for detailed element documentation.

◆ DiscordMessage

◆ DiscordUser

typedef struct DiscordUser_s DiscordUser

Discord user.

See also
DiscordUser_s for detailed element documentation.

◆ dscrd_type

typedef enum dscrd_type_e dscrd_type

Discord datatypes.

See also
dscrd_type_e for detailed element documentation.

◆ DscrdAuth

typedef struct DscrdAuth_s DscrdAuth

DscrdAuth structure

See also
DscrdAuth_s

◆ DscrdFile

typedef struct DscrdFile_s DscrdFile

Discord file wrapper.

See also
DscrdFile_s for detailed element documentation.
Todo:
detailed element documentation

◆ GatewayResp

typedef struct GatewayResp_s GatewayResp

◆ permissions

typedef enum permissions_e permissions

◆ token_type

typedef enum token_type_e token_type

Type of the token

◆ Webhook

typedef struct Webhook_s Webhook

Webhook structure.

See also
Webhook_s for detailed element documentation.

◆ WebhookList

typedef struct WebhookList_s WebhookList

WebhookList structure.

See also
WebhookList_s for detailed element documentation.

Enumeration Type Documentation

◆ activity_types

Activity types.

Note
Bots are only able to send name, type, and optionally url.
See also
DiscordActivity_s for detailed element documentation
Enumerator
ACTIVITY_GAME 

Playing ...

ACTIVITY_STREAMING 

Streaming ...

ACTIVITY_LISTENING 

Listening to ...

◆ channel_types

Channel types.

Possible types to be found in DiscordChannel::type

Enumerator
GUILD_TEXT 
DM 
GUILD_VOICE 
GROUP_DM 
GUILD_CATEGORY 

◆ dscrd_type_e

Discord datatypes.

See also
dscrd_type_e for detailed element documentation.
Enumerator
DSCRD_TYPE_FIRST 

0 element, will be set if uninitialized, therefore ignored

DSCRD_GUILD 

DiscordGuild

DSCRD_CHANNEL 

DiscordChannel

DSCRD_USER 

DiscordUser

DSCRD_WEBHOOK 

Webhook

DSCRD_CLIENT 

DiscordClient

DSCRD_REST_RESP 

RestResp

DSCRD_FILE 

DscrdFile

DSCRD_MESSAGE 

DiscordMessage

DSCRD_TYPE_LAST 

indicates last value of types

DSCRD_TYPE_LIST 

◆ dscrd_user_status

User status.

Enumerator
STATUS_ONLINE 

Online.

STATUS_DND 

Do not disturb.

STATUS_IDLE 

AFK.

STATUS_INVISIBLE 

Shown as offline.

STATUS_OFFLINE 

Offline.

◆ dscrd_verification_level

Enumerator
NONE 

unrestricted

LOW 

must have verified email on account

MEDIUM 

must be registered on Discord for longer than 5 minutes

HIGH 

must be a member of the server for longer than 10 minutes

VERY_HIGH 

must have a verified phone number

◆ gateway_callback_resp

Enumerator
CALLBACK_OK 
CALLBACK_ABORT 

◆ gateway_flags

Enumerator
LAZYLOAD_GUILDS 
GATEWAY_FLAGS_LAST 

◆ http_method

HTTP Methods.

HTTP Methods which can be used to call REST library.

Enumerator
HTTP_POST 
HTTP_GET 
HTTP_PUT 
HTTP_DELETE 
HTTP_HEAD 
HTTP_OPTIONS 
HTTP_PATCH 

◆ message_types

Enumerator
DEFAULT 
RECIPIENT_ADD 
RECIPIENT_REMOVE 
CALL 
CHANNEL_NAME_CHANGE 
CHANNEL_ICON_CHANGE 
CHANNEL_PINNED_MESSAGE 
GUILD_MEMBER_JOIN 

◆ permissions_e

Permissions also described at https://discordapp.com/developers/docs/topics/permissions.

Enumerator
CREATE_INSTANT_INVITE 

Allows creation of instant invites.

KICK_MEMBERS 

Allows kicking members.

BAN_MEMBERS 

Allows banning members.

ADMINISTRATOR 

Allows all permissions and bypasses channel permission overwrites.

MANAGE_CHANNELS 

Allows management and editing of channels.

MANAGE_GUILD 

Allows management and editing of the guild.

ADD_REACTIONS 

Allows for the addition of reactions to messages.

VIEW_AUDIT_LOG 

Allows for viewing of audit logs.

VIEW_CHANNEL 

Allows guild members to view a channel, which includes reading messages in text channels.

SEND_MESSAGES 

Allows for sending messages in a channel.

SEND_TTS_MESSAGES 

Allows for sending of /tts messages.

MANAGE_MESSAGES 

Allows for deletion of other users messages.

EMBED_LINKS 

Links sent by users with this permission will be auto-embedded.

ATTACH_FILES 

Allows for uploading images and files.

READ_MESSAGE_HISTORY 

Allows for reading of message history.

MENTION_EVERYONE 

Allows for using the @everyone tag to notify all users in a channel, and the @here tag to notify all online users in a channel.

USE_EXTERNAL_EMOJIS 

Allows the usage of custom emojis from other servers.

CONNECT 

Allows for joining of a voice channel.

SPEAK 

Allows for speaking in a voice channel.

MUTE_MEMBERS 

Allows for muting members in a voice channel.

DEAFEN_MEMBERS 

Allows for deafening of members in a voice channel.

MOVE_MEMBERS 

Allows for moving of members between voice channels.

USE_VAD 

Allows for using voice-activity-detection in a voice channel.

PRIORITY_SPEAKER 

Allows for using priority speaker in a voice channel.

CHANGE_NICKNAME 

Allows for modification of own nickname.

MANAGE_NICKNAMES 

Allows for modification of other users nicknames.

MANAGE_ROLES 

Allows management and editing of roles.

MANAGE_WEBHOOKS 

Allows management and editing of webhooks.

MANAGE_EMOJI 

Allows management and editing of emojis.

◆ token_type_e

Type of the token

Enumerator
Bearer 
Bot 
User 
Anonymous 

Function Documentation

◆ DiscordChannel_by_name()

DiscordChannel* DiscordChannel_by_name ( DiscordGuild guild,
char *  channel_name 
)

Gets DiscordChannel after specified channel name in specified guild.

Returned pointer has to be freed with DiscordChannel_destroy.

Parameters
guildDiscordGuild pointer
channel_namechannel name in guild
Returns
pointer to DiscordChannel on success
NULL on failure

◆ DiscordChannel_destroy()

void DiscordChannel_destroy ( DiscordChannel channel)

Frees DiscordChannel pointer.

Parameters
channelDiscordChannel pointer

◆ DiscordChannel_get()

DiscordChannel* DiscordChannel_get ( DiscordClient client,
char *  channel_id 
)

Gets DiscordChannel after specified channel id. You can get channel id manually by enabling discord developer mode (Settings/Apperance/Developer Mode), and right-clicking desired channel

Returned pointer has to be freed with DiscordChannel_destroy.

Parameters
clientDiscordClient session
channel_idchannel ID
Returns
pointer to DiscordChannel on success
NULL on failure
Note
Friendly reminder: Look forward to not hard-code any channel id in your code.

◆ DiscordChannel_get_fast()

DiscordChannel* DiscordChannel_get_fast ( DiscordClient client,
char *  channel_id 
)

Gets DiscordChannel after specified channel id. In comparison to DiscordChannel, this will not load any external information about the channel from Discord servers.

Returned pointer has to be freed with DiscordChannel_destroy.

Parameters
clientDiscordClient session
channel_idchannel ID
Returns
pointer to DiscordChannel on success
NULL on failure
See also
DiscordChannel_get

◆ DiscordChannel_modify()

int DiscordChannel_modify ( DiscordChannel channel,
  ... 
)

Modifies DiscordChannel specified values. Changes are listed in pairs also: "key",(value), ...

Parameters
channelDiscordChannel pointer
...key {"name", ...}
...value (type depends on key)
...
Returns
0 on success
NOT 0 on failure
Todo:
write this function :)

◆ DiscordChannel_send_message_simple()

int DiscordChannel_send_message_simple ( DiscordChannel channel,
const char *  message 
)

Sends text message to given channel.

Parameters
channelDiscordChannel pointer
messagemessage string
Returns
0 on success
NOT 0 on failure

◆ DiscordChannelList_destroy()

void DiscordChannelList_destroy ( DiscordChannelList channels)

Frees DiscordChannelList pointer.

Parameters
channelsDiscordChannelList pointer

◆ DiscordChannelList_pop()

DiscordChannel* DiscordChannelList_pop ( DiscordChannelList list,
int  i 
)

Removes specified element from DiscordChannelList and returns it.

Parameters
listDiscordChannelList
ielement number
Returns
DiscordChannel pointer

◆ DiscordChannels_in_guild()

DiscordChannelList* DiscordChannels_in_guild ( DiscordGuild guild)

Gets DiscordChannelList for current user. Returned pointer has to be freed with DiscordChannelList_destroy.

Parameters
guildDiscordGuild pointer
Returns
pointer to DiscordChannelList on success
NULL on failure

◆ DiscordClient_close()

void DiscordClient_close ( DiscordClient d)

Close Discord session. You should free any resources allocated with given DiscordClient before you close it. dscrd traces allocations and will notify you if you did not free all resources.

Parameters
dpointer to DiscordClient session to close
See also
DiscordClient_open

◆ DiscordClient_gateway()

int DiscordClient_gateway ( DiscordClient client,
int  flags 
)

Enable Gateway API for specific client. It will try to connect and authenticate to the Discord Gateway API.

Parameters
clientDiscordClient session
flagsGateway flags, ORed values of gateway_flags
Returns
0 on success
NOT 0 on failure
See also
dscrd_has_gateway()

◆ DiscordClient_lazy_guilds()

struct DiscordGuild_s** DiscordClient_lazy_guilds ( DiscordClient client)

Loads lazyloaded DiscordGuild. Returned pointers will be freed automatically on gateway close.

Parameters
clientDiscordClient session
Returns
pointer to DiscordGuild array on success
NULL on failure

◆ DiscordClient_open()

DiscordClient* DiscordClient_open ( token_type  type,
const char *  token 
)

Start Discord session. Every session is bound to specified user/bot. Authentication credentials are passed to this function. DiscordClient is needed for most of the dscrd library functions. After you're done with your session you need to free DiscordClient using DiscordClient_close.

Parameters
typetype of the token you're passing, one of token_type_e
tokenpointer to token string
Returns
DiscordClient* on success
NULL on failure
See also
DiscordClient_close

◆ DiscordClient_set_game()

int DiscordClient_set_game ( DiscordClient client,
DiscordActivity activity 
)

Set game for DiscordClient

Returns
0 on success
NOT 0 on failure
See also
dscrd_has_gateway()
Note
This function requires DiscordClient_gateway to be enabled.

◆ DiscordClient_set_status()

int DiscordClient_set_status ( DiscordClient client,
enum dscrd_user_status  status 
)

Set status for DiscordClient

Returns
0 on success
NOT 0 on failure
See also
dscrd_has_gateway()
Note
This function requires DiscordClient_gateway to be enabled.

◆ DiscordGateway_callback()

int DiscordGateway_callback ( DiscordClient client,
char *  event,
int(*)(GatewayResp *)  func,
void *  userdata 
)

◆ DiscordGuild_by_name()

DiscordGuild* DiscordGuild_by_name ( DiscordClient client,
char *  guild_name 
)

Gets DiscordGuild after specified guild name. Returned pointer has to be freed with DiscordGuild_destroy.

Parameters
clientDiscordClient session
guild_nameguild name
Returns
pointer to DiscordGuild on success
NULL on failure

◆ DiscordGuild_destroy()

void DiscordGuild_destroy ( DiscordGuild guild)

Frees DiscordGuild pointer.

Parameters
guildDiscordGuild pointer

◆ DiscordGuild_get()

DiscordGuild* DiscordGuild_get ( DiscordClient client,
char *  guild_id 
)

Gets DiscordGuild after specified guild id. You can get guild id manually by enabling discord developer mode (Settings/Apperance/Developer Mode), and right-clicking desired guild. Returned pointer has to be freed with DiscordGuild_destroy.

Parameters
clientDiscordClient session
guild_idguild ID
Returns
pointer to DiscordGuild on success
NULL on failure

◆ DiscordGuilds_destroy()

void DiscordGuilds_destroy ( DiscordGuild **  guilds)

Frees DiscordGuild pointer array.

Parameters
guildDiscordGuild array

◆ DiscordGuilds_get()

DiscordGuild** DiscordGuilds_get ( DiscordClient client)

Gets DiscordGuild ** for current user. As stated in discord API documentation it will return maximally 100 guilds. Returned pointer has to be freed with DiscordGuilds_destroy.

Parameters
clientDiscordClient session
Returns
DiscordGuild ** on success
NULL on failure

◆ DiscordMessage_callback_all()

int DiscordMessage_callback_all ( DiscordClient client,
int(*)(DiscordMessage *)  callback 
)

TODO.

◆ DiscordMessage_callback_mentions()

int DiscordMessage_callback_mentions ( DiscordClient client,
int(*)(DiscordMessage *)  callback 
)

◆ DiscordMessage_delete()

int DiscordMessage_delete ( DiscordMessage message)

Delete specified message.

◆ DiscordMessage_delete_id()

int DiscordMessage_delete_id ( DiscordClient client,
const char *  channel_id,
const char *  message_id 
)

Delete message after channel and message id.

◆ DiscordMessage_destroy()

void DiscordMessage_destroy ( DiscordMessage msg)

◆ DiscordMessage_get()

DiscordMessage* DiscordMessage_get ( DiscordChannel channel,
char *  message_id 
)

◆ DiscordMessage_new_simple()

DiscordMessage* DiscordMessage_new_simple ( DiscordChannel channel,
const char *  message 
)

new message (returns back)

◆ DiscordUser_destroy()

void DiscordUser_destroy ( DiscordUser user)

Frees DiscordUser pointer.

Parameters
userDiscordUser_s pointer

◆ DiscordUser_get()

DiscordUser* DiscordUser_get ( struct DiscordClient_s client,
char *  user_id 
)

Get user information after user id. Returned pointer has to be freed with DiscordUser_destroy.

Parameters
clientDiscordClient session
user_iduser ID string
Returns
pointer to DiscordUser_s on success
NULL on failure

◆ DiscordUser_me()

DiscordUser* DiscordUser_me ( struct DiscordClient_s client)

Get current user information. Returned pointer has to be freed with DiscordUser_destroy.

Parameters
clientDiscordClient session
Returns
pointer to DiscordUser_s on success
NULL on failure
Deprecated:

dscrd gets current user information when opening new client.

You can access it through DiscordClient::me or DiscordClient::user pointer.

◆ dscrd_error()

const char* dscrd_error ( void  )

Read last error message.

See also
dscrd_error_long

◆ dscrd_error_long()

const char* dscrd_error_long ( void  )

Read last error message. In comparison to dscrd_error() this function will show in what function error happened.

See also
dscrd_error

◆ dscrd_has_gateway()

int dscrd_has_gateway ( void  )

Checks if library has gateway support.

Returns
0 if library was compiled without gateway support, all gateway functions will fail
1 if library supports Gateway API
See also
DiscordClient_gateway() - to be called if Gateway API will be used

◆ dscrd_initialize()

int dscrd_initialize ( void  )

Initialize dscrd library. You should call this function before calling any other function.

Returns
0 on success
See also
dscrd_terminate
Note
At the time of writing this function always returns 0.

◆ dscrd_overwrite_api()

void dscrd_overwrite_api ( int  api)

Overwrite library API version dscrd uses. For current Discord API version look https://discordapp.com/developers/docs/reference#api-versioning-api-versions

Parameters
apiAPI version number
See also
DISCORD_API

◆ dscrd_terminate()

int dscrd_terminate ( void  )

Terminate dscrd library. Call this function if you're done with dscrd library. You should not call any library function after this function.

Returns
0 on success
See also
dscrd_initialize
Note
At the time of writing this function always returns 0.

◆ dscrdd_auth()

int dscrdd_auth ( DscrdAuth auth,
const char *  app_name 
)

Try to connect to dscrdd (dscrd daemon) to receive credentials for given app.

Parameters
authpointer to DscrdAuth to write data into
app_namename of the application
Returns
0 on success
NOT 0 on failure
Todo:
It's possible that in the future app_name can take password and/or instance number
See also
dscrdd

◆ DscrdFile_destroy()

void DscrdFile_destroy ( DscrdFile file)

Frees DscrdFile pointer.

Parameters
fileDscrdFile pointer

◆ DscrdFile_get()

DscrdFile* DscrdFile_get ( const char *  filename)

Returns DscrdFile pointer for specified filename. Returned pointer has to be freed with DscrdFile_destroy.

Parameters
filenamepath to file
Returns
pointer to DscrdFile on success
NULL on failure
See also
DscrdFile_get_mime

◆ DscrdFile_get_mime()

DscrdFile* DscrdFile_get_mime ( const char *  filename,
const char *  mime_type 
)

Returns DscrdFile pointer for specified filename. In comparsion to DscrdFile_get here you can specify MIME type by yourself Returned pointer has to be freed with DscrdFile_destroy.

Parameters
filenamepath to file
mime_typeMIME-type string
Returns
pointer to DscrdFile on success
NULL on failure

◆ Webhook_create()

Webhook* Webhook_create ( DiscordChannel channel,
char *  name,
DscrdFile avatar 
)

Creates new webhook in given channel. Returned pointer has to be freed with Webhook_destroy.

Parameters
channelDiscordChannel pointer
namewebhook name
avataravatar data
Returns
pointer to Webhook on success
NULL on failure

◆ Webhook_delete()

int Webhook_delete ( Webhook webhook)

Deletes Webhook from Discord servers.

Parameters
webhookWebhook pointer
Returns
0 on success
NOT 0 on failure
Warning
This function does not free Webhook pointer. To free Webhook pointer use Webhook_destroy.
This function is not reversible.

◆ Webhook_destroy()

void Webhook_destroy ( Webhook webhook)

Frees Webhook pointer.

Parameters
webhookWebhook pointer

◆ Webhook_execute()

int Webhook_execute ( Webhook webhook,
const char *  message,
const char *  username,
const char *  avatar_url 
)

Execute a Webhook (send a message).

Parameters
webhookWebhook pointer
messagetext content to be sent
usernameoverride default webhook name, can be NULL
avatar_urlavatar URL, can be NULL
Returns
0 on success
NOT 0 on failure
See also
Webhook_execute_simple

◆ Webhook_execute_simple()

int Webhook_execute_simple ( Webhook webhook,
const char *  message 
)

Execute a Webhook and send a message. In comparison to Webhook_execute this function does not allow to change username or avatar

Parameters
webhookWebhook pointer
messagetext content to be sent
Returns
0 on success
NOT 0 on failure

◆ Webhook_get()

Webhook* Webhook_get ( DiscordClient client,
char *  id 
)

Gets Webhook pointer after webhook id. If you have Webhook url you can extract ID by using following schema:

https://discordapp.com/api/webhooks/{ID}/{TOKEN}

Returned pointer has to be freed with Webhook_destroy.

Parameters
clientDiscordClient session
idwebhook ID
Returns
pointer to Webhook on success
NULL on failure
See also
Webhook_get_no_auth

◆ Webhook_get_no_auth()

Webhook* Webhook_get_no_auth ( char *  id,
char *  token 
)

Gets Webhook pointer after webhook id and token. No DiscordClient needed. If you have Webhook url you can extract ID and TOKEN by using following schema:

https://discordapp.com/api/webhooks/{ID}/{TOKEN}

Returned pointer has to be freed with Webhook_destroy.

Parameters
idwebhook ID
tokenwebhook TOKEN
Returns
pointer to Webhook on success
NULL on failure
See also
Webhook_get_no_auth_url

◆ Webhook_get_no_auth_url()

Webhook* Webhook_get_no_auth_url ( const char *  url)

Gets Webhook pointer after webhook url. No DiscordClient needed. Returned pointer has to be freed with Webhook_destroy.

Parameters
urlwebhook url
Returns
pointer to Webhook on success
NULL on failure

◆ Webhook_modify()

int Webhook_modify ( Webhook webhook,
const char *  name,
DscrdFile avatar 
)

Modifies Webhook values.

Parameters
webhookWebhook pointer
namenew name
avatarDscrdFile pointer to avatar
Returns
0 on success
NOT 0 on failure
See also
Webhook_move to move webhook to different channel

◆ Webhook_move()

int Webhook_move ( Webhook webhook,
DiscordChannel channel 
)

Moves Webhook into different channel.

Parameters
webhookWebhook pointer
channelDiscordChannel pointer to new channel
Returns
0 on success
NOT 0 on failure

◆ WebhookList_destroy()

void WebhookList_destroy ( WebhookList list)

Frees WebhookList pointer.

Parameters
listWebhookList pointer

◆ Webhooks_in_channel()

WebhookList* Webhooks_in_channel ( DiscordClient client,
DiscordChannel channel 
)

Returns list over Webhooks in specified channel. Returned pointer has to be freed with WebhookList_destroy.

Parameters
clientDiscordClient session
channelDiscordChannel pointer
Returns
pointer to WebhookList on success
NULL on failure

◆ Webhooks_in_guild()

WebhookList* Webhooks_in_guild ( DiscordClient client,
DiscordGuild guild 
)

Returns list over Webhooks in specified guild. Returned pointer has to be freed with WebhookList_destroy.

Parameters
clientDiscordClient session
guildDiscordGuild pointer
Returns
pointer to WebhookList on success
NULL on failure