|
dscrd
Discord C library
|
#include <stdint.h>#include <stdbool.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 |
| #define DISCORD_API 6 |
Discord API version library was compiled for
| #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.
| X | pointer to DscrdAuth |
| #define DSCRD_FILE_NULL ((DscrdFile *) "dummy") |
Use this if you want to reset avatar (needed to distinguish from not changing avatar)
| #define ID | ( | X | ) | X ## "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" |
| typedef struct DiscordActivity_s DiscordActivity |
Activity object (game)
| typedef struct DiscordChannel_s DiscordChannel |
Discord channel.
| typedef struct DiscordChannelList_s DiscordChannelList |
| typedef struct DiscordClient_s DiscordClient |
Discord session.
You should not access any values except DiscordClient::me / DiscordClient::user and DiscordClient::api
| typedef struct DiscordGuild_s DiscordGuild |
Discord guild.
| typedef struct DiscordMessage_s DiscordMessage |
| typedef struct DiscordUser_s DiscordUser |
Discord user.
| typedef enum dscrd_type_e dscrd_type |
Discord datatypes.
| typedef struct DscrdAuth_s DscrdAuth |
DscrdAuth structure
| typedef struct DscrdFile_s DscrdFile |
Discord file wrapper.
| typedef struct GatewayResp_s GatewayResp |
| typedef enum permissions_e permissions |
Permissions also described at https://discordapp.com/developers/docs/topics/permissions.
| typedef enum token_type_e token_type |
Type of the token
Webhook structure.
| typedef struct WebhookList_s WebhookList |
WebhookList structure.
| enum activity_types |
Activity types.
| Enumerator | |
|---|---|
| ACTIVITY_GAME | Playing ... |
| ACTIVITY_STREAMING | Streaming ... |
| ACTIVITY_LISTENING | Listening to ... |
| enum channel_types |
Channel types.
Possible types to be found in DiscordChannel::type
| Enumerator | |
|---|---|
| GUILD_TEXT | |
| DM | |
| GUILD_VOICE | |
| GROUP_DM | |
| GUILD_CATEGORY | |
| enum dscrd_type_e |
Discord datatypes.
| enum dscrd_user_status |
| enum gateway_flags |
| enum http_method |
| enum message_types |
| enum permissions_e |
Permissions also described at https://discordapp.com/developers/docs/topics/permissions.
| enum token_type_e |
| 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.
| guild | DiscordGuild pointer |
| channel_name | channel name in guild |
| void DiscordChannel_destroy | ( | DiscordChannel * | channel | ) |
Frees DiscordChannel pointer.
| channel | DiscordChannel pointer |
| 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.
| client | DiscordClient session |
| channel_id | channel ID |
| 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.
| client | DiscordClient session |
| channel_id | channel ID |
| int DiscordChannel_modify | ( | DiscordChannel * | channel, |
| ... | |||
| ) |
Modifies DiscordChannel specified values. Changes are listed in pairs also: "key",(value), ...
| channel | DiscordChannel pointer |
| ... | key {"name", ...} |
| ... | value (type depends on key) |
| ... |
| int DiscordChannel_send_message_simple | ( | DiscordChannel * | channel, |
| const char * | message | ||
| ) |
Sends text message to given channel.
| channel | DiscordChannel pointer |
| message | message string |
| void DiscordChannelList_destroy | ( | DiscordChannelList * | channels | ) |
Frees DiscordChannelList pointer.
| channels | DiscordChannelList pointer |
| DiscordChannel* DiscordChannelList_pop | ( | DiscordChannelList * | list, |
| int | i | ||
| ) |
Removes specified element from DiscordChannelList and returns it.
| list | DiscordChannelList |
| i | element number |
| DiscordChannelList* DiscordChannels_in_guild | ( | DiscordGuild * | guild | ) |
Gets DiscordChannelList for current user. Returned pointer has to be freed with DiscordChannelList_destroy.
| guild | DiscordGuild pointer |
| 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.
| d | pointer to DiscordClient session to close |
| 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.
| client | DiscordClient session |
| flags | Gateway flags, ORed values of gateway_flags |
| struct DiscordGuild_s** DiscordClient_lazy_guilds | ( | DiscordClient * | client | ) |
Loads lazyloaded DiscordGuild. Returned pointers will be freed automatically on gateway close.
| client | DiscordClient session |
| 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.
| type | type of the token you're passing, one of token_type_e |
| token | pointer to token string |
| int DiscordClient_set_game | ( | DiscordClient * | client, |
| DiscordActivity * | activity | ||
| ) |
Set game for DiscordClient
| int DiscordClient_set_status | ( | DiscordClient * | client, |
| enum dscrd_user_status | status | ||
| ) |
Set status for DiscordClient
| int DiscordGateway_callback | ( | DiscordClient * | client, |
| char * | event, | ||
| int(*)(GatewayResp *) | func, | ||
| void * | userdata | ||
| ) |
| DiscordGuild* DiscordGuild_by_name | ( | DiscordClient * | client, |
| char * | guild_name | ||
| ) |
Gets DiscordGuild after specified guild name. Returned pointer has to be freed with DiscordGuild_destroy.
| client | DiscordClient session |
| guild_name | guild name |
| void DiscordGuild_destroy | ( | DiscordGuild * | guild | ) |
Frees DiscordGuild pointer.
| guild | DiscordGuild pointer |
| 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.
| client | DiscordClient session |
| guild_id | guild ID |
| void DiscordGuilds_destroy | ( | DiscordGuild ** | guilds | ) |
Frees DiscordGuild pointer array.
| guild | DiscordGuild array |
| 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.
| client | DiscordClient session |
| int DiscordMessage_callback_all | ( | DiscordClient * | client, |
| int(*)(DiscordMessage *) | callback | ||
| ) |
TODO.
| int DiscordMessage_callback_mentions | ( | DiscordClient * | client, |
| int(*)(DiscordMessage *) | callback | ||
| ) |
| int DiscordMessage_delete | ( | DiscordMessage * | message | ) |
Delete specified message.
| int DiscordMessage_delete_id | ( | DiscordClient * | client, |
| const char * | channel_id, | ||
| const char * | message_id | ||
| ) |
Delete message after channel and message id.
| void DiscordMessage_destroy | ( | DiscordMessage * | msg | ) |
| DiscordMessage* DiscordMessage_get | ( | DiscordChannel * | channel, |
| char * | message_id | ||
| ) |
| DiscordMessage* DiscordMessage_new_simple | ( | DiscordChannel * | channel, |
| const char * | message | ||
| ) |
new message (returns back)
| void DiscordUser_destroy | ( | DiscordUser * | user | ) |
Frees DiscordUser pointer.
| user | DiscordUser_s pointer |
| 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.
| client | DiscordClient session |
| user_id | user ID string |
| DiscordUser* DiscordUser_me | ( | struct DiscordClient_s * | client | ) |
Get current user information. Returned pointer has to be freed with DiscordUser_destroy.
| client | DiscordClient session |
dscrd gets current user information when opening new client.
You can access it through DiscordClient::me or DiscordClient::user pointer.
| const char* dscrd_error | ( | void | ) |
Read last error message.
| const char* dscrd_error_long | ( | void | ) |
Read last error message. In comparison to dscrd_error() this function will show in what function error happened.
| int dscrd_has_gateway | ( | void | ) |
Checks if library has gateway support.
| int dscrd_initialize | ( | void | ) |
Initialize dscrd library. You should call this function before calling any other function.
| 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
| api | API version number |
| 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.
| int dscrdd_auth | ( | DscrdAuth * | auth, |
| const char * | app_name | ||
| ) |
Try to connect to dscrdd (dscrd daemon) to receive credentials for given app.
| auth | pointer to DscrdAuth to write data into |
| app_name | name of the application |
| void DscrdFile_destroy | ( | DscrdFile * | file | ) |
| DscrdFile* DscrdFile_get | ( | const char * | filename | ) |
Returns DscrdFile pointer for specified filename. Returned pointer has to be freed with DscrdFile_destroy.
| filename | path to file |
| 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.
| filename | path to file |
| mime_type | MIME-type string |
| Webhook* Webhook_create | ( | DiscordChannel * | channel, |
| char * | name, | ||
| DscrdFile * | avatar | ||
| ) |
Creates new webhook in given channel. Returned pointer has to be freed with Webhook_destroy.
| channel | DiscordChannel pointer |
| name | webhook name |
| avatar | avatar data |
| int Webhook_delete | ( | Webhook * | webhook | ) |
Deletes Webhook from Discord servers.
| webhook | Webhook pointer |
| int Webhook_execute | ( | Webhook * | webhook, |
| const char * | message, | ||
| const char * | username, | ||
| const char * | avatar_url | ||
| ) |
Execute a Webhook (send a message).
| webhook | Webhook pointer |
| message | text content to be sent |
| username | override default webhook name, can be NULL |
| avatar_url | avatar URL, can be NULL |
| 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
| webhook | Webhook pointer |
| message | text content to be sent |
| 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:
Returned pointer has to be freed with Webhook_destroy.
| client | DiscordClient session |
| id | webhook ID |
| 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:
Returned pointer has to be freed with Webhook_destroy.
| id | webhook ID |
| token | webhook TOKEN |
| 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.
| url | webhook url |
Modifies Webhook values.
| int Webhook_move | ( | Webhook * | webhook, |
| DiscordChannel * | channel | ||
| ) |
Moves Webhook into different channel.
| webhook | Webhook pointer |
| channel | DiscordChannel pointer to new channel |
| void WebhookList_destroy | ( | WebhookList * | list | ) |
Frees WebhookList pointer.
| list | WebhookList pointer |
| WebhookList* Webhooks_in_channel | ( | DiscordClient * | client, |
| DiscordChannel * | channel | ||
| ) |
Returns list over Webhooks in specified channel. Returned pointer has to be freed with WebhookList_destroy.
| client | DiscordClient session |
| channel | DiscordChannel pointer |
| WebhookList* Webhooks_in_guild | ( | DiscordClient * | client, |
| DiscordGuild * | guild | ||
| ) |
Returns list over Webhooks in specified guild. Returned pointer has to be freed with WebhookList_destroy.
| client | DiscordClient session |
| guild | DiscordGuild pointer |
1.8.13