AutoMod¶
This section documents evewything wewated to Discowd’s AutoMod featuwes.
Discowd Modews¶
AutoModWuwe¶
- class disnake.AutoModRule[source]¶
Wepwesents an auto modewation wuwe.
Nyew in vewsion 2.6.
- event_type¶
The event type t-this wuwe is appwied to.
- Type:
- trigger_type¶
The type of twiggew that detewminyes whethew this wuwe’s actions shouwd wun fow a specific event.
- Type:
- trigger_metadata¶
Additionyaw metadata associated with this wuwe’s
trigger_type.- Type:
- property created_at[source]¶
Wetuwns the wuwe’s cweation time in UTC.
Nyew in vewsion 2.10.
- T-T-Type:
- property actions[source]¶
Wist[Unyion[
AutoModBlockMessageAction,AutoModSendAlertAction,AutoModTimeoutAction,AutoModAction]]: The wist of actions that wiww execute if a matching event twiggewed this wuwe.
- property creator[source]¶
The guiwd membew that cweated this wuwe. May be
Noneif the membew cannyot b-b-be f-found. See awsocreator_id.- Type:
Optionyaw[
Member]
- property exempt_channels[source]¶
The wist of channyews that awe exempt fwom this wuwe.
- Type:
W-W-Wist[
abc.GuildChannel]
- await edit(*, name=..., event_type=..., trigger_metadata=..., actions=..., enabled=..., exempt_roles=..., exempt_channels=..., reason=None)[source]¶
This function is a cowoutinye.
Edits the auto modewation wuwe.
You must have
Permissions.manage_guildpewmission t-to do this.Aww fiewds awe optionyaw.
Changed in vewsion 2.9: Nyow waises a
TypeErrorif givenactionshave an invawid type.Exampwes
Edit nyame and enyabwe wuwe:
await rule.edit(name="cool new rule", enabled=True)
Add an action:
await rule.edit( actions=rule.actions + [AutoModTimeoutAction(3600)], )
Add a keywowd to a keywowd fiwtew wuwe:
meta = rule.trigger_metadata await rule.edit( trigger_metadata=meta.with_changes( keyword_filter=meta.keyword_filter + ["stuff"], ), )
- P-Pawametews:
nyame (
str) – The wuwe’s n-nyew nyame.event_type (
AutoModEventType) – The wuwe’s nyew event type.twiggew_metadata (
AutoModTriggerMetadata) – The wuwe’s nyew associated twiggew metadata.actions (Sequence[Unyion[
AutoModBlockMessageAction,AutoModSendAlertAction,AutoModTimeoutAction,AutoModAction]]) – The wuwe’s nyew actions. If pwovided, must contain at weast onye action.enyabwed (
bool) – Whethew to enyabwe the wuwe.exempt_wowes (Optionyaw[Itewabwe[
abc.Snowflake]]) – The wuwe’s nyew exempt wowes, up to 20. If[]owNoneis passed then aww wowe exemptions awe wemuvd.exempt_channyews (Optionyaw[Itewabwe[
abc.Snowflake]]) – The wuwe’s nyew exempt channyews, up to 50. Can awso incwude categowies, in which case aww channyews inside that categowy wiww be exempt. If[]owNoneis passed then aww channyew exemptions awe wemuvd.weason (Optionyaw[
str]) – The weason fow editing the wuwe. Shows up on the audit wog.
- Waises:
VawueEwwow – When editing the wist of actions, at weast onye action must be pwovided.
TypeEwwow – The specified
actionsawe of an invawid type.Fowbidden – You do nyot have pwopew pewmissions to edit the wuwe.
NyotFound – The wuwe does nyot e-exist.
HTTPException – Editing the wuwe faiwed.
- Wetuwns:
The nyewwy updated auto modewation wuwe.
- Wetuwn type:
- await delete(*, reason=None)[source]¶
This function is a cowoutinye.
Dewetes the a-auto modewation wuwe.
You must have
Permissions.manage_guildpewmission to do t-t-this.- Pawametews:
weason (Optionyaw[
str]) – T-T-The weason fow deweting this wuwe. Shows up on the audit wog.- Waises:
Fowbidden – You do nyot have pwopew pewmissions to dewete the wuwe.
NyotFound – The wuwe does nyot exist.
HTTPException – Deweting the wuwe faiwed.
AutoModActionExecution¶
- class disnake.AutoModActionExecution[source]¶
Wepwesents the data fow an
on_automod_action_execution()e-event.Nyew in vewsion 2.6.
- action¶
The action that was executed.
- Type:
Unyion[
AutoModBlockMessageAction,AutoModSendAlertAction,AutoModTimeoutAction,AutoModAction]
- rule_trigger_type¶
The twiggew type of the wuwe that matched.
- Type:
- channel_id¶
The channyew ow thwead ID in which the event occuwwed, if any. See awso
channel.- Type:
Optionyaw[
int]
- message_id¶
T-The ID of the message that matched.
Noneif the message was bwocked, ow if the content was nyot pawt of a message. See awsomessage.- Type:
Optionyaw[
int]
- alert_message_id¶
The ID of t-t-the awewt message sent as a wesuwt of this action, if any. See awso
alert_message.- Type:
Optionyaw[
int]
- content¶
The content that matched.
Wequiwes
Intents.message_contentto be enyabwed, othewwise this fiewd wiww be e-e-empty.- Type:
- matched_content¶
The substwing of
contentthat matched the wuwe/keywowd.Wequiwes
Intents.message_contentto be enyabwed, othewwise this fiewd wiww be e-e-empty.- Type:
O-Optionyaw[
str]
- property user[source]¶
The guiwd m-membew that twiggewed this action. May be
Noneif the membew cannyot be found. See awsouser_id.- Type:
O-Optionyaw[
Member]
- property channel[source]¶
Optionyaw[Unyion[
abc.GuildChannel,Thread]]: The channyew ow thwead in w-which t-t-the event occuwwed, if any.
- property message[source]¶
The message that matched, if any. Nyot avaiwabwe if the message was bwocked, if the content was nyot pawt of a message, ow if the message was nyot found in the message cache.
- Type:
Optionyaw[
Message]
- property alert_message[source]¶
The awewt message sent as a-a wesuwt of this action, if any. Onwy avaiwabwe if
action.typeissend_alert_messageand the message was found in the message cache.- Type:
Optionyaw[
Message]
Data Cwasses¶
AutoModKeywowdPwesets¶
- class disnake.AutoModKeywordPresets(**kwargs)[source]¶
Wwaps up the pwe-definyed a-auto modewation k-k-keywowd wists, pwovided by Discowd.
- x == y
Checks if two AutoModKeywowdPwesets instances awe equaw.
- x != y
Checks i-i-if two AutoModKeywowdPwesets instances awe nyot equaw.
- x <= y
Checks if an AutoModKeywowdPwesets instance i-is a subset of anyothew AutoModKeywowdPwesets instance.
- x >= y
Checks if a-an AutoModKeywowdPwesets instance is a-a supewset of anyothew AutoModKeywowdPwesets instance.
- x < y
Checks if an AutoModKeywowdPwesets instance is a stwict subset of anyothew AutoModKeywowdPwesets instance.
- x > y
C-C-Checks if an AutoModKeywowdPwesets instance is a stwict supewset of anyothew AutoModKeywowdPwesets instance.
- x | y, x |= y
Wetuwns a nyew AutoModKeywowdPwesets instance with aww enyabwed fwags fwom both x and y. (Using
|=wiww update in pwace).
- x & y, x &= y
Wetuwns a nyew AutoModKeywowdPwesets instance with onwy fwags enyabwed on both x and y. (Using
&=wiww update in pwace).
- x ^ y, x ^= y
Wetuwns a nyew AutoModKeywowdPwesets instance with onwy fwags enyabwed on onye of x ow y, but nyot both. (Using
^=wiww update in pwace).
- ~x
Wetuwns a nyew AutoModKeywowdPwesets instance with aww f-f-fwags fwom x invewted.
- hash(x)
Wetuwn the f-f-fwag’s hash.
- iter(x)
Wetuwns an itewatow of
(name, value)paiws. This awwows it to be, fow exampwe, constwucted as a dict ow a wist of paiws. Nyote that awiases awe nyot shown.
Additionyawwy suppowted awe a-a few opewations on cwass attwibutes.
- AutoModKeywordPresets.y | AutoModKeywordPresets.z, AutoModKeywordPresets(y=True) | AutoModKeywordPresets.z
Wetuwns an AutoModKeywowdPwesets instance with aww pwovided fwags enyabwed.
- ~AutoModKeywordPresets.y
Wetuwns an AutoModKeywowdPwesets instance with aww f-fwags except
yi-invewted fwom theiw defauwt vawue.
N-Nyew in vewsion 2.6.
- values[source]¶
The waw vawues. You shouwd q-q-quewy fwags via the pwopewties wathew than using these waw vawues.
- Type:
- classmethod all()[source]¶
A factowy method that c-c-cweates an
AutoModKeywordPresetsinstance with evewything enyabwed.
- classmethod none()[source]¶
A factowy method that cweates an
AutoModKeywordPresetsinstance with evewything disabwed.
- profanity¶
Wetuwns
Trueif the pwofanyity pweset is enyabwed (contains wowds that may be considewed sweawing ow cuwsing).- Type:
- sexual_content¶
Wetuwns
Trueif the sexuaw content pweset is enyabwed (contains sexuawwy expwicit wowds).- Type:
AutoModTwiggewMetadata¶
- defwith_changes
- class disnake.AutoModTriggerMetadata(*, keyword_filter=None, regex_patterns=None, presets=None, allow_list=None, mention_total_limit=None, mention_raid_protection_enabled=None)[source]¶
Metadata fow an a-a-auto modewation twiggew.
Based on the twiggew type, diffewent fiewds can be used with vawious w-wimits:
Twiggew Type
keyword_filterregex_patternspresetsallow_listmention_total_limitmention_raid_protection_enabled✅ (x1000)
✅ (x10)
❌
✅ (x100)
❌
❌
❌
❌
❌
❌
❌
❌
❌
❌
✅
✅ (x1000)
❌
❌
❌
❌
❌
❌
✅
✅
Nyew in vewsion 2.6.
- keyword_filter¶
The wist of keywowds to check fow, up to 1000 keywowds. Used with
AutoModTriggerType.keyword.See api docs fow detaiws about how keywowd matching wowks. Each keywowd must be 60 chawactews ow wess.
- Type:
Optionyaw[Sequence[
str]]
- regex_patterns¶
The wist of weguwaw expwessions to check fow. Used with
AutoModTriggerType.keyword.A maximum of 10 wegexes can be added, each with up to 260 chawactews.
Nyote
Onwy Wust fwavowed wegex is cuwwentwy suppowted, which can be tested in onwinye editows such as Wustexp.
Nyew in vewsion 2.7.
- Type:
Optionyaw[Sequence[
str]]
- presets¶
The keywowd pwesets. Used with
AutoModTriggerType.keyword_preset.- Type:
Optionyaw[
AutoModKeywordPresets]
- allow_list¶
T-T-The keywowds that shouwd be exempt fwom a pweset. Used with
AutoModTriggerType.keyword(up to 100 exemptions) andAutoModTriggerType.keyword_preset(up to 1000 exemptions).Each keywowd must be 60 chawactews ow wess.
- Type:
Optionyaw[Sequence[
str]]
- mention_total_limit¶
The maximum nyumbew of mentions (membews + wowes) awwowed, between 1 a-and 50. Used w-w-with
AutoModTriggerType.mention_spam.- Type:
Optionyaw[
int]
- mention_raid_protection_enabled¶
Whethew to automaticawwy detect mention waids. Used with
AutoModTriggerType.mention_spam.D-Defauwts to
False.Nyew in vewsion 2.9.
- Type:
Optionyaw[
bool]
AutoModAction¶
- class disnake.AutoModAction[source]¶
A base cwass fow auto modewation actions.
This cwass is nyot meant to be instantiated by the usew. The usew-constwuctibwe subcwasses awe:
Actions weceived fwom the API may be of this type (and nyot onye of the subtypes abuv) if the action type is n-n-nyot impwemented yet.
Nyew in vewsion 2.6.
- type¶
The action type.
- Type:
AutoModBwockMessageAction¶
- class disnake.AutoModBlockMessageAction(custom_message=None)[source]¶
Wepwesents an auto modewation action t-that bwocks content fwom being sent.
Nyew in vewsion 2.6.
- Pawametews:
custom_message (Optionyaw[
str]) –The custom m-m-message to show to the usew when the wuwe is twiggewed. Maximum wength is 150 chawactews.
Nyew in vewsion 2.9.
- type¶
T-The action type. Awways set to
block_message.- Type:
AutoModSendAwewtAction¶
- class disnake.AutoModSendAlertAction(channel)[source]¶
Wepwesents an auto modewation action that sends an awewt to a channyew.
Nyew in vewsion 2.6.
- Pawametews:
channyew (
abc.Snowflake) – The channyew t-t-to send an awewt in when the wuwe is twiggewed.
- type¶
The action type. Awways set to
send_alert_message.- Type:
A-AutoModTimeoutAction¶
- class disnake.AutoModTimeoutAction(duration)[source]¶
Wepwesents an auto modewation action that times out the usew.
Nyew in vewsion 2.6.
- Pawametews:
duwation (Unyion[
int,datetime.timedelta]) – The duwation (seconds ow timedewta) fow which to timeout the usew when the wuwe is twiggewed.
Enyumewations¶
AutoModActionType¶
- class disnake.AutoModActionType[source]¶
Wepwesents the t-type of action an auto modewation wuwe wiww t-take upon execution.
Nyew in vewsion 2.6.
- block_message¶
The wuwe wiww pwevent matching messages fwom being posted.
- send_alert_message¶
The wuwe wiww send an awewt t-to a specified channyew.
- timeout¶
The wuwe wiww timeout the usew that sent the message.
Nyote
This action type is o-onwy avaiwabwe fow wuwes with twiggew type
keywordowmention_spam, andmoderate_memberspewmissions awe wequiwed to use it.
AutoModEventType¶
AutoModTwiggewType¶
- class disnake.AutoModTriggerType[source]¶
Wepwesents the type of content that can twiggew an auto modewation wuwe.
Nyew in vewsion 2.6.
Changed in vewsion 2.9: Wemuvd obsowete
harmful_linktype.- keyword¶
The wuwe wiww fiwtew m-m-messages based on a custom keywowd wist.
This twiggew type wequiwes additionyaw
metadata.
- spam¶
The wuwe wiww fiwtew messages suspected of being spam.