Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update API events, structures, enums #169

Draft
wants to merge 4 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions gencodecs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ HEADERS = $(API_DIR)/application.h \
$(API_DIR)/channel.h \
$(API_DIR)/custom.h \
$(API_DIR)/emoji.h \
$(API_DIR)/entitlements.h \
$(API_DIR)/gateway.h \
$(API_DIR)/guild.h \
$(API_DIR)/guild_scheduled_event.h \
Expand All @@ -43,6 +44,7 @@ HEADERS = $(API_DIR)/application.h \
$(API_DIR)/message_components.h \
$(API_DIR)/oauth2.h \
$(API_DIR)/permissions.h \
$(API_DIR)/poll.h \
$(API_DIR)/stage_instance.h \
$(API_DIR)/sticker.h \
$(API_DIR)/teams.h \
Expand Down
2 changes: 2 additions & 0 deletions gencodecs/all.PRE.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "invite.PRE.h"
#include "channel.PRE.h"
#include "emoji.PRE.h"
#include "entitlements.PRE.h"
#include "guild.PRE.h"
#include "guild_scheduled_event.PRE.h"
#include "guild_template.PRE.h"
Expand All @@ -18,6 +19,7 @@
#include "gateway.PRE.h"
#include "oauth2.PRE.h"
#include "permissions.PRE.h"
#include "poll.PRE.h"
#include "teams.PRE.h"
#include "voice_connections.PRE.h"

