DiscordCoreAPI
A Discord bot library written in C++, with custom asynchronous coroutines.
Loading...
Searching...
No Matches
AutoModerationEntities.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/// AutoModerationEntities.cpp - Source file for the application_command_data classes and structs.
27/// Aug 25, 2021
28/// https://discordcoreapi.com
29/// \file AutoModerationEntities.cpp
30
33
34namespace jsonifier {
35
36 template<> struct core<discord_core_api::create_auto_moderation_rule_data> {
38 static constexpr auto parseValue = createObject("exemptChannels", &value_type::exemptChannels, "exemptRoles", &value_type::exemptRoles, "triggerMetadata",
39 &value_type::triggerMetadata, "actions", &value_type::actions, "triggerType", &value_type::triggerType, "eventType", &value_type::eventType, "guildId",
40 &value_type::guildId, "name", &value_type::name, "enabled", &value_type::enabled);
41 };
42
43 template<> struct core<discord_core_api::modify_auto_moderation_rule_data> {
45 static constexpr auto parseValue = createObject("exemptChannels", &value_type::exemptChannels, "exemptRoles", &value_type::exemptRoles, "triggerMetadata",
46 &value_type::triggerMetadata, "actions", &value_type::actions, "autoModerationRuleId", &value_type::autoModerationRuleId, "eventType", &value_type::eventType,
47 "guildId", &value_type::guildId, "name", &value_type::name, "enabled", &value_type::enabled);
48 };
49
50}
51
52namespace discord_core_api {
53
54 void auto_moderation_rules::initialize(discord_core_internal::https_client* https_client_new) {
55 auto_moderation_rules::httpsClient = https_client_new;
56 }
57
59 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Get_Auto_Moderation_Rules };
60 co_await newThreadAwaitable<jsonifier::vector<auto_moderation_rule_data>>();
61 workload.workloadClass = discord_core_internal::https_workload_class::Get;
62 workload.relativePath = "/guilds/" + dataPackage.guildId + "/auto-moderation/rules";
63 workload.callStack = "auto_moderation_rules::listAutoModerationRulesForGuildAsync()";
64 jsonifier::vector<auto_moderation_rule_data> returnVector{};
65 auto_moderation_rules::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnVector);
66 co_return std::move(returnVector);
67 }
68
70 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Get_Auto_Moderation_Rule };
71 co_await newThreadAwaitable<auto_moderation_rule_data>();
72 workload.workloadClass = discord_core_internal::https_workload_class::Get;
73 workload.relativePath = "/guilds/" + dataPackage.guildId + "/auto-moderation/rules/" + dataPackage.autoModerationRuleId.operator jsonifier::string();
74 workload.callStack = "auto_moderation_rules::getAutoModerationRuleAsync()";
75 auto_moderation_rule_data returnData{};
76 auto_moderation_rules::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
77 co_return returnData;
78 }
79
81 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Post_Auto_Moderation_Rule };
82 co_await newThreadAwaitable<auto_moderation_rule_data>();
83 workload.workloadClass = discord_core_internal::https_workload_class::Post;
84 workload.relativePath = "/guilds/" + dataPackage.guildId + "/auto-moderation/rules";
85 parser.serializeJson<true>(dataPackage, workload.content);
86 workload.callStack = "auto_moderation_rules::createAutoModerationRuleAsync()";
87 auto_moderation_rule_data returnData{};
88 auto_moderation_rules::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
89 co_return returnData;
90 }
91
93 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Patch_Auto_Moderation_Rule };
94 co_await newThreadAwaitable<auto_moderation_rule_data>();
95 workload.workloadClass = discord_core_internal::https_workload_class::Patch;
96 workload.relativePath = "/guilds/" + dataPackage.guildId + "/auto-moderation/rules/" + dataPackage.autoModerationRuleId;
97 parser.serializeJson<true>(dataPackage, workload.content);
98 workload.callStack = "auto_moderation_rules::modifyAutoModerationRuleAsync()";
99 auto_moderation_rule_data returnData{};
100 auto_moderation_rules::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
101 co_return returnData;
102 }
103
105 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Delete_Auto_Moderation_Rule };
106 co_await newThreadAwaitable<void>();
107 workload.workloadClass = discord_core_internal::https_workload_class::Delete;
108 workload.relativePath = "/guilds/" + dataPackage.guildId + "/auto-moderation/rules/" + dataPackage.autoModerationRuleId;
109 workload.callStack = "auto_moderation_rules::deleteAutoModerationRuleAsync()";
110 auto_moderation_rules::httpsClient->submitWorkloadAndGetResult(std::move(workload));
111 co_return;
112 }
113
114 discord_core_internal::https_client* auto_moderation_rules::httpsClient{};
115
116}
Represents an auto-moderation-rule.
co_routine< jsonifier::vector< auto_moderation_rule_data > > listAutoModerationRulesForGuildAsync(const list_auto_moderation_rules_for_guild_data dataPackage)
Get all of the guild's auto-moderation-rules.
co_routine< auto_moderation_rule_data > modifyAutoModerationRuleAsync(const modify_auto_moderation_rule_data dataPackage)
Modify a particular auto-moderation-rule.
co_routine< auto_moderation_rule_data > createAutoModerationRuleAsync(const create_auto_moderation_rule_data dataPackage)
Create a particular auto-moderation-rule.
co_routine< auto_moderation_rule_data > getAutoModerationRuleAsync(const get_auto_moderation_rule_data dataPackage)
Get a particular auto-moderation-rule.
co_routine< void > deleteAutoModerationRuleAsync(const delete_auto_moderation_rule_data dataPackage)
Delete a particular auto-moderation-rule.
A co_routine - representing a potentially asynchronous operation/function.
Definition: CoRoutine.hpp:83
The main namespace for the forward-facing interfaces.
snowflake guildId
The guild within which to create the auto_moderation_rule_data.
snowflake guildId
Guild within which to delete the auto-moderation-rule.
snowflake autoModerationRuleId
The id of the auto-moderation-rule you would like to delete.
For collecting an auto-moderation-rule for a particular auto_moderation_rule_data.
snowflake autoModerationRuleId
The id of the auto-moderation-rule you would like to collect.
snowflake guildId
The id of the guild from which you would like to collect the auto-moderation-rule from.
For listing all of the auto-moderation-rules for a particular guild .
snowflake guildId
The id of the guild for which you would like to list the auto-moderation rules.
snowflake guildId
The auto_moderation_rule_data within which to modify the auto-moderation-rule.
snowflake autoModerationRuleId
The id of the auto-moderation-rule you would like to modify.