DiscordCoreAPI
A Discord bot library written in C++, with custom asynchronous coroutines.
Loading...
Searching...
No Matches
ApplicationCommandEntities.hpp
Go to the documentation of this file.
1/*
2 DiscordCoreAPI, A bot library for Discord, written in C++, and featuring explicit multithreading through the usage of custom, asynchronous C++ CoRoutines.
3
4 Copyright 2021, 2022, 2023 Chris M. (RealTimeChris)
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 USA
20*/
21/// ApplicationCommandEntities.hpp - Header for the ApplicationCommand classes
22/// and structs. Aug 25, 2021 Chris M.
23/// https://discordcoreapi.com
24/// \file ApplicationCommandEntities.hpp
25
26#pragma once
27
30
31namespace DiscordCoreAPI {
32
33 /**
34 * \addtogroup foundation_entities
35 * @{
36 */
37
38 /// \brief For getting all of the Global Application Commands.
39 struct DiscordCoreAPI_Dll GetGlobalApplicationCommandsData {
40 Snowflake applicationId{};///< The current application's Snowflake (The Bot's User Snowflake).
41 bool withLocalizations{};///< Do we collect the name-and-description localizations?
42 };
43
44 /// \brief For collecting a single global ApplicationCommand.
45 struct DiscordCoreAPI_Dll GetGlobalApplicationCommandData {
46 Snowflake applicationId{};///< The current application's Snowflake (The Bot's User Snowflake).
47 std::string commandId{};///< The id of the command which you would like to collect.
48 };
49
50 /// \brief For creating an application command.
51 struct DiscordCoreAPI_Dll CreateApplicationCommandData : public ApplicationCommandData {
52 friend class DiscordCoreClient;
53
54 protected:
55 bool alwaysRegister{};
56 };
57
58 /// \brief For creating a single global ApplicationCommand.
60
61 /// \brief For editing a single global ApplicationCommand.
62 struct DiscordCoreAPI_Dll EditGlobalApplicationCommandData {
63 std::unordered_map<std::string, std::string>
64 descriptionLocalizations{};///< Dictionary with keys in available locales Localization dictionary for the description field.
65 std::unordered_map<std::string, std::string>
66 nameLocalizations{};///< Dictionary with keys in available locales Localization dictionary for the name field.
67 std::vector<ApplicationCommandOptionData> options{};///< The options for the ApplicationCommand.
68 Permissions defaultMemberPermissions{};///< Set of permissions represented as a bit set. only for globally - scoped commands.
69 std::string description{};///< A description of the command.
70 Snowflake applicationId{};///< The current application's Snowflake (The Bot's User Snowflake).
71 bool dmPermission{};///< Indicates whether the command is available in DMs with the app.
72 std::string name{};///< A name for the new command.
73 };
74
75 /// \brief For deleting a single global ApplicationCommand.
76 struct DiscordCoreAPI_Dll DeleteGlobalApplicationCommandData {
77 Snowflake applicationId{};///< The current application's Snowflake (The Bot's User Snowflake).
78 std::string name{};///< The name of the command to delete.
79 };
80
81 /// \brief For bulk-overwriting a collection of global ApplicationCommands.
83 std::vector<CreateGlobalApplicationCommandData> responseData{};///< A vector of the options for the ApplicationCommands.
84 Snowflake applicationId{};///< The current application's Snowflake (The Bot's User Snowflake).
85 };
86
87 /// \brief For acquiring all of the Guild ApplicationCommands of a single Guild.
88 struct DiscordCoreAPI_Dll GetGuildApplicationCommandsData {
89 Snowflake applicationId{};///< The current application's Snowflake (The Bot's User Snowflake).
90 bool withLocalizations{};///< Do we collect the name-and-description localizations?
91 Snowflake guildId{};///< The id of the Guild for which you would like to acquire the ApplicationCommands from.
92 };
93
94 /// \brief For creating a single Guild ApplicationCommand.
96
97 /// \brief For acquiring a single Guild ApplicationCommand.
98 struct DiscordCoreAPI_Dll GetGuildApplicationCommandData {
99 Snowflake applicationId{};///< The current application's Snowflake (The Bot's User Snowflake).
100 uint64_t commandId{};///< The command id which you would like to acquire.
101 Snowflake guildId{};///< The id of the Guild from which you would like to acquire the ApplicationCommand from.
102 };
103
104 /// \brief For editing a single Guild ApplicationCommand.
105 struct DiscordCoreAPI_Dll EditGuildApplicationCommandData {
106 std::unordered_map<std::string, std::string> descriptionLocalizations{};///< Dictionary with keys in available locales.
107 std::unordered_map<std::string, std::string> nameLocalizations{};///< Dictionary with keys in available locales.
108 std::vector<ApplicationCommandOptionData> options{};///< The options for the ApplicationCommand.
109 Permissions defaultMemberPermissions{};///< Set of permissions represented as a bit set. only for globally - scoped commands.
110 std::string description{};///< A description of the command.
111 Snowflake applicationId{};///< The current application's Snowflake (The Bot's User Snowflake).
112 bool dmPermission{};///< Indicates whether the command is available in DMs with the app.
113 Snowflake guildId{};///< The id of the Guild which you would like to add the new command to.
114 std::string name{};///< A name for the new command.
115 };
116
117 /// \brief For deleting a single Guild ApplicationCommand.
118 struct DiscordCoreAPI_Dll DeleteGuildApplicationCommandData {
119 Snowflake applicationId{};///< The current application's Snowflake (The Bot's User Snowflake).
120 Snowflake guildId{};///< The id of the Guild which you would like to delete the command from.
121 std::string name{};///< A name of the command which you would like to delete.
122 };
123
124 /// \brief For bulk-overwriting a collection of Guild ApplicationCommands.
126 std::vector<CreateGuildApplicationCommandData> responseData{};///< A vector of the options for the ApplicationCommands.
127 Snowflake applicationId{};///< The current application's Snowflake (The Bot's User Snowflake).
128 Snowflake guildId{};///< The id of the Guild which you would like to overwrite the commands of.
129 };
130
131 /// \brief For acquiring the permissions of a collection of Guild ApplicationCommands.
133 Snowflake applicationId{};///< The current application's Snowflake (The Bot's User Snowflake).
134 Snowflake guildId{};///< The id of the Guild from which you would like to acquire the command permissions.
135 };
136
137 /// \brief For acquiring the permissions of a single Guild ApplicationCommand.
138 struct DiscordCoreAPI_Dll GetApplicationCommandPermissionsData {
139 std::string commandName{};///< The name of the command which you would like to collect the permissions of.
140 Snowflake applicationId{};///< The current application's Snowflake (The Bot's User Snowflake).
141 Snowflake guildId{};///< The id of the Guild from which you would like to acquire the command permissions.
142 };
143
144 /// \brief For editing the permissions of a single Guild ApplicationCommand.
146 std::vector<ApplicationCommandPermissionData> permissions{};///< A vector of ApplicationCommand permissions.
147 std::string commandName{};///< The command name which you would like to edit the permissions of.
148 Snowflake applicationId{};///< The current application's Snowflake (The Bot's User Snowflake).
149 uint64_t commandId{};///< The command id which you would like to edit the permissions of.
150 Snowflake guildId{};///< The Guild id of the Guild for which you would like to edit the command permissions.
151 };
152
153 /// \brief For batch editing the permissions of a collection of Guild ApplicationCommands.
155 std::vector<DiscordCoreAPI::GuildApplicationCommandPermissionsData>
156 permissions{};///< A vector of edit-Guild-application-permissions responseData to edit.
157 Snowflake applicationId{};///< The current application's Snowflake (The Bot's User Snowflake).
158 Snowflake guildId{};///< The Guild id of the Guild for which you would like to batch edit Guild application permissions.
159 };
160
161 /**@}*/
162
163 /**
164 * \addtogroup main_endpoints
165 * @{
166 */
167 /// \brief An interface class for the ApplicationCommand related Discord endpoints.
168 class DiscordCoreAPI_Dll ApplicationCommands {
169 public:
170 static void initialize(DiscordCoreInternal::HttpsClient*);
171
172 /// \brief Get all of the global ApplicationCommands for this bot.
173 /// \returns A CoRoutine containing a vector<ApplicationCommand>.
174 static CoRoutine<std::vector<ApplicationCommand>> getGlobalApplicationCommandsAsync(GetGlobalApplicationCommandsData dataPackage);
175
176 /// \brief Create a global ApplicationCommand for this bot.
177 /// \param dataPackage A CreateGlobalApplicationCommandData structure.
178 /// \returns A CoRoutine containing an ApplicationCommand.
179 static CoRoutine<ApplicationCommand> createGlobalApplicationCommandAsync(CreateGlobalApplicationCommandData dataPackage);
180
181 /// \brief Get a single global ApplicationCommand for this bot.
182 /// \param dataPackage A GetGlobalApplicationCommandData structure.
183 /// \returns A CoRoutine containing an ApplicationCommand.
184 static CoRoutine<ApplicationCommand> getGlobalApplicationCommandAsync(GetGlobalApplicationCommandData dataPackage);
185
186 /// \brief Edit a global ApplicationCommand for this bot.
187 /// \param dataPackage An EditGlobalApplicationCommandData structure.
188 /// \returns A CoRoutine containing an ApplicationCommand.
189 static CoRoutine<ApplicationCommand> editGlobalApplicationCommandAsync(EditGlobalApplicationCommandData dataPackage);
190
191 /// \brief Delete a global ApplicationCommand for this bot.
192 /// \param dataPackage A DeleteGlobalApplicationCommandData structure.
193 /// \returns A CoRoutine containing void.
194 static CoRoutine<void> deleteGlobalApplicationCommandAsync(DeleteGlobalApplicationCommandData dataPackage);
195
196 /// \brief Bulk overwrites a collection of global ApplicationCommands.
197 /// \param dataPackage A BulkOverwriteGlobalApplicationCommandsData structure.
198 /// \returns A CoRoutine containing a vector<ApplicationCommand>.
199 static CoRoutine<std::vector<ApplicationCommand>> bulkOverwriteGlobalApplicationCommandsAsync(
201
202 /// \brief Get all of the Guild ApplicationCommands for a single Guild for this bot.
203 /// \param dataPackage A GetGuildApplicationCommandsData structure.
204 /// \returns A CoRoutine containing a vector<ApplicationCommand>.
205 static CoRoutine<std::vector<ApplicationCommand>> getGuildApplicationCommandsAsync(GetGuildApplicationCommandsData dataPackage);
206
207 /// \brief Create a Guild ApplicationCommand for a single server for this bot.
208 /// \param dataPackage A CreateGuildApplicationCommandData structure.
209 /// \returns A CoRoutine containing an ApplicationCommand.
210 static CoRoutine<ApplicationCommand> createGuildApplicationCommandAsync(CreateGuildApplicationCommandData dataPackage);
211
212 /// \brief Get a single Guild ApplicationCommand for a single server for this bot.
213 /// \param dataPackage A GetGuildApplicationCommandData structure.
214 /// \returns A CoRoutine containing an ApplicationCommand.
215 static CoRoutine<ApplicationCommand> getGuildApplicationCommandAsync(GetGuildApplicationCommandData dataPackage);
216
217 /// \brief Edit a single Guild ApplicationCommand for a single server for this bot.
218 /// \param dataPackage An EditGuildApplicationCommandData structure.
219 /// \returns A CoRoutine containing an ApplicationCommand.
220 static CoRoutine<ApplicationCommand> editGuildApplicationCommandAsync(EditGuildApplicationCommandData dataPackage);
221
222 /// \brief Delete a single Guild ApplicationCommand for a single server for this bot.
223 /// \param dataPackage A DeleteGuildApplicationCommandData structure.
224 /// \returns A CoRoutine containing void.
225 static CoRoutine<void> deleteGuildApplicationCommandAsync(DeleteGuildApplicationCommandData dataPackage);
226
227 /// \brief Bulkoverwrites some Guild ApplicationCommands for this bot.
228 /// \param dataPackage A BulkOverwriteGuildApplicationCommandsData structure.
229 /// \returns A CoRoutine containing a vector<ApplicationCommand>.
230 static CoRoutine<std::vector<ApplicationCommand>> bulkOverwriteGuildApplicationCommandsAsync(
232
233 /// \brief Gets Guild ApplicationCommand permissions for a single server on this bot.
234 /// \param dataPackage A GetGuildApplicationCommandPermissionsData structure.
235 /// \returns A CoRoutine containing a vector<DiscordCoreAPI::GuildApplicationCommandPermissionsData>.
236 static CoRoutine<std::vector<GuildApplicationCommandPermissionsData>> getGuildApplicationCommandPermissionsAsync(
238
239 /// \brief Get ApplicationCommand permissions for a single command on this bot.
240 /// \param dataPackage A GetApplicationCommandPermissionsData structure.
241 /// \returns A CoRoutine containing a DiscordCoreAPI::GuildApplicationCommandPermissionsData.
242 static CoRoutine<GuildApplicationCommandPermissionsData> getApplicationCommandPermissionsAsync(
244
245 /// \brief Edit Guild ApplicationCommand permissions for a server on this bot.
246 /// \param dataPackage An EditGuildApplicationCommandPermissionsData structure.
247 /// \returns A CoRoutine containing a DiscordCoreAPI::GuildApplicationCommandPermissionsData.
248 static CoRoutine<GuildApplicationCommandPermissionsData> editGuildApplicationCommandPermissionsAsync(
250
251 protected:
252 static DiscordCoreInternal::HttpsClient* httpsClient;
253 };
254
255 /**@}*/
256
257}
The main namespace for this library.
For getting all of the Global Application Commands.
For collecting a single global ApplicationCommand.
For creating a single global ApplicationCommand.
For editing a single global ApplicationCommand.
For deleting a single global ApplicationCommand.
For bulk-overwriting a collection of global ApplicationCommands.
For acquiring all of the Guild ApplicationCommands of a single Guild.
For creating a single Guild ApplicationCommand.
For acquiring a single Guild ApplicationCommand.
For editing a single Guild ApplicationCommand.
For deleting a single Guild ApplicationCommand.
For bulk-overwriting a collection of Guild ApplicationCommands.
For acquiring the permissions of a collection of Guild ApplicationCommands.
For acquiring the permissions of a single Guild ApplicationCommand.
For editing the permissions of a single Guild ApplicationCommand.
For batch editing the permissions of a collection of Guild ApplicationCommands.
An interface class for the ApplicationCommand related Discord endpoints.
A CoRoutine - representing a potentially asynchronous operation/function.
Definition: CoRoutine.hpp:52
DiscordCoreClient - The main class for this library.
Data structure representing an ApplicationCommand.
Permissions class, for representing and manipulating Permission values.
Definition: Utilities.hpp:871