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 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/// AutoModerationEntities.cpp - Source file for the ApplicationCommand classes and structs.
22/// Aug 25, 2021
23/// https://discordcoreapi.com
24/// \file AutoModerationEntities.cpp
25
27
28namespace Jsonifier {
29
30 template<> struct Core<DiscordCoreAPI::CreateAutoModerationRuleData> {
32 static constexpr auto parseValue = object("exemptChannels", &ValueType::exemptChannels, "exemptRoles", &ValueType::exemptRoles,
33 "triggerMetadata", &ValueType::triggerMetadata, "actions", &ValueType::actions, "triggerType", &ValueType::triggerType, "eventType",
34 &ValueType::eventType, "guildId", &ValueType::guildId, "name", &ValueType::name, "enabled", &ValueType::enabled);
35 };
36
37 template<> struct Core<DiscordCoreAPI::ModifyAutoModerationRuleData> {
39 static constexpr auto parseValue = object("exemptChannels", &ValueType::exemptChannels, "exemptRoles", &ValueType::exemptRoles,
40 "triggerMetadata", &ValueType::triggerMetadata, "actions", &ValueType::actions, "autoModerationRuleId", &ValueType::autoModerationRuleId,
41 "eventType", &ValueType::eventType, "guildId", &ValueType::guildId, "name", &ValueType::name, "enabled", &ValueType::enabled);
42 };
43
44}
45
46namespace DiscordCoreAPI {
47
48 void AutoModerationRules::initialize(DiscordCoreInternal::HttpsClient* HttpsClientNew) {
49 AutoModerationRules::httpsClient = HttpsClientNew;
50 }
51
54 DiscordCoreInternal::HttpsWorkloadData workload{ DiscordCoreInternal::HttpsWorkloadType::Get_Auto_Moderation_Rules };
55 co_await NewThreadAwaitable<std::vector<AutoModerationRule>>();
56 workload.workloadClass = DiscordCoreInternal::HttpsWorkloadClass::Get;
57 workload.relativePath = "/guilds/" + dataPackage.guildId + "/auto-moderation/rules";
58 workload.callStack = "AutoModerationRules::listAutoModerationRulesForGuildAsync()";
59 AutoModerationRuleVector returnVector{};
60 AutoModerationRules::httpsClient->submitWorkloadAndGetResult<AutoModerationRuleVector>(workload, returnVector);
61 co_return returnVector;
62 }
63
65 DiscordCoreInternal::HttpsWorkloadData workload{ DiscordCoreInternal::HttpsWorkloadType::Get_Auto_Moderation_Rule };
66 co_await NewThreadAwaitable<AutoModerationRule>();
67 workload.workloadClass = DiscordCoreInternal::HttpsWorkloadClass::Get;
68 workload.relativePath = "/guilds/" + dataPackage.guildId + "/auto-moderation/rules/" + std::to_string(dataPackage.autoModerationRuleId);
69 workload.callStack = "AutoModerationRules::getAutoModerationRuleAsync()";
70 AutoModerationRule returnData{};
71 AutoModerationRules::httpsClient->submitWorkloadAndGetResult<AutoModerationRule>(workload, returnData);
72 co_return returnData;
73 }
74
76 DiscordCoreInternal::HttpsWorkloadData workload{ DiscordCoreInternal::HttpsWorkloadType::Post_Auto_Moderation_Rule };
77 co_await NewThreadAwaitable<AutoModerationRule>();
78 workload.workloadClass = DiscordCoreInternal::HttpsWorkloadClass::Post;
79 workload.relativePath = "/guilds/" + dataPackage.guildId + "/auto-moderation/rules";
80 Jsonifier::JsonifierCore parser{};
81 parser.serializeJson(dataPackage, workload.content);
82 workload.callStack = "AutoModerationRules::createAutoModerationRuleAsync()";
83 AutoModerationRule returnData{};
84 AutoModerationRules::httpsClient->submitWorkloadAndGetResult<AutoModerationRule>(workload, returnData);
85 co_return returnData;
86 }
87
89 DiscordCoreInternal::HttpsWorkloadData workload{ DiscordCoreInternal::HttpsWorkloadType::Patch_Auto_Moderation_Rule };
90 co_await NewThreadAwaitable<AutoModerationRule>();
91 workload.workloadClass = DiscordCoreInternal::HttpsWorkloadClass::Patch;
92 workload.relativePath = "/guilds/" + dataPackage.guildId + "/auto-moderation/rules/" + std::to_string(dataPackage.autoModerationRuleId);
93 Jsonifier::JsonifierCore parser{};
94 parser.serializeJson(dataPackage, workload.content);
95 workload.callStack = "AutoModerationRules::modifyAutoModerationRuleAsync()";
96 AutoModerationRule returnData{};
97 AutoModerationRules::httpsClient->submitWorkloadAndGetResult<AutoModerationRule>(workload, returnData);
98 co_return returnData;
99 }
100
102 DiscordCoreInternal::HttpsWorkloadData workload{ DiscordCoreInternal::HttpsWorkloadType::Delete_Auto_Moderation_Rule };
103 co_await NewThreadAwaitable<void>();
104 workload.workloadClass = DiscordCoreInternal::HttpsWorkloadClass::Delete;
105 workload.relativePath = "/guilds/" + dataPackage.guildId + "/auto-moderation/rules/" + std::to_string(dataPackage.autoModerationRuleId);
106 workload.callStack = "AutoModerationRules::deleteAutoModerationRuleAsync()";
107 AutoModerationRules::httpsClient->submitWorkloadAndGetResult<void>(workload);
108 co_return;
109 }
110
111 DiscordCoreInternal::HttpsClient* AutoModerationRules::httpsClient{};
112
113}
The main namespace for this library.
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.
For collecting an auto-moderation-rule for a particular AutoModerationRule.
uint64_t 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 creating an auto-moderation-rule.
Snowflake guildId
The Guild within which to create the AutoModerationRule.
For modifying an auto-moderation-rule.
Snowflake guildId
The AutoModerationRule within which to modify the auto-moderation-rule.
uint64_t autoModerationRuleId
The id of the auto-moderation-rule you would like to modify.
For deleting an auto-moderation-rule.
uint64_t autoModerationRuleId
The id of the auto-moderation-rule you would like to delete.
Snowflake guildId
Guild within which to delete the auto-moderation-rule.
CoRoutine< void > deleteAutoModerationRuleAsync(DeleteAutoModerationRuleData dataPackage)
Delete a particular Auto-Moderation-Rule.
CoRoutine< AutoModerationRule > modifyAutoModerationRuleAsync(ModifyAutoModerationRuleData dataPackage)
Modify a particular Auto-Moderation-Rule.
CoRoutine< AutoModerationRule > createAutoModerationRuleAsync(CreateAutoModerationRuleData dataPackage)
Create a particular Auto-Moderation-Rule.
CoRoutine< std::vector< AutoModerationRule > > listAutoModerationRulesForGuildAsync(ListAutoModerationRulesForGuildData dataPackage)
Get all of the Guild's Auto-Moderation-Rules.
CoRoutine< AutoModerationRule > getAutoModerationRuleAsync(GetAutoModerationRuleData dataPackage)
Get a particular Auto-Moderation-Rule.
A CoRoutine - representing a potentially asynchronous operation/function.
Definition: CoRoutine.hpp:52
Represents an auto-moderation-rule.