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.
217 218 219 220 221 |
# File 'lib/discorb/automod.rb', line 217 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.
206 207 208 |
# File 'lib/discorb/automod.rb', line 206 def duration_seconds @duration_seconds end |
#type -> Symbol (readonly)
Returns the type of the action.
203 204 205 |
# File 'lib/discorb/automod.rb', line 203 def type @type end |
Class Method Details
.from_hash(client, data) -> Object
264 265 266 |
# File 'lib/discorb/automod.rb', line 264 def self.from_hash(client, data) allocate.tap { |action| action.initialize_hash(client, data) } end |
Instance Method Details
#channel -> Object
253 254 255 |
# File 'lib/discorb/automod.rb', line 253 def channel @client.channels[@channel_id] end |
#to_hash -> Hash
Convert the action to hash.
228 229 230 231 232 233 234 235 236 |
# File 'lib/discorb/automod.rb', line 228 def to_hash { type: @type, metadata: { channel_id: @channel&.id, duration_seconds: @duration_seconds, }, } end |