Class AutoModRuleData

java.lang.Object
net.dv8tion.jda.api.entities.automod.build.AutoModRuleData
All Implemented Interfaces:
SerializableData

public class AutoModRuleData extends Object implements SerializableData
Data class used to create new AutoModRules.

Every rule must configure at least one response.

Example


 TriggerConfig config = TriggerConfig.keywordFilter("discord.gg/*").addAllowList("gateway.discord.gg/*");
 AutoModRuleData data = AutoModRuleData.onMessage("Invite Block", config);
 data.addExemptRoles(guild.getRolesByName("Moderator", true));
 data.putResponse(AutoModResponse.blockMessage());
 
  1. The TriggerConfig defines under what conditions the rule should be triggered and execute a response. It should trigger on all invite links, but not trigger on the gateway subdomain.
  2. The rule is then created with this trigger config and we name it "Invite Block".
  3. Using addExemptRoles(Role...), the moderator role has been excluded to allow moderators to post links.
  4. With putResponses(AutoModResponse...), an automatic action is enabled to block the message, whenever it triggers the rule.
See Also: