Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing auto moderation #2159

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
29b546c
update the intents for auto moderation.
RealYusufIsmail Jun 18, 2022
5749089
Finished with all the Auto Moderation enums and interfaces.
RealYusufIsmail Jun 18, 2022
054d1dd
Added copyright
RealYusufIsmail Jun 18, 2022
6da8270
Finished with impls and Entity builder
RealYusufIsmail Jun 18, 2022
db47def
Finished with the java doc
RealYusufIsmail Jun 18, 2022
5e3b8ad
Continued adding the AuditLogKey tomorrow
RealYusufIsmail Jun 18, 2022
4ad07c6
Finished with the Audit for auto moderation
RealYusufIsmail Jun 19, 2022
8fa3cb3
Adding missing </ul>
RealYusufIsmail Jun 19, 2022
fb5ca0a
Finished with auto moderation create handler
RealYusufIsmail Jun 19, 2022
bc7d164
added create event to ListenerAdapter
RealYusufIsmail Jun 19, 2022
e7a0a0a
Added Java Doc
RealYusufIsmail Jun 19, 2022
aee3126
Updated some java doc
RealYusufIsmail Jun 19, 2022
bcd71b0
Update more java doc and some tweaks
RealYusufIsmail Jun 19, 2022
a882a4e
Thats it for today
RealYusufIsmail Jun 19, 2022
d654a7b
some minor tweaks and also added delete event
RealYusufIsmail Jun 19, 2022
b3d9675
Merge branch 'master' into updat/intents
RealYusufIsmail Jun 19, 2022
21d5f7c
Pretty much done
RealYusufIsmail Jun 20, 2022
f981524
Save
RealYusufIsmail Jun 20, 2022
16846a7
Fixed an error
RealYusufIsmail Jun 20, 2022
04e3c81
modifyAutoModerationRule left
RealYusufIsmail Jun 20, 2022
1541b9f
Added a todo
RealYusufIsmail Jun 20, 2022
3e1bafb
Added java doc for update events
RealYusufIsmail Jun 21, 2022
0088004
cleaned up the handlers
RealYusufIsmail Jun 21, 2022
ce4caf2
Cleaned up most of the code.
RealYusufIsmail Jun 21, 2022
bab9490
fixed an error
RealYusufIsmail Jun 21, 2022
26b5444
missing doc + minor class cleanup
RealYusufIsmail Jun 21, 2022
4e977df
Finished with modify
RealYusufIsmail Jun 21, 2022
80cc57b
Update intents to match the breaking changes
RealYusufIsmail Jun 22, 2022
e8cd6ac
doc update
RealYusufIsmail Jun 22, 2022
f8c4415
forgot about AUTO_MODERATION_ACTION_EXECUTION
RealYusufIsmail Jun 22, 2022
71eb683
hmm
RealYusufIsmail Jun 22, 2022
2601a05
return null;
RealYusufIsmail Jun 22, 2022
b928040
Added a TODO
RealYusufIsmail Jun 22, 2022
a1169f4
Reformatted most of the code.
RealYusufIsmail Jun 22, 2022
8dbae4d
Merge branch 'master' into updat/intents
RealYusufIsmail Jun 22, 2022
0bb88f3
Update some java doc and some code
RealYusufIsmail Jun 23, 2022
feb2832
quick fix
RealYusufIsmail Jun 23, 2022
a82925b
some import clean up
RealYusufIsmail Jun 23, 2022
4620db0
some minor doc updates
RealYusufIsmail Jun 23, 2022
70fa2f7
add ignore ds store
RealYusufIsmail Jun 23, 2022
2336a0e
Made the required changes
RealYusufIsmail Jun 26, 2022
2d6c7e0
optimising imports
RealYusufIsmail Jun 26, 2022
223a2af
Merge branch 'master' into updat/intents
RealYusufIsmail Jun 28, 2022
f0893db
Updated the alignment
RealYusufIsmail Jun 28, 2022
b7697a6
Update ActionType.java
RealYusufIsmail Jun 28, 2022
8346dc8
Made some required changes(not all of it)
RealYusufIsmail Jun 28, 2022
570d180
Made some doc changes and move some classess
RealYusufIsmail Jun 29, 2022
1398909
Changed code to rule_id
RealYusufIsmail Jun 29, 2022
1074469
Updated the event update names
RealYusufIsmail Jun 29, 2022
412bc65
Fixed some import issues
RealYusufIsmail Jun 30, 2022
de4650d
Updated event java doc
RealYusufIsmail Jun 30, 2022
0bd8c05
Trying something with the create rule
RealYusufIsmail Jun 30, 2022
d1f6b60
remove ```@NotNul```
RealYusufIsmail Jun 30, 2022
a11bfa2
AutoModerationRuledDataImpl to AutoModerationRuledData in createAutoM…
RealYusufIsmail Jun 30, 2022
1c2b00f
casr
RealYusufIsmail Jun 30, 2022
71f436d
renamed from AutoModerationRuledData to AutoModerationRuleData
RealYusufIsmail Jul 1, 2022
8e03086
added Collections.unmodifiableList
RealYusufIsmail Jul 1, 2022
5b5db14
Finished with Modify
RealYusufIsmail Jul 1, 2022
e5e0af1
some minor java doc fixeses
RealYusufIsmail Jul 1, 2022
f07ffc7
Update AutoModerationRuleDataImpl.java
RealYusufIsmail Jul 1, 2022
3a352dc
some minor tweaks
RealYusufIsmail Jul 2, 2022
55a398e
removed SortedSnowflakeCacheViewImpl<AutoModerationRule>
RealYusufIsmail Jul 3, 2022
c8ab12e
Update GuildImpl.java
RealYusufIsmail Jul 3, 2022
9dffc59
Merge branch 'master' into updat/intents
RealYusufIsmail Jul 3, 2022
3918023
Adding missing java doc
RealYusufIsmail Jul 11, 2022
bd453fe
Merge branch 'master' into updat/intents
RealYusufIsmail Jul 11, 2022
7203946
fixed the error
RealYusufIsmail Jul 11, 2022
5297aa2
Update AutoModerationRuleData.java
RealYusufIsmail Jul 11, 2022
d78e9e1
finished java doc
RealYusufIsmail Jul 11, 2022
50de4c9
pretty much finish
RealYusufIsmail Jul 11, 2022
97a8c94
Thnking about how it should work
RealYusufIsmail Jul 11, 2022
fc792c5
save
RealYusufIsmail Jul 11, 2022
0c612d0
Improved rule create system
RealYusufIsmail Jul 12, 2022
8435e05
hard coded the trigger types for keyword and preset
RealYusufIsmail Jul 12, 2022
4623d5a
Updated rule java doc
RealYusufIsmail Jul 12, 2022
2d1fab4
Merge branch 'master' into updat/intents
RealYusufIsmail Jul 17, 2022
529199a
Merge branch 'master' into updat/intents
RealYusufIsmail Jul 29, 2022
1dd766e
added some new changes
RealYusufIsmail Aug 5, 2022
e2cbbc7
Merge branch 'master' into updat/intents
RealYusufIsmail Aug 5, 2022
91618af
setKeyword to setExemptSubstrings in ExemptSubstrings
RealYusufIsmail Aug 6, 2022
400659e
Not done yet
RealYusufIsmail Aug 24, 2022
5e21963
added MentionTotalLimit
RealYusufIsmail Aug 24, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/main/java/net/dv8tion/jda/api/entities/ActionMetadata.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package net.dv8tion.jda.api.entities;
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved

