|
19 | 19 | *
|
20 | 20 | ************************************************************************************/
|
21 | 21 | #pragma once
|
| 22 | +#include <dpp/integration.h> |
22 | 23 | #include <dpp/export.h>
|
23 | 24 | #include <dpp/snowflake.h>
|
24 | 25 | #include <dpp/managed.h>
|
@@ -773,6 +774,26 @@ enum interaction_type {
|
773 | 774 | it_modal_submit = 5,
|
774 | 775 | };
|
775 | 776 |
|
| 777 | +/* |
| 778 | +* @brief Context type where the interaction can be used or triggered from, e.g. guild, user etc |
| 779 | +*/ |
| 780 | +enum interaction_context_type { |
| 781 | + /** |
| 782 | + * @brief Interaction can be used within servers |
| 783 | + */ |
| 784 | + itc_guild = 0, |
| 785 | + |
| 786 | + /** |
| 787 | + * @brief Interaction can be used within DMs with the app's bot user |
| 788 | + */ |
| 789 | + itc_bot_dm = 1, |
| 790 | + |
| 791 | + /** |
| 792 | + * @brief Interaction can be used within Group DMs and DMs other than the app's bot user |
| 793 | + */ |
| 794 | + itc_private_channel = 2, |
| 795 | +}; |
| 796 | + |
776 | 797 | /**
|
777 | 798 | * @brief Right-click context menu types
|
778 | 799 | */
|
@@ -952,6 +973,16 @@ class DPP_EXPORT interaction : public managed, public json_interface<interaction
|
952 | 973 | virtual json to_json_impl(bool with_id = false) const;
|
953 | 974 |
|
954 | 975 | public:
|
| 976 | + /** |
| 977 | + * @brief Context where the interaction was triggered from |
| 978 | + */ |
| 979 | + std::map<application_integration_types, snowflake> authorizing_integration_owners; |
| 980 | + |
| 981 | + /** |
| 982 | + * @brief Context where the interaction was triggered from |
| 983 | + */ |
| 984 | + std::optional<interaction_context_type> context; |
| 985 | + |
955 | 986 | /**
|
956 | 987 | * @brief ID of the application this interaction is for.
|
957 | 988 | */
|
@@ -1194,6 +1225,30 @@ class DPP_EXPORT interaction : public managed, public json_interface<interaction
|
1194 | 1225 | * is not for a command.
|
1195 | 1226 | */
|
1196 | 1227 | std::string get_command_name() const;
|
| 1228 | + |
| 1229 | + /** |
| 1230 | + * @brief Get the user who installed the application for a given type. |
| 1231 | + * @param type Type of installation for the command, e.g. dpp::ait_guild_install or |
| 1232 | + * dpp::ait_user_install. |
| 1233 | + * @return The snowflake of the user. In the event this type is not allowed for the |
| 1234 | + * given command, this will return a default-initialised snowflake with value 0. |
| 1235 | + */ |
| 1236 | + dpp::snowflake get_authorizing_integration_owner(application_integration_types type) const; |
| 1237 | + |
| 1238 | + /** |
| 1239 | + * @brief Returns true if this interaction occurred as a user-app interaction, e.g. |
| 1240 | + * within a DM or group DM, added to the user not a guild. |
| 1241 | + * @return true if a user-app interaction |
| 1242 | + */ |
| 1243 | + bool is_user_app_interaction() const; |
| 1244 | + |
| 1245 | + /** |
| 1246 | + * @brief Returns true if this interaction occurred as a guild-invited interaction, e.g. |
| 1247 | + * within a guild's channel, or a DM of a user in that guild. |
| 1248 | + * @return true if a guild interaction |
| 1249 | + */ |
| 1250 | + bool is_guild_interaction() const; |
| 1251 | + |
1197 | 1252 | };
|
1198 | 1253 |
|
1199 | 1254 | /**
|
@@ -1420,10 +1475,21 @@ class DPP_EXPORT slashcommand : public managed, public json_interface<slashcomma
|
1420 | 1475 | */
|
1421 | 1476 | permission default_member_permissions;
|
1422 | 1477 |
|
| 1478 | + /** |
| 1479 | + * @brief Installation contexts where the command is available, only for globally-scoped commands. Defaults to your app's configured contexts |
| 1480 | + */ |
| 1481 | + std::vector<application_integration_types> integration_types; |
| 1482 | + |
| 1483 | + /** |
| 1484 | + * @brief Interaction context(s) where the command can be used, only for globally-scoped commands. By default, all interaction context types included for new commands. |
| 1485 | + */ |
| 1486 | + std::vector<interaction_context_type> contexts; |
| 1487 | + |
1423 | 1488 | /**
|
1424 | 1489 | * @brief True if this command should be allowed in a DM
|
1425 | 1490 | * D++ defaults this to false. Cannot be set to true in a guild
|
1426 | 1491 | * command, only a global command.
|
| 1492 | + * @deprecated Use dpp::slashcommand_t::set_interaction_contexts instead |
1427 | 1493 | */
|
1428 | 1494 | bool dm_permission;
|
1429 | 1495 |
|
@@ -1543,6 +1609,14 @@ class DPP_EXPORT slashcommand : public managed, public json_interface<slashcomma
|
1543 | 1609 | */
|
1544 | 1610 | slashcommand& set_application_id(snowflake i);
|
1545 | 1611 |
|
| 1612 | + /** |
| 1613 | + * @brief Set the interaction contexts for the command |
| 1614 | + * |
| 1615 | + * @param contexts the contexts to set |
| 1616 | + * @return slashcommand& reference to self for chaining of calls |
| 1617 | + */ |
| 1618 | + slashcommand& set_interaction_contexts(std::vector<interaction_context_type> contexts); |
| 1619 | + |
1546 | 1620 | /**
|
1547 | 1621 | * @brief Adds a permission to the command
|
1548 | 1622 | *
|
|
0 commit comments