discorb 0.18.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) 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 +25 -0
  5. data/Gemfile +4 -4
  6. data/README.md +2 -1
  7. data/Rakefile +482 -459
  8. data/Steepfile +8 -6
  9. data/docs/application_command.md +1 -0
  10. data/docs/events.md +2 -2
  11. data/docs/voice_events.md +6 -6
  12. data/lib/discorb/allowed_mentions.rb +68 -72
  13. data/lib/discorb/app_command/command.rb +466 -394
  14. data/lib/discorb/app_command/common.rb +65 -25
  15. data/lib/discorb/app_command/handler.rb +304 -265
  16. data/lib/discorb/app_command.rb +5 -5
  17. data/lib/discorb/application.rb +198 -197
  18. data/lib/discorb/asset.rb +101 -101
  19. data/lib/discorb/attachment.rb +134 -119
  20. data/lib/discorb/audit_logs.rb +412 -385
  21. data/lib/discorb/automod.rb +279 -269
  22. data/lib/discorb/channel/base.rb +107 -108
  23. data/lib/discorb/channel/category.rb +32 -32
  24. data/lib/discorb/channel/container.rb +44 -44
  25. data/lib/discorb/channel/dm.rb +26 -28
  26. data/lib/discorb/channel/guild.rb +311 -246
  27. data/lib/discorb/channel/stage.rb +156 -140
  28. data/lib/discorb/channel/text.rb +430 -336
  29. data/lib/discorb/channel/thread.rb +374 -325
  30. data/lib/discorb/channel/voice.rb +85 -79
  31. data/lib/discorb/channel.rb +5 -5
  32. data/lib/discorb/client.rb +635 -623
  33. data/lib/discorb/color.rb +178 -182
  34. data/lib/discorb/common.rb +168 -164
  35. data/lib/discorb/components/button.rb +107 -106
  36. data/lib/discorb/components/select_menu.rb +157 -145
  37. data/lib/discorb/components/text_input.rb +103 -106
  38. data/lib/discorb/components.rb +68 -66
  39. data/lib/discorb/dictionary.rb +135 -135
  40. data/lib/discorb/embed.rb +404 -398
  41. data/lib/discorb/emoji.rb +309 -302
  42. data/lib/discorb/emoji_table.rb +16099 -8857
  43. data/lib/discorb/error.rb +131 -131
  44. data/lib/discorb/event.rb +360 -314
  45. data/lib/discorb/event_handler.rb +39 -39
  46. data/lib/discorb/exe/about.rb +17 -17
  47. data/lib/discorb/exe/irb.rb +72 -67
  48. data/lib/discorb/exe/new.rb +323 -315
  49. data/lib/discorb/exe/run.rb +69 -68
  50. data/lib/discorb/exe/setup.rb +57 -55
  51. data/lib/discorb/exe/show.rb +12 -12
  52. data/lib/discorb/extend.rb +25 -45
  53. data/lib/discorb/extension.rb +89 -83
  54. data/lib/discorb/flag.rb +126 -128
  55. data/lib/discorb/gateway.rb +984 -794
  56. data/lib/discorb/gateway_events.rb +670 -638
  57. data/lib/discorb/gateway_requests.rb +45 -48
  58. data/lib/discorb/guild.rb +2115 -1626
  59. data/lib/discorb/guild_template.rb +280 -241
  60. data/lib/discorb/http.rb +247 -232
  61. data/lib/discorb/image.rb +42 -42
  62. data/lib/discorb/integration.rb +169 -161
  63. data/lib/discorb/intents.rb +161 -163
  64. data/lib/discorb/interaction/autocomplete.rb +76 -62
  65. data/lib/discorb/interaction/command.rb +279 -224
  66. data/lib/discorb/interaction/components.rb +114 -104
  67. data/lib/discorb/interaction/modal.rb +36 -32
  68. data/lib/discorb/interaction/response.rb +379 -330
  69. data/lib/discorb/interaction/root.rb +271 -118
  70. data/lib/discorb/interaction.rb +5 -5
  71. data/lib/discorb/invite.rb +154 -153
  72. data/lib/discorb/member.rb +344 -311
  73. data/lib/discorb/message.rb +615 -544
  74. data/lib/discorb/message_meta.rb +197 -186
  75. data/lib/discorb/modules.rb +371 -290
  76. data/lib/discorb/permission.rb +305 -289
  77. data/lib/discorb/presence.rb +352 -346
  78. data/lib/discorb/rate_limit.rb +81 -76
  79. data/lib/discorb/reaction.rb +55 -54
  80. data/lib/discorb/role.rb +272 -240
  81. data/lib/discorb/shard.rb +76 -74
  82. data/lib/discorb/sticker.rb +193 -171
  83. data/lib/discorb/user.rb +205 -188
  84. data/lib/discorb/utils/colored_puts.rb +16 -16
  85. data/lib/discorb/utils.rb +12 -16
  86. data/lib/discorb/voice_state.rb +305 -281
  87. data/lib/discorb/webhook.rb +537 -507
  88. data/lib/discorb.rb +62 -56
  89. data/sig/discorb/activity.rbs +1 -0
  90. data/sig/discorb/allowed_mentions.rbs +1 -0
  91. data/sig/discorb/app_command/base.rbs +7 -1
  92. data/sig/discorb/application.rbs +6 -0
  93. data/sig/discorb/asset.rbs +2 -0
  94. data/sig/discorb/attachment.rbs +8 -0
  95. data/sig/discorb/audit_log.rbs +7 -0
  96. data/sig/discorb/automod.rbs +32 -6
  97. data/sig/discorb/avatar.rbs +1 -0
  98. data/sig/discorb/channel/base.rbs +8 -1
  99. data/sig/discorb/channel/category.rbs +1 -0
  100. data/sig/discorb/channel/container.rbs +4 -0
  101. data/sig/discorb/channel/stage.rbs +4 -0
  102. data/sig/discorb/channel/text.rbs +2 -2
  103. data/sig/discorb/channel/thread.rbs +11 -0
  104. data/sig/discorb/channel/voice.rbs +2 -0
  105. data/sig/discorb/client.rbs +21 -20
  106. data/sig/discorb/color.rbs +6 -0
  107. data/sig/discorb/component/base.rbs +1 -0
  108. data/sig/discorb/component/button.rbs +2 -0
  109. data/sig/discorb/component/select_menu.rbs +4 -0
  110. data/sig/discorb/component/text_input.rbs +1 -0
  111. data/sig/discorb/custom_emoji.rbs +5 -1
  112. data/sig/discorb/dictionary.rbs +2 -0
  113. data/sig/discorb/discord_model.rbs +2 -0
  114. data/sig/discorb/embed.rbs +7 -0
  115. data/sig/discorb/emoji.rbs +1 -0
  116. data/sig/discorb/event_handler.rbs +2 -1
  117. data/sig/discorb/extension.rbs +13 -12
  118. data/sig/discorb/flag.rbs +2 -0
  119. data/sig/discorb/gateway.rbs +5 -0
  120. data/sig/discorb/guild.rbs +8 -4
  121. data/sig/discorb/guild_template.rbs +1 -1
  122. data/sig/discorb/http.rbs +4 -1
  123. data/sig/discorb/image.rbs +2 -0
  124. data/sig/discorb/integration.rbs +1 -1
  125. data/sig/discorb/intents.rbs +4 -3
  126. data/sig/discorb/interaction/base.rbs +36 -0
  127. data/sig/discorb/interaction/message_component.rbs +1 -2
  128. data/sig/discorb/interaction/modal.rbs +1 -2
  129. data/sig/discorb/interaction/responder.rbs +49 -49
  130. data/sig/discorb/invite.rbs +1 -1
  131. data/sig/discorb/member.rbs +2 -0
  132. data/sig/discorb/message.rbs +8 -1
  133. data/sig/discorb/messageable.rbs +1 -4
  134. data/sig/discorb/partial_emoji.rbs +3 -0
  135. data/sig/discorb/permissions.rbs +7 -0
  136. data/sig/discorb/presence.rbs +2 -0
  137. data/sig/discorb/reaction.rbs +5 -1
  138. data/sig/discorb/role.rbs +7 -1
  139. data/sig/discorb/scheduled_event.rbs +2 -1
  140. data/sig/discorb/shard.rbs +2 -1
  141. data/sig/discorb/snowflake.rbs +2 -0
  142. data/sig/discorb/stage_instance.rbs +9 -3
  143. data/sig/discorb/sticker.rbs +1 -1
  144. data/sig/discorb/unicode_emoji.rbs +4 -0
  145. data/sig/discorb/user.rbs +24 -20
  146. data/sig/discorb/webhook.rbs +17 -6
  147. data/sig/discorb/welcome_screen.rbs +1 -0
  148. data/sig/override.rbs +2 -0
  149. metadata +3 -3