public interface ActionMetadata {
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
/**
* The channel were the logging of the auto-moderation rule breaking should be sent to.
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
*
* @return {@link net.dv8tion.jda.api.entities.TextChannel TextChannel}
*/
TextChannel getChannel();

/**
* The duration of the timeout in seconds.
*
* @return {@link java.lang.Integer Integer}
*/
int getDuration();
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
}
40 changes: 40 additions & 0 deletions src/main/java/net/dv8tion/jda/api/entities/ActionType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package net.dv8tion.jda.api.entities;
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved

public enum ActionType
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
{
/**
* Blocks the message if the message breaks the auto-moderation rules.
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
*/
BLOCK_MESSAGE(1),
/**
* Sends an alert to a specific channel if a member breaks the auto-moderation rules.
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
*/
SEND_ALERT_MESSAGE(2),
/**
* Times out the member who broke the auto-moderation rules.
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
*/
TIMEOUT(3),
/**
* An unknown action type.
*/
UNKNOWN(-1);

private final int value;

ActionType(int value) {
this.value = value;
}

public int getValue() {
return value;
}

public static ActionType fromValue(int value) {
for (ActionType type : values()) {
if (type.value == value) {
return type;
}
}
return UNKNOWN;
}
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package net.dv8tion.jda.api.entities;
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

public interface AutoModerationAction {
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
/**
* Gets the action type.
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
*
* @return {@link ActionType ActionTypes}
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
*/
@Nonnull
ActionType getActionType();

/**
* Additional metadata needed during the execution for this specific action type
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
*
* @return {@link ActionMetadata ActionMetadata}
*/
@Nullable
ActionMetadata getActionMetadata();
}
83 changes: 83 additions & 0 deletions src/main/java/net/dv8tion/jda/api/entities/AutoModerationRule.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package net.dv8tion.jda.api.entities;
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved

import javax.annotation.Nonnull;
import java.util.List;

public interface AutoModerationRule extends ISnowflake {
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
/**
* The Guild in which the role belongs to.
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
*
* @return {@link net.dv8tion.jda.api.entities.Guild Guild}
*/
@Nonnull
Guild getGuild();

/**
* The name of the rule.
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
*
* @return {@link java.lang.String String}
*/
@Nonnull
String getName();

/**
* The user who created the rule.
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
*
* @return {@link net.dv8tion.jda.api.entities.User User}
*/
@Nonnull
User getUser();

/**
* The event type which triggers the rule.
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
*
* @return {@link net.dv8tion.jda.api.entities.EventType EventType}
*/
@Nonnull
EventType getEventType();

/**
* The trigger of the rule.
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
*
* @return {@link net.dv8tion.jda.api.entities.TriggerType TriggerTypes}
*/
@Nonnull
TriggerType getTriggerType();

/**
* The metadata of the trigger.
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
*
* @return {@link net.dv8tion.jda.api.entities.TriggerMetadata TriggerMetadata}
*/
@Nonnull
TriggerMetadata getTriggerMetadata();

/**
* The actions which will be performed when the rule is triggered.
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
*
* @return A {@link java.util.List List} of {@link net.dv8tion.jda.api.entities.AutoModerationAction ActionTypes}
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
*/
@Nonnull
List<AutoModerationAction> getActions();

/**
* Weather the rule is enabled or not.
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
*
* @return {@link java.lang.Boolean Boolean}
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
*/
boolean isEnabled();

/**
* The roles which are exempt from the rules.
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
*
* @return A {@link java.util.List List} of {@link net.dv8tion.jda.api.entities.Role Roles} which are exempt from the rules.
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
*/
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
List<Role> getExemptRoles();

/**
* The channels which are exempt from the rules.
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
*
* @return A {@link java.util.List List} of {@link net.dv8tion.jda.api.entities.Channel Channels} which are exempt from the rules.
*/
List<Channel> getExemptChannels();
}
32 changes: 32 additions & 0 deletions src/main/java/net/dv8tion/jda/api/entities/EventType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package net.dv8tion.jda.api.entities;
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved

public enum EventType {
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
/**
* This event is triggered when a message is sent.
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
*/
MESSAGE_SEND(1),
/**
* An unknown event type.
*/
UNKNOWN(-1);


private final int value;

EventType(int value) {
this.value = value;
}

public int getValue() {
return value;
}

public static EventType fromValue(int value) {
for (EventType type : values()) {
if (type.value == value) {
return type;
}
}
return UNKNOWN;
}
}
39 changes: 39 additions & 0 deletions src/main/java/net/dv8tion/jda/api/entities/KeywordPresetType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package net.dv8tion.jda.api.entities;
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved

public enum KeywordPresetType {
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
/**
* Words that may be considered forms of swearing or cursing.
*/
PROFANITY(1),
/**
* Words that refer to sexually explicit behavior or activity.
*/
SEXUAL_CONTENT(2),
/**
* Personal insults or words that may be considered hate speech.
*/
SLURS(3),
/**
* An unknown preset type.
*/
UNKNOWN(-1);

private final int value;

KeywordPresetType(int value) {
this.value = value;
}

public int getValue() {
return value;
}

public static KeywordPresetType fromValue(int value) {
for (KeywordPresetType type : values()) {
if (type.value == value) {
return type;
}
}
return UNKNOWN;
}
}
25 changes: 25 additions & 0 deletions src/main/java/net/dv8tion/jda/api/entities/TriggerMetadata.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package net.dv8tion.jda.api.entities;

import java.util.List;

public interface TriggerMetadata {
/**
* The substring which will be searched for in content
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
*
* <br>
* Associated trigger type is KEYWORD
*
* @return A {@link java.util.List List} of {@link java.lang.String Strings}
*/
List<String> getKeywords();

/**
* The internally pre-defined word sets which will be searched for in content.
*
* <br>
* Associated trigger type is KEYWORD_PRESET
*
* @return A {@link java.util.List List} of {@link net.dv8tion.jda.api.entities.KeywordPresetType KeywordPresets}
*/
List<KeywordPresetType> KeywordPresetType();
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
}
62 changes: 62 additions & 0 deletions src/main/java/net/dv8tion/jda/api/entities/TriggerType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package net.dv8tion.jda.api.entities;
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved


public enum TriggerType
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
{
/**
* This checks if the content sent by a member contains a specific word.
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
* <br>
* The max per guild is 3.
*/
KEYWORD(1, 3),
/**
* As the name suggests it checks for any links which are found to be harmful.
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
*
* <br>
* The max per guild is 1.
*/
HARMFUL_LINK(2, 1),
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
/**
* This checks for generic spam.
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
*
* <br>
* The max per guild is 1.
*/
SPAM(3, 1),
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
/**
* This check if the content contains words from internal pre-defined word sets
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved
*
* <br>
* The max per guild is 1.
*/
KEYWORD_PRESET(4, 1),
/**
* An unknown trigger type.
*/
UNKNOWN(-1, 0);

private final int value;
private final int maxPerGuild;

TriggerType(int value, int maxPerGuild) {
this.value = value;
this.maxPerGuild = maxPerGuild;
}

public int getValue() {
return value;
}

public int getMaxPerGuild() {
return maxPerGuild;
}

public static TriggerType fromValue(int value) {
for (TriggerType type : values()) {
if (type.value == value) {
return type;
}
}
return UNKNOWN;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package net.dv8tion.jda.internal.handle;
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved

import net.dv8tion.jda.api.utils.data.DataObject;
import net.dv8tion.jda.internal.JDAImpl;

public class AutoModerationRuleCreateHandler extends SocketHandler {

public AutoModerationRuleCreateHandler(JDAImpl api) {
super(api);
}

@Override
protected Long handleInternally(DataObject content) {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package net.dv8tion.jda.internal.handle;
RealYusufIsmail marked this conversation as resolved.
Show resolved Hide resolved

import net.dv8tion.jda.api.utils.data.DataObject;
import net.dv8tion.jda.internal.JDAImpl;

public class AutoModerationRuleUpdateHandler extends SocketHandler {

public AutoModerationRuleUpdateHandler(JDAImpl api) {
super(api);
}

@Override
protected Long handleInternally(DataObject content) {
return null;
}
}