DiscordCoreAPI
A Discord bot library written in C++, with custom asynchronous coroutines.
Loading...
Searching...
No Matches
AutoModerationEntities.hpp
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 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.hpp - Header for the Auto-Moderation related classes and structs.
22/// Jun 17, 2022 Chris M.
23/// https://discordcoreapi.com
24/// \file AutoModerationEntities.hpp
25
26#pragma once
27
31
32namespace DiscordCoreAPI {
33
34 /**
35 * \addtogroup foundation_entities
36 * @{
37 */
38
39 /// \brief For listing all of the auto-moderation-rules for a particular Guild .
40 struct DiscordCoreAPI_Dll ListAutoModerationRulesForGuildData {
41 Snowflake guildId{};///< The id of the Guild for which you would like to list the auto-moderation rules.
42 };
43
44 /// \brief For collecting an auto-moderation-rule for a particular AutoModerationRule.
45 struct DiscordCoreAPI_Dll GetAutoModerationRuleData {
46 uint64_t autoModerationRuleId{};///< The id of the auto-moderation-rule you would like to collect.
47 Snowflake guildId{};///< The id of the Guild from which you would like to collect the auto-moderation-rule from.
48 };
49
50 /// \brief For creating an auto-moderation-rule.
51 struct DiscordCoreAPI_Dll CreateAutoModerationRuleData {
52 std::vector<uint64_t> exemptChannels{};///< The channel ids that should not be affected by the rule(Maximum of 50).
53 std::vector<uint64_t> exemptRoles{};///< The role ids that should not be affected by the rule(Maximum of 20).
54 TriggerMetaData triggerMetadata{};///< The trigger metadata.
55 std::vector<ActionData> actions{};///< The actions which will execute when the rule is triggered
56 TriggerType triggerType{};///< The trigger type.
57 EventType eventType{};///< The event type.
58 Snowflake guildId{};///< The Guild within which to create the AutoModerationRule.
59 std::string name{};///< The rule name.
60 bool enabled{};///< Whether the rule is enabled(False by default).
61
62 operator Jsonifier();
63 };
64
65 /// \brief For modifying an auto-moderation-rule.
66 struct DiscordCoreAPI_Dll ModifyAutoModerationRuleData {
67 std::vector<uint64_t> exemptChannels{};///< The channel ids that should not be affected by the rule(Maximum of 50).
68 std::vector<uint64_t> exemptRoles{};///< The role ids that should not be affected by the rule(Maximum of 20).
69 TriggerMetaData triggerMetadata{};///< The trigger metadata.
70 std::vector<ActionData> actions{};///< The actions which will execute when the rule is triggered
71 uint64_t autoModerationRuleId{};///< The id of the auto-moderation-rule you would like to modify.
72 EventType eventType{};///< The event type.
73 Snowflake guildId{};///< The AutoModerationRule within which to modify the auto-moderation-rule.
74 std::string name{};///< The rule name.
75 bool enabled{};///< Whether the rule is enabled(False by default).
76
77 operator Jsonifier();
78 };
79
80 /// \brief For when an auto-moderation-rule is executed.
81 struct DiscordCoreAPI_Dll AutoModerationActionExecutionEventData {
82 Snowflake alertSystemMessageId{};///< The id of any system auto moderation messages posted as a result of this action.
83 TriggerType ruleTriggerType{};///< The trigger type of rule which was triggered.
84 std::string matchedKeyword{};///< The word or phrase configured in the rule that triggered the rule
85 std::string matchedContent{};///< The substring in content that triggered the rule.
86 std::string content{};///< The user generated text content.
87 Snowflake channelId{};///< The id of the channel in which user content was posted.
88 Snowflake messageId{};///< The id of any user message which content belongs to.
89 ActionData action{};///< The action which was executed.
90 Snowflake guildId{};///< The id of the guild in which action was executed.
91 Snowflake ruleId{};///< The id of the rule which action belongs to.
92 Snowflake userId{};///< The id of the user which generated the content which triggered the rule.
93
94 AutoModerationActionExecutionEventData() noexcept = default;
95
96 AutoModerationActionExecutionEventData(simdjson::ondemand::value jsonObjectData);
97
98 virtual ~AutoModerationActionExecutionEventData() noexcept = default;
99 };
100
101 /// \brief For deleting an auto-moderation-rule.
102 struct DiscordCoreAPI_Dll DeleteAutoModerationRuleData {
103 uint64_t autoModerationRuleId{};///< The id of the auto-moderation-rule you would like to delete.
104 Snowflake guildId{};///< Guild within which to delete the auto-moderation-rule.
105 };
106
107 /// \brief Represents an auto-moderation-rule.
108 class DiscordCoreAPI_Dll AutoModerationRule : public AutoModerationRuleData {
109 public:
110 AutoModerationRule() noexcept = default;
111
112 AutoModerationRule(simdjson::ondemand::value jsonObjectData);
113
114 virtual ~AutoModerationRule() noexcept = default;
115 };
116
117 class DiscordCoreAPI_Dll AutoModerationRuleVector {
118 public:
119 AutoModerationRuleVector() noexcept = default;
120
121 operator std::vector<AutoModerationRule>();
122
123 AutoModerationRuleVector(simdjson::ondemand::value jsonObjectData);
124
125 virtual ~AutoModerationRuleVector() noexcept = default;
126
127 protected:
128 std::vector<AutoModerationRule> theAutoModerationRules{};
129 };
130
131 /**@}*/
132
133 /**
134 * \addtogroup main_endpoints
135 * @{
136 */
137 /// \brief An interface class for the AutoModerationRule related Discord endpoints.
138 class DiscordCoreAPI_Dll AutoModerationRules {
139 public:
140 static void initialize(DiscordCoreInternal::HttpsClient*);
141
142 /// \brief Get all of the Guild's Auto-Moderation-Rules.
143 /// \returns A CoRoutine containing a vector<AutoModerationRule>.
144 CoRoutine<std::vector<AutoModerationRule>> listAutoModerationRulesForGuildAsync(ListAutoModerationRulesForGuildData dataPackage);
145
146 /// \brief Get a particular Auto-Moderation-Rule
147 /// \returns A CoRoutine containing a AutoModerationRule.
148 CoRoutine<AutoModerationRule> getAutoModerationRuleAsync(GetAutoModerationRuleData dataPackage);
149
150 /// \brief Create a particular Auto-Moderation-Rule
151 /// \returns A CoRoutine containing a AutoModerationRule.
152 CoRoutine<AutoModerationRule> createAutoModerationRuleAsync(CreateAutoModerationRuleData dataPackage);
153
154 /// \brief Modify a particular Auto-Moderation-Rule
155 /// \returns A CoRoutine containing a AutoModerationRule.
156 CoRoutine<AutoModerationRule> modifyAutoModerationRuleAsync(ModifyAutoModerationRuleData dataPackage);
157
158 /// \brief Delete a particular Auto-Moderation-Rule
159 /// \returns A CoRoutine containing a void.
160 CoRoutine<void> deleteAutoModerationRuleAsync(DeleteAutoModerationRuleData dataPackage);
161
162 protected:
163 static DiscordCoreInternal::HttpsClient* httpsClient;
164 };
165
166 /**@}*/
167
168}// namespace DiscordCoreInternal
TriggerType
Trigger types for auto-moderation.
EventType
Event types for auto-moderation.
The main namespace for this library.
For listing all of the auto-moderation-rules for a particular Guild .
For collecting an auto-moderation-rule for a particular AutoModerationRule.
For creating an auto-moderation-rule.
For modifying an auto-moderation-rule.
For when an auto-moderation-rule is executed.
Represents an auto-moderation-rule.
An interface class for the AutoModerationRule related Discord endpoints.
A CoRoutine - representing a potentially asynchronous operation/function.
Definition: CoRoutine.hpp:52
Trigger metadata for auto-moderation-rules.
For representing a single auto-moderation-rule-action.
Represents an auto-moderation-rule.