Class: Discorb::AutoModRule::Action
- Inherits:
-
DiscordModel
- Object
- DiscordModel
- Discorb::AutoModRule::Action
- Defined in:
- lib/discorb/automod.rb
Overview
Represents the action of auto moderation.
Instance Attribute Summary collapse
-
#duration_seconds ⇒ Integer
readonly
The duration of the timeout.
-
#type ⇒ Symbol
readonly
Returns the type of the action.
Class Method Summary collapse
Instance Method Summary collapse
- #channel ⇒ Object
-
#initialize(type, duration_seconds: nil, channel: nil) ⇒ Action
constructor
Initialize a new action.
-
#to_hash ⇒ Hash
Convert the action to hash.
Methods inherited from DiscordModel
Constructor Details
#initialize(type, duration_seconds: nil, channel: nil) ⇒ Action
Initialize a new action.
227 228 229 230 231 |
# File 'lib/discorb/automod.rb', line 227 def initialize(type, duration_seconds: nil, channel: nil) @type = type @duration_seconds = duration_seconds @channel = channel end |
Instance Attribute Details
#duration_seconds ⇒ Integer (readonly)
Note:
This is only available if the action type is :timeout
.
Returns The duration of the timeout.
216 217 218 |
# File 'lib/discorb/automod.rb', line 216 def duration_seconds @duration_seconds end |
#type ⇒ Symbol (readonly)
Returns the type of the action.
213 214 215 |
# File 'lib/discorb/automod.rb', line 213 def type @type end |
Class Method Details
.from_hash(client, data) ⇒ Object
274 275 276 |
# File 'lib/discorb/automod.rb', line 274 def self.from_hash(client, data) allocate.tap { |action| action.initialize_hash(client, data) } end |
Instance Method Details
#channel ⇒ Object
263 264 265 |
# File 'lib/discorb/automod.rb', line 263 def channel @client.channels[@channel_id] end |
#to_hash ⇒ Hash
Convert the action to hash.
238 239 240 241 242 243 244 245 246 |
# File 'lib/discorb/automod.rb', line 238 def to_hash { type: @type, metadata: { channel_id: @channel&.id, duration_seconds: @duration_seconds } } end |