@@ -1,281 +1,305 @@
1
- # frozen_string_literal: true
2
-
3
- module Discorb
4
- #
5
- # Represents a state of user in voice channel.
6
- #
7
- class VoiceState < DiscordModel
8
- # @return [Discorb::Member] The member associated with this voice state.
9
- attr_reader :member
10
- # @return [Discorb::Snowflake] The ID of the guild this voice state is for.
11
- attr_reader :session_id
12
- # @return [Time] The time at which the user requested to speak.
13
- attr_reader :request_to_speak_timestamp
14
- # @return [Boolean] Whether the user is deafened.
15
- attr_reader :self_deaf
16
- alias self_deaf? self_deaf
17
- # @return [Boolean] Whether the user is muted.
18
- attr_reader :self_mute
19
- alias self_mute? self_mute
20
- # @return [Boolean] Whether the user is streaming.
21
- attr_reader :self_stream
22
- alias stream? self_stream
23
- alias live? stream?
24
- # @return [Boolean] Whether the user is video-enabled.
25
- attr_reader :self_video
26
- alias video? self_video
27
- # @return [Boolean] Whether the user is suppressed. (Is at audience)
28
- attr_reader :suppress
29
- alias suppress? suppress
30
-
31
- # @!attribute [r] deaf?
32
- # @return [Boolean] Whether the user is deafened.
33
- # @!attribute [r] mute?
34
- # @return [Boolean] Whether the user is muted.
35
- # @!attribute [r] server_deaf?
36
- # @return [Boolean] Whether the user is deafened on the server.
37
- # @!attribute [r] server_mute?
38
- # @return [Boolean] Whether the user is muted on the server.
39
- # @!attribute [r] guild
40
- # @macro client_cache
41
- # @return [Discorb::Guild] The guild this voice state is for.
42
- # @!attribute [r] channel
43
- # @macro client_cache
44
- # @return [Discorb::Channel] The channel this voice state is for.
45
- # @!attribute [r] user
46
- # @macro client_cache
47
- # @return [Discorb::User] The user this voice state is for.
48
-
49
- #
50
- # Initialize a new voice state.
51
- # @private
52
- #
53
- # @param [Discorb::Client] client The client this voice state belongs to.
54
- # @param [Hash] data The data of the voice state.
55
- #
56
- def initialize(client, data)
57
- @client = client
58
- _set_data(data)
59
- end
60
-
61
- def deaf?
62
- @deaf || @self_deaf
63
- end
64
-
65
- def mute?
66
- @mute || @self_mute
67
- end
68
-
69
- def server_deaf?
70
- @deaf
71
- end
72
-
73
- def server_mute?
74
- @mute
75
- end
76
-
77
- def guild
78
- @guild_id && @client.guilds[@guild_id]
79
- end
80
-
81
- def channel
82
- @channel_id && @client.channels[@channel_id]
83
- end
84
-
85
- def user
86
- @client.users[@user_id]
87
- end
88
-
89
- private
90
-
91
- def _set_data(data)
92
- @data = data
93
- @guild_id = data[:guild_id]
94
- @channel_id = data[:channel_id]
95
- @user_id = data[:user_id]
96
- unless guild.nil?
97
- @member = if data.key?(:member)
98
- guild.members[data[:user_id]] || Member.new(@client, @guild_id, data[:member][:user], data[:member])
99
- else
100
- guild.members[data[:user_id]]
101
- end
102
- end
103
- @session_id = data[:session_id]
104
- @deaf = data[:deaf]
105
- @mute = data[:mute]
106
- @self_deaf = data[:self_deaf]
107
- @self_mute = data[:self_mute]
108
- @self_stream = data[:self_stream]
109
- @self_video = data[:self_video]
110
- @suppress = data[:suppress]
111
- @request_to_speak_timestamp = data[:request_to_speak_timestamp] && Time.iso8601(data[:request_to_speak_timestamp])
112
- end
113
- end
114
-
115
- #
116
- # Represents a stage instance of a voice state.
117
- #
118
- class StageInstance < DiscordModel
119
- # @return [Discorb::Snowflake] The ID of the guild this voice state is for.
120
- attr_reader :id
121
- # @return [String] The topic of the stage instance.
122
- attr_reader :topic
123
- # @return [:public, :guild_only] The privacy level of the stage instance.
124
- attr_reader :privacy_level
125
-
126
- # @!attribute [r] guild
127
- # @macro client_cache
128
- # @return [Discorb::Guild] The guild this voice state is for.
129
- # @!attribute [r] channel
130
- # @macro client_cache
131
- # @return [Discorb::Channel] The channel this voice state is for.
132
- # @!attribute [r] discoverable?
133
- # @return [Boolean] Whether the stage instance is discoverable.
134
- # @!attribute [r] public?
135
- # @return [Boolean] Whether the stage instance is public.
136
- # @!attribute [r] guild_only?
137
- # @return [Boolean] Whether the stage instance is guild-only.
138
-
139
- @privacy_level = {
140
- 1 => :public,
141
- 2 => :guild_only,
142
- }
143
-
144
- #
145
- # Initialize a new instance of the StageInstance class.
146
- # @private
147
- #
148
- # @param [Discorb::Client] client The client.
149
- # @param [Hash] data The data of the stage instance.
150
- # @param [Boolean] no_cache Whether to disable caching.
151
- #
152
- def initialize(client, data, no_cache: false)
153
- @client = client
154
- @data = data
155
- _set_data(data)
156
- channel.stage_instances[@id] = self unless no_cache
157
- end
158
-
159
- def guild
160
- @client.guilds[@data[:guild_id]]
161
- end
162
-
163
- def channel
164
- @client.channels[@data[:channel_id]]
165
- end
166
-
167
- def discoverable?
168
- !@discoverable_disabled
169
- end
170
-
171
- def public?
172
- @privacy_level == :public
173
- end
174
-
175
- def guild_only?
176
- @privacy_level == :guild_only
177
- end
178
-
179
- def inspect
180
- "#<#{self.class} topic=#{@topic.inspect}>"
181
- end
182
-
183
- #
184
- # Edits the stage instance.
185
- # @async
186
- # @macro edit
187
- #
188
- # @param [String] topic The new topic of the stage instance.
189
- # @param [:public, :guild_only] privacy_level The new privacy level of the stage instance.
190
- # @param [String] reason The reason for editing the stage instance.
191
- #
192
- # @return [Async::Task<void>] The task.
193
- #
194
- def edit(topic: Discorb::Unset, privacy_level: Discorb::Unset, reason: nil)
195
- Async do
196
- payload = {}
197
- payload[:topic] = topic if topic != Discorb::Unset
198
- payload[:privacy_level] = PRIVACY_LEVEL.key(privacy_level) if privacy_level != Discorb::Unset
199
- @client.http.request(
200
- Route.new("/stage-instances/#{@channel_id}", "//stage-instances/:channel_id",
201
- :patch), payload, audit_log_reason: reason,
202
- ).wait
203
- self
204
- end
205
- end
206
-
207
- alias modify edit
208
-
209
- #
210
- # Deletes the stage instance.
211
- #
212
- # @param [String] reason The reason for deleting the stage instance.
213
- #
214
- # @return [Async::Task<void>] The task.
215
- #
216
- def delete!(reason: nil)
217
- Async do
218
- @client.http.request(
219
- Route.new("/stage-instances/#{@channel_id}", "//stage-instances/:stage_instance_id",
220
- :delete), {}, audit_log_reason: reason,
221
- ).wait
222
- self
223
- end
224
- end
225
-
226
- alias destroy! delete!
227
- alias end! delete!
228
-
229
- private
230
-
231
- def _set_data(data)
232
- @id = Snowflake.new(data[:id])
233
- @guild_id = Snowflake.new(data[:guild_id])
234
- @channel_id = Snowflake.new(data[:channel_id])
235
- @topic = data[:topic]
236
- @privacy_level = PRIVACY_LEVEL[data[:privacy_level]]
237
- @discoverable_disabled = data[:discoverable_disabled]
238
- end
239
-
240
- class << self
241
- attr_reader :privacy_level
242
- end
243
- end
244
-
245
- #
246
- # Represents a voice region.
247
- #
248
- class VoiceRegion < DiscordModel
249
- # @return [Discorb::Snowflake] The ID of the voice region.
250
- attr_reader :id
251
- # @return [String] The name of the voice region.
252
- attr_reader :name
253
- # @return [Boolean] Whether the voice region is VIP.
254
- attr_reader :vip
255
- alias vip? vip
256
- # @return [Boolean] Whether the voice region is optimal.
257
- attr_reader :optimal
258
- alias optimal? optimal
259
- # @return [Boolean] Whether the voice region is deprecated.
260
- attr_reader :deprecated
261
- alias deprecated? deprecated
262
- # @return [Boolean] Whether the voice region is custom.
263
- attr_reader :custom
264
- alias custom? custom
265
-
266
- #
267
- # Initialize a new instance of the VoiceRegion class.
268
- # @private
269
- #
270
- # @param [Hash] data The data of the voice region.
271
- #
272
- def initialize(data)
273
- @id = data[:id]
274
- @name = data[:name]
275
- @vip = data[:vip]
276
- @optimal = data[:optimal]
277
- @deprecated = data[:deprecated]
278
- @custom = data[:custom]
279
- end
280
- end
281
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Discorb
4
+ #
5
+ # Represents a state of user in voice channel.
6
+ #
7
+ class VoiceState < DiscordModel
8
+ # @return [Discorb::Member] The member associated with this voice state.
9
+ attr_reader :member
10
+ # @return [Discorb::Snowflake] The ID of the guild this voice state is for.
11
+ attr_reader :session_id
12
+ # @return [Time] The time at which the user requested to speak.
13
+ attr_reader :request_to_speak_timestamp
14
+ # @return [Boolean] Whether the user is deafened.
15
+ attr_reader :self_deaf
16
+ alias self_deaf? self_deaf
17
+ # @return [Boolean] Whether the user is muted.
18
+ attr_reader :self_mute
19
+ alias self_mute? self_mute
20
+ # @return [Boolean] Whether the user is streaming.
21
+ attr_reader :self_stream
22
+ alias stream? self_stream
23
+ alias live? stream?
24
+ # @return [Boolean] Whether the user is video-enabled.
25
+ attr_reader :self_video
26
+ alias video? self_video
27
+ # @return [Boolean] Whether the user is suppressed. (Is at audience)
28
+ attr_reader :suppress
29
+ alias suppress? suppress
30
+
31
+ # @!attribute [r] deaf?
32
+ # @return [Boolean] Whether the user is deafened.
33
+ # @!attribute [r] mute?
34
+ # @return [Boolean] Whether the user is muted.
35
+ # @!attribute [r] server_deaf?
36
+ # @return [Boolean] Whether the user is deafened on the server.
37
+ # @!attribute [r] server_mute?
38
+ # @return [Boolean] Whether the user is muted on the server.
39
+ # @!attribute [r] guild
40
+ # @macro client_cache
41
+ # @return [Discorb::Guild] The guild this voice state is for.
42
+ # @!attribute [r] channel
43
+ # @macro client_cache
44
+ # @return [Discorb::Channel] The channel this voice state is for.
45
+ # @!attribute [r] user
46
+ # @macro client_cache
47
+ # @return [Discorb::User] The user this voice state is for.
48
+
49
+ #
50
+ # Initialize a new voice state.
51
+ # @private
52
+ #
53
+ # @param [Discorb::Client] client The client this voice state belongs to.
54
+ # @param [Hash] data The data of the voice state.
55
+ #
56
+ def initialize(client, data)
57
+ @client = client
58
+ _set_data(data)
59
+ end
60
+
61
+ def deaf?
62
+ @deaf || @self_deaf
63
+ end
64
+
65
+ def mute?
66
+ @mute || @self_mute
67
+ end
68
+
69
+ def server_deaf?
70
+ @deaf
71
+ end
72
+
73
+ def server_mute?
74
+ @mute
75
+ end
76
+
77
+ def guild
78
+ @guild_id && @client.guilds[@guild_id]
79
+ end
80
+
81
+ def channel
82
+ @channel_id && @client.channels[@channel_id]
83
+ end
84
+
85
+ def user
86
+ @client.users[@user_id]
87
+ end
88
+
89
+ private
90
+
91
+ def _set_data(data)
92
+ @data = data
93
+ @guild_id = data[:guild_id]
94
+ @channel_id = data[:channel_id]
95
+ @user_id = data[:user_id]
96
+ unless guild.nil?
97
+ @member =
98
+ if data.key?(:member)
99
+ guild.members[data[:user_id]] ||
100
+ Member.new(
101
+ @client,
102
+ @guild_id,
103
+ data[:member][:user],
104
+ data[:member]
105
+ )
106
+ else
107
+ guild.members[data[:user_id]]
108
+ end
109
+ end
110
+ @session_id = data[:session_id]
111
+ @deaf = data[:deaf]
112
+ @mute = data[:mute]
113
+ @self_deaf = data[:self_deaf]
114
+ @self_mute = data[:self_mute]
115
+ @self_stream = data[:self_stream]
116
+ @self_video = data[:self_video]
117
+ @suppress = data[:suppress]
118
+ @request_to_speak_timestamp =
119
+ data[:request_to_speak_timestamp] &&
120
+ Time.iso8601(data[:request_to_speak_timestamp])
121
+ end
122
+ end
123
+
124
+ #
125
+ # Represents a stage instance of a voice state.
126
+ #
127
+ class StageInstance < DiscordModel
128
+ # @return [Discorb::Snowflake] The ID of the guild this voice state is for.
129
+ attr_reader :id
130
+ # @return [String] The topic of the stage instance.
131
+ attr_reader :topic
132
+ # @return [:public, :guild_only] The privacy level of the stage instance.
133
+ attr_reader :privacy_level
134
+
135
+ # @!attribute [r] guild
136
+ # @macro client_cache
137
+ # @return [Discorb::Guild] The guild this voice state is for.
138
+ # @!attribute [r] channel
139
+ # @macro client_cache
140
+ # @return [Discorb::Channel] The channel this voice state is for.
141
+ # @!attribute [r] discoverable?
142
+ # @return [Boolean] Whether the stage instance is discoverable.
143
+ # @!attribute [r] public?
144
+ # @return [Boolean] Whether the stage instance is public.
145
+ # @!attribute [r] guild_only?
146
+ # @return [Boolean] Whether the stage instance is guild-only.
147
+
148
+ @privacy_level = { 1 => :public, 2 => :guild_only }
149
+
150
+ #
151
+ # Initialize a new instance of the StageInstance class.
152
+ # @private
153
+ #
154
+ # @param [Discorb::Client] client The client.
155
+ # @param [Hash] data The data of the stage instance.
156
+ # @param [Boolean] no_cache Whether to disable caching.
157
+ #
158
+ def initialize(client, data, no_cache: false)
159
+ @client = client
160
+ @data = data
161
+ _set_data(data)
162
+ channel.stage_instances[@id] = self unless no_cache
163
+ end
164
+
165
+ def guild
166
+ @client.guilds[@data[:guild_id]]
167
+ end
168
+
169
+ def channel
170
+ @client.channels[@data[:channel_id]]
171
+ end
172
+
173
+ def discoverable?
174
+ !@discoverable_disabled
175
+ end
176
+
177
+ def public?
178
+ @privacy_level == :public
179
+ end
180
+
181
+ def guild_only?
182
+ @privacy_level == :guild_only
183
+ end
184
+
185
+ def inspect
186
+ "#<#{self.class} topic=#{@topic.inspect}>"
187
+ end
188
+
189
+ #
190
+ # Edits the stage instance.
191
+ # @async
192
+ # @macro edit
193
+ #
194
+ # @param [String] topic The new topic of the stage instance.
195
+ # @param [:public, :guild_only] privacy_level The new privacy level of the stage instance.
196
+ # @param [String] reason The reason for editing the stage instance.
197
+ #
198
+ # @return [Async::Task<void>] The task.
199
+ #
200
+ def edit(topic: Discorb::Unset, privacy_level: Discorb::Unset, reason: nil)
201
+ Async do
202
+ payload = {}
203
+ payload[:topic] = topic if topic != Discorb::Unset
204
+ payload[:privacy_level] = PRIVACY_LEVEL.key(
205
+ privacy_level
206
+ ) if privacy_level != Discorb::Unset
207
+ @client
208
+ .http
209
+ .request(
210
+ Route.new(
211
+ "/stage-instances/#{@channel_id}",
212
+ "//stage-instances/:channel_id",
213
+ :patch
214
+ ),
215
+ payload,
216
+ audit_log_reason: reason
217
+ )
218
+ .wait
219
+ self
220
+ end
221
+ end
222
+
223
+ alias modify edit
224
+
225
+ #
226
+ # Deletes the stage instance.
227
+ #
228
+ # @param [String] reason The reason for deleting the stage instance.
229
+ #
230
+ # @return [Async::Task<void>] The task.
231
+ #
232
+ def delete(reason: nil)
233
+ Async do
234
+ @client
235
+ .http
236
+ .request(
237
+ Route.new(
238
+ "/stage-instances/#{@channel_id}",
239
+ "//stage-instances/:stage_instance_id",
240
+ :delete
241
+ ),
242
+ {},
243
+ audit_log_reason: reason
244
+ )
245
+ .wait
246
+ self
247
+ end
248
+ end
249
+
250
+ alias destroy delete
251
+ alias end delete
252
+
253
+ private
254
+
255
+ def _set_data(data)
256
+ @id = Snowflake.new(data[:id])
257
+ @guild_id = Snowflake.new(data[:guild_id])
258
+ @channel_id = Snowflake.new(data[:channel_id])
259
+ @topic = data[:topic]
260
+ @privacy_level = PRIVACY_LEVEL[data[:privacy_level]]
261
+ @discoverable_disabled = data[:discoverable_disabled]
262
+ end
263
+
264
+ class << self
265
+ attr_reader :privacy_level
266
+ end
267
+ end
268
+
269
+ #
270
+ # Represents a voice region.
271
+ #
272
+ class VoiceRegion < DiscordModel
273
+ # @return [Discorb::Snowflake] The ID of the voice region.
274
+ attr_reader :id
275
+ # @return [String] The name of the voice region.
276
+ attr_reader :name
277
+ # @return [Boolean] Whether the voice region is VIP.
278
+ attr_reader :vip
279
+ alias vip? vip
280
+ # @return [Boolean] Whether the voice region is optimal.
281
+ attr_reader :optimal
282
+ alias optimal? optimal
283
+ # @return [Boolean] Whether the voice region is deprecated.
284
+ attr_reader :deprecated
285
+ alias deprecated? deprecated
286
+ # @return [Boolean] Whether the voice region is custom.
287
+ attr_reader :custom
288
+ alias custom? custom
289
+
290
+ #
291
+ # Initialize a new instance of the VoiceRegion class.
292
+ # @private
293
+ #
294
+ # @param [Hash] data The data of the voice region.
295
+ #
296
+ def initialize(data)
297
+ @id = data[:id]
298
+ @name = data[:name]
299
+ @vip = data[:vip]
300
+ @optimal = data[:optimal]
301
+ @deprecated = data[:deprecated]
302
+ @custom = data[:custom]
303
+ end
304
+ end
305
+ end