discorb 0.19.0 → 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build_version.yml +2 -2
  3. data/.rubocop.yml +12 -75
  4. data/Changelog.md +10 -0
  5. data/Rakefile +482 -454
  6. data/lib/discorb/allowed_mentions.rb +68 -72
  7. data/lib/discorb/app_command/command.rb +466 -398
  8. data/lib/discorb/app_command/common.rb +65 -25
  9. data/lib/discorb/app_command/handler.rb +304 -266
  10. data/lib/discorb/app_command.rb +5 -5
  11. data/lib/discorb/application.rb +198 -197
  12. data/lib/discorb/asset.rb +101 -101
  13. data/lib/discorb/attachment.rb +134 -119
  14. data/lib/discorb/audit_logs.rb +412 -385
  15. data/lib/discorb/automod.rb +279 -269
  16. data/lib/discorb/channel/base.rb +107 -108
  17. data/lib/discorb/channel/category.rb +32 -32
  18. data/lib/discorb/channel/container.rb +44 -44
  19. data/lib/discorb/channel/dm.rb +26 -28
  20. data/lib/discorb/channel/guild.rb +311 -246
  21. data/lib/discorb/channel/stage.rb +156 -140
  22. data/lib/discorb/channel/text.rb +430 -336
  23. data/lib/discorb/channel/thread.rb +374 -325
  24. data/lib/discorb/channel/voice.rb +85 -79
  25. data/lib/discorb/channel.rb +5 -5
  26. data/lib/discorb/client.rb +635 -621
  27. data/lib/discorb/color.rb +178 -182
  28. data/lib/discorb/common.rb +168 -164
  29. data/lib/discorb/components/button.rb +107 -106
  30. data/lib/discorb/components/select_menu.rb +157 -145
  31. data/lib/discorb/components/text_input.rb +103 -106
  32. data/lib/discorb/components.rb +68 -66
  33. data/lib/discorb/dictionary.rb +135 -135
  34. data/lib/discorb/embed.rb +404 -398
  35. data/lib/discorb/emoji.rb +309 -302
  36. data/lib/discorb/emoji_table.rb +16099 -8857
  37. data/lib/discorb/error.rb +131 -131
  38. data/lib/discorb/event.rb +360 -314
  39. data/lib/discorb/event_handler.rb +39 -39
  40. data/lib/discorb/exe/about.rb +17 -17
  41. data/lib/discorb/exe/irb.rb +72 -67
  42. data/lib/discorb/exe/new.rb +323 -315
  43. data/lib/discorb/exe/run.rb +69 -68
  44. data/lib/discorb/exe/setup.rb +57 -55
  45. data/lib/discorb/exe/show.rb +12 -12
  46. data/lib/discorb/extend.rb +25 -45
  47. data/lib/discorb/extension.rb +89 -83
  48. data/lib/discorb/flag.rb +126 -128
  49. data/lib/discorb/gateway.rb +984 -804
  50. data/lib/discorb/gateway_events.rb +670 -638
  51. data/lib/discorb/gateway_requests.rb +45 -48
  52. data/lib/discorb/guild.rb +2115 -1626
  53. data/lib/discorb/guild_template.rb +280 -241
  54. data/lib/discorb/http.rb +247 -232
  55. data/lib/discorb/image.rb +42 -42
  56. data/lib/discorb/integration.rb +169 -161
  57. data/lib/discorb/intents.rb +161 -163
  58. data/lib/discorb/interaction/autocomplete.rb +76 -62
  59. data/lib/discorb/interaction/command.rb +279 -224
  60. data/lib/discorb/interaction/components.rb +114 -104
  61. data/lib/discorb/interaction/modal.rb +36 -32
  62. data/lib/discorb/interaction/response.rb +379 -336
  63. data/lib/discorb/interaction/root.rb +271 -257
  64. data/lib/discorb/interaction.rb +5 -5
  65. data/lib/discorb/invite.rb +154 -153
  66. data/lib/discorb/member.rb +344 -311
  67. data/lib/discorb/message.rb +615 -544
  68. data/lib/discorb/message_meta.rb +197 -186
  69. data/lib/discorb/modules.rb +371 -290
  70. data/lib/discorb/permission.rb +305 -291
  71. data/lib/discorb/presence.rb +352 -346
  72. data/lib/discorb/rate_limit.rb +81 -76
  73. data/lib/discorb/reaction.rb +55 -54
  74. data/lib/discorb/role.rb +272 -240
  75. data/lib/discorb/shard.rb +76 -74
  76. data/lib/discorb/sticker.rb +193 -171
  77. data/lib/discorb/user.rb +205 -188
  78. data/lib/discorb/utils/colored_puts.rb +16 -16
  79. data/lib/discorb/utils.rb +12 -16
  80. data/lib/discorb/voice_state.rb +305 -281
  81. data/lib/discorb/webhook.rb +537 -507
  82. data/lib/discorb.rb +62 -56
  83. data/sig/discorb/application.rbs +2 -0
  84. data/sig/discorb/automod.rbs +10 -1
  85. data/sig/discorb/guild.rbs +2 -0
  86. data/sig/discorb/message.rbs +2 -0
  87. data/sig/discorb/user.rbs +22 -20
  88. metadata +2 -2