Expand Down
38 changes: 36 additions & 2 deletions gencodecs/api/application.PRE.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,39 @@
* @ingroup DiscordConstants
* @{ */

#if GENCODECS_RECIPE == DATA
ENUM(discord_application_integration_types)
/** app is installable to servers */
ENUMERATOR(DISCORD_APPLICATIONS_GUILD_INSTALL, = 0)
/** App is installable to users */
ENUMERATOR_LAST(DISCORD_APPLICATIONS_USER_INSTALL, = 1)
ENUM_END
#endif

/** indicates if an app uses the Auto Moderation API */
PP_DEFINE(DISCORD_APPLICATION_APPLICATION_AUTO_MODERATION_RULE_CREATE_BADGE 1 << 6)
/** intent required for bots in 100 or more servers to
receive presence_update events */
PP_DEFINE(DISCORD_APPLICATION_GATEWAY_PRESENCE 1 << 12)
/** intent required for bots in under 100 servers to receive
presence_update events */
PP_DEFINE(DISCORD_APPLICATION_GATEWAY_PRESENCE_LIMITED 1 << 13)
/** intent required for bots in 100 or more servers to receive
member-related events like guild_member_add */
PP_DEFINE(DISCORD_APPLICATION_GATEWAY_GUILD_MEMBERS 1 << 14)
/** intent required for bots in under 100 servers to receive
member-related events like guild_member_add */
PP_DEFINE(DISCORD_APPLICATION_GATEWAY_GUILD_MEMBERS_LIMITED 1 << 15)
/** indicates unusual growth of an app that prevents verification */
PP_DEFINE(DISCORD_APPLICATION_VERIFICATION_PENDING_GUILD_LIMIT 1 << 16)
/** indicates if an app is embedded within the Discord client */
PP_DEFINE(DISCORD_APPLICATION_EMBEDDED 1 << 17)
/** intent required for bots in 100 or more servers to receive message content */
PP_DEFINE(DISCORD_APPLICATION_GATEWAY_MESSAGE_CONTENT 1 << 18)
/** intent required for bots in under 100 servers to receive message content */
PP_DEFINE(DISCORD_APPLICATION_GATEWAY_MESSAGE_CONTENT_LIMITED 1 << 19)
/** indicates if an app has registered global application commands */
PP_DEFINE(DISCORD_APPLICATION_APPLICATION_COMMAND_BADGE 1 << 23)

/** @} DiscordApplicationFlags */

Expand Down Expand Up @@ -45,8 +70,7 @@ PUB_STRUCT(discord_application)
COND_WRITE(self->owner != NULL)
FIELD_STRUCT_PTR(owner, discord_user, *)
COND_END
/** if this application is a game sold on Discord, this field will be the
summary field for the store page of its primary sku */
/** @deprecated will be removed in API v11 */
FIELD_PTR(summary, char, *)
/** the hex encoded key for verification in interactions and the GameSDK's
GetTicket */
Expand All @@ -59,6 +83,10 @@ PUB_STRUCT(discord_application)
/** if this application is a game sold on Discord, this field will be the
guild to which it has been linked */
FIELD_SNOWFLAKE(guild_id)
/** Partial object of the associated guild */
COND_WRITE(self->guild != NULL)
FIELD_STRUCT_PTR(guild, discord_guild, *)
COND_END
/** if this application is a game sold on Discord, this field will be the
ID of the \"Game SKU\" that is created, if exists */
FIELD_SNOWFLAKE(primary_sku_id)
Expand All @@ -69,6 +97,12 @@ PUB_STRUCT(discord_application)
FIELD_PTR(cover_image, char, *)
/** the application's public flags @see DiscordApplicationFlags */
FIELD_BITMASK(flags)
/** Approximate count of guilds the app has been added to */
FIELD(guild_count, size_t, 0)
/** Array of redirect URIs for the app */
COND_WRITE(self->redirect_uris != NULL)
FIELD_STRUCT_PTR(redirect_uris, strings, *)
COND_END
STRUCT_END
#endif

Expand Down
127 changes: 110 additions & 17 deletions gencodecs/api/application_commands.PRE.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,23 @@ PUB_STRUCT(discord_application_command)
COND_WRITE(self->application_id != 0)
FIELD_SNOWFLAKE(application_id)
COND_END
COND_WRITE(self->guild_id != 0)
/** guild ID of the command, if not global */
COND_WRITE(self->guild_id != 0)
FIELD_SNOWFLAKE(guild_id)
COND_END
/** 1-32 character name */
COND_WRITE(self->name != NULL)
/** name of the command, 1-32 characters */
FIELD_PTR(name, char, *)
/** localization dictionary for the `name` field. Values follow the same
restriction as `name` */
COND_WRITE(self->name_localizations != NULL)
FIELD_STRUCT_PTR(name_localizations, strings, *)
COND_END
/** 1-100 character description for `CHAT_INPUT` commands, empty string
for `USER` and `MESSAGE` commands */
COND_WRITE(self->description != NULL)
/** 1-100 character description */
FIELD_PTR(description, char, *)
/** localization dictionary for the `description` field. Values follow the
same restriction as `description` */
COND_WRITE(self->description_localizations != NULL)
FIELD_STRUCT_PTR(description_localizations, strings, *)
COND_END
/** the parameters for the command, max 25 */
COND_WRITE(self->options != NULL)
Expand All @@ -91,6 +96,10 @@ PUB_STRUCT(discord_application_command)
COND_WRITE(self->default_permission != true)
FIELD(default_permission, bool, true)
COND_END
/** indicates whether the command is age-restricted */
COND_WRITE(self->nsfw != false)
FIELD(nsfw, bool, false)
COND_END
/** autoincrementing version identifier updated during substantial
record changes */
COND_WRITE(self->version != 0)
Expand All @@ -109,10 +118,20 @@ LIST_END
STRUCT(discord_application_command_option)
/** value of application command option type */
FIELD_ENUM(type, discord_application_command_option_types)
/** 1-32 character name */
/** name of the command, 1-32 characters */
FIELD_PTR(name, char, *)
/** localization dictionary for the `name` field. Values follow the same
restriction as `name` */
COND_WRITE(self->name_localizations != NULL)
FIELD_STRUCT_PTR(name_localizations, strings, *)
COND_END
/** 1-100 character description */
FIELD_PTR(description, char, *)
/** localization dictionary for the `description` field. Values follow the
same restriction as `description` */
COND_WRITE(self->description_localizations != NULL)
FIELD_STRUCT_PTR(description_localizations, strings, *)
COND_END
/** if the parameter is required or optional -- default `false` */
COND_WRITE(self->required != false)
FIELD(required, bool, false)
Expand All @@ -132,15 +151,24 @@ STRUCT(discord_application_command_option)
FIELD_STRUCT_PTR(channel_types, integers, *)
COND_END
/** if the option is an INTEGER or NUMBER type, the minimum value permitted */
COND_WRITE(self->min_value != NULL)
FIELD_PTR(min_value, char, *)
COND_WRITE(self->min_value != 0)
FIELD(min_value, int, 0)
COND_END
/** if the option is an INTEGER or NUMBER type, the maximum value permitted */
COND_WRITE(self->max_value != NULL)
FIELD_PTR(max_value, char, *)
COND_WRITE(self->max_value != 0)
FIELD(max_value, int, 0)
COND_END
/** for option type STRING, the minimum allowed length */
COND_WRITE(self->min_length != 0)
FIELD(min_length, int, 0)
COND_END
/** for option type STRING, the maximum allowed length */
COND_WRITE(self->max_length != 0)
FIELD(max_length, int, 0)
COND_END
/** enable autocomplete interactions for this option */
COND_WRITE(self->choices == NULL)
/** if autocomplete interactions are enabled for this STRING, INTEGER,
or NUMBER type option */
COND_WRITE(self->autocomplete != 0)
FIELD(autocomplete, bool, false)
COND_END
STRUCT_END
Expand All @@ -156,6 +184,11 @@ LIST_END
STRUCT(discord_application_command_option_choice)
/** 1-100 character choice name */
FIELD_PTR(name, char, *)
/** localization dictionary for the `name` field. Values follow the same
restriction as `name` */
COND_WRITE(self->name_localizations != NULL)
FIELD_STRUCT_PTR(name_localizations, strings, *)
COND_END
/** value of the choice, up to 100 characters if string @note in case of a
string the value must be enclosed with escaped commas, ex: `\"hi\"` */
FIELD_PTR(value, json_char, *)
Expand Down Expand Up @@ -236,10 +269,20 @@ LIST_END

#if GENCODECS_RECIPE & (DATA | JSON)
PUB_STRUCT(discord_create_global_application_command)
/** 1-32 lowercase character name */
/** name of the command, 1-32 characters */
FIELD_PTR(name, char, *)
/** localization dictionary for the `name` field. Values follow the same
restriction as `name` */
COND_WRITE(self->name_localizations != NULL)
FIELD_STRUCT_PTR(name_localizations, strings, *)
COND_END
/** 1-100 character description */
FIELD_PTR(description, char, *)
/** localization dictionary for the `description` field. Values follow the
same restriction as `description` */
COND_WRITE(self->description_localizations != NULL)
FIELD_STRUCT_PTR(description_localizations, strings, *)
COND_END
/** the parameters for the command */
COND_WRITE(self->options != NULL)
FIELD_STRUCT_PTR(options, discord_application_command_options, *)
Expand All @@ -259,15 +302,29 @@ PUB_STRUCT(discord_create_global_application_command)
COND_WRITE(self->type != 0)
FIELD_ENUM(type, discord_application_command_types)
COND_END
/** indicates whether the command is age-restricted */
COND_WRITE(self->nsfw != false)
FIELD(nsfw, bool, false)
COND_END
STRUCT_END
#endif

#if GENCODECS_RECIPE & (DATA | JSON)
PUB_STRUCT(discord_edit_global_application_command)
/** 1-32 lowercase character name */
/** name of the command, 1-32 characters */
FIELD_PTR(name, char, *)
/** localization dictionary for the `name` field. Values follow the same
restriction as `name` */
COND_WRITE(self->name_localizations != NULL)
FIELD_STRUCT_PTR(name_localizations, strings, *)
COND_END
/** 1-100 character description */
FIELD_PTR(description, char, *)
/** localization dictionary for the `description` field. Values follow the
same restriction as `description` */
COND_WRITE(self->description_localizations != NULL)
FIELD_STRUCT_PTR(description_localizations, strings, *)
COND_END
/** the parameters for the command */
COND_WRITE(self->options != NULL)
FIELD_STRUCT_PTR(options, discord_application_command_options, *)
Expand All @@ -283,15 +340,29 @@ PUB_STRUCT(discord_edit_global_application_command)
FIELD(dm_permission, bool, false)
/** @deprecated use `default_member_permissions` instead */
FIELD(default_permission, bool, true)
/** indicates whether the command is age-restricted */
COND_WRITE(self->nsfw != false)
FIELD(nsfw, bool, false)
COND_END
STRUCT_END
#endif

#if GENCODECS_RECIPE & (DATA | JSON)
PUB_STRUCT(discord_create_guild_application_command)
/** 1-32 lowercase character name */
/** name of the command, 1-32 characters */
FIELD_PTR(name, char, *)
/** localization dictionary for the `name` field. Values follow the same
restriction as `name` */
COND_WRITE(self->name_localizations != NULL)
FIELD_STRUCT_PTR(name_localizations, strings, *)
COND_END
/** 1-100 character description */
FIELD_PTR(description, char, *)
/** localization dictionary for the `description` field. Values follow the
same restriction as `description` */
COND_WRITE(self->description_localizations != NULL)
FIELD_STRUCT_PTR(description_localizations, strings, *)
COND_END
/** the parameters for the command */
COND_WRITE(self->options != NULL)
FIELD_STRUCT_PTR(options, discord_application_command_options, *)
Expand All @@ -311,15 +382,29 @@ PUB_STRUCT(discord_create_guild_application_command)
COND_WRITE(self->type != 0)
FIELD_ENUM(type, discord_application_command_types)
COND_END
/** indicates whether the command is age-restricted */
COND_WRITE(self->nsfw != false)
FIELD(nsfw, bool, false)
COND_END
STRUCT_END
#endif

#if GENCODECS_RECIPE & (DATA | JSON)
PUB_STRUCT(discord_edit_guild_application_command)
/** 1-32 lowercase character name */
/** name of the command, 1-32 characters */
FIELD_PTR(name, char, *)
/** localization dictionary for the `name` field. Values follow the same
restriction as `name` */
COND_WRITE(self->name_localizations != NULL)
FIELD_STRUCT_PTR(name_localizations, strings, *)
COND_END
/** 1-100 character description */
FIELD_PTR(description, char, *)
/** localization dictionary for the `description` field. Values follow the
same restriction as `description` */
COND_WRITE(self->description_localizations != NULL)
FIELD_STRUCT_PTR(description_localizations, strings, *)
COND_END
/** the parameters for the command */
COND_WRITE(self->options != NULL)
FIELD_STRUCT_PTR(options, discord_application_command_options, *)
Expand All @@ -330,6 +415,10 @@ PUB_STRUCT(discord_edit_guild_application_command)
COND_END
/** @deprecated use `default_member_permissions` instead */
FIELD(default_permission, bool, true)
/** indicates whether the command is age-restricted */
COND_WRITE(self->nsfw != false)
FIELD(nsfw, bool, false)
COND_END
STRUCT_END
#endif

Expand All @@ -341,12 +430,16 @@ PUB_STRUCT(discord_bulk_overwrite_guild_application_commands)
FIELD_PTR(name, char, *)
/** Localization dictionary for the `name` field. Values follow the same
* restriction as `name` */
COND_WRITE(self->name_localizations != NULL)
FIELD_STRUCT_PTR(name_localizations, strings, *)
COND_END
/** 1-100 character description */
FIELD_PTR(description, char, *)
/** Localization dictionary for the `description` field. Values follow the
* same restriction as `description` */
COND_WRITE(self->description_localizations != NULL)
FIELD_STRUCT_PTR(description_localizations, strings, *)
COND_END
/** the parameters for the command */
COND_WRITE(self->options != NULL)
FIELD_STRUCT_PTR(options, discord_application_command_options, *)
Expand Down
Loading
Loading