40 static constexpr auto parseValue = createObject(
"threadId", &value_type::threadId,
"wait", &value_type::wait,
"attachments", &value_type::attachments,
"components",
41 &value_type::components,
"allowedMentions", &value_type::allowedMentions,
"embeds", &value_type::embeds,
"files", &value_type::files,
"webhookToken",
42 &value_type::webhookToken,
"avatarUrl", &value_type::avatarUrl,
"username", &value_type::userName,
"customId", &value_type::customId,
"webHookId",
43 &value_type::webHookId,
"content", &value_type::content,
"title", &value_type::title,
"flags", &value_type::flags,
"tts", &value_type::tts);
48 static constexpr auto parseValue = createObject(
"channelId", &value_type::channelId,
"avatar", &value_type::avatar,
"name", &value_type::name);
53 static constexpr auto parseValue =
54 createObject(
"channelId", &value_type::channelId,
"webHookId", &value_type::webHookId,
"avatar", &value_type::avatar,
"name", &value_type::name);
59 static constexpr auto parseValue = createObject(
"webhookToken", &value_type::webhookToken,
"channelId", &value_type::channelId,
"webHookId", &value_type::webHookId,
60 "avatar", &value_type::avatar,
"name", &value_type::name);
65 static constexpr auto parseValue =
66 createObject(
"threadId", &value_type::threadId,
"wait", &value_type::wait,
"attachments", &value_type::attachments,
"components", &value_type::components,
67 "allowedMentions", &value_type::allowedMentions,
"embeds", &value_type::embeds,
"files", &value_type::files,
"webhookToken", &value_type::webhookToken,
"avatarUrl",
68 &value_type::avatarUrl,
"username", &value_type::userName,
"customId", &value_type::customId,
"webHookId", &value_type::webHookId,
"content", &value_type::content,
69 "title", &value_type::title,
"flags", &value_type::flags,
"tts", &value_type::tts,
"message_id", &value_type::messageId,
"thread_id", &value_type::threadId);
76 execute_web_hook_data::execute_web_hook_data(
const web_hook_data& dataNew) {
82 jsonifier::string_view emojiName,
snowflake emojiId, jsonifier::string_view url) {
89 component_data component;
91 component.emoji.name = emojiName;
92 component.label = buttonLabel;
93 component.style =
static_cast<uint64_t
>(buttonStyle);
94 component.customId = customIdNew;
95 component.disabled = disabled;
96 component.emoji.id = emojiId;
108 jsonifier::string_view placeholder, int32_t maxValues, int32_t minValues, select_menu_type type,
const jsonifier::vector<channel_type>& channelTypes) {
115 component_data componentData;
117 componentData.channelTypes = channelTypes;
118 componentData.placeholder = placeholder;
119 componentData.customId = customIdNew;
120 componentData.maxValues =
static_cast<uint64_t
>(maxValues);
121 componentData.minValues =
static_cast<uint64_t
>(minValues);
122 componentData.disabled = disabled;
123 componentData.options = options;
134 jsonifier::string_view customIdNew,
bool required, int32_t minLength, int32_t maxLength,
text_input_style inputStyle, jsonifier::string_view label,
135 jsonifier::string_view placeholder) {
144 component_data component{};
146 component.customId = customIdNew;
147 component.style =
static_cast<uint64_t
>(inputStyle);
148 component.title = titleNew;
149 component.maxLength =
static_cast<uint64_t
>(maxLength);
150 component.minLength =
static_cast<uint64_t
>(minLength);
151 component.label = label;
152 component.required = required;
153 component.placeholder = placeholder;
164 files.emplace_back(theFile);
179 embeds.emplace_back(dataPackage);
193 edit_web_hook_data::edit_web_hook_data(
const web_hook_data& dataNew) {
198 void execute_web_hook_data::generateExcludedKeys() {
200 excludedKeys.emplace(
"attachments");
203 excludedKeys.emplace(
"allowed_mentions");
206 excludedKeys.emplace(
"components");
209 value.generateExcludedKeys();
212 excludedKeys.emplace(
"embeds");
214 for (
auto& value:
embeds) {
215 value.generateExcludedKeys();
217 if (
files.size() == 0) {
218 excludedKeys.emplace(
"files");
221 excludedKeys.emplace(
"avatar_url");
224 excludedKeys.emplace(
"custom_id");
227 excludedKeys.emplace(
"username");
230 excludedKeys.emplace(
"title");
233 excludedKeys.emplace(
"content");
239 void discord_core_api::web_hooks::initialize(discord_core_internal::https_client* client) {
240 discord_core_api::web_hooks::httpsClient = client;
244 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Post_Webhook };
245 co_await newThreadAwaitable<web_hook_data>();
246 workload.workloadClass = discord_core_internal::https_workload_class::Post;
247 workload.relativePath =
"/channels/" + dataPackage.
channelId +
"/webhooks";
248 workload.callStack =
"discord_core_api::web_hooks::createWebHookAsync()";
249 parser.serializeJson<
true>(dataPackage, workload.content);
251 discord_core_api::web_hooks::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
252 co_return returnData;
256 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Get_Channel_Webhooks };
257 co_await newThreadAwaitable<jsonifier::vector<web_hook_data>>();
258 workload.workloadClass = discord_core_internal::https_workload_class::Get;
259 workload.relativePath =
"/channels/" + dataPackage.
channelId +
"/webhooks";
260 workload.callStack =
"discord_core_api::web_hooks::getChannelWebHooksAsync()";
261 jsonifier::vector<web_hook_data> returnData{};
262 discord_core_api::web_hooks::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
263 co_return returnData;
267 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Get_Guild_Webhooks };
268 co_await newThreadAwaitable<jsonifier::vector<web_hook_data>>();
269 workload.workloadClass = discord_core_internal::https_workload_class::Get;
270 workload.relativePath =
"/guilds/" + dataPackage.
guildId +
"/webhooks";
271 workload.callStack =
"discord_core_api::web_hooks::getGuildWebHooksAsync()";
272 jsonifier::vector<web_hook_data> returnData{};
273 discord_core_api::web_hooks::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
274 co_return returnData;
278 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Get_Webhook };
279 co_await newThreadAwaitable<web_hook_data>();
280 workload.workloadClass = discord_core_internal::https_workload_class::Get;
281 workload.relativePath =
"/webhooks/" + dataPackage.
webHookId;
282 workload.callStack =
"discord_core_api::web_hooks::getWebHookAsync()";
284 discord_core_api::web_hooks::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
285 co_return returnData;
289 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Get_Webhook_With_Token };
290 co_await newThreadAwaitable<web_hook_data>();
291 workload.workloadClass = discord_core_internal::https_workload_class::Get;
293 workload.callStack =
"discord_core_api::web_hooks::getWebHookWithTokenAsync()";
295 discord_core_api::web_hooks::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
296 co_return returnData;
300 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Patch_Webhook };
301 co_await newThreadAwaitable<web_hook_data>();
302 workload.workloadClass = discord_core_internal::https_workload_class::Patch;
303 workload.relativePath =
"/webhooks/" + dataPackage.
webHookId;
304 parser.serializeJson<
true>(dataPackage, workload.content);
305 workload.callStack =
"discord_core_api::web_hooks::modifyWebHookAsync()";
307 discord_core_api::web_hooks::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
308 co_return returnData;
312 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Patch_Webhook_With_Token };
313 co_await newThreadAwaitable<web_hook_data>();
314 workload.workloadClass = discord_core_internal::https_workload_class::Patch;
316 parser.serializeJson<
true>(dataPackage, workload.content);
317 workload.callStack =
"discord_core_api::web_hooks::modifyWebHookWithTokenAsync()";
319 discord_core_api::web_hooks::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
320 co_return returnData;
324 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Delete_Webhook };
325 co_await newThreadAwaitable<void>();
326 workload.workloadClass = discord_core_internal::https_workload_class::Delete;
327 workload.relativePath =
"/webhooks/" + dataPackage.
webHookId;
328 workload.callStack =
"discord_core_api::web_hooks::deleteWebHookAsync()";
329 discord_core_api::web_hooks::httpsClient->submitWorkloadAndGetResult(std::move(workload));
334 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Delete_Webhook_With_Token };
335 co_await newThreadAwaitable<void>();
336 workload.workloadClass = discord_core_internal::https_workload_class::Delete;
338 workload.callStack =
"discord_core_api::web_hooks::deleteWebHookWithTokenAsync()";
339 discord_core_api::web_hooks::httpsClient->submitWorkloadAndGetResult(std::move(workload));
344 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Post_Execute_Webhook };
345 co_await newThreadAwaitable<message_data>();
346 workload.workloadClass = discord_core_internal::https_workload_class::Post;
348 workload.callStack =
"discord_core_api::web_hooks::executeWebHookAsync()";
349 if (dataPackage.
wait) {
350 workload.relativePath +=
"?wait=true";
352 workload.relativePath +=
"&thread_id=" + dataPackage.
threadId;
356 workload.relativePath +=
"?thread_id=" + dataPackage.
threadId;
358 if (dataPackage.
files.size() > 0) {
359 workload.payloadType = discord_core_internal::payload_type::Multipart_Form;
360 parser.serializeJson<
true>(dataPackage, workload.
content);
361 workload.content = constructMultiPartData(workload.content, dataPackage.
files);
363 parser.serializeJson<
true>(dataPackage, workload.
content);
366 discord_core_api::web_hooks::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
367 co_return returnData;
371 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Get_Webhook_Message };
372 co_await newThreadAwaitable<message_data>();
373 workload.workloadClass = discord_core_internal::https_workload_class::Get;
376 workload.relativePath +=
"?thread_id=" + dataPackage.
threadId;
378 workload.callStack =
"discord_core_api::web_hooks::getWebHookMessageAsync()";
380 discord_core_api::web_hooks::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
381 co_return returnData;
385 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Patch_Webhook_Message };
386 co_await newThreadAwaitable<message_data>();
387 workload.workloadClass = discord_core_internal::https_workload_class::Patch;
390 workload.relativePath +=
"?thread_id=" + dataPackage.
threadId;
392 if (dataPackage.
files.size() > 0) {
393 workload.payloadType = discord_core_internal::payload_type::Multipart_Form;
394 parser.serializeJson<
true>(dataPackage, workload.
content);
395 workload.content = constructMultiPartData(workload.content, dataPackage.
files);
397 parser.serializeJson<
true>(dataPackage, workload.
content);
399 workload.callStack =
"discord_core_api::web_hooks::editWebHookMessageAsync()";
401 discord_core_api::web_hooks::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
402 co_return returnData;
406 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Delete_Webhook_Message };
407 co_await newThreadAwaitable<void>();
408 workload.workloadClass = discord_core_internal::https_workload_class::Delete;
411 workload.relativePath +=
"?thread_id=" + dataPackage.
threadId;
413 workload.callStack =
"discord_core_api::web_hooks::deleteWebHookMessageAsync()";
414 discord_core_api::web_hooks::httpsClient->submitWorkloadAndGetResult(std::move(workload));
Action row data of message components.
Allowable mentions for a message.
jsonifier::vector< jsonifier::string > roles
Array of role_ids to mention (max size of 100)
jsonifier::vector< jsonifier::string > users
Array of user_ids to mention (max size of 100)
jsonifier::vector< jsonifier::string > parse
A vector of allowed mention types to parse from the content.
A co_routine - representing a potentially asynchronous operation/function.
For sending Https requests.
For editing a web_hook message_data.
snowflake threadId
Send a message to the specified thread within a webhook's channel_data. the thread will automatically...
snowflake messageId
The message snowflake to collect.
For executing a web_hook.
allowed_mentions_data allowedMentions
Allowed mention object.
jsonifier::vector< embed_data > embeds
Array of up to 10 embed objects.
jsonifier::string content
The message contents (up to 2000 characters) one of content, file, embeds.
snowflake webHookId
The web_hook_data you would like to execute.
jsonifier::string userName
Override the default username of the webhook.
execute_web_hook_data & addContent(jsonifier::string_view dataPackage)
For setting the content in a response.
jsonifier::string webhookToken
The web_hook_data token you would like to execute.
snowflake threadId
Send a message to the specified thread within a webhook's channel_data. the thread will automatically...
execute_web_hook_data & setTTSStatus(bool enabledTTs)
For setting the tts status of a response.
execute_web_hook_data & addAllowedMentions(const allowed_mentions_data dataPackage)
For setting the allowable mentions in a response.
execute_web_hook_data & addFile(const file &theFile)
Adds a file to the current collection of files for this message response.
jsonifier::string title
Title for the modal.
jsonifier::vector< file > files
File contents the contents of the file being sent.
execute_web_hook_data & addMessageEmbed(const embed_data dataPackage)
For setting the embeds in a response.
execute_web_hook_data & addSelectMenu(bool disabled, jsonifier::string_view customIdNew, const jsonifier::vector< select_option_data > &options, jsonifier::string_view placeholder, int32_t maxValues, int32_t minValues, select_menu_type type, const jsonifier::vector< channel_type > &channelTypes=jsonifier::vector< channel_type >{})
Adds a select-menu to the response message_data.
jsonifier::vector< attachment_data > attachments
Array of partial attachment objects attachment objects with filename and description.
execute_web_hook_data & addComponentRow(const action_row_data dataPackage)
For setting the components in a response.
jsonifier::string customId
custom id for the modal.
bool wait
Waits for server confirmation of message send before response, and returns the created message body.
jsonifier::string avatarUrl
Override the default avatar of the webhook.
execute_web_hook_data & addButton(bool disabled, jsonifier::string_view customIdNew, jsonifier::string_view buttonLabel, button_style buttonStyle, jsonifier::string_view emojiName="", snowflake emojiId=snowflake{}, jsonifier::string_view url="")
Adds a button to the response message_data.
jsonifier::vector< action_row_data > components
Array of message component the components to include with the message.
bool tts
True if this is a tts message.
execute_web_hook_data & addModal(jsonifier::string_view topTitleNew, jsonifier::string_view topCustomIdNew, jsonifier::string_view titleNew, jsonifier::string_view customIdNew, bool required, int32_t minLength, int32_t maxLength, text_input_style inputStyle, jsonifier::string_view label="", jsonifier::string_view placeholder="")
Adds a modal to the response message_data.
Data structure representing a single message_data.
A class representing a snowflake identifier with various operations.
uint64_t id
The snowflake id.
jsonifier::string token
Token of the web_hook_data.
static co_routine< jsonifier::vector< web_hook_data > > getGuildWebHooksAsync(const get_guild_web_hooks_data dataPackage)
Collects a list of web_hooks from a chosen guild.
static co_routine< web_hook_data > modifyWebHookWithTokenAsync(const modify_web_hook_with_token_data dataPackage)
Modifies a single web_hook_data, using its token.
static co_routine< web_hook_data > getWebHookWithTokenAsync(const get_web_hook_with_token_data dataPackage)
Collects a single web_hook_data, using the token.
static co_routine< void > deleteWebHookMessageAsync(const delete_web_hook_message_data dataPackage)
Deletes a web_hook message_data.
static co_routine< jsonifier::vector< web_hook_data > > getChannelWebHooksAsync(const get_channel_web_hooks_data dataPackage)
Collects a list of web_hooks from a chosen channel_data.
static co_routine< void > deleteWebHookWithTokenAsync(const delete_web_hook_with_token_data dataPackage)
Deletes a single web_hook_data, using its token.
static co_routine< web_hook_data > createWebHookAsync(const create_web_hook_data dataPackage)
Creates a new web_hook_data.
static co_routine< message_data > getWebHookMessageAsync(const get_web_hook_message_data dataPackage)
Collects a web_hook message_data.
static co_routine< void > deleteWebHookAsync(const delete_web_hook_data dataPackage)
Deletes a single web_hook_data.
static co_routine< message_data > executeWebHookAsync(const execute_web_hook_data dataPackage)
Executes a single web_hook_data.
static co_routine< message_data > editWebHookMessageAsync(const edit_web_hook_data dataPackage)
Edits a web_hook message_data.
static co_routine< web_hook_data > modifyWebHookAsync(const modify_web_hook_data dataPackage)
Modifies a single web_hook_data.
static co_routine< web_hook_data > getWebHookAsync(const get_web_hook_data dataPackage)
Collects a single web_hook_data.
button_style
Button styles.
text_input_style
Text input style for modals.
component_type
Component types.
@ Text_Input
Text input object.
The main namespace for the forward-facing interfaces.
For creating a new web_hook_data.
snowflake channelId
The channel_data within which to create the web_hook_data.
snowflake webHookId
The desired web_hook_data to delete.
For deleting a web_hook message_data.
snowflake threadId
Send a message to the specified thread within a webhook's channel_data. the thread will automatically...
snowflake webHookId
The web_hook_data you would like to collect.
snowflake messageId
The message snowflake to collect.
jsonifier::string webhookToken
The web_hook_data token you would like to collect.
For deleting a web_hook, using its token.
snowflake webHookId
The desired web_hook_data to delete.
jsonifier::string webhookToken
Token of the desired web_hook_data.
Data representing a file to be sent via multipart-form data.
For collecting a list of web_hooks from a chosen channel_data.
snowflake channelId
The channel_data from which to collect the web_hooks.
For collecting a list of web_hooks from a chosen guild.
snowflake guildId
The guild from which to collect the web_hooks.
Collects a single web_hook_data.
snowflake webHookId
snowflake of the desired web_hook_data to collect.
For getting a web_hook message_data.
jsonifier::string webhookToken
The web_hook_data token you would like to collect.
snowflake webHookId
The web_hook_data you would like to collect.
snowflake messageId
The message snowflake to collect.
snowflake threadId
The thread that the message is in.
Collects a single web_hook_data, using the token and snowflake.
snowflake webHookId
snowflake of the desired web_hook_data.
jsonifier::string webhookToken
Token of the desired web_hook_data.
For modifying a web_hook.
snowflake webHookId
The web_hook_data to be modified.
For modifying a web_hook.
jsonifier::string webhookToken
Token of the desired web_hook_data.
snowflake webHookId
The web_hook_data to be modified.