Class: RubyCord::Guild::AutoModRule
- Inherits:
-
DiscordModel
- Object
- DiscordModel
- RubyCord::Guild::AutoModRule
- Defined in:
- lib/rubycord/guild/automod_rule.rb
Defined Under Namespace
Classes: Action
Instance Attribute Summary collapse
-
#actions ⇒ Array<RubyCord::Guild::AutoModRule::Action>
readonly
The actions of the rule.
-
#allow_list ⇒ Array<String>
readonly
Substrings which will be exempt from triggering the preset trigger type.
-
#enabled ⇒ Boolean
(also: #enabled?)
readonly
Whether the rule is enabled.
-
#id ⇒ RubyCord::Snowflake
readonly
The ID of the rule.
-
#keyword_filter ⇒ Array<String>
readonly
The keywords that the rule is triggered by.
-
#mention_total_limit ⇒ Integer
readonly
Total number of mentions allowed per message.
-
#name ⇒ String
readonly
The name of the rule.
Instance Method Summary collapse
-
#creator ⇒ RubyCord::Guild::Member
The member who created the rule.
-
#delete(reason: nil) ⇒ Async::Task<void>
Delete the rule.
-
#edit(name: RubyCord::Unset, event_type: RubyCord::Unset, actions: RubyCord::Unset, enabled: RubyCord::Unset, exempt_roles: RubyCord::Unset, exempt_channels: RubyCord::Unset, keyword_filter: RubyCord::Unset, presets: RubyCord::Unset, reason: nil) ⇒ Async::Task<void>
Edit the rule.
-
#event_type ⇒ Symbol
Returns the type of the event.
-
#exempt_channels ⇒ Array<RubyCord::Channel>
The channels that the rule is exempt from.
-
#exempt_roles ⇒ Array<RubyCord::Guild::Role>
The roles that the rule is exempt from.
-
#guild ⇒ RubyCord::Guild
The guild that the rule is in.
-
#preset_type ⇒ Symbol
Returns the type of the preset.
-
#trigger_type ⇒ Symbol
Returns the type of the trigger.
Methods inherited from DiscordModel
Instance Attribute Details
#actions ⇒ Array<RubyCord::Guild::AutoModRule::Action> (readonly)
Returns The actions of the rule.
34 35 36 |
# File 'lib/rubycord/guild/automod_rule.rb', line 34 def actions @actions end |
#allow_list ⇒ Array<String> (readonly)
This is only available if the trigger type is :keyword_preset
.
Returns Substrings which will be exempt from triggering the preset trigger type.
40 41 42 |
# File 'lib/rubycord/guild/automod_rule.rb', line 40 def allow_list @allow_list end |
#enabled ⇒ Boolean (readonly) Also known as: enabled?
Returns Whether the rule is enabled.
31 32 33 |
# File 'lib/rubycord/guild/automod_rule.rb', line 31 def enabled @enabled end |
#id ⇒ RubyCord::Snowflake (readonly)
Returns The ID of the rule.
27 28 29 |
# File 'lib/rubycord/guild/automod_rule.rb', line 27 def id @id end |
#keyword_filter ⇒ Array<String> (readonly)
This is only available if the trigger type is :keyword
.
Returns The keywords that the rule is triggered by.
37 38 39 |
# File 'lib/rubycord/guild/automod_rule.rb', line 37 def keyword_filter @keyword_filter end |
#mention_total_limit ⇒ Integer (readonly)
This is only available if the trigger type is :mention_spam
.
Returns Total number of mentions allowed per message.
43 44 45 |
# File 'lib/rubycord/guild/automod_rule.rb', line 43 def mention_total_limit @mention_total_limit end |
#name ⇒ String (readonly)
Returns The name of the rule.
29 30 31 |
# File 'lib/rubycord/guild/automod_rule.rb', line 29 def name @name end |
Instance Method Details
#creator ⇒ RubyCord::Guild::Member
Returns The member who created the rule.
74 75 76 |
# File 'lib/rubycord/guild/automod_rule.rb', line 74 def creator guild.members[@creator_id] end |
#delete(reason: nil) ⇒ Async::Task<void>
Delete the rule.
155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/rubycord/guild/automod_rule.rb', line 155 def delete(reason: nil) Async do @client.http.request( RubyCord::Internal::Route.new( "/guilds/#{@guild_id}/automod/rules/#{@id}", "//guilds/:guild_id/automod/rules/:id", :delete ), audit_log_reason: reason ) end end |
#edit(name: RubyCord::Unset, event_type: RubyCord::Unset, actions: RubyCord::Unset, enabled: RubyCord::Unset, exempt_roles: RubyCord::Unset, exempt_channels: RubyCord::Unset, keyword_filter: RubyCord::Unset, presets: RubyCord::Unset, reason: nil) ⇒ Async::Task<void>
Edit the rule.
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/rubycord/guild/automod_rule.rb', line 109 def edit( name: RubyCord::Unset, event_type: RubyCord::Unset, actions: RubyCord::Unset, enabled: RubyCord::Unset, exempt_roles: RubyCord::Unset, exempt_channels: RubyCord::Unset, keyword_filter: RubyCord::Unset, presets: RubyCord::Unset, reason: nil ) payload = { metadata: {} } payload[:name] = name unless name == RubyCord::Unset payload[:event_type] = EVENT_TYPES.key(event_type) unless event_type == RubyCord::Unset payload[:actions] = actions unless actions == RubyCord::Unset payload[:enabled] = enabled unless enabled == RubyCord::Unset payload[:exempt_roles] = exempt_roles.map(&:id) unless exempt_roles == RubyCord::Unset payload[:exempt_channels] = exempt_channels.map( &:id ) unless exempt_channels == RubyCord::Unset payload[:metadata][ :keyword_filter ] = keyword_filter unless keyword_filter == RubyCord::Unset payload[:metadata][:presets] = PRESET_TYPES.key(presets) unless presets == RubyCord::Unset @client.http.request( RubyCord::Internal::Route.new( "/guilds/#{@guild_id}/automod/rules/#{@id}", "//guilds/:guild_id/automod/rules/:id", :patch ), payload, audit_log_reason: reason ) end |
#event_type ⇒ Symbol
Returns the type of the event.
69 70 71 |
# File 'lib/rubycord/guild/automod_rule.rb', line 69 def event_type EVENT_TYPES[@event_type_raw] end |
#exempt_channels ⇒ Array<RubyCord::Channel>
Returns The channels that the rule is exempt from.
89 90 91 |
# File 'lib/rubycord/guild/automod_rule.rb', line 89 def exempt_channels @exempt_channels_id.map { |id| guild.channels[id] } end |
#exempt_roles ⇒ Array<RubyCord::Guild::Role>
Returns The roles that the rule is exempt from.
84 85 86 |
# File 'lib/rubycord/guild/automod_rule.rb', line 84 def exempt_roles @exempt_roles_id.map { |id| guild.roles[id] } end |
#guild ⇒ RubyCord::Guild
Returns The guild that the rule is in.
79 80 81 |
# File 'lib/rubycord/guild/automod_rule.rb', line 79 def guild @client.guilds[@guild_id] end |
#preset_type ⇒ Symbol
This is only available if the trigger type is :keyword_preset
.
Returns the type of the preset.
59 60 61 |
# File 'lib/rubycord/guild/automod_rule.rb', line 59 def preset_type PRESET_TYPES[@presets_raw] end |
#trigger_type ⇒ Symbol
Returns the type of the trigger.
64 65 66 |
# File 'lib/rubycord/guild/automod_rule.rb', line 64 def trigger_type TRIGGER_TYPES[@trigger_type_raw] end |