diff --git a/gencodecs/Makefile b/gencodecs/Makefile index 1466fda31..3d3a3cc59 100644 --- a/gencodecs/Makefile +++ b/gencodecs/Makefile @@ -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 \ @@ -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 \ diff --git a/gencodecs/all.PRE.h b/gencodecs/all.PRE.h index 8c5c804b0..c3a5c8acd 100644 --- a/gencodecs/all.PRE.h +++ b/gencodecs/all.PRE.h @@ -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" @@ -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" diff --git a/gencodecs/api/application.PRE.h b/gencodecs/api/application.PRE.h index 4ab5dea84..26bce4056 100644 --- a/gencodecs/api/application.PRE.h +++ b/gencodecs/api/application.PRE.h @@ -6,17 +6,70 @@ * @ingroup DiscordConstants * @{ */ +#if GENCODECS_RECIPE == DATA +ENUM(discord_application_integration_type) + /** 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 + +/** @CCORD_pub_list{discord_application_integration_types} */ +#if GENCODECS_RECIPE & (DATA | JSON) +PUB_LIST(discord_application_integration_types) + LISTTYPE_ENUM(discord_application_integration_type) +LIST_END +#endif + +#if GENCODECS_RECIPE == DATA +ENUM(discord_application_event_webhook_status) + /** webhook events are disabled by developer */ + ENUMERATOR(DISCORD_APPLICATIONS_WEBHOOK_DISABLED, = 1) + /** webhook events are enabled by developer */ + ENUMERATOR(DISCORD_APPLICATIONS_WEBHOOK_ENABLED, = 2) + /** webhook events are disabled by Discord, usually due to inactivity */ + ENUMERATOR_LAST(DISCORD_APPLICATIONS_WEBHOOK_DISABLED_BY_DISCORD, = 3) +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 */ +/** @CCORD_pub_struct{discord_application_install_params} */ +#if GENCODECS_RECIPE & (DATA | JSON) +PUB_STRUCT(discord_application_install_params) + /** the scopes to add the application to the server with */ + FIELD_STRUCT_PTR(scopes, strings, *) + /** the permissions to request for the bot role */ + FIELD_BITMASK(permissions) +STRUCT_END +#endif + /** @CCORD_pub_struct{discord_application} */ #if GENCODECS_RECIPE & (DATA | JSON) PUB_STRUCT(discord_application) @@ -37,6 +90,10 @@ PUB_STRUCT(discord_application) /** when true the app's bot will only join upon completion of the full oauth2 code grant flow */ FIELD(bot_require_code_grant, bool, false) + /** partial user object for the bot user associated with the app */ + COND_WRITE(self->bot != NULL) + FIELD_STRUCT_PTR(bot, discord_user, *) + COND_END /** the url of the app's terms of service */ FIELD_PTR(terms_of_service_url, char, *) /** the url of the app's privacy policy */ @@ -45,9 +102,6 @@ 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 */ - FIELD_PTR(summary, char, *) /** the hex encoded key for verification in interactions and the GameSDK's GetTicket */ FIELD_PTR(verify_key, char, *) @@ -59,6 +113,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) @@ -69,6 +127,38 @@ PUB_STRUCT(discord_application) FIELD_PTR(cover_image, char, *) /** the application's public flags @see DiscordApplicationFlags */ FIELD_BITMASK(flags) + /** the approximate count of guilds the app has been added to */ + FIELD(applicatimate_guild_count, size_t, 0) + /** the approximate count of users that have installed the app */ + FIELD(approximate_user_install_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 + /** the interactions endpoint URL for the app */ + FIELD_PTR(interactions_endpoint_url, char, *) + /** the role connection verification URL for the app */ + FIELD_PTR(role_connections_verification_url, char, *) + /** the event webhooks URL for the app to receive webhook events */ + FIELD_PTR(event_webhooks_url, char, *) + /** if webhook events are enabled for the app. */ + FIELD_ENUM(event_webhooks_status, discord_application_event_webhook_status) + /** the list of Webhook event types the app subscribes to */ + COND_WRITE(self->event_webhooks_types != NULL) + FIELD_STRUCT_PTR(event_webhooks_types, strings, *) + COND_END + /** the list of tags describing the content and functionality of the + app. Max of 5 tags. */ + COND_WRITE(self->tags != NULL) + FIELD_STRUCT_PTR(tags, strings, *) + COND_END + /** the settings for the app's default in-app authorization link, if enabled */ + COND_WRITE(self->install_params != NULL) + FIELD_STRUCT_PTR(install_params, discord_application_install_params, *) + COND_END + /* TODO: integration_types_config */ + /** default custom authorization URL for the app, if enabled */ + FIELD_PTR(custom_install_url, char, *) STRUCT_END #endif diff --git a/gencodecs/api/application_commands.PRE.h b/gencodecs/api/application_commands.PRE.h index a0e91a7d5..4f4e6a013 100644 --- a/gencodecs/api/application_commands.PRE.h +++ b/gencodecs/api/application_commands.PRE.h @@ -12,7 +12,10 @@ ENUM(discord_application_command_types) ENUMERATOR(DISCORD_APPLICATION_USER, = 2) /** A UI-based command that shows up when a user right clicks or tap on a message */ - ENUMERATOR_LAST(DISCORD_APPLICATION_MESSAGE, = 3) + ENUMERATOR(DISCORD_APPLICATION_MESSAGE, = 3) + /** A UI-based command that represents the primary + way to invoke an app's Activity */ + ENUMERATOR_LAST(DISCORD_APPLICATION_PRIMARY_ENTRY_POINT, = 4) ENUM_END #endif @@ -37,6 +40,13 @@ ENUM(discord_application_command_option_types) ENUM_END #endif +#if GENCODECS_RECIPE == DATA +ENUM(discord_application_command_entry_point_command_handler_types) + ENUMERATOR(DISCORD_APPLICATION_HANDLER_APP_HANDLER, = 1) + ENUMERATOR_LAST(DISCORD_APPLICATION_HANDLER_DISCORD_LAUNCH_ACTIVITY, = 2) +ENUM_END +#endif + #if GENCODECS_RECIPE == DATA ENUM(discord_application_command_permission_types) ENUMERATOR(DISCORD_APPLICATION_PERMISSION_ROLE, = 1) @@ -59,18 +69,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) @@ -80,10 +95,8 @@ PUB_STRUCT(discord_application_command) COND_WRITE(self->default_member_permissions != 0) FIELD_BITMASK(default_member_permissions) COND_END - /** - * Indicates whether the command is available in DMs with the app, only - * for globally-scoped commands. By default, commands are invisible. - */ + /** indicates whether the command is available in DMs with the app, only + for globally-scoped commands. By default, commands are invisible. */ COND_WRITE(self->dm_permission != false) FIELD(dm_permission, bool, false) COND_END @@ -91,11 +104,30 @@ 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 + /** installation contexts where the command is available, + only for globally-scoped commands */ + COND_WRITE(self->integration_types != NULL) + FIELD_STRUCT_PTR(integration_types, discord_application_integration_types, *) + COND_END + /** interaction context(s) where the command can be used, + only for globally-scoped commands. */ + COND_WRITE(self->contexts != NULL) + FIELD_STRUCT_PTR(contexts, discord_interaction_context_types, *) + COND_END /** autoincrementing version identifier updated during substantial record changes */ COND_WRITE(self->version != 0) FIELD_SNOWFLAKE(version) COND_END + /** Determines whether the interaction is handled by the + app's interactions handler or by Discord */ + COND_WRITE(self->handler != 0) + FIELD_ENUM(handler, discord_application_command_entry_point_command_handler_types) + COND_END STRUCT_END #endif @@ -109,10 +141,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) @@ -132,15 +174,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 @@ -156,6 +207,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, *) @@ -236,10 +292,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, *) @@ -255,19 +321,41 @@ PUB_STRUCT(discord_create_global_application_command) FIELD(dm_permission, bool, false) /** @deprecated use `default_member_permissions` instead */ FIELD(default_permission, bool, true) + /** installation context(s) where the command is available */ + COND_WRITE(self->integration_types != NULL) + FIELD_STRUCT_PTR(integration_types, discord_application_integration_types, *) + COND_END + /** interaction context(s) where the command can be used */ + COND_WRITE(self->contexts != NULL) + FIELD_STRUCT_PTR(contexts, discord_interaction_context_types, *) + COND_END /** the type of command, default `1` if not set */ 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, *) @@ -283,15 +371,37 @@ PUB_STRUCT(discord_edit_global_application_command) FIELD(dm_permission, bool, false) /** @deprecated use `default_member_permissions` instead */ FIELD(default_permission, bool, true) + /** installation context(s) where the command is available */ + COND_WRITE(self->integration_types != NULL) + FIELD_STRUCT_PTR(integration_types, discord_application_integration_types, *) + COND_END + /** interaction context(s) where the command can be used */ + COND_WRITE(self->contexts != NULL) + FIELD_STRUCT_PTR(contexts, discord_interaction_context_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_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, *) @@ -311,15 +421,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, *) @@ -330,23 +454,31 @@ 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 #if GENCODECS_RECIPE & (DATA | JSON) -PUB_STRUCT(discord_bulk_overwrite_guild_application_commands) +PUB_STRUCT(discord_bulk_overwrite_guild_application_command) /** ID of the command, if known */ FIELD_SNOWFLAKE(id) /** 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, *) @@ -360,9 +492,29 @@ PUB_STRUCT(discord_bulk_overwrite_guild_application_commands) * for globally-scoped commands. By default, commands are invisible. */ FIELD(dm_permission, bool, false) + /** @deprecated use `default_member_permissions` instead */ + FIELD(default_permission, bool, true) + /** installation context(s) where the command is available */ + COND_WRITE(self->integration_types != NULL) + FIELD_STRUCT_PTR(integration_types, discord_application_integration_types, *) + COND_END + /** interaction context(s) where the command can be used */ + COND_WRITE(self->contexts != NULL) + FIELD_STRUCT_PTR(contexts, discord_interaction_context_types, *) + COND_END /** one of application command types */ 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_LIST(discord_bulk_overwrite_guild_application_commands) + LISTTYPE_STRUCT(discord_bulk_overwrite_guild_application_command) +LIST_END +#endif diff --git a/gencodecs/api/audit_log.PRE.h b/gencodecs/api/audit_log.PRE.h index 5d60bc5ca..ce7560665 100644 --- a/gencodecs/api/audit_log.PRE.h +++ b/gencodecs/api/audit_log.PRE.h @@ -55,18 +55,30 @@ ENUM(discord_audit_log_events) ENUMERATOR(DISCORD_AUDIT_LOG_AUTO_MODERATION_RULE_CREATE, = 140) ENUMERATOR(DISCORD_AUDIT_LOG_AUTO_MODERATION_RULE_UPDATE, = 141) ENUMERATOR(DISCORD_AUDIT_LOG_AUTO_MODERATION_RULE_DELETE, = 142) - ENUMERATOR_LAST(DISCORD_AUDIT_LOG_AUTO_MODERATION_BLOCK_MESSAGE, = 143) + ENUMERATOR(DISCORD_AUDIT_LOG_AUTO_MODERATION_BLOCK_MESSAGE, = 143) + ENUMERATOR(DISCORD_AUDIT_LOG_AUTO_MODERATION_FLAG_TO_CHANNEL, = 144) + ENUMERATOR(DISCORD_AUDIT_LOG_AUTO_MODERATION_USER_COMMUNICATION_DISABLED, = 145) + ENUMERATOR(DISCORD_AUDIT_LOG_CREATOR_MONETIZATION_REQUEST_CREATED, = 150) + ENUMERATOR_LAST(DISCORD_AUDIT_LOG_CREATOR_MONETIZATION_TERMS_ACCEPTED, = 151) ENUM_END #endif /** @CCORD_pub_struct{discord_audit_log} */ #if GENCODECS_RECIPE & (DATA | JSON) PUB_STRUCT(discord_audit_log) - /** list of audit log entries */ + /** list of application commands referenced in the audit log */ + COND_WRITE(self->application_commands != NULL) + FIELD_STRUCT_PTR(application_commands, discord_application_commands, *) + COND_END + /** list of audit log entries referenced in the audit log */ COND_WRITE(self->audit_log_entries != NULL) FIELD_STRUCT_PTR(audit_log_entries, discord_audit_log_entries, *) COND_END - /** list of guild scheduled events found in the audit log */ + /** list of auto moderation rules referenced in the audit log */ + COND_WRITE(self->auto_moderation_rules != NULL) + FIELD_STRUCT_PTR(auto_moderation_rules, discord_auto_moderation_rules, *) + COND_END + /** list of guild scheduled events referenced in the audit log */ COND_WRITE(self->guild_scheduled_events != NULL) FIELD_STRUCT_PTR(guild_scheduled_events, discord_guild_scheduled_events, *) COND_END @@ -89,8 +101,9 @@ PUB_STRUCT(discord_audit_log) STRUCT_END #endif +/** @CCORD_pub_struct{discord_audit_log_entry} */ #if GENCODECS_RECIPE & (DATA | JSON) -STRUCT(discord_audit_log_entry) +PUB_STRUCT(discord_audit_log_entry) /** ID of the affected entity (webhook, user, role, etc.) */ FIELD_SNOWFLAKE(target_id) /** changes made to the target_id */ @@ -122,6 +135,12 @@ LIST_END #if GENCODECS_RECIPE & (DATA | JSON) STRUCT(discord_optional_audit_entry_info) + /** ID of the app whose permissions were targeted */ + FIELD_SNOWFLAKE(application_id) + /** Name of the Auto Moderation rule that was triggered */ + FIELD_PTR(auto_moderation_rule_name, char, *) + /** Trigger type of the Auto Moderation rule that was triggered */ + FIELD_PTR(auto_moderation_rule_trigger_type, char, *) /** channel in which the entities were targeted */ FIELD_SNOWFLAKE(channel_id) /** number of entities that were targeted */ @@ -138,6 +157,8 @@ STRUCT(discord_optional_audit_entry_info) FIELD_PTR(role_name, char, *) /** type of overwritten entity - 0 for role or 1 for \"member\" */ FIELD_PTR(type, char, *) + /** The type of integration which performed the action */ + FIELD_PTR(integration_type, char, *) STRUCT_END #endif @@ -171,11 +192,17 @@ LIST_END #if GENCODECS_RECIPE == DATA STRUCT(discord_get_guild_audit_log) /** filter the log for actions made by a user */ + COND_WRITE(self->user_id != 0) FIELD_SNOWFLAKE(user_id) + COND_END /** the type of audit log event */ + COND_WRITE(self->action_type != 0) FIELD(action_type, int, 0) + COND_END /** filter the log before a certain entry ID */ + COND_WRITE(self->before != 0) FIELD_SNOWFLAKE(before) + COND_END /** how many entries are returned (default 50, minimum 1, maximum 100) */ COND_WRITE(self->limit >= 1 && self->limit <= 100) FIELD(limit, int, 50) diff --git a/gencodecs/api/auto_moderation.PRE.h b/gencodecs/api/auto_moderation.PRE.h index 3d681e05f..082e480b3 100644 --- a/gencodecs/api/auto_moderation.PRE.h +++ b/gencodecs/api/auto_moderation.PRE.h @@ -7,14 +7,9 @@ ENUM(discord_auto_moderation_trigger_types) /** * check if content contains words from a user defined list of keywords - * @note maximum 3 per guild + * @note maximum 6 per guild */ ENUMERATOR(DISCORD_AUTO_MODERATION_KEYWORD, = 1) - /** - * check if content contains any harmful links - * @note maximum 1 per guild - */ - ENUMERATOR(DISCORD_AUTO_MODERATION_HARMFUL_LINK, = 2) /** * check if content represents generic spam * @note maximum 1 per guild @@ -24,7 +19,12 @@ ENUM(discord_auto_moderation_trigger_types) * check if content contains words from internal pre-defined wordsets * @note maximum 1 per guild */ - ENUMERATOR_LAST(DISCORD_AUTO_MODERATION_KEYWORD_PRESET, = 4) + ENUMERATOR(DISCORD_AUTO_MODERATION_KEYWORD_PRESET, = 4) + /** + * check if content contains more unique mentions than allowed + * @note maximum 1 per guild + */ + ENUMERATOR_LAST(DISCORD_AUTO_MODERATION_MENTION_SPAM, = 5) ENUM_END #endif @@ -64,24 +64,40 @@ STRUCT(discord_auto_moderation_trigger_metadata) * @note associated with @ref DISCORD_AUTO_MODERATION_KEYWORD */ FIELD_STRUCT_PTR(keyword_filter, strings, *) + /** + * regular expression patterns which will be matched against content + * @note associated with @ref DISCORD_AUTO_MODERATION_KEYWORD + */ + FIELD_STRUCT_PTR(regex_patterns, strings, *) /** * the internally pre-defined wordsets which will be searched for in * content * @note associated with @ref DISCORD_AUTO_MODERATION_KEYWORD_PRESET */ FIELD_STRUCT_PTR(presets, integers, *) + /** + * substrings which should not trigger the rule + * @note associated with @ref DISCORD_AUTO_MODERATION_KEYWORD and @ref DISCORD_AUTO_MODERATION_KEYWORD_PRESET + */ + FIELD_STRUCT_PTR(allow_list, strings, *) + /** + * total number of unique role and user mentions allowed per message + * @note associated with @ref DISCORD_AUTO_MODERATION_MENTION_SPAM + */ + FIELD(mention_total_limit, int, 0) + /** + * whether to automatically detect mention raids + * @note associated with @ref DISCORD_AUTO_MODERATION_MENTION_SPAM + */ + FIELD(mention_raid_protection_enabled, bool, false) STRUCT_END #endif #if GENCODECS_RECIPE & (DATA | JSON) STRUCT(discord_auto_moderation_action) /** the type of action */ - COND_WRITE(self->type != 0) FIELD_ENUM(type, discord_auto_moderation_action_types) - COND_END - /** - * additional metadata needed during execution for this specific action type - */ + /** additional metadata needed during execution for this specific action type */ COND_WRITE(self->metadata != NULL) FIELD_STRUCT_PTR(metadata, discord_auto_moderation_action_metadata, *) COND_END @@ -100,22 +116,27 @@ STRUCT(discord_auto_moderation_action_metadata) * channel to which user content should be logged * @note associated with @ref DISCORD_AUTO_MODERATION_ACTION_SEND_ALERT_MESSAGE */ - COND_WRITE(self->channel_id != 0) FIELD_SNOWFLAKE(channel_id) - COND_END /** * timeout duration in seconds * @note associated with @ref DISCORD_AUTO_MODERATION_ACTION_TIMEOUT * @note maximum of 2419200 seconds (4 weeks) */ - COND_WRITE(self->duration_seconds != 0) FIELD(duration_seconds, int, 0) + /** + * additional explanation that will be shown to members + * whenever their message is blocked + * @note associated with @ref DISCORD_AUTO_MODERATION_ACTION_BLOCK_MESSAGE + * @note maximum of 150 characters + */ + COND_WRITE(self->custom_message != NULL) + FIELD_PTR(custom_message, char, *) COND_END STRUCT_END #endif /** @CCORD_pub_struct{discord_auto_moderation_rule} */ -#if GENCODECS_RECIPE & (DATA | JSON_DECODER) +#if GENCODECS_RECIPE & (DATA | JSON) PUB_STRUCT(discord_auto_moderation_rule) /** the ID of this rule */ FIELD_SNOWFLAKE(id) @@ -126,13 +147,9 @@ PUB_STRUCT(discord_auto_moderation_rule) /** the ID of the user which first created this rule */ FIELD_SNOWFLAKE(creator_id) /** the rule event type */ - COND_WRITE(self->event_type != 0) FIELD_ENUM(event_type, discord_auto_moderation_event_types) - COND_END /** the rule trigger type */ - COND_WRITE(self->trigger_type != 0) FIELD_ENUM(trigger_type, discord_auto_moderation_trigger_types) - COND_END /** the actions which will execute when the rule is triggered */ FIELD_STRUCT_PTR(actions, discord_auto_moderation_actions, *) /** the actions which will execute when the rule is triggered */ @@ -147,7 +164,7 @@ STRUCT_END #endif /** @CCORD_pub_list{discord_auto_moderation_rules} */ -#if GENCODECS_RECIPE & (DATA | JSON_DECODER) +#if GENCODECS_RECIPE & (DATA | JSON) PUB_LIST(discord_auto_moderation_rules) LISTTYPE_STRUCT(discord_auto_moderation_rule) LIST_END @@ -167,23 +184,21 @@ PUB_STRUCT(discord_create_auto_moderation_rule) /** the rule name */ FIELD_PTR(name, char, *) /** the rule event type */ - COND_WRITE(self->event_type != 0) FIELD_ENUM(event_type, discord_auto_moderation_event_types) - COND_END /** the rule trigger type */ COND_WRITE(self->trigger_type != 0) FIELD_ENUM(trigger_type, discord_auto_moderation_trigger_types) COND_END /** the actions which will execute when the rule is triggered */ - COND_WRITE(self->actions != NULL) - FIELD_STRUCT_PTR(actions, discord_auto_moderation_actions, *) - COND_END - /** the actions which will execute when the rule is triggered */ COND_WRITE(self->trigger_metadata != NULL) FIELD_STRUCT_PTR(trigger_metadata, discord_auto_moderation_trigger_metadata, *) COND_END + /** the actions which will execute when the rule is triggered */ + FIELD_STRUCT_PTR(actions, discord_auto_moderation_actions, *) /** whether the rule is enabled */ + COND_WRITE(self->enabled != false) FIELD(enabled, bool, false) + COND_END /** the role ids that should not be affected by the rule (Maximum of 20) */ COND_WRITE(self->exempt_roles != NULL) FIELD_STRUCT_PTR(exempt_roles, snowflakes, *) @@ -203,13 +218,9 @@ PUB_STRUCT(discord_modify_auto_moderation_rule) FIELD_PTR(reason, char, *) #endif /** the rule name */ - COND_WRITE(self->name != NULL) FIELD_PTR(name, char, *) - COND_END /** the rule event type */ - COND_WRITE(self->event_type != 0) FIELD_ENUM(event_type, discord_auto_moderation_event_types) - COND_END /** the actions which will execute when the rule is triggered */ COND_WRITE(self->trigger_metadata != NULL) FIELD_STRUCT_PTR(trigger_metadata, discord_auto_moderation_trigger_metadata, *) diff --git a/gencodecs/api/emoji.PRE.h b/gencodecs/api/emoji.PRE.h index 89a359001..ba2f39aa2 100644 --- a/gencodecs/api/emoji.PRE.h +++ b/gencodecs/api/emoji.PRE.h @@ -18,14 +18,22 @@ PUB_STRUCT(discord_emoji) FIELD_STRUCT_PTR(user, discord_user, *) COND_END /** whether this emoji must be wrapped in colons */ + COND_WRITE(self->require_colons != false) FIELD(require_colons, bool, false) + COND_END /** whether this emoji is managed */ + COND_WRITE(self->managed != false) FIELD(managed, bool, false) + COND_END /** whether this emoji is animated */ + COND_WRITE(self->animated != false) FIELD(animated, bool, false) + COND_END /** whether this emoji can be used, may be false due to loss of Server Boosts */ + COND_WRITE(self->available != false) FIELD(available, bool, false) + COND_END STRUCT_END #endif @@ -53,9 +61,7 @@ PUB_STRUCT(discord_create_guild_emoji) /** the 128x128 emoji image */ FIELD_PTR(image, char, *) /** roles allowed to use this emoji */ - COND_WRITE(self->roles != NULL) FIELD_STRUCT_PTR(roles, snowflakes, *) - COND_END STRUCT_END #endif @@ -68,9 +74,6 @@ PUB_STRUCT(discord_modify_guild_emoji) #endif /** name of the emoji */ FIELD_PTR(name, char, *) - /* TODO: implement base64 encoding */ - /** the 128x128 emoji image */ - FIELD_PTR(image, char, *) /** roles allowed to use this emoji */ COND_WRITE(self->roles != NULL) FIELD_STRUCT_PTR(roles, snowflakes, *) diff --git a/gencodecs/api/entitlements.PRE.h b/gencodecs/api/entitlements.PRE.h new file mode 100644 index 000000000..89c3954c8 --- /dev/null +++ b/gencodecs/api/entitlements.PRE.h @@ -0,0 +1,71 @@ +/***************************************************************************** + * Entitlement Datatypes + * **************************************************************************/ + +/** Discord polls + * @see https://discord.com/developers/docs/monetization/entitlements */ + +#if GENCODECS_RECIPE == DATA +ENUM(discord_entitlement_types) + /** entitlement was purchased by user */ + ENUMERATOR(DISCORD_ENTITLEMENT_PURCHASE, = 1) + /** entitlement for Discord Nitro subscription */ + ENUMERATOR(DISCORD_ENTITLEMENT_PREMIUM_SUBSCRIPTION, = 2) + /** entitlement was gifted by developer */ + ENUMERATOR(DISCORD_ENTITLEMENT_DEVELOPER_GIFT, = 3) + /** entitlement was purchased by a dev in application test mode */ + ENUMERATOR(DISCORD_ENTITLEMENT_TEST_MODE_PURCHASE, = 4) + /** entitlement was granted when the SKU was free */ + ENUMERATOR(DISCORD_ENTITLEMENT_FREE_PURCHASE, = 5) + /** entitlement was gifted by another user */ + ENUMERATOR(DISCORD_ENTITLEMENT_USER_GIFT, = 6) + /** entitlement was claimed by user for free as a Nitro Subscriber */ + ENUMERATOR(DISCORD_ENTITLEMENT_PREMIUM_PURCHASE, = 7) + /** entitlement was purchased as an app subscription */ + ENUMERATOR_LAST(DISCORD_ENTITLEMENT_APPLICATION_SUBSCRIPTION, = 8) +ENUM_END +#endif + +/** @CCORD_pub_struct{discord_entitlement} */ +#if GENCODECS_RECIPE & (DATA | JSON) +PUB_STRUCT(discord_entitlement) + /** ID of the entitlement */ + FIELD_SNOWFLAKE(id) + /** ID of the SKU */ + FIELD_SNOWFLAKE(sku_id) + /** ID of the parent application */ + FIELD_SNOWFLAKE(application_id) + /** ID of the user that is granted access + to the entitlement's sku */ + COND_WRITE(self->user_id != 0) + FIELD_SNOWFLAKE(user_id) + COND_END + /** the type of entitlement */ + FIELD_ENUM(type, discord_entitlement_types) + /** if the entitlement was deleted */ + FIELD(deleted, bool, false) + /** start date at which the entitlement is valid */ + COND_WRITE(self->start_date != 0) + FIELD_TIMESTAMP(start_date) + COND_END + /** date at which the entitlement is no longer valid */ + COND_WRITE(self->end_date != 0) + FIELD_TIMESTAMP(end_date) + COND_END + /** ID of the guild that is granted access to the entitlement's sku */ + COND_WRITE(self->guild_id != 0) + FIELD_SNOWFLAKE(guild_id) + COND_END + /** for consumable items, whether or not the entitlement has been consumed */ + FIELD(consumed, bool, false) +STRUCT_END +#endif + + +/** @CCORD_pub_list{discord_entitlements} */ +#if GENCODECS_RECIPE & (DATA | JSON) +PUB_LIST(discord_entitlements) + LISTTYPE_STRUCT(discord_entitlement) +LIST_END + +#endif diff --git a/gencodecs/api/gateway.PRE.h b/gencodecs/api/gateway.PRE.h index 4eee5afcb..5d30e57f6 100644 --- a/gencodecs/api/gateway.PRE.h +++ b/gencodecs/api/gateway.PRE.h @@ -474,6 +474,103 @@ PUB_STRUCT(discord_channel_pins_update) STRUCT_END #endif +/** @CCORD_pub_struct{discord_thread_create} */ +#if GENCODECS_RECIPE & (DATA | JSON_DECODER) +PUB_STRUCT(discord_thread_create) + /** the ID of this channel */ + FIELD_SNOWFLAKE(id) + /** the type of channel */ + FIELD_ENUM(type, discord_channel_types) + /** the ID of the guild (may be missing for some channel objects received + over gateway guild dispatches) */ + COND_WRITE(self->guild_id != 0) + FIELD_SNOWFLAKE(guild_id) + COND_END + /** sorting position of the channel */ + FIELD(position, int, 0) + /** explicit permission overwrites for members and roles */ + FIELD_STRUCT_PTR(permission_overwrites, discord_overwrites, *) + /** the name of the channel (0-1024 characters) */ + FIELD_PTR(name, char, *) + /** the channel topic (0-1024 characters) */ + FIELD_PTR(topic, char, *) + /** whether the channel is nsfw */ + FIELD(nsfw, bool, false) + /** the id of the last message sent in this channel (may not point to an + existing or valid message) */ + FIELD_SNOWFLAKE(last_message_id) + /** the bitrate (in bits) of the voice channel */ + FIELD(bitrate, int, 0) + /** the user limit of the voice channel */ + FIELD(user_limit, int, 0) + /** amount of seconds a user has to wait before sending another message + (0-21600). bots, as well as users with the permission + `MANAGE_MESSAGES` or `MANAGE_CHANNEL` are unaffected */ + FIELD(rate_limit_per_user, int, 0) + /** array of user objects */ + FIELD_STRUCT_PTR(recipients, discord_users, *) + /** icon hash of the group DM */ + FIELD_PTR(icon, char, *) + /** id of the creator of the group DM or thread */ + FIELD_SNOWFLAKE(owner_id) + /** application ID of the group DM creator if its bot-created */ + FIELD_SNOWFLAKE(application_id) + /** for group DM channels: whether the channel is managed by an application + via the gdm.join OAuth2 scope */ + FIELD(managed, bool, false) + /** for guild channels: ID of the parent category for a channel (each + parent category can contain up to 50 channels), for threads: id of + the text channel this thread was created */ + FIELD_SNOWFLAKE(parent_id) + /** when the last pinned message was pinned. This may be `NULL` in events + such as `GUILD_CREATE` when a message is not pinned */ + FIELD_TIMESTAMP(last_pin_timestamp) + /** voice region ID for the voice channel, automatic when set to null */ + FIELD_PTR(rtc_region, char, *) + /** the camera video quality mode of the voice channel, 1 when not present */ + FIELD(voice_quality_mode, int, 0) + /** an approximate count of messages in a thread, stops counting at 50 */ + FIELD(message_count, int, 0) + /** an approximate count of users in a thread, stops counting at 50 */ + FIELD(member_count, int, 0) + /** thread-specific fields not needed by other channels */ + FIELD_STRUCT_PTR(thread_metadata, discord_thread_metadata, *) + /** thread member object for the current user, if they have joined the + thread, only included on certain API endpoints */ + FIELD_STRUCT_PTR(member, discord_thread_member, *) + /** default duration that the clients (not the API) will use for newly + created threads, in minutes, to automatically archive the thread + after recent activity, can be set to: 60, 1440, 4320, 10080 */ + FIELD(default_auto_archive_duration, int, 0) + /** computed permissions for the invoking user in the channel, including + overwrites, only included when part of the `resolved` data received + on a application command interaction */ + FIELD_BITMASK(permissions) + /** channel flags combined as a bitfield */ + FIELD_BITMASK(flags) + /** number of messages ever sent in a thread */ + FIELD(total_message_sent, int, 0) + /** the set of tags that can be used in a GUILD_FORUM or a GUILD_MEDIA channel */ + FIELD_STRUCT_PTR(available_tags, discord_thread_tags, *) + /** the IDs of the set of tags that have been applied to a thread + in a GUILD_FORUM or a GUILD_MEDIA channel */ + FIELD_STRUCT_PTR(applied_tags, snowflakes, *) + /** the emoji to show in the add reaction button on a thread + in a GUILD_FORUM or a GUILD_MEDIA channel */ + FIELD_STRUCT_PTR(default_reaction_emoji, discord_thread_default_reaction, *) + /** the initial rate_limit_per_user to set on newly created threads in a channel */ + FIELD(default_thread_rate_limit_per_user, int, 0) + /** the default sort order type used to order posts in GUILD_FORUM + and GUILD_MEDIA channels */ + FIELD_ENUM(default_sort_order, discord_sort_order_types) + /** he default forum layout view used to display posts in GUILD_FORUM channels */ + FIELD_ENUM(default_forum_layout, discord_forum_layout_types) + /** Whether tdiscord_channel)he thread has been just created */ + FIELD(newly_created, bool, false) + /**/ +STRUCT_END +#endif + /** @CCORD_pub_struct{discord_guild_ban_add} */ #if GENCODECS_RECIPE & (DATA | JSON_DECODER) PUB_STRUCT(discord_guild_ban_add) diff --git a/gencodecs/api/guild_scheduled_event.PRE.h b/gencodecs/api/guild_scheduled_event.PRE.h index 43ee4959f..5cf318554 100644 --- a/gencodecs/api/guild_scheduled_event.PRE.h +++ b/gencodecs/api/guild_scheduled_event.PRE.h @@ -97,9 +97,7 @@ STRUCT(discord_guild_scheduled_event_user) /** the scheduled event ID which the user subscribed to */ FIELD_SNOWFLAKE(guild_scheduled_event_id) /** user which subscribed to an event */ - COND_WRITE(self->user != NULL) FIELD_STRUCT_PTR(user, discord_user, *) - COND_END /** guild member data for this user for the guild which this event belongs to, if any */ COND_WRITE(self->member != NULL) @@ -144,13 +142,9 @@ PUB_STRUCT(discord_create_guild_scheduled_event) /** the name of the scheduled event */ FIELD_PTR(name, char, *) /** the privacy level of the scheduled event */ - COND_WRITE(self->privacy_level != 0) FIELD_ENUM(privacy_level, discord_guild_scheduled_event_privacy_level) - COND_END /** the time the scheduled event will start */ - COND_WRITE(self->scheduled_start_time != 0) FIELD_TIMESTAMP(scheduled_start_time) - COND_END /** the time the scheduled event will end */ COND_WRITE(self->scheduled_end_time != 0) FIELD_TIMESTAMP(scheduled_end_time) @@ -160,13 +154,9 @@ PUB_STRUCT(discord_create_guild_scheduled_event) FIELD_PTR(description, char, *) COND_END /** the entity type of the scheduled event */ - COND_WRITE(self->entity_type != 0) FIELD_ENUM(entity_type, discord_guild_scheduled_event_entity_types) - COND_END /** the cover image of the scheduled event */ - COND_WRITE(self->image != NULL) FIELD_PTR(image, char, *) - COND_END STRUCT_END #endif @@ -193,7 +183,13 @@ PUB_STRUCT(discord_modify_guild_scheduled_event) FIELD_STRUCT_PTR(entity_metadata, discord_guild_scheduled_event_entity_metadata, *) COND_END /** the name of the scheduled event */ + COND_WRITE(self->name != NULL) FIELD_PTR(name, char, *) + COND_END + /** the privacy level of the scheduled event */ + COND_WRITE(self->privacy_level != 0) + FIELD_ENUM(privacy_level, discord_guild_scheduled_event_privacy_level) + COND_END /** the time the scheduled event will start */ COND_WRITE(self->scheduled_start_time != 0) FIELD_TIMESTAMP(scheduled_start_time) @@ -224,9 +220,13 @@ STRUCT_END #if GENCODECS_RECIPE == DATA STRUCT(discord_get_guild_scheduled_event_users) /** number of users to return (up to maximum of 100) */ + COND_WRITE(self->limit != 0) FIELD(limit, int, 0) + COND_END /** include guild member data if exists */ + COND_WRITE(self->with_member != false) FIELD(with_member, bool, false) + COND_END /** consider only users before given user ID */ COND_WRITE(self->before != 0) FIELD_SNOWFLAKE(before) diff --git a/gencodecs/api/interactions.PRE.h b/gencodecs/api/interactions.PRE.h index 42ef95607..5327f2a72 100644 --- a/gencodecs/api/interactions.PRE.h +++ b/gencodecs/api/interactions.PRE.h @@ -2,6 +2,7 @@ * Interactions Datatypes * **************************************************************************/ +/* TODO: add comments */ #if GENCODECS_RECIPE == DATA ENUM(discord_interaction_types) ENUMERATOR(DISCORD_INTERACTION_PING, = 1) @@ -12,6 +13,24 @@ ENUM(discord_interaction_types) ENUM_END #endif +#if GENCODECS_RECIPE == DATA +ENUM(discord_interaction_context_type) + /** interaction can be used within servers */ + ENUMERATOR(DISCORD_INTERACTION_CONTEXT_GUILD, = 1) + /** interaction can be used within DMs with the app's bot user */ + ENUMERATOR(DISCORD_INTERACTION_CONTEXT_BOT_DM, = 2) + /** interaction can be used within Group DMs and DMs other than the app's bot user */ + ENUMERATOR_LAST(DISCORD_INTERACTION_CONTEXT_PRIVATE_CHANNEL, = 3) +ENUM_END +#endif + +/** @CCORD_pub_list{discord_interaction_context_type} */ +#if GENCODECS_RECIPE & (DATA | JSON) +PUB_LIST(discord_interaction_context_types) + LISTTYPE_ENUM(discord_interaction_context_type) +LIST_END +#endif + #if GENCODECS_RECIPE == DATA ENUM(discord_interaction_callback_types) /** ACK a @ref DISCORD_INTERACTION_PING */ @@ -29,7 +48,10 @@ ENUM(discord_interaction_callback_types) /** respond to an autocomplete interaction with suggested choices */ ENUMERATOR(DISCORD_INTERACTION_APPLICATION_COMMAND_AUTOCOMPLETE_RESULT, = 8) /** respond to an interaction with a popup modal */ - ENUMERATOR_LAST(DISCORD_INTERACTION_MODAL, = 9) + ENUMERATOR(DISCORD_INTERACTION_MODAL, = 9) + /** respond to an interaction with an upgrade button, + only available for apps with monetization enabled */ + ENUMERATOR_LAST(DISCORD_INTERACTION_PREMIUM_REQUIRED, = 10) ENUM_END #endif @@ -46,6 +68,8 @@ PUB_STRUCT(discord_interaction) FIELD_STRUCT_PTR(data, discord_interaction_data, *) /** the guild it was sent from */ FIELD_SNOWFLAKE(guild_id) + /** partial channel object that the interaction was sent from */ + FIELD_STRUCT_PTR(channel, discord_channel, *) /** the channel it was sent from */ FIELD_SNOWFLAKE(channel_id) /** guild member data for the invoking user, including permissions */ @@ -58,15 +82,28 @@ PUB_STRUCT(discord_interaction) FIELD(version, int, 1) /** for components, the message they were attached to */ FIELD_STRUCT_PTR(message, discord_message, *) + /** bitwise set of permissions the app has in the source location + of the interaction */ + FIELD_PTR(app_permissions, char, *) /** the selected language of the invoking user */ FIELD_PTR(locale, char, *) /** the guild preferred locale, if invoked in a guild */ FIELD_PTR(guild_locale, char, *) + /** for monetized apps, any entitlements for the invoking user, + representing access to premium SKUs */ + COND_WRITE(self->entitlements != NULL) + FIELD_STRUCT_PTR(entitlements, discord_entitlements, *) + COND_END + /* TODO: Add "authorizing_integration_owners" -- What do they mean with dictionary? */ + /** context where the interaction was triggered from */ + FIELD_ENUM(context, discord_interaction_context_type) STRUCT_END #endif #if GENCODECS_RECIPE & (DATA | JSON) STRUCT(discord_interaction_data) + /** Those are always present for application commands: */ + /** the ID of the invoked command */ FIELD_SNOWFLAKE(id) /** the name of the invoked command */ @@ -74,19 +111,37 @@ STRUCT(discord_interaction_data) /** the type of the invoked command */ FIELD_ENUM(type, discord_application_command_types) /** converted users + roles + channels + attachments */ + COND_WRITE(self->resolved != NULL) FIELD_STRUCT_PTR(resolved, discord_resolved_data, *) + COND_END /** the params + values from the user */ + COND_WRITE(self->options != NULL) FIELD_STRUCT_PTR(options, discord_application_command_interaction_data_options, *) + COND_END + /** the id of the guild the command is registered to */ + FIELD_SNOWFLAKE(guild_id) + /** the ID of the user or messaged targetted by a user or message command */ + FIELD_SNOWFLAKE(target_id) + + /** Those are always present for select menu components: */ + /** the custom_id of the component */ + COND_WRITE(self->custom_id != NULL) FIELD_PTR(custom_id, char, *) + COND_END /** the type of the component */ FIELD_ENUM(component_type, discord_component_types) /** the values the user selected */ + COND_WRITE(self->values != NULL) FIELD_STRUCT_PTR(values, strings, *) - /** the ID of the user or messaged targetted by a user or message command */ - FIELD_SNOWFLAKE(target_id) + COND_END + + /** This is always present for model submits: */ + /** the values submitted by the user */ + COND_WRITE(self->components != NULL) FIELD_STRUCT_PTR(components, discord_components, *) + COND_END STRUCT_END #endif @@ -140,7 +195,9 @@ STRUCT(discord_interaction_callback_data) COND_WRITE(self->components != NULL) FIELD_STRUCT_PTR(components, discord_components, *) COND_END - /* MESSAGES */ + + /* Those are only available for Messages: */ + /** is the response TTS */ COND_WRITE(self->tts != false) FIELD(tts, bool, false) diff --git a/gencodecs/api/invite.PRE.h b/gencodecs/api/invite.PRE.h index 9695c6126..1b0bc0a0c 100644 --- a/gencodecs/api/invite.PRE.h +++ b/gencodecs/api/invite.PRE.h @@ -38,10 +38,13 @@ PUB_STRUCT(discord_invite) FIELD_STRUCT_PTR(target_application, discord_application, *) COND_END /** approximate count of online members */ + COND_WRITE(self->approximate_presence_count != 0) FIELD(approximate_presence_count, int, 0) + COND_END /** approximate count of total members */ + COND_WRITE(self->approximate_member_count != 0) FIELD(approximate_member_count, int, 0) - /* TODO: nullable */ + COND_END /** the expiration date of this invite */ COND_WRITE(self->expires_at != 0) FIELD_TIMESTAMP(expires_at) @@ -77,18 +80,14 @@ STRUCT(discord_invite_metadata) /** whether this invite only grants temporary membership */ FIELD(temporary, bool, false) /** when this invite was created */ - COND_WRITE(self->created_at != 0) FIELD_TIMESTAMP(created_at) - COND_END STRUCT_END #endif #if GENCODECS_RECIPE & (DATA | JSON) STRUCT(discord_invite_stage_instance) /** the members speaking in the Stage */ - COND_WRITE(self->members != NULL) FIELD_STRUCT_PTR(members, discord_guild_members, *) - COND_END /** the number of users in the Stage */ FIELD(participant_count, int, 0) /** the number of users speaking in the Stage */ @@ -106,9 +105,13 @@ STRUCT_END #if GENCODECS_RECIPE & (DATA | JSON) PUB_STRUCT(discord_get_invite) /** whether the invite should contain approximate member counts */ + COND_WRITE(self->with_counts != false) FIELD(with_counts, bool, false) + COND_END /** whether the invite should contain the expiration date */ + COND_WRITE(self->with_expiration != false) FIELD(with_expiration, bool, false) + COND_END /** the guild scheduled event to include with the invite */ COND_WRITE(self->guild_scheduled_event_id != 0) FIELD_SNOWFLAKE(guild_scheduled_event_id) diff --git a/gencodecs/api/message_components.PRE.h b/gencodecs/api/message_components.PRE.h index 0e38fe5ee..2442e7a84 100644 --- a/gencodecs/api/message_components.PRE.h +++ b/gencodecs/api/message_components.PRE.h @@ -102,9 +102,7 @@ PUB_STRUCT(discord_component) FIELD_SNOWFLAKE(id) COND_END /** component type */ - COND_WRITE(self->type != 0) FIELD_ENUM(type, discord_component_types) - COND_END /** a developer-defined identifier for the component, max 100 characters */ FIELD_PTR(custom_id, char, *) /** identifier for a purchasable SKU, only available when using premium-style buttons */ @@ -169,7 +167,9 @@ STRUCT(discord_select_option) /** the dev-define value of the option, max 100 characters */ FIELD_PTR(value, char, *) /** an additional description of the option, max 100 characters */ + COND_WRITE(self->description != NULL) FIELD_PTR(description, char, *) + COND_END /** `id`, `name`, and `animated` */ COND_WRITE(self->emoji != NULL) FIELD_STRUCT_PTR(emoji, discord_emoji, *) diff --git a/gencodecs/api/poll.PRE.h b/gencodecs/api/poll.PRE.h new file mode 100644 index 000000000..79545c8f4 --- /dev/null +++ b/gencodecs/api/poll.PRE.h @@ -0,0 +1,122 @@ +/***************************************************************************** + * Pool Datatypes + * **************************************************************************/ + +/** Discord polls + * @see https://discord.com/developers/docs/resources/poll */ + +/** @CCORD_pub_struct{discord_poll_question} */ +#if GENCODECS_RECIPE & (DATA | JSON) +PUB_STRUCT(discord_poll_question) + /** the text of the field */ + COND_WRITE(self->text != NULL) + FIELD_PTR(text, char, *) + COND_END + /** the emoji of the field */ + COND_WRITE(self->emoji != NULL) + FIELD_STRUCT_PTR(emoji, discord_emoji, *) + COND_END +STRUCT_END +#endif + +/** @CCORD_pub_struct{discord_poll} */ +#if GENCODECS_RECIPE & (DATA | JSON) +PUB_STRUCT(discord_poll) + /** the ID of this channel */ + FIELD_SNOWFLAKE(id) + /** the type of channel */ + FIELD_ENUM(type, discord_channel_types) + /** the ID of the guild (may be missing for some channel objects received + over gateway guild dispatches) */ + COND_WRITE(self->guild_id != 0) + FIELD_SNOWFLAKE(guild_id) + COND_END + /** sorting position of the channel */ + FIELD(position, int, 0) + /** explicit permission overwrites for members and roles */ + FIELD_STRUCT_PTR(permission_overwrites, discord_overwrites, *) + /** the name of the channel (0-1024 characters) */ + FIELD_PTR(name, char, *) + /** the channel topic (0-1024 characters) */ + FIELD_PTR(topic, char, *) + /** whether the channel is nsfw */ + FIELD(nsfw, bool, false) + /** the id of the last message sent in this channel (may not point to an + existing or valid message) */ + FIELD_SNOWFLAKE(last_message_id) + /** the bitrate (in bits) of the voice channel */ + FIELD(bitrate, int, 0) + /** the user limit of the voice channel */ + FIELD(user_limit, int, 0) + /** amount of seconds a user has to wait before sending another message + (0-21600). bots, as well as users with the permission + `MANAGE_MESSAGES` or `MANAGE_CHANNEL` are unaffected */ + FIELD(rate_limit_per_user, int, 0) + /** array of user objects */ + FIELD_STRUCT_PTR(recipients, discord_users, *) + /** icon hash of the group DM */ + FIELD_PTR(icon, char, *) + /** id of the creator of the group DM or thread */ + FIELD_SNOWFLAKE(owner_id) + /** application ID of the group DM creator if its bot-created */ + FIELD_SNOWFLAKE(application_id) + /** for group DM channels: whether the channel is managed by an application + via the gdm.join OAuth2 scope */ + FIELD(managed, bool, false) + /** for guild channels: ID of the parent category for a channel (each + parent category can contain up to 50 channels), for threads: id of + the text channel this thread was created */ + FIELD_SNOWFLAKE(parent_id) + /** when the last pinned message was pinned. This may be `NULL` in events + such as `GUILD_CREATE` when a message is not pinned */ + FIELD_TIMESTAMP(last_pin_timestamp) + /** voice region ID for the voice channel, automatic when set to null */ + FIELD_PTR(rtc_region, char, *) + /** the camera video quality mode of the voice channel, 1 when not present */ + FIELD(voice_quality_mode, int, 0) + /** an approximate count of messages in a thread, stops counting at 50 */ + FIELD(message_count, int, 0) + /** an approximate count of users in a thread, stops counting at 50 */ + FIELD(member_count, int, 0) + /** thread-specific fields not needed by other channels */ + FIELD_STRUCT_PTR(thread_metadata, discord_thread_metadata, *) + /** thread member object for the current user, if they have joined the + thread, only included on certain API endpoints */ + FIELD_STRUCT_PTR(member, discord_thread_member, *) + /** default duration that the clients (not the API) will use for newly + created threads, in minutes, to automatically archive the thread + after recent activity, can be set to: 60, 1440, 4320, 10080 */ + FIELD(default_auto_archive_duration, int, 0) + /** computed permissions for the invoking user in the channel, including + overwrites, only included when part of the `resolved` data received + on a application command interaction */ + FIELD_BITMASK(permissions) + /** channel flags combined as a bitfield */ + FIELD_BITMASK(flags) + /** number of messages ever sent in a thread */ + FIELD(total_message_sent, int, 0) + /** the set of tags that can be used in a GUILD_FORUM or a GUILD_MEDIA channel */ + FIELD_STRUCT_PTR(available_tags, discord_thread_tags, *) + /** the IDs of the set of tags that have been applied to a thread + in a GUILD_FORUM or a GUILD_MEDIA channel */ + FIELD_STRUCT_PTR(applied_tags, snowflakes, *) + /** the emoji to show in the add reaction button on a thread + in a GUILD_FORUM or a GUILD_MEDIA channel */ + FIELD_STRUCT_PTR(default_reaction_emoji, discord_thread_default_reaction, *) + /** the initial rate_limit_per_user to set on newly created threads in a channel */ + FIELD(default_thread_rate_limit_per_user, int, 0) + /** the default sort order type used to order posts in GUILD_FORUM + and GUILD_MEDIA channels */ + FIELD_ENUM(default_sort_order, discord_sort_order_types) + /** he default forum layout view used to display posts in GUILD_FORUM channels */ + FIELD_ENUM(default_forum_layout, discord_forum_layout_types) +STRUCT_END +#endif + +/** @CCORD_pub_list{discord_poll_answer_voters} */ +#if GENCODECS_RECIPE & (DATA | JSON) +PUB_STRUCT(discord_poll_answer_voters) + /** users who voted for this answer */ + FIELD_STRUCT_PTR(users, discord_user, *) +STRUCT_END +#endif diff --git a/gencodecs/api/stage_instance.PRE.h b/gencodecs/api/stage_instance.PRE.h index 48597de99..f48d2aedb 100644 --- a/gencodecs/api/stage_instance.PRE.h +++ b/gencodecs/api/stage_instance.PRE.h @@ -23,11 +23,11 @@ PUB_STRUCT(discord_stage_instance) /** the topic of the Stage instance (1-120 characters) */ FIELD_PTR(topic, char, *) /** the privacy level of the stage instance */ - COND_WRITE(self->privacy_level != 0) FIELD_ENUM(privacy_level, discord_privacy_level) - COND_END /** whether or not stage discovery is disabled @deprecated deprecated field */ FIELD(discoverable_disabled, bool, false) + /** the id of the scheduled event for this Stage instance */ + FIELD_SNOWFLAKE(guild_scheduled_event_id) STRUCT_END #endif @@ -42,7 +42,7 @@ LIST_END * **************************************************************************/ /** @CCORD_pub_struct{discord_create_stage_instance} */ -#if GENCODECS_RECIPE & (DATA | JSON_DECODER) +#if GENCODECS_RECIPE & (DATA | JSON) PUB_STRUCT(discord_create_stage_instance) /** @CCORD_reason{reason} */ #if GENCODECS_RECIPE == DATA @@ -56,18 +56,28 @@ PUB_STRUCT(discord_create_stage_instance) COND_WRITE(self->privacy_level != 0) FIELD_ENUM(privacy_level, discord_privacy_level) COND_END + /** notify @everyone that a Stage instance has started */ + COND_WRITE(self->send_start_notification != false) + FIELD(send_start_notification, bool, false) + COND_END + /** the id of the scheduled event for this Stage instance */ + COND_WRITE(self->guild_scheduled_event_id != 0) + FIELD_SNOWFLAKE(guild_scheduled_event_id) + COND_END STRUCT_END #endif /** @CCORD_pub_struct{discord_modify_stage_instance} */ -#if GENCODECS_RECIPE & (DATA | JSON_DECODER) +#if GENCODECS_RECIPE & (DATA | JSON) PUB_STRUCT(discord_modify_stage_instance) /** @CCORD_reason{reason} */ #if GENCODECS_RECIPE == DATA FIELD_PTR(reason, char, *) #endif /** the topic of the Stage instance (1-120 characters) */ + COND_WRITE(self->topic != NULL) FIELD_PTR(topic, char, *) + COND_END /** the privacy level of the stage instance */ COND_WRITE(self->privacy_level != 0) FIELD_ENUM(privacy_level, discord_privacy_level) diff --git a/gencodecs/api/sticker.PRE.h b/gencodecs/api/sticker.PRE.h index 1a781819e..7cf6805aa 100644 --- a/gencodecs/api/sticker.PRE.h +++ b/gencodecs/api/sticker.PRE.h @@ -35,17 +35,21 @@ PUB_STRUCT(discord_sticker) FIELD_PTR(description, char, *) /** autocomplete/suggestion tags for the sticker (max 200 characters) */ FIELD_PTR(tags, char, *) + /** the sticker asset hash, now an empty string @deprecated deprecated field */ + COND_WRITE(self->asset != NULL) + FIELD_PTR(asset, char, *) + COND_END /** type of sticker */ - COND_WRITE(self->type != 0) FIELD_ENUM(type, discord_sticker_types) - COND_END /** type of sticker format */ COND_WRITE(self->format_type != 0) FIELD_ENUM(format_type, discord_sticker_format_types) COND_END /** whether this guild sticker can be used, may be false due to loss of Server Boosts */ + COND_WRITE(self->available != false) FIELD(available, bool, false) + COND_END /** ID of the guild that owns this sticker */ COND_WRITE(self->guild_id != 0) FIELD_SNOWFLAKE(guild_id) @@ -73,9 +77,7 @@ STRUCT(discord_sticker_item) /** name of the sticker */ FIELD_PTR(name, char, *) /** type of sticker format */ - COND_WRITE(self->format_type != 0) FIELD_ENUM(format_type, discord_sticker_format_types) - COND_END STRUCT_END #endif @@ -90,9 +92,7 @@ STRUCT(discord_sticker_pack) /** ID of the sticker */ FIELD_SNOWFLAKE(id) /** the stickers in the pack */ - COND_WRITE(self->stickers != NULL) FIELD_STRUCT_PTR(stickers, discord_stickers, *) - COND_END /** name of the sticker pack */ FIELD_PTR(name, char, *) /** ID of the pack's SKU */ @@ -154,12 +154,16 @@ PUB_STRUCT(discord_modify_guild_sticker) FIELD_PTR(description, char, *) /** autocomplete/suggestion tags for the sticker (max 200 characters) */ FIELD_PTR(tags, char, *) + /** @CCORD_reason{reason} */ + FIELD_PTR(reason, char, *) STRUCT_END #endif #if GENCODECS_RECIPE == DATA STRUCT(discord_delete_guild_sticker) /** @CCORD_reason{reason} */ +#if GENCODECS_RECIPE == DATA FIELD_PTR(reason, char, *) +#endif STRUCT_END #endif diff --git a/gencodecs/api/user.PRE.h b/gencodecs/api/user.PRE.h index 0c2eed6a3..033b16deb 100644 --- a/gencodecs/api/user.PRE.h +++ b/gencodecs/api/user.PRE.h @@ -66,6 +66,9 @@ PUB_STRUCT(discord_user) FIELD_PTR(username, char, *) /** the user's 4-digit discord tag */ FIELD_PTR(discriminator, char, *) + /** the user's display name, if it is set. For bots, this is the + application name */ + FIELD_PTR(global_name, char, *) /** the user's avatar hash */ FIELD_PTR(avatar, char, *) /** whether the user belong to an OAuth2 application */ diff --git a/gencodecs/gencodecs.h b/gencodecs/gencodecs.h index b992cb76d..2f3701a4f 100644 --- a/gencodecs/gencodecs.h +++ b/gencodecs/gencodecs.h @@ -23,6 +23,7 @@ # define PUB_LIST GENCODECS_PUB_LIST # define LIST GENCODECS_LIST # define LISTTYPE GENCODECS_LISTTYPE +# define LISTTYPE_ENUM GENCODECS_LISTTYPE_ENUM # define LISTTYPE_STRUCT GENCODECS_LISTTYPE_STRUCT # define LISTTYPE_PTR GENCODECS_LISTTYPE_PTR # define LIST_END GENCODECS_LIST_END diff --git a/gencodecs/recipes/gencodecs-gen.PRE.h b/gencodecs/recipes/gencodecs-gen.PRE.h index cae9f6f4d..9b8e809f2 100644 --- a/gencodecs/recipes/gencodecs-gen.PRE.h +++ b/gencodecs/recipes/gencodecs-gen.PRE.h @@ -55,6 +55,9 @@ #ifndef GENCODECS_LISTTYPE # define GENCODECS_LISTTYPE(_type) #endif +#ifndef GENCODECS_LISTTYPE_ENUM +# define GENCODECS_LISTTYPE_ENUM(_type) +#endif #ifndef GENCODECS_LISTTYPE_STRUCT # define GENCODECS_LISTTYPE_STRUCT(_type) #endif @@ -103,6 +106,7 @@ #undef GENCODECS_PUB_LIST #undef GENCODECS_LIST #undef GENCODECS_LISTTYPE +#undef GENCODECS_LISTTYPE_ENUM #undef GENCODECS_LISTTYPE_STRUCT #undef GENCODECS_LISTTYPE_PTR #undef GENCODECS_LIST_END diff --git a/gencodecs/recipes/json-decoder.h b/gencodecs/recipes/json-decoder.h index 225082941..f63f6d52f 100644 --- a/gencodecs/recipes/json-decoder.h +++ b/gencodecs/recipes/json-decoder.h @@ -83,6 +83,15 @@ carray_insert(self, i, o); \ } +#define GENCODECS_LISTTYPE_ENUM(_type) \ + __carray_init(self, root->size, enum _type, , ); \ + for (i = 0; i < root->size; ++i) { \ + jsmnf_pair *f = root->fields + i; \ + enum _type o; \ + GENCODECS_JSON_DECODER_int(f, js, o, _type); \ + carray_insert(self, i, o); \ + } + #define GENCODECS_LISTTYPE_STRUCT(_type) \ __carray_init(self, root->size, struct _type, , ); \ for (i = 0; i < root->size; ++i) { \ diff --git a/gencodecs/recipes/json-encoder.h b/gencodecs/recipes/json-encoder.h index 0a9ac661e..450bdd398 100644 --- a/gencodecs/recipes/json-encoder.h +++ b/gencodecs/recipes/json-encoder.h @@ -74,8 +74,13 @@ int i; #define GENCODECS_LIST(_type) static GENCODECS_PUB_LIST(_type) #define GENCODECS_LISTTYPE(_type) \ - for (i = 0; i < self->size; ++i) \ - GENCODECS_JSON_ENCODER_##_type(b, buf, size, self->array[i], _type); + for (i = 0; i < self->size; ++i) \ + GENCODECS_JSON_ENCODER_##_type(b, buf, size, self->array[i], \ + _type); +#define GENCODECS_LISTTYPE_ENUM(_type) \ + for (i = 0; i < self->size; ++i) \ + GENCODECS_JSON_ENCODER_int(b, buf, size, self->array[i], \ + enum _type); #define GENCODECS_LISTTYPE_STRUCT(_type) \ for (i = 0; i < self->size; ++i) \ if ((code = _type##_to_jsonb(b, buf, size, &self->array[i]))) \ diff --git a/gencodecs/recipes/struct.h b/gencodecs/recipes/struct.h index 031eed090..174824285 100644 --- a/gencodecs/recipes/struct.h +++ b/gencodecs/recipes/struct.h @@ -35,6 +35,8 @@ int size; #define GENCODECS_LISTTYPE(_type) \ _type *array; +#define GENCODECS_LISTTYPE_ENUM(_type) \ + enum _type *array; #define GENCODECS_LISTTYPE_STRUCT(_type) \ struct _type *array; #define GENCODECS_LISTTYPE_PTR(_type, _decor) \ @@ -123,6 +125,8 @@ static GENCODECS_PUB_LIST(_type) #define GENCODECS_LISTTYPE(_type) \ __carray_free(self, _type, NULL, NULL); +#define GENCODECS_LISTTYPE_ENUM(_type) \ + __carray_free(self, enum _type, NULL, NULL); #define GENCODECS_LISTTYPE_STRUCT(_type) \ __carray_free(self, struct _type, NULL, \ _type##_cleanup(&__CARRAY_OPERAND_A)); diff --git a/include/discord-events.h b/include/discord-events.h index 66f35c7c0..8b78ca331 100644 --- a/include/discord-events.h +++ b/include/discord-events.h @@ -86,6 +86,7 @@ enum discord_gateway_events { DISCORD_EV_GUILD_CREATE, DISCORD_EV_GUILD_UPDATE, DISCORD_EV_GUILD_DELETE, + DISCORD_EV_GUILD_AUDIT_LOG_ENTRY_CREATE, DISCORD_EV_GUILD_BAN_ADD, DISCORD_EV_GUILD_BAN_REMOVE, DISCORD_EV_GUILD_EMOJIS_UPDATE, @@ -412,7 +413,7 @@ void discord_set_on_channel_pins_update( void discord_set_on_thread_create( struct discord *client, void (*callback)(struct discord *client, - const struct discord_channel *event)); + const struct discord_thread_create *event)); /** * @brief Triggers when a thread is updated @@ -513,6 +514,18 @@ void discord_set_on_guild_delete( void (*callback)(struct discord *client, const struct discord_guild *event)); +/** + * @brief Triggers when an audit log entry is created + * @note This implicitly sets @ref DISCORD_GATEWAY_GUILDS intent + * + * @param client the client created with discord_init() + * @param callback the callback to be triggered on event + */ +void discord_set_on_guild_audit_log_entry_create( + struct discord *client, + void (*callback)(struct discord *client, + const struct discord_audit_log_entry *event)); + /** * @brief Triggers when a user is banned from a guild * @note This implicitly sets @ref DISCORD_GATEWAY_GUILD_BANS intent diff --git a/include/discord-response.h b/include/discord-response.h index 8f643a7f3..f81a156e3 100644 --- a/include/discord-response.h +++ b/include/discord-response.h @@ -189,4 +189,9 @@ DISCORD_RETURN(guild_application_command_permissions); DISCORD_RETURN(interaction_response); /** @} DiscordAPIInteractionsReact */ +/** @addtogroup DiscordAPIPolls + * @{ */ +DISCORD_RETURN(poll_answer_voters); +/** @} DiscordAPIPolls */ + #endif /* DISCORD_RESPONSE_H */ diff --git a/include/interaction.h b/include/interaction.h index e1e90ba9c..53e899df9 100644 --- a/include/interaction.h +++ b/include/interaction.h @@ -35,14 +35,14 @@ CCORDcode discord_create_interaction_response( * @param client the client created with discord_init() * @param application_id the unique id of the application * @param interaction_token the unique token of the interaction - * @CCORD_ret_obj{ret,interaction_response} + * @CCORD_ret_obj{ret,interaction} * @CCORD_return */ CCORDcode discord_get_original_interaction_response( struct discord *client, u64snowflake application_id, const char interaction_token[], - struct discord_ret_interaction_response *ret); + struct discord_ret_message *ret); /** * @brief Edit the initial Interaction response diff --git a/include/stage_instance.h b/include/stage_instance.h index 2fd4dbd8e..3647837e9 100644 --- a/include/stage_instance.h +++ b/include/stage_instance.h @@ -66,6 +66,7 @@ CCORDcode discord_modify_stage_instance( */ CCORDcode discord_delete_stage_instance(struct discord *client, u64snowflake channel_id, + struct discord_delete_stage_instance *params, struct discord_ret *ret); /** @} DiscordAPIStageInstance */ diff --git a/include/sticker.h b/include/sticker.h index be4aa5e49..2b2dce3ea 100644 --- a/include/sticker.h +++ b/include/sticker.h @@ -96,6 +96,7 @@ CCORDcode discord_modify_guild_sticker( CCORDcode discord_delete_guild_sticker(struct discord *client, u64snowflake guild_id, u64snowflake sticker_id, + struct discord_delete_guild_sticker *params, struct discord_ret *ret); /** @} DiscordAPISticker */ diff --git a/src/Makefile b/src/Makefile index 14fed08f9..72dfeab1b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -49,6 +49,9 @@ OBJS += concord-once.o \ guild_template.o \ invite.o \ oauth2.o \ + poll.o \ + stage_instance.o \ + sticker.o \ user.o \ voice.o \ webhook.o diff --git a/src/application_command.c b/src/application_command.c index 03565aa03..b687a5591 100644 --- a/src/application_command.c +++ b/src/application_command.c @@ -36,6 +36,10 @@ discord_create_global_application_command( CCORD_BAD_PARAMETER, ""); CCORD_EXPECT_OK(client, discord_create_global_application_command_to_json( &body.start, &body.size, params)); + if (params->type != 2 && params->type != 3) { + CCORD_EXPECT(client, NOT_EMPTY_STR(params->description), + CCORD_BAD_PARAMETER, ""); + } DISCORD_ATTR_INIT(attr, discord_application_command, ret, NULL); return discord_rest_run(&client->rest, &attr, &body, HTTP_POST, "/applications/%" PRIu64 "/commands", @@ -147,6 +151,10 @@ discord_create_guild_application_command( CCORD_BAD_PARAMETER, ""); CCORD_EXPECT_OK(client, discord_create_guild_application_command_to_json( &body.start, &body.size, params)); + if (params->type != 2 && params->type != 3) { + CCORD_EXPECT(client, NOT_EMPTY_STR(params->description), + CCORD_BAD_PARAMETER, ""); + } DISCORD_ATTR_INIT(attr, discord_application_command, ret, NULL); return discord_rest_run(&client->rest, &attr, &body, HTTP_POST, "/applications/%" PRIu64 "/guilds/%" PRIu64 diff --git a/src/discord-events.c b/src/discord-events.c index c89a6c0c5..0398b4a56 100644 --- a/src/discord-events.c +++ b/src/discord-events.c @@ -213,7 +213,7 @@ discord_set_on_channel_pins_update( void discord_set_on_thread_create(struct discord *client, void (*cb)(struct discord *client, - const struct discord_channel *event)) + const struct discord_thread_create *event)) { ASSIGN_CB(DISCORD_EV_THREAD_CREATE, cb); discord_add_intents(client, DISCORD_GATEWAY_GUILDS); @@ -295,6 +295,16 @@ discord_set_on_guild_delete(struct discord *client, discord_add_intents(client, DISCORD_GATEWAY_GUILDS); } +void +discord_set_on_guild_audit_log_entry_create( + struct discord *client, + void (*cb)(struct discord *client, + const struct discord_audit_log_entry *event)) +{ + ASSIGN_CB(DISCORD_EV_GUILD_AUDIT_LOG_ENTRY_CREATE, cb); + discord_add_intents(client, DISCORD_GATEWAY_GUILDS); +} + void discord_set_on_guild_ban_add( struct discord *client, diff --git a/src/discord-gateway_dispatch.c b/src/discord-gateway_dispatch.c index 353e87c1f..620558cc3 100644 --- a/src/discord-gateway_dispatch.c +++ b/src/discord-gateway_dispatch.c @@ -36,7 +36,7 @@ static const struct { [DISCORD_EV_CHANNEL_UPDATE] = INIT(discord_channel), [DISCORD_EV_CHANNEL_DELETE] = INIT(discord_channel), [DISCORD_EV_CHANNEL_PINS_UPDATE] = INIT(discord_channel_pins_update), - [DISCORD_EV_THREAD_CREATE] = INIT(discord_channel), + [DISCORD_EV_THREAD_CREATE] = INIT(discord_thread_create), [DISCORD_EV_THREAD_UPDATE] = INIT(discord_channel), [DISCORD_EV_THREAD_DELETE] = INIT(discord_channel), [DISCORD_EV_THREAD_LIST_SYNC] = INIT(discord_thread_list_sync), @@ -45,6 +45,8 @@ static const struct { [DISCORD_EV_GUILD_CREATE] = INIT(discord_guild), [DISCORD_EV_GUILD_UPDATE] = INIT(discord_guild), [DISCORD_EV_GUILD_DELETE] = INIT(discord_guild), + [DISCORD_EV_GUILD_AUDIT_LOG_ENTRY_CREATE] = + INIT(discord_audit_log_entry), [DISCORD_EV_GUILD_BAN_ADD] = INIT(discord_guild_ban_add), [DISCORD_EV_GUILD_BAN_REMOVE] = INIT(discord_guild_ban_remove), [DISCORD_EV_GUILD_EMOJIS_UPDATE] = INIT(discord_guild_emojis_update), diff --git a/src/interaction.c b/src/interaction.c index e43c91234..5b33eacbe 100644 --- a/src/interaction.c +++ b/src/interaction.c @@ -39,17 +39,16 @@ discord_create_interaction_response( } CCORDcode -discord_get_original_interaction_response( - struct discord *client, - u64snowflake application_id, - const char interaction_token[], - struct discord_ret_interaction_response *ret) +discord_get_original_interaction_response(struct discord *client, + u64snowflake application_id, + const char interaction_token[], + struct discord_ret_message *ret) { struct discord_attributes attr = { 0 }; CCORD_EXPECT(client, application_id != 0, CCORD_BAD_PARAMETER, ""); CCORD_EXPECT(client, NOT_EMPTY_STR(interaction_token), CCORD_BAD_PARAMETER, ""); - DISCORD_ATTR_INIT(attr, discord_interaction_response, ret, NULL); + DISCORD_ATTR_INIT(attr, discord_message, ret, NULL); return discord_rest_run(&client->rest, &attr, NULL, HTTP_GET, "/webhooks/%" PRIu64 "/%s/messages/@original", application_id, interaction_token); diff --git a/src/poll.c b/src/poll.c new file mode 100644 index 000000000..5f66dd65a --- /dev/null +++ b/src/poll.c @@ -0,0 +1,47 @@ +#include +#include +#include + +#include "discord.h" +#include "discord-internal.h" +#include "discord-request.h" + +/****************************************************************************** + * REST functions + ******************************************************************************/ + +CCORDcode +discord_get_answer_voters(struct discord *client, + u64snowflake channel_id, + u64snowflake poll_id, + u64snowflake answer_id, + struct discord_ret_poll_answer_voters *ret) +{ + struct discord_attributes attr = { 0 }; + + CCORD_EXPECT(client, channel_id != 0, CCORD_BAD_PARAMETER, ""); + CCORD_EXPECT(client, poll_id != 0, CCORD_BAD_PARAMETER, ""); + CCORD_EXPECT(client, answer_id != 0, CCORD_BAD_PARAMETER, ""); + + DISCORD_ATTR_INIT(attr, discord_poll_answer_voters, ret, NULL); + + return discord_rest_run(&client->rest, &attr, NULL, HTTP_GET, + "/channnels/%" PRIu64 "/polls/%" PRIu64 "/answers/%" PRIu64, channel_id, poll_id, answer_id); +} + +CCORDcode +discord_end_poll(struct discord *client, + u64snowflake channel_id, + u64snowflake poll_id, + struct discord_ret *ret) +{ + struct discord_attributes attr = { 0 }; + + CCORD_EXPECT(client, channel_id != 0, CCORD_BAD_PARAMETER, ""); + CCORD_EXPECT(client, poll_id != 0, CCORD_BAD_PARAMETER, ""); + + DISCORD_ATTR_BLANK_INIT(attr, ret, NULL); + + return discord_rest_run(&client->rest, &attr, NULL, HTTP_POST, + "/channels/%" PRIu64 "/polls/%" PRIu64 "/expire", channel_id, poll_id); +} diff --git a/src/stage_instance.c b/src/stage_instance.c index b57fb37d1..aa8e7338d 100644 --- a/src/stage_instance.c +++ b/src/stage_instance.c @@ -19,8 +19,8 @@ discord_create_stage_instance(struct discord *client, struct ccord_szbuf body = { 0 }; CCORD_EXPECT(client, params != NULL, CCORD_BAD_PARAMETER, ""); CCORD_EXPECT(client, params->channel_id != 0, CCORD_BAD_PARAMETER, ""); - CCORD_EXPECT(client, IS_NOT_EMPTY_STRING(params->topic), - CCORD_BAD_PARAMETER, ""); + CCORD_EXPECT(client, NOT_EMPTY_STR(params->topic), CCORD_BAD_PARAMETER, + ""); CCORD_EXPECT_OK(client, discord_create_stage_instance_to_json( &body.start, &body.size, params)); DISCORD_ATTR_INIT(attr, discord_stage_instance, ret, params->reason);