@@ -1,269 +1,279 @@
1
- # frozen_string_literal: true
2
-
3
- module Discorb
4
- #
5
- # Represents a rule of auto moderation.
6
- #
7
- class AutoModRule < DiscordModel
8
- # @return [Hash{Integer => Symbol}] The mapping of trigger types.
9
- # @private
10
- TRIGGER_TYPES = {
11
- 1 => :keyword,
12
- 2 => :harmful_link,
13
- 3 => :spam,
14
- 4 => :keyword_preset,
15
- }.freeze
16
- # @return [Hash{Integer => Symbol}] The mapping of preset types.
17
- # @private
18
- PRESET_TYPES = {
19
- 1 => :profanity,
20
- 2 => :sexual_content,
21
- 3 => :slurs,
22
- }.freeze
23
- # @return [Hash{Integer => Symbol}] The mapping of event types.
24
- # @private
25
- EVENT_TYPES = {
26
- 1 => :message_send,
27
- }.freeze
28
-
29
- # @return [Discorb::Snowflake] The ID of the rule.
30
- attr_reader :id
31
- # @return [String] The name of the rule.
32
- attr_reader :name
33
- # @return [Boolean] Whether the rule is enabled.
34
- attr_reader :enabled
35
- alias enabled? enabled
36
- # @return [Array<Discorb::AutoModRule::Action>] The actions of the rule.
37
- attr_reader :actions
38
- # @return [Array<String>] The keywords that the rule is triggered by.
39
- # @note This is only available if the trigger type is `:keyword`.
40
- attr_reader :keyword_filter
41
-
42
- #
43
- # Initialize a new auto mod.
44
- # @private
45
- #
46
- # @param [Discorb::Client] client The client.
47
- # @param [Hash] data The auto mod data.
48
- #
49
- def initialize(client, data)
50
- @client = client
51
- _set_data(data)
52
- end
53
-
54
- # @!attribute [r]
55
- # @return [Symbol] Returns the type of the preset.
56
- # @note This is only available if the trigger type is `:keyword_preset`.
57
- def preset_type
58
- PRESET_TYPES[@presets_raw]
59
- end
60
-
61
- # @!attribute [r]
62
- # @return [Symbol] Returns the type of the trigger.
63
- def trigger_type
64
- TRIGGER_TYPES[@trigger_type_raw]
65
- end
66
-
67
- # @!attribute [r]
68
- # @return [Symbol] Returns the type of the event.
69
- def event_type
70
- EVENT_TYPES[@event_type_raw]
71
- end
72
-
73
- # @!attribute [r]
74
- # @macro client_cache
75
- # @return [Discorb::Member] The member who created the rule.
76
- def creator
77
- guild.members[@creator_id]
78
- end
79
-
80
- # @!attribute [r]
81
- # @return [Discorb::Guild] The guild that the rule is in.
82
- def guild
83
- @client.guilds[@guild_id]
84
- end
85
-
86
- # @!attribute [r]
87
- # @return [Array<Discorb::Role>] The roles that the rule is exempt from.
88
- def exempt_roles
89
- @exempt_roles_id.map { |id| guild.roles[id] }
90
- end
91
-
92
- # @!attribute [r]
93
- # @return [Array<Discorb::Channel>] The channels that the rule is exempt from.
94
- def exempt_channels
95
- @exempt_channels_id.map { |id| guild.channels[id] }
96
- end
97
-
98
- #
99
- # Edit the rule.
100
- # @async
101
- # @edit
102
- #
103
- # @param [String] name The name of the rule.
104
- # @param [Symbol] event_type The event type of the rule. See {Discorb::AutoModRule::EVENT_TYPES}.
105
- # @param [Array<Discorb::AutoModRule::Action>] actions The actions of the rule.
106
- # @param [Boolean] enabled Whether the rule is enabled or not.
107
- # @param [Array<Discorb::Role>] exempt_roles The roles that are exempt from the rule.
108
- # @param [Array<Discorb::Channel>] exempt_channels The channels that are exempt from the rule.
109
- # @param [Array<String>] keyword_filter The keywords to filter.
110
- # @param [Symbol] presets The preset of the rule. See {Discorb::AutoModRule::PRESET_TYPES}.
111
- # @param [String] reason The reason for creating the rule.
112
- #
113
- # @return [Async::Task<void>] The task.
114
- #
115
- def edit(
116
- name: Discorb::Unset,
117
- event_type: Discorb::Unset,
118
- actions: Discorb::Unset,
119
- enabled: Discorb::Unset,
120
- exempt_roles: Discorb::Unset,
121
- exempt_channels: Discorb::Unset,
122
- keyword_filter: Discorb::Unset,
123
- presets: Discorb::Unset,
124
- reason: nil
125
- )
126
- # @type var payload: Hash[Symbol, untyped]
127
- payload = {
128
- metadata: {},
129
- }
130
- payload[:name] = name unless name == Discorb::Unset
131
- payload[:event_type] = EVENT_TYPES.key(event_type) unless event_type == Discorb::Unset
132
- payload[:actions] = actions unless actions == Discorb::Unset
133
- payload[:enabled] = enabled unless enabled == Discorb::Unset
134
- payload[:exempt_roles] = exempt_roles.map(&:id) unless exempt_roles == Discorb::Unset
135
- payload[:exempt_channels] = exempt_channels.map(&:id) unless exempt_channels == Discorb::Unset
136
- payload[:metadata][:keyword_filter] = keyword_filter unless keyword_filter == Discorb::Unset
137
- payload[:metadata][:presets] = PRESET_TYPES.key(presets) unless presets == Discorb::Unset
138
-
139
- @client.http.request(
140
- Route.new(
141
- "/guilds/#{@guild_id}/automod/rules/#{@id}",
142
- "//guilds/:guild_id/automod/rules/:id",
143
- :patch
144
- ),
145
- payload,
146
- audit_log_reason: reason,
147
- )
148
- end
149
-
150
- #
151
- # Delete the rule.
152
- #
153
- # @param [String] reason The reason for deleting the rule.
154
- #
155
- # @return [Async::Task<void>] The task.
156
- #
157
- def delete(reason: nil)
158
- Async do
159
- @client.http.request(
160
- Route.new(
161
- "/guilds/#{@guild_id}/automod/rules/#{@id}",
162
- "//guilds/:guild_id/automod/rules/:id",
163
- :delete
164
- ),
165
- audit_log_reason: reason,
166
- )
167
- end
168
- end
169
-
170
- # @private
171
- def _set_data(data)
172
- @id = Snowflake.new(data[:id])
173
- @guild_id = data[:guild_id]
174
- @name = data[:name]
175
- @creator_id = data[:creator_id]
176
- @trigger_type_raw = data[:trigger_type]
177
- @event_type_raw = data[:event_type]
178
- @actions = data[:actions].map { |action| Action.from_hash(@client, action) }
179
- case trigger_type
180
- when :keyword
181
- @keyword_filter = data[:trigger_metadata][:keyword_filter]
182
- when :presets
183
- @presets_raw = data[:trigger_metadata][:presets]
184
- end
185
- @enabled = data[:enabled]
186
- @exempt_roles_id = data[:exempt_roles]
187
- @exempt_channels_id = data[:exempt_channels]
188
- end
189
-
190
- #
191
- # Represents the action of auto moderation.
192
- #
193
- class Action < DiscordModel
194
- # @return [Hash{Integer => Symbol}] The mapping of action types.
195
- # @private
196
- ACTION_TYPES = {
197
- 1 => :block_message,
198
- 2 => :send_alert_message,
199
- 3 => :timeout,
200
- }.freeze
201
-
202
- # @return [Symbol] Returns the type of the action.
203
- attr_reader :type
204
- # @return [Integer] The duration of the timeout.
205
- # @note This is only available if the action type is `:timeout`.
206
- attr_reader :duration_seconds
207
-
208
- #
209
- # Initialize a new action.
210
- #
211
- # @param [Symbol] type The type of the action.
212
- # @param [Integer] duration_seconds The duration of the timeout.
213
- # This is only available if the action type is `:timeout`.
214
- # @param [Discorb::Channel] channel The channel that the alert message is sent to.
215
- # This is only available if the action type is `:send_alert_message`.
216
- #
217
- def initialize(type, duration_seconds: nil, channel: nil)
218
- @type = type
219
- @duration_seconds = duration_seconds
220
- @channel = channel
221
- end
222
-
223
- #
224
- # Convert the action to hash.
225
- #
226
- # @return [Hash] The action hash.
227
- #
228
- def to_hash
229
- {
230
- type: @type,
231
- metadata: {
232
- channel_id: @channel&.id,
233
- duration_seconds: @duration_seconds,
234
- },
235
- }
236
- end
237
-
238
- #
239
- # Initialize a new action from hash.
240
- # @private
241
- #
242
- # @param [Discorb::Client] client The client.
243
- # @param [Hash] data The action data.
244
- #
245
- def initialize_hash(client, data)
246
- @client = client
247
- _set_data(data)
248
- end
249
-
250
- # @!attribute [r]
251
- # @return [Discorb::Channel] The channel that the alert message is sent to.
252
- # @note This is only available if the action type is `:send_alert_message`.
253
- def channel
254
- @client.channels[@channel_id]
255
- end
256
-
257
- # @private
258
- def _set_data(data)
259
- @type = ACTION_TYPES[data[:type]]
260
- @channel_id = data[:metadata][:channel_id]
261
- @duration_seconds = data[:metadata][:duration_seconds]
262
- end
263
-
264
- def self.from_hash(client, data)
265
- allocate.tap { |action| action.initialize_hash(client, data) }
266
- end
267
- end
268
- end
269
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Discorb
4
+ #
5
+ # Represents a rule of auto moderation.
6
+ #
7
+ class AutoModRule < DiscordModel
8
+ # @return [Hash{Integer => Symbol}] The mapping of trigger types.
9
+ # @private
10
+ TRIGGER_TYPES = {
11
+ 1 => :keyword,
12
+ 2 => :harmful_link,
13
+ 3 => :spam,
14
+ 4 => :keyword_preset,
15
+ 5 => :mention_spam
16
+ }.freeze
17
+ # @return [Hash{Integer => Symbol}] The mapping of preset types.
18
+ # @private
19
+ PRESET_TYPES = { 1 => :profanity, 2 => :sexual_content, 3 => :slurs }.freeze
20
+ # @return [Hash{Integer => Symbol}] The mapping of event types.
21
+ # @private
22
+ EVENT_TYPES = { 1 => :message_send }.freeze
23
+
24
+ # @return [Discorb::Snowflake] The ID of the rule.
25
+ attr_reader :id
26
+ # @return [String] The name of the rule.
27
+ attr_reader :name
28
+ # @return [Boolean] Whether the rule is enabled.
29
+ attr_reader :enabled
30
+ alias enabled? enabled
31
+ # @return [Array<Discorb::AutoModRule::Action>] The actions of the rule.
32
+ attr_reader :actions
33
+ # @return [Array<String>] The keywords that the rule is triggered by.
34
+ # @note This is only available if the trigger type is `:keyword`.
35
+ attr_reader :keyword_filter
36
+ # @return [Array<String>] Substrings which will be exempt from triggering the preset trigger type.
37
+ # @note This is only available if the trigger type is `:keyword_preset`.
38
+ attr_reader :allow_list
39
+ # @return [Integer] Total number of mentions allowed per message.
40
+ # @note This is only available if the trigger type is `:mention_spam`.
41
+ attr_reader :mention_total_limit
42
+
43
+ #
44
+ # Initialize a new auto mod.
45
+ # @private
46
+ #
47
+ # @param [Discorb::Client] client The client.
48
+ # @param [Hash] data The auto mod data.
49
+ #
50
+ def initialize(client, data)
51
+ @client = client
52
+ _set_data(data)
53
+ end
54
+
55
+ # @!attribute [r]
56
+ # @return [Symbol] Returns the type of the preset.
57
+ # @note This is only available if the trigger type is `:keyword_preset`.
58
+ def preset_type
59
+ PRESET_TYPES[@presets_raw]
60
+ end
61
+
62
+ # @!attribute [r]
63
+ # @return [Symbol] Returns the type of the trigger.
64
+ def trigger_type
65
+ TRIGGER_TYPES[@trigger_type_raw]
66
+ end
67
+
68
+ # @!attribute [r]
69
+ # @return [Symbol] Returns the type of the event.
70
+ def event_type
71
+ EVENT_TYPES[@event_type_raw]
72
+ end
73
+
74
+ # @!attribute [r]
75
+ # @macro client_cache
76
+ # @return [Discorb::Member] The member who created the rule.
77
+ def creator
78
+ guild.members[@creator_id]
79
+ end
80
+
81
+ # @!attribute [r]
82
+ # @return [Discorb::Guild] The guild that the rule is in.
83
+ def guild
84
+ @client.guilds[@guild_id]
85
+ end
86
+
87
+ # @!attribute [r]
88
+ # @return [Array<Discorb::Role>] The roles that the rule is exempt from.
89
+ def exempt_roles
90
+ @exempt_roles_id.map { |id| guild.roles[id] }
91
+ end
92
+
93
+ # @!attribute [r]
94
+ # @return [Array<Discorb::Channel>] The channels that the rule is exempt from.
95
+ def exempt_channels
96
+ @exempt_channels_id.map { |id| guild.channels[id] }
97
+ end
98
+
99
+ #
100
+ # Edit the rule.
101
+ # @async
102
+ # @edit
103
+ #
104
+ # @param [String] name The name of the rule.
105
+ # @param [Symbol] event_type The event type of the rule. See {Discorb::AutoModRule::EVENT_TYPES}.
106
+ # @param [Array<Discorb::AutoModRule::Action>] actions The actions of the rule.
107
+ # @param [Boolean] enabled Whether the rule is enabled or not.
108
+ # @param [Array<Discorb::Role>] exempt_roles The roles that are exempt from the rule.
109
+ # @param [Array<Discorb::Channel>] exempt_channels The channels that are exempt from the rule.
110
+ # @param [Array<String>] keyword_filter The keywords to filter.
111
+ # @param [Symbol] presets The preset of the rule. See {Discorb::AutoModRule::PRESET_TYPES}.
112
+ # @param [String] reason The reason for creating the rule.
113
+ #
114
+ # @return [Async::Task<void>] The task.
115
+ #
116
+ def edit(
117
+ name: Discorb::Unset,
118
+ event_type: Discorb::Unset,
119
+ actions: Discorb::Unset,
120
+ enabled: Discorb::Unset,
121
+ exempt_roles: Discorb::Unset,
122
+ exempt_channels: Discorb::Unset,
123
+ keyword_filter: Discorb::Unset,
124
+ presets: Discorb::Unset,
125
+ reason: nil
126
+ )
127
+ # @type var payload: Hash[Symbol, untyped]
128
+ payload = { metadata: {} }
129
+ payload[:name] = name unless name == Discorb::Unset
130
+ payload[:event_type] = EVENT_TYPES.key(event_type) unless event_type ==
131
+ Discorb::Unset
132
+ payload[:actions] = actions unless actions == Discorb::Unset
133
+ payload[:enabled] = enabled unless enabled == Discorb::Unset
134
+ payload[:exempt_roles] = exempt_roles.map(&:id) unless exempt_roles ==
135
+ Discorb::Unset
136
+ payload[:exempt_channels] = exempt_channels.map(
137
+ &:id
138
+ ) unless exempt_channels == Discorb::Unset
139
+ payload[:metadata][
140
+ :keyword_filter
141
+ ] = keyword_filter unless keyword_filter == Discorb::Unset
142
+ payload[:metadata][:presets] = PRESET_TYPES.key(presets) unless presets ==
143
+ Discorb::Unset
144
+
145
+ @client.http.request(
146
+ Route.new(
147
+ "/guilds/#{@guild_id}/automod/rules/#{@id}",
148
+ "//guilds/:guild_id/automod/rules/:id",
149
+ :patch
150
+ ),
151
+ payload,
152
+ audit_log_reason: reason
153
+ )
154
+ end
155
+
156
+ #
157
+ # Delete the rule.
158
+ #
159
+ # @param [String] reason The reason for deleting the rule.
160
+ #
161
+ # @return [Async::Task<void>] The task.
162
+ #
163
+ def delete(reason: nil)
164
+ Async do
165
+ @client.http.request(
166
+ Route.new(
167
+ "/guilds/#{@guild_id}/automod/rules/#{@id}",
168
+ "//guilds/:guild_id/automod/rules/:id",
169
+ :delete
170
+ ),
171
+ audit_log_reason: reason
172
+ )
173
+ end
174
+ end
175
+
176
+ # @private
177
+ def _set_data(data)
178
+ @id = Snowflake.new(data[:id])
179
+ @guild_id = data[:guild_id]
180
+ @name = data[:name]
181
+ @creator_id = data[:creator_id]
182
+ @trigger_type_raw = data[:trigger_type]
183
+ @event_type_raw = data[:event_type]
184
+ @actions =
185
+ data[:actions].map { |action| Action.from_hash(@client, action) }
186
+ case trigger_type
187
+ when :keyword
188
+ @keyword_filter = data[:trigger_metadata][:keyword_filter]
189
+ when :keyword_preset
190
+ @presets_raw = data[:trigger_metadata][:presets]
191
+ @allow_list = data[:trigger_metadata][:allow_list]
192
+ when :mention_spam
193
+ @mention_total_limit = data[:metadata][:mention_total_limit]
194
+ end
195
+ @enabled = data[:enabled]
196
+ @exempt_roles_id = data[:exempt_roles]
197
+ @exempt_channels_id = data[:exempt_channels]
198
+ end
199
+
200
+ #
201
+ # Represents the action of auto moderation.
202
+ #
203
+ class Action < DiscordModel
204
+ # @return [Hash{Integer => Symbol}] The mapping of action types.
205
+ # @private
206
+ ACTION_TYPES = {
207
+ 1 => :block_message,
208
+ 2 => :send_alert_message,
209
+ 3 => :timeout
210
+ }.freeze
211
+
212
+ # @return [Symbol] Returns the type of the action.
213
+ attr_reader :type
214
+ # @return [Integer] The duration of the timeout.
215
+ # @note This is only available if the action type is `:timeout`.
216
+ attr_reader :duration_seconds
217
+
218
+ #
219
+ # Initialize a new action.
220
+ #
221
+ # @param [Symbol] type The type of the action.
222
+ # @param [Integer] duration_seconds The duration of the timeout.
223
+ # This is only available if the action type is `:timeout`.
224
+ # @param [Discorb::Channel] channel The channel that the alert message is sent to.
225
+ # This is only available if the action type is `:send_alert_message`.
226
+ #
227
+ def initialize(type, duration_seconds: nil, channel: nil)
228
+ @type = type
229
+ @duration_seconds = duration_seconds
230
+ @channel = channel
231
+ end
232
+
233
+ #
234
+ # Convert the action to hash.
235
+ #
236
+ # @return [Hash] The action hash.
237
+ #
238
+ def to_hash
239
+ {
240
+ type: @type,
241
+ metadata: {
242
+ channel_id: @channel&.id,
243
+ duration_seconds: @duration_seconds
244
+ }
245
+ }
246
+ end
247
+
248
+ #
249
+ # Initialize a new action from hash.
250
+ # @private
251
+ #
252
+ # @param [Discorb::Client] client The client.
253
+ # @param [Hash] data The action data.
254
+ #
255
+ def initialize_hash(client, data)
256
+ @client = client
257
+ _set_data(data)
258
+ end
259
+
260
+ # @!attribute [r]
261
+ # @return [Discorb::Channel] The channel that the alert message is sent to.
262
+ # @note This is only available if the action type is `:send_alert_message`.
263
+ def channel
264
+ @client.channels[@channel_id]
265
+ end
266
+
267
+ # @private
268
+ def _set_data(data)
269
+ @type = ACTION_TYPES[data[:type]]
270
+ @channel_id = data[:metadata][:channel_id]
271
+ @duration_seconds = data[:metadata][:duration_seconds]
272
+ end
273
+
274
+ def self.from_hash(client, data)
275
+ allocate.tap { |action| action.initialize_hash(client, data) }
276
+ end
277
+ end
278
+ end
279
+ end