AutoModerationRule
Auto moderation feature which allows guilds to set rules that trigger based on some criteria.
Attributes actions :
Actions which will execute when the rule is triggered. Defaults to 0
.
int
The user who created the rule. Defaults to 0
.
bool
Whether the rule is enabled.
For which events is the rule applied.
None
, tuple
of int
The excluded channels' identifiers.
None
, tuple
of int
The excluded roles' identifiers.
int
The guild's identifier where the rule is. Defaults to 0
.
int
The unique identifier of the auto moderation rule. Defaults to 0
.
str
The rule's name.
Trigger type specific metadata if applicable.
Characterizes the type of content which can trigger the rule.
Properties
created_at
When the entity was created.
Returns
created_at : datetime
creator
excluded_channels
excluded_roles
guild
Returns the auto moderation rule's guild. If the guild is not cached returns None
Returns
guild : None
, Guild
partial
Returns whether the auto moderation rule is partial.
Returns
partial : bool
Methods
(...)
__new__Creates a new auto moderation rule with the given parameters.
Parameter | Type | Optional | Keyword only | Description |
---|---|---|---|---|
name |
| The rule's name. | ||
actions |
| Actions which will execute when the rule is triggered. | ||
trigger_type | Auto moderation trigger type. | |||
enabled |
| Whether the rule is enabled. | ||
event_type |
| For which events is the rule applied. | ||
excluded_channel_ids | Excluded channels from the rule. | |||
excluded_role_ids | Excluded roles from the rule. | |||
**keyword_parameters | Keyword parameters | Additional keyword parameters defining how the rule is triggered. | ||
excluded_keywords |
| Excluded keywords from preset filter. | ||
keyword_presets |
| Keyword preset defined by Discord which will be searched for in content. | ||
keywords |
| Substrings which will be searched for in content. | ||
mention_limit |
| The amount of mentions in a message after the rule is triggered. | ||
regex_patterns |
| Regular expression patterns which are matched against content. |
Raises
TypeError
- If a parameter's type is incorrect.
ValueError
- If a parameter's value is incorrect.
()
copy(...)
copy_withCopies the auto moderation rule with the given attributes replaced.
Parameter | Type | Optional | Keyword only | Description |
---|---|---|---|---|
actions |
| Actions which will execute when the rule is triggered. | ||
enabled |
| Whether the rule is enabled. | ||
event_type |
| For which events is the rule applied. | ||
excluded_channel_ids | Excluded channels from the rule. | |||
excluded_role_ids | Excluded roles from the rule. | |||
name |
| The rule's name. | ||
trigger_type | Auto moderation trigger type. | |||
**keyword_parameters | Keyword parameters | Additional keyword parameters defining how the rule is triggered. | ||
excluded_keywords |
| Excluded keywords from preset filter. | ||
keyword_presets |
| Keyword preset defined by Discord which will be searched for in content. | ||
keywords |
| Substrings which will be searched for in content. | ||
mention_limit |
| The amount of mentions in a message after the rule is triggered. | ||
regex_patterns |
| Regular expression patterns which are matched against content. |
Returns
new : AutoModerationRule
Raises
TypeError
- If a parameter's type is incorrect.
ValueError
- If a parameter's value is incorrect.
(data)
from_dataCreates a new AutoModerationRule
from the given data.
Parameter | Type | Description |
---|---|---|
data |
| Received auto moderation rule data. |
Returns
self : AutoModerationRule
The created auto moderation rule.
()
iter_actionsIterates over the actions of the auto moderation rule.
This method is an iterable generator.
Yields
action : AutoModerationAction
()
iter_excluded_channel_idsIterates over the excluded channel identifiers from the rule.
This method is an iterable generator.
Yields
excluded_channel_id : int
()
iter_excluded_channelsIterates over the excluded channels from the rule.
This method is an iterable generator.
Yields
excluded_channel : Channel
()
iter_excluded_role_idsIterates over the excluded role identifiers from the rule.
This method is an iterable generator.
Yields
excluded_role_id : int
()
iter_excluded_rolesIterates over the excluded roles from the rule.
This method is an iterable generator.
Yields
excluded_role : Role
(rule_id, ...)
precreatePrecreates the auto moderation rule by creating a new one if not yet exists of the given identifier.
Parameter | Type | Optional | Keyword only | Description |
---|---|---|---|---|
rule_id |
| The auto moderation rule's identifier. | ||
*keyword_parameters | Keyword parameters | Keyword parameters defining how should the rule's attributes be set. | ||
actions |
| Actions which will execute when the rule is triggered. | ||
creator_id |
| The user who created the rule. | ||
enabled |
| Whether the rule is enabled. | ||
event_type |
| For which events is the rule applied. | ||
excluded_channel_ids | Excluded channels from the rule. | |||
excluded_role_ids | Excluded roles from the rule. | |||
guild_id |
| The guild's identifier where the rule is. | ||
name |
| The rule's name. | ||
trigger_type | Auto moderation trigger type. | |||
excluded_keywords |
| Excluded keywords from preset filter. | ||
keyword_presets |
| Keyword preset defined by Discord which will be searched for in content. | ||
keywords |
| Substrings which will be searched for in content. | ||
mention_limit |
| The amount of mentions in a message after the rule is triggered. | ||
regex_patterns |
| Regular expression patterns which are matched against content. |
Returns
self : instance<cls>
Raises
TypeError
- If a parameter's type is incorrect.
- Extra or unused parameters given.
ValueError
- If a parameter's value is incorrect.
(...)
to_dataConverts the auto moderation rule to a json serializable object.
Parameter | Type | Optional | Keyword only | Default | Description |
---|---|---|---|---|---|
defaults |
|
| Whether default values should be included as well. | ||
include_internals |
|
| Whether internal fields should be included. |
Returns
data : dict
of (str
, object
) items
(rule_id)
_create_emptyCreates an auto moderation rule with it's attributes set as their default values.
Parameter | Type | Description |
---|---|---|
rule_id |
| The auto moderation rule's identifier. |
Returns
self : instance<cls>
(data)
_difference_update_attributesUpdates the auto moderation rule and returns the changed attributes in a dictionary with the changed attributes in a attribute-name
, old-value
relation.
Parameter | Type | Description |
---|---|---|
data |
| Received guild profile data. |
Returns
old_attributes : dict
of (str
, object
) items
All item in the returned dict is optional.
Might contain the following items:
Keys | Values |
---|---|
actions | None , tuple of AutoModerationAction |
enabled | bool |
event_type | AutoModerationEventType |
excluded_channel_ids | None , tuple of int |
excluded_role_ids | None , tuple of int |
name | str |
trigger_metadata | AutoModerationRuleTriggerMetadataBase |
trigger_type | AutoModerationRuleTriggerType |
(data)
_set_attributesSets the auto moderation rule's attributes (excluding .id
).
Parameter | Type | Description |
---|---|---|
data |
| Received guild profile data. |
(data)
_update_attributesUpdates the auto moderation rule with overwriting it's old attributes.
Parameter | Type | Description |
---|---|---|
data |
| Received guild profile data. |
()
__eq__Returns whether the two auto moderation rules are equal.
()
__ge__Whether this entity's id is greater or equal than the other's.
()
__getattr__Drops a rich attribute error.
()
__gt__Whether this entity's id is greater than the other's.
()
__hash__Returns the auto moderation rule's hash value.
()
__le__Whether this entity's id is less or equal than the other's.
()
__lt__Whether this entity's id is less than the other's.
()
__ne__Returns whether the two auto moderation rules are not equal.
()
__repr__Returns the auto moderation rule's representation