DiscordCoreAPI
A Discord bot library written in C++, with custom asynchronous coroutines.
Loading...
Searching...
No Matches
StageInstanceEntities.cpp
Go to the documentation of this file.
1/*
2 MIT License
3
4 DiscordCoreAPI, A bot library for Discord, written in C++, and featuring explicit multithreading through the usage of custom, asynchronous C++ CoRoutines.
5
6 Copyright 2022, 2023 Chris M. (RealTimeChris)
7
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
14
15 The above copyright notice and this permission notice shall be included in all
16 copies or substantial portions of the Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 SOFTWARE.
25*/
26/// StageInstanceEntities.cpp - Source file for the stage instance related stuff.
27/// Nov 29, 2021
28/// https://discordcoreapi.com
29/// \file StageInstanceEntities.cpp
30
34
35namespace jsonifier {
36
37 template<> struct core<discord_core_api::create_stage_instance_data> {
39 static constexpr auto parseValue =
40 createObject("privacyLevel", &value_type::privacyLevel, "channelId", &value_type::channelId, "reason", &value_type::reason, "topic", &value_type::topic);
41 };
42
43 template<> struct core<discord_core_api::modify_stage_instance_data> {
45 static constexpr auto parseValue =
46 createObject("privacyLevel", &value_type::privacyLevel, "channelId", &value_type::channelId, "reason", &value_type::reason, "topic", &value_type::topic);
47 };
48
49}
50
51namespace discord_core_api {
52
53 void stage_instances::initialize(discord_core_internal::https_client* client) {
54 stage_instances::httpsClient = client;
55 }
56
58 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Post_Stage_Instance };
59 co_await newThreadAwaitable<stage_instance_data>();
60 workload.workloadClass = discord_core_internal::https_workload_class::Post;
61 workload.relativePath = "/stage-instances";
62 workload.callStack = "stage_instances::createStageInstanceAsync()";
63 parser.serializeJson<true>(dataPackage, workload.content);
64 if (dataPackage.reason != "") {
65 workload.headersToInsert["x-audit-log-reason"] = dataPackage.reason;
66 }
67 stage_instance_data returnData{};
68 stage_instances::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
69 co_return returnData;
70 }
71
73 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Get_Stage_Instance };
74 co_await newThreadAwaitable<stage_instance_data>();
75 workload.workloadClass = discord_core_internal::https_workload_class::Get;
76 workload.relativePath = "/stage-instances/" + dataPackage.channelId;
77 workload.callStack = "stage_instances::getStageInstanceAsync()";
78 stage_instance_data returnData{};
79 stage_instances::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
80 co_return returnData;
81 }
82
84 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Patch_Stage_Instance };
85 co_await newThreadAwaitable<stage_instance_data>();
86 workload.workloadClass = discord_core_internal::https_workload_class::Patch;
87 workload.relativePath = "/stage-instances/" + dataPackage.channelId;
88 parser.serializeJson<true>(dataPackage, workload.content);
89 workload.callStack = "stage_instances::modifyStageInstanceAsync()";
90 if (dataPackage.reason != "") {
91 workload.headersToInsert["x-audit-log-reason"] = dataPackage.reason;
92 }
93 stage_instance_data returnData{};
94 stage_instances::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
95 co_return returnData;
96 }
97
99 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Delete_Stage_Instance };
100 co_await newThreadAwaitable<void>();
101 workload.workloadClass = discord_core_internal::https_workload_class::Delete;
102 workload.relativePath = "/stage-instances/" + dataPackage.channelId;
103 workload.callStack = "stage_instances::deleteStageInstanceAsync()";
104 if (dataPackage.reason != "") {
105 workload.headersToInsert["x-audit-log-reason"] = dataPackage.reason;
106 }
107 stage_instances::httpsClient->submitWorkloadAndGetResult(std::move(workload));
108 co_return;
109 }
110 discord_core_internal::https_client* stage_instances::httpsClient{};
111}
A co_routine - representing a potentially asynchronous operation/function.
Definition: CoRoutine.hpp:83
static co_routine< stage_instance_data > modifyStageInstanceAsync(const modify_stage_instance_data dataPackage)
Modifies a stage_instance_data.
static co_routine< stage_instance_data > createStageInstanceAsync(const create_stage_instance_data dataPackage)
Creates a stage_instance_data.
static co_routine< void > deleteStageInstanceAsync(const delete_stage_instance_data dataPackage)
Deletes a stage_instance_data.
static co_routine< stage_instance_data > getStageInstanceAsync(const get_stage_instance_data dataPackage)
Collects a stage_instance_data.
The main namespace for the forward-facing interfaces.
jsonifier::string reason
The reason for starting it.
For deleting a single stage_instance_data.
jsonifier::string reason
Reason for deleting the stage_instance_data.
snowflake channelId
The channel_data snowflake of the stage_instance_data.
For collecting a single stage_instance_data.
snowflake channelId
The channel_data id from which you would like to collect the stage_instance_data.
For modifying a single stage_instance_data.
snowflake channelId
The channel_data snowflake of the stage_instance_data.
jsonifier::string reason
Reason for modifying the stage_instance_data.