39 template<>
struct core<discord_core_api::execute_web_hook_data> {
40 using value_type = discord_core_api::execute_web_hook_data;
41 static constexpr auto parseValue = createValue(
"threadId", &value_type::threadId,
"wait", &value_type::wait,
"attachments", &value_type::attachments,
"components",
42 &value_type::components,
"allowedMentions", &value_type::allowedMentions,
"embeds", &value_type::embeds,
"webhookToken",
43 &value_type::webhookToken,
"avatarUrl", &value_type::avatarUrl,
"username", &value_type::userName,
"customId", &value_type::customId,
"webHookId",
44 &value_type::webHookId,
"content", &value_type::content,
"title", &value_type::title,
"flags", &value_type::flags,
"tts", &value_type::tts);
47 template<>
struct core<discord_core_api::create_web_hook_data> {
48 using value_type = discord_core_api::create_web_hook_data;
49 static constexpr auto parseValue = createValue(
"channelId", &value_type::channelId,
"avatar", &value_type::avatar,
"name", &value_type::name);
52 template<>
struct core<discord_core_api::modify_web_hook_data> {
53 using value_type = discord_core_api::modify_web_hook_data;
54 static constexpr auto parseValue =
55 createValue(
"channelId", &value_type::channelId,
"webHookId", &value_type::webHookId,
"avatar", &value_type::avatar,
"name", &value_type::name);
58 template<>
struct core<discord_core_api::modify_web_hook_with_token_data> {
59 using value_type = discord_core_api::modify_web_hook_with_token_data;
60 static constexpr auto parseValue = createValue(
"webhookToken", &value_type::webhookToken,
"channelId", &value_type::channelId,
"webHookId", &value_type::webHookId,
61 "avatar", &value_type::avatar,
"name", &value_type::name);
64 template<>
struct core<discord_core_api::edit_web_hook_data> {
65 using value_type = discord_core_api::edit_web_hook_data;
66 static constexpr auto parseValue =
67 createValue(
"threadId", &value_type::threadId,
"wait", &value_type::wait,
"attachments", &value_type::attachments,
"components", &value_type::components,
68 "allowedMentions", &value_type::allowedMentions,
"embeds", &value_type::embeds,
"webhookToken", &value_type::webhookToken,
"avatarUrl",
69 &value_type::avatarUrl,
"username", &value_type::userName,
"customId", &value_type::customId,
"webHookId", &value_type::webHookId,
"content", &value_type::content,
70 "title", &value_type::title,
"flags", &value_type::flags,
"tts", &value_type::tts,
"message_id", &value_type::messageId,
"thread_id", &value_type::threadId);
77 execute_web_hook_data::execute_web_hook_data(
const web_hook_data& dataNew) {
83 jsonifier::string_view emojiName,
snowflake emojiId, jsonifier::string_view url) {
85 action_row_data actionRowData;
90 component_data component;
92 component.emoji.
name = emojiName;
93 component.label = buttonLabel;
94 component.style =
static_cast<uint64_t
>(buttonStyle);
95 component.customId = customIdNew;
96 component.disabled = disabled;
97 component.emoji.
id = emojiId;
101 action_row_data actionRowData;
109 jsonifier::string_view placeholder, int32_t maxValues, int32_t minValues, select_menu_type type,
const jsonifier::vector<channel_type>& channelTypes) {
111 action_row_data actionRowData;
116 component_data componentData;
118 componentData.channelTypes = channelTypes;
119 componentData.placeholder = placeholder;
120 componentData.customId = customIdNew;
121 componentData.maxValues =
static_cast<uint64_t
>(maxValues);
122 componentData.minValues =
static_cast<uint64_t
>(minValues);
123 componentData.disabled = disabled;
124 componentData.options = options;
127 action_row_data actionRowData;
135 jsonifier::string_view customIdNew,
bool required, int32_t minLength, int32_t maxLength,
text_input_style inputStyle, jsonifier::string_view label,
136 jsonifier::string_view placeholder) {
140 action_row_data actionRowData;
145 component_data component{};
147 component.customId = customIdNew;
148 component.style =
static_cast<uint64_t
>(inputStyle);
149 component.title = titleNew;
150 component.maxLength =
static_cast<uint64_t
>(maxLength);
151 component.minLength =
static_cast<uint64_t
>(minLength);
152 component.label = label;
153 component.required = required;
154 component.placeholder = placeholder;
157 action_row_data actionRowData;
165 files.emplace_back(theFile);
180 embeds.emplace_back(dataPackage);
194 edit_web_hook_data::edit_web_hook_data(
const web_hook_data& dataNew) {
199 void execute_web_hook_data::generateExcludedKeys() {
201 jsonifierExcludedKeys.emplace(
"attachments");
204 jsonifierExcludedKeys.emplace(
"allowed_mentions");
207 jsonifierExcludedKeys.emplace(
"components");
210 value.generateExcludedKeys();
213 jsonifierExcludedKeys.emplace(
"embeds");
215 for (
auto& value:
embeds) {
216 value.generateExcludedKeys();
222 jsonifierExcludedKeys.emplace(
"avatar_url");
225 jsonifierExcludedKeys.emplace(
"custom_id");
228 jsonifierExcludedKeys.emplace(
"username");
231 jsonifierExcludedKeys.emplace(
"title");
234 jsonifierExcludedKeys.emplace(
"content");
241 discord_core_api::web_hooks::httpsClient = client;
245 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Post_Webhook };
247 workload.workloadClass = discord_core_internal::https_workload_class::Post;
248 workload.relativePath =
"/channels/" + dataPackage.
channelId +
"/webhooks";
249 workload.callStack =
"discord_core_api::web_hooks::createWebHookAsync()";
250 parser.serializeJson(dataPackage, workload.content);
252 discord_core_api::web_hooks::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
253 co_return returnData;
257 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Get_Channel_Webhooks };
259 workload.workloadClass = discord_core_internal::https_workload_class::Get;
260 workload.relativePath =
"/channels/" + dataPackage.
channelId +
"/webhooks";
261 workload.callStack =
"discord_core_api::web_hooks::getChannelWebHooksAsync()";
262 jsonifier::vector<web_hook_data> returnData{};
263 discord_core_api::web_hooks::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
264 co_return returnData;
268 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Get_Guild_Webhooks };
270 workload.workloadClass = discord_core_internal::https_workload_class::Get;
271 workload.relativePath =
"/guilds/" + dataPackage.
guildId +
"/webhooks";
272 workload.callStack =
"discord_core_api::web_hooks::getGuildWebHooksAsync()";
273 jsonifier::vector<web_hook_data> returnData{};
274 discord_core_api::web_hooks::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
275 co_return returnData;
279 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Get_Webhook };
281 workload.workloadClass = discord_core_internal::https_workload_class::Get;
282 workload.relativePath =
"/webhooks/" + dataPackage.
webHookId;
283 workload.callStack =
"discord_core_api::web_hooks::getWebHookAsync()";
285 discord_core_api::web_hooks::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
286 co_return returnData;
290 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Get_Webhook_With_Token };
292 workload.workloadClass = discord_core_internal::https_workload_class::Get;
294 workload.callStack =
"discord_core_api::web_hooks::getWebHookWithTokenAsync()";
296 discord_core_api::web_hooks::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
297 co_return returnData;
301 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Patch_Webhook };
303 workload.workloadClass = discord_core_internal::https_workload_class::Patch;
304 workload.relativePath =
"/webhooks/" + dataPackage.
webHookId;
305 parser.serializeJson(dataPackage, workload.content);
306 workload.callStack =
"discord_core_api::web_hooks::modifyWebHookAsync()";
308 discord_core_api::web_hooks::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
309 co_return returnData;
313 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Patch_Webhook_With_Token };
315 workload.workloadClass = discord_core_internal::https_workload_class::Patch;
317 parser.serializeJson(dataPackage, workload.content);
318 workload.callStack =
"discord_core_api::web_hooks::modifyWebHookWithTokenAsync()";
320 discord_core_api::web_hooks::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
321 co_return returnData;
325 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Delete_Webhook };
327 workload.workloadClass = discord_core_internal::https_workload_class::Delete;
328 workload.relativePath =
"/webhooks/" + dataPackage.
webHookId;
329 workload.callStack =
"discord_core_api::web_hooks::deleteWebHookAsync()";
330 discord_core_api::web_hooks::httpsClient->submitWorkloadAndGetResult(std::move(workload));
335 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Delete_Webhook_With_Token };
337 workload.workloadClass = discord_core_internal::https_workload_class::Delete;
339 workload.callStack =
"discord_core_api::web_hooks::deleteWebHookWithTokenAsync()";
340 discord_core_api::web_hooks::httpsClient->submitWorkloadAndGetResult(std::move(workload));
345 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Post_Execute_Webhook };
347 workload.workloadClass = discord_core_internal::https_workload_class::Post;
349 workload.callStack =
"discord_core_api::web_hooks::executeWebHookAsync()";
350 if (dataPackage.
wait) {
351 workload.relativePath +=
"?wait=true";
353 workload.relativePath +=
"&thread_id=" + dataPackage.
threadId;
357 workload.relativePath +=
"?thread_id=" + dataPackage.
threadId;
359 if (dataPackage.
files.size() > 0) {
360 workload.payloadType = discord_core_internal::payload_type::Multipart_Form;
361 parser.serializeJson(dataPackage, workload.
content);
362 workload.content = constructMultiPartData(workload.content, dataPackage.
files);
364 parser.serializeJson(dataPackage, workload.
content);
367 discord_core_api::web_hooks::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
368 co_return returnData;
372 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Get_Webhook_Message };
374 workload.workloadClass = discord_core_internal::https_workload_class::Get;
377 workload.relativePath +=
"?thread_id=" + dataPackage.
threadId;
379 workload.callStack =
"discord_core_api::web_hooks::getWebHookMessageAsync()";
381 discord_core_api::web_hooks::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
382 co_return returnData;
386 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Patch_Webhook_Message };
388 workload.workloadClass = discord_core_internal::https_workload_class::Patch;
391 workload.relativePath +=
"?thread_id=" + dataPackage.
threadId;
393 if (dataPackage.
files.size() > 0) {
394 workload.payloadType = discord_core_internal::payload_type::Multipart_Form;
395 parser.serializeJson(dataPackage, workload.
content);
396 workload.content = constructMultiPartData(workload.content, dataPackage.
files);
398 parser.serializeJson(dataPackage, workload.
content);
400 workload.callStack =
"discord_core_api::web_hooks::editWebHookMessageAsync()";
402 discord_core_api::web_hooks::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
403 co_return returnData;
407 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Delete_Webhook_Message };
409 workload.workloadClass = discord_core_internal::https_workload_class::Delete;
412 workload.relativePath +=
"?thread_id=" + dataPackage.
threadId;
414 workload.callStack =
"discord_core_api::web_hooks::deleteWebHookMessageAsync()";
415 discord_core_api::web_hooks::httpsClient->submitWorkloadAndGetResult(std::move(workload));
Action row data of message components.
Allowable mentions for a message.
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.
The core of a message's data structure.
snowflake id
This emoji's id.
jsonifier::string name
What is its name?
A class representing a snowflake identifier with various operations.
jsonifier::string token
Token of the web_hook_data.
static co_routine< web_hook_data > modifyWebHookWithTokenAsync(modify_web_hook_with_token_data dataPackage)
Modifies a single web_hook_data, using its token.
static co_routine< message_data > editWebHookMessageAsync(edit_web_hook_data dataPackage)
Edits a web_hook message_data.
static co_routine< void > deleteWebHookMessageAsync(delete_web_hook_message_data dataPackage)
Deletes a web_hook message_data.
static co_routine< void > deleteWebHookAsync(delete_web_hook_data dataPackage)
Deletes a single web_hook_data.
static co_routine< message_data > getWebHookMessageAsync(get_web_hook_message_data dataPackage)
Collects a web_hook message_data.
static co_routine< message_data > executeWebHookAsync(execute_web_hook_data dataPackage)
Executes a single web_hook_data.
static co_routine< web_hook_data > getWebHookAsync(get_web_hook_data dataPackage)
Collects a single web_hook_data.
static co_routine< void > deleteWebHookWithTokenAsync(delete_web_hook_with_token_data dataPackage)
Deletes a single web_hook_data, using its token.
static co_routine< web_hook_data > modifyWebHookAsync(modify_web_hook_data dataPackage)
Modifies a single web_hook_data.
static co_routine< jsonifier::vector< web_hook_data > > getChannelWebHooksAsync(get_channel_web_hooks_data dataPackage)
Collects a list of web_hooks from a chosen channel_data.
static co_routine< web_hook_data > createWebHookAsync(create_web_hook_data dataPackage)
Creates a new web_hook_data.
static co_routine< jsonifier::vector< web_hook_data > > getGuildWebHooksAsync(get_guild_web_hooks_data dataPackage)
Collects a list of web_hooks from a chosen guild.
static co_routine< web_hook_data > getWebHookWithTokenAsync(get_web_hook_with_token_data dataPackage)
Collects a single web_hook_data, using the token.
button_style
Button styles.
text_input_style
Text input style for modals.
component_type
Component types.
@ Text_Input
Text input object.
DCA_INLINE auto newThreadAwaitable()
An awaitable that can be used to launch the co_routine onto a new thread - as well as return the hand...
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.