discorb 0.15.0 → 0.15.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -2
- data/Changelog.md +9 -0
- data/Rakefile +6 -0
- data/docs/events.md +50 -0
- data/lib/discorb/allowed_mentions.rb +7 -0
- data/lib/discorb/app_command/command.rb +64 -2
- data/lib/discorb/application.rb +16 -7
- data/lib/discorb/asset.rb +9 -0
- data/lib/discorb/attachment.rb +16 -1
- data/lib/discorb/audit_logs.rb +42 -4
- data/lib/discorb/channel.rb +42 -3
- data/lib/discorb/client.rb +4 -0
- data/lib/discorb/common.rb +17 -3
- data/lib/discorb/components/button.rb +5 -6
- data/lib/discorb/components/select_menu.rb +2 -16
- data/lib/discorb/dictionary.rb +2 -0
- data/lib/discorb/embed.rb +33 -7
- data/lib/discorb/emoji.rb +29 -2
- data/lib/discorb/emoji_table.rb +1 -1
- data/lib/discorb/error.rb +7 -1
- data/lib/discorb/event.rb +27 -17
- data/lib/discorb/gateway.rb +79 -22
- data/lib/discorb/gateway_requests.rb +4 -7
- data/lib/discorb/guild.rb +67 -33
- data/lib/discorb/guild_template.rb +24 -3
- data/lib/discorb/http.rb +7 -2
- data/lib/discorb/integration.rb +23 -8
- data/lib/discorb/intents.rb +7 -7
- data/lib/discorb/interaction/autocomplete.rb +2 -2
- data/lib/discorb/interaction/command.rb +32 -3
- data/lib/discorb/interaction/components.rb +14 -1
- data/lib/discorb/interaction/response.rb +12 -0
- data/lib/discorb/interaction/root.rb +15 -0
- data/lib/discorb/invite.rb +11 -7
- data/lib/discorb/log.rb +4 -4
- data/lib/discorb/member.rb +21 -0
- data/lib/discorb/message.rb +9 -1
- data/lib/discorb/message_meta.rb +38 -9
- data/lib/discorb/permission.rb +14 -5
- data/lib/discorb/presence.rb +41 -8
- data/lib/discorb/rate_limit.rb +5 -0
- data/lib/discorb/reaction.rb +6 -0
- data/lib/discorb/role.rb +12 -0
- data/lib/discorb/sticker.rb +22 -14
- data/lib/discorb/user.rb +11 -0
- data/lib/discorb/voice_state.rb +20 -2
- data/lib/discorb/webhook.rb +52 -1
- data/lib/discorb.rb +3 -1
- data/sig/discorb.rbs +6850 -5836
- metadata +2 -2
data/lib/discorb/invite.rb
CHANGED
@@ -66,13 +66,22 @@ module Discorb
|
|
66
66
|
# Whether the invite is temporary.
|
67
67
|
# @return [Boolean]
|
68
68
|
|
69
|
-
@
|
69
|
+
# @private
|
70
|
+
# @return [{Integer => Symbol}] The mapping of target types.
|
71
|
+
TARGET_TYPES = {
|
70
72
|
nil => :voice,
|
71
73
|
1 => :stream,
|
72
74
|
2 => :guild,
|
73
75
|
}.freeze
|
74
76
|
|
77
|
+
#
|
78
|
+
# Initialize a new invite.
|
75
79
|
# @private
|
80
|
+
#
|
81
|
+
# @param [Discorb::Client] client The client.
|
82
|
+
# @param [Hash] data The data of invite.
|
83
|
+
# @param [Boolean] gateway Whether the data is from gateway.
|
84
|
+
#
|
76
85
|
def initialize(client, data, gateway)
|
77
86
|
@client = client
|
78
87
|
@data = data[:data]
|
@@ -124,7 +133,7 @@ module Discorb
|
|
124
133
|
@expires_at = data[:expires_at] && Time.iso8601(data[:expires_at])
|
125
134
|
end
|
126
135
|
@inviter_data = data[:inviter]
|
127
|
-
@target_type =
|
136
|
+
@target_type = TARGET_TYPES[data[:target_type]]
|
128
137
|
@target_user = @client.users[data[:target_user][:id]] || User.new(@client, data[:target_user]) if data[:target_user]
|
129
138
|
# @target_application = nil
|
130
139
|
|
@@ -137,10 +146,5 @@ module Discorb
|
|
137
146
|
@temporary = data[:temporary]
|
138
147
|
@created_at = Time.iso8601(data[:created_at])
|
139
148
|
end
|
140
|
-
|
141
|
-
class << self
|
142
|
-
# @private
|
143
|
-
attr_reader :target_types
|
144
|
-
end
|
145
149
|
end
|
146
150
|
end
|
data/lib/discorb/log.rb
CHANGED
@@ -5,11 +5,11 @@ module Discorb
|
|
5
5
|
class Logger
|
6
6
|
attr_accessor :out, :colorize_log
|
7
7
|
|
8
|
-
|
8
|
+
LEVELS = %i[debug info warn error fatal].freeze
|
9
9
|
|
10
10
|
def initialize(out, colorize_log, level)
|
11
11
|
@out = out
|
12
|
-
@level =
|
12
|
+
@level = LEVELS.index(level)
|
13
13
|
@colorize_log = colorize_log
|
14
14
|
end
|
15
15
|
|
@@ -18,11 +18,11 @@ module Discorb
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def level
|
21
|
-
|
21
|
+
LEVELS[@level]
|
22
22
|
end
|
23
23
|
|
24
24
|
def level=(level)
|
25
|
-
@level =
|
25
|
+
@level = LEVELS.index(level)
|
26
26
|
raise ArgumentError, "Invalid log level: #{level}" unless @level
|
27
27
|
end
|
28
28
|
|
data/lib/discorb/member.rb
CHANGED
@@ -62,7 +62,15 @@ module Discorb
|
|
62
62
|
# @!attribute [r] owner?
|
63
63
|
# @return [Boolean] Whether the member is the owner of the guild.
|
64
64
|
|
65
|
+
#
|
66
|
+
# Initialize a new instance of the member.
|
65
67
|
# @private
|
68
|
+
#
|
69
|
+
# @param [Discorb::Client] client The client.
|
70
|
+
# @param [Discorb::Snowflake] guild_id The ID of the guild.
|
71
|
+
# @param [Hash] user_data The data of the user.
|
72
|
+
# @param [Hash] member_data The data of the member.
|
73
|
+
#
|
66
74
|
def initialize(client, guild_id, user_data, member_data)
|
67
75
|
@guild_id = guild_id
|
68
76
|
@client = client
|
@@ -248,6 +256,19 @@ module Discorb
|
|
248
256
|
end
|
249
257
|
end
|
250
258
|
|
259
|
+
#
|
260
|
+
# Checks if the member can manage the given role.
|
261
|
+
#
|
262
|
+
# @param [Discorb::Role] role The role.
|
263
|
+
#
|
264
|
+
# @return [Boolean] `true` if the member can manage the role.
|
265
|
+
#
|
266
|
+
def can_manage?(role)
|
267
|
+
return true if owner?
|
268
|
+
top_role = roles.max_by(&:position)
|
269
|
+
top_role.position > role.position
|
270
|
+
end
|
271
|
+
|
251
272
|
private
|
252
273
|
|
253
274
|
def _set_data(user_data, member_data)
|
data/lib/discorb/message.rb
CHANGED
@@ -152,7 +152,14 @@ module Discorb
|
|
152
152
|
!@guild_id.nil?
|
153
153
|
end
|
154
154
|
|
155
|
+
#
|
156
|
+
# Initialize a new message.
|
155
157
|
# @private
|
158
|
+
#
|
159
|
+
# @param [Discorb::Client] client The client.
|
160
|
+
# @param [Hash] data The data of the welcome screen.
|
161
|
+
# @param [Boolean] no_cache Whether to disable caching.
|
162
|
+
#
|
156
163
|
def initialize(client, data, no_cache: false)
|
157
164
|
@client = client
|
158
165
|
@data = {}
|
@@ -446,7 +453,8 @@ module Discorb
|
|
446
453
|
"#<#{self.class} #{@content.inspect} id=#{@id}>"
|
447
454
|
end
|
448
455
|
|
449
|
-
|
456
|
+
private
|
457
|
+
|
450
458
|
def _set_data(data)
|
451
459
|
@id = Snowflake.new(data[:id])
|
452
460
|
@channel_id = data[:channel_id]
|
data/lib/discorb/message_meta.rb
CHANGED
@@ -88,18 +88,31 @@ module Discorb
|
|
88
88
|
def self.from_hash(data)
|
89
89
|
new(data[:guild_id], data[:channel_id], data[:message_id], fail_if_not_exists: data[:fail_if_not_exists])
|
90
90
|
end
|
91
|
+
|
92
|
+
def inspect
|
93
|
+
"#<#{self.class.name} #{@channel_id}/#{@message_id}>"
|
94
|
+
end
|
91
95
|
end
|
92
96
|
|
93
97
|
#
|
94
98
|
# Represents a sticker.
|
95
99
|
#
|
96
100
|
class Sticker
|
97
|
-
|
101
|
+
# @return [Discorb::Snowflake] The sticker ID.
|
102
|
+
attr_reader :id
|
103
|
+
# @return [String] The sticker name.
|
104
|
+
attr_reader :name
|
105
|
+
# @return [Symbol] The sticker format.
|
106
|
+
attr_reader :format
|
98
107
|
|
99
108
|
def initialize(data)
|
100
109
|
@id = Snowflake.new(data[:id])
|
101
110
|
@name = data[:name]
|
102
|
-
@format = Discorb::Sticker
|
111
|
+
@format = Discorb::Sticker::STICKER_FORMAT[data[:format]]
|
112
|
+
end
|
113
|
+
|
114
|
+
def inspect
|
115
|
+
"#<#{self.class.name} #{@id}: #{@name} format=#{@format}>"
|
103
116
|
end
|
104
117
|
end
|
105
118
|
|
@@ -107,7 +120,7 @@ module Discorb
|
|
107
120
|
# Represents a interaction of message.
|
108
121
|
#
|
109
122
|
class Interaction < DiscordModel
|
110
|
-
# @return [Discorb::Snowflake] The
|
123
|
+
# @return [Discorb::Snowflake] The interaction ID.
|
111
124
|
attr_reader :id
|
112
125
|
# @return [String] The name of command.
|
113
126
|
# @return [nil] If the message is not a command.
|
@@ -117,13 +130,23 @@ module Discorb
|
|
117
130
|
# @return [Discorb::User] The user.
|
118
131
|
attr_reader :user
|
119
132
|
|
133
|
+
#
|
134
|
+
# Initialize a new interaction.
|
120
135
|
# @private
|
136
|
+
#
|
137
|
+
# @param [Discorb::Client] client The client.
|
138
|
+
# @param [Hash] data The interaction data.
|
139
|
+
#
|
121
140
|
def initialize(client, data)
|
122
141
|
@id = Snowflake.new(data[:id])
|
123
142
|
@name = data[:name]
|
124
143
|
@type = Discorb::Interaction.descendants.find { |c| c.interaction_type == data[:type] }
|
125
144
|
@user = client.users[data[:user][:id]] || User.new(client, data[:user])
|
126
145
|
end
|
146
|
+
|
147
|
+
def inspect
|
148
|
+
"<#{self.class.name} #{@id}: #{@name} type=#{@type} #{@user}>"
|
149
|
+
end
|
127
150
|
end
|
128
151
|
|
129
152
|
#
|
@@ -135,22 +158,28 @@ module Discorb
|
|
135
158
|
# @return [Symbol] The type of activity.
|
136
159
|
attr_reader :type
|
137
160
|
|
138
|
-
@
|
161
|
+
# @private
|
162
|
+
# @return [{Integer => Symbol}] The mapping of activity type.
|
163
|
+
TYPES = {
|
139
164
|
1 => :join,
|
140
165
|
2 => :spectate,
|
141
166
|
3 => :listen,
|
142
167
|
5 => :join_request,
|
143
|
-
}
|
168
|
+
}.freeze
|
144
169
|
|
170
|
+
#
|
171
|
+
# Initialize a new activity.
|
145
172
|
# @private
|
173
|
+
#
|
174
|
+
# @param [Hash] data The activity data.
|
175
|
+
#
|
146
176
|
def initialize(data)
|
147
177
|
@name = data[:name]
|
148
|
-
@type =
|
178
|
+
@type = TYPES[data[:type]]
|
149
179
|
end
|
150
180
|
|
151
|
-
|
152
|
-
# @
|
153
|
-
attr_reader :type
|
181
|
+
def inspect
|
182
|
+
"<#{self.class.name} #{@name} type=#{@type}>"
|
154
183
|
end
|
155
184
|
end
|
156
185
|
end
|
data/lib/discorb/permission.rb
CHANGED
@@ -138,7 +138,13 @@ module Discorb
|
|
138
138
|
}.freeze
|
139
139
|
@bits = @raw_bits.transform_values { |v| 1 << v }.freeze
|
140
140
|
|
141
|
+
#
|
142
|
+
# Initializes a new PermissionOverwrite.
|
141
143
|
# @private
|
144
|
+
#
|
145
|
+
# @param allow [Integer] The allowed permissions.
|
146
|
+
# @param deny [Integer] The denied permissions.
|
147
|
+
#
|
142
148
|
def initialize(allow, deny)
|
143
149
|
@allow = allow
|
144
150
|
@deny = deny
|
@@ -175,11 +181,14 @@ module Discorb
|
|
175
181
|
#
|
176
182
|
def to_hash
|
177
183
|
self.class.bits.keys.to_h do |field|
|
178
|
-
[
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
184
|
+
[
|
185
|
+
field,
|
186
|
+
if @allow & self.class.bits[field] != 0
|
187
|
+
true
|
188
|
+
elsif @deny & self.class.bits[field] != 0
|
189
|
+
false
|
190
|
+
end,
|
191
|
+
]
|
183
192
|
end
|
184
193
|
end
|
185
194
|
|
data/lib/discorb/presence.rb
CHANGED
@@ -19,7 +19,13 @@ module Discorb
|
|
19
19
|
# @!attribute [r] activity
|
20
20
|
# @return [Discorb::Presence::Activity] The activity of the presence.
|
21
21
|
|
22
|
+
#
|
23
|
+
# Initialize a presence.
|
22
24
|
# @private
|
25
|
+
#
|
26
|
+
# @param [Discorb::Client] client The client.
|
27
|
+
# @param [Hash] data The data of the presence.
|
28
|
+
#
|
23
29
|
def initialize(client, data)
|
24
30
|
@client = client
|
25
31
|
@data = data
|
@@ -80,19 +86,26 @@ module Discorb
|
|
80
86
|
# @return [Discorb::Presence::Activity::Flag] The flags of the activity.
|
81
87
|
attr_reader :flags
|
82
88
|
|
83
|
-
@
|
89
|
+
# @private
|
90
|
+
# @return [{Integer => Symbol}] The mapping of activity types.
|
91
|
+
ACTIVITY_TYPES = {
|
84
92
|
0 => :game,
|
85
93
|
1 => :streaming,
|
86
94
|
2 => :listening,
|
87
95
|
3 => :watching,
|
88
96
|
4 => :custom,
|
89
97
|
5 => :competing,
|
90
|
-
}
|
98
|
+
}.freeze
|
91
99
|
|
100
|
+
#
|
101
|
+
# Initialize the activity.
|
92
102
|
# @private
|
103
|
+
#
|
104
|
+
# @param [Hash] data The activity data.
|
105
|
+
#
|
93
106
|
def initialize(data)
|
94
107
|
@name = data[:name]
|
95
|
-
@type =
|
108
|
+
@type = ACTIVITY_TYPES[data[:type]]
|
96
109
|
@url = data[:url]
|
97
110
|
@created_at = Time.at(data[:created_at])
|
98
111
|
@timestamps = data[:timestamps] && Timestamps.new(data[:timestamps])
|
@@ -140,7 +153,12 @@ module Discorb
|
|
140
153
|
# @return [Time] The end time of the activity.
|
141
154
|
attr_reader :end
|
142
155
|
|
156
|
+
#
|
157
|
+
# Initialize the timestamps.
|
143
158
|
# @private
|
159
|
+
#
|
160
|
+
# @param [Hash] data The timestamps data.
|
161
|
+
#
|
144
162
|
def initialize(data)
|
145
163
|
@start = data[:start] && Time.at(data[:start])
|
146
164
|
@end = data[:end] && Time.at(data[:end])
|
@@ -159,7 +177,12 @@ module Discorb
|
|
159
177
|
# @!attribute [r] max_size
|
160
178
|
# @return [Integer] The max size of the party.
|
161
179
|
|
180
|
+
#
|
181
|
+
# Initialize the party.
|
162
182
|
# @private
|
183
|
+
#
|
184
|
+
# @param [Hash] data The party data.
|
185
|
+
#
|
163
186
|
def initialize(data)
|
164
187
|
@id = data[:id]
|
165
188
|
@size = data[:size]
|
@@ -229,7 +252,12 @@ module Discorb
|
|
229
252
|
# @return [String] The match secret of the activity.
|
230
253
|
attr_reader :match
|
231
254
|
|
255
|
+
#
|
256
|
+
# Initialize the secrets.
|
232
257
|
# @private
|
258
|
+
#
|
259
|
+
# @param [Hash] data The secrets data.
|
260
|
+
#
|
233
261
|
def initialize(data)
|
234
262
|
@join = data[:join]
|
235
263
|
@spectate = data[:spectate]
|
@@ -247,17 +275,17 @@ module Discorb
|
|
247
275
|
attr_reader :url
|
248
276
|
alias text label
|
249
277
|
|
278
|
+
#
|
279
|
+
# Initialize the button.
|
250
280
|
# @private
|
281
|
+
#
|
282
|
+
# @param [Hash] data The button data.
|
283
|
+
#
|
251
284
|
def initialize(data)
|
252
285
|
@label = data[0]
|
253
286
|
@url = data[1]
|
254
287
|
end
|
255
288
|
end
|
256
|
-
|
257
|
-
class << self
|
258
|
-
# @private
|
259
|
-
attr_reader :activity_types
|
260
|
-
end
|
261
289
|
end
|
262
290
|
|
263
291
|
#
|
@@ -278,7 +306,12 @@ module Discorb
|
|
278
306
|
# @!attribute [r] web?
|
279
307
|
# @return [Boolean] Whether the user is not offline on web.
|
280
308
|
|
309
|
+
#
|
310
|
+
# Initialize the client status.
|
281
311
|
# @private
|
312
|
+
#
|
313
|
+
# @param [Hash] data The client status data.
|
314
|
+
#
|
282
315
|
def initialize(data)
|
283
316
|
@desktop = data[:desktop]&.to_sym || :offline
|
284
317
|
@mobile = data[:mobile]&.to_sym || :offline
|
data/lib/discorb/rate_limit.rb
CHANGED
data/lib/discorb/reaction.rb
CHANGED
@@ -16,7 +16,13 @@ module Discorb
|
|
16
16
|
alias me? me
|
17
17
|
alias reacted? me
|
18
18
|
|
19
|
+
#
|
20
|
+
# Initialize a new reaction.
|
19
21
|
# @private
|
22
|
+
#
|
23
|
+
# @param [Discorb::Message] message The message that this reaction is on.
|
24
|
+
# @param [Hash] data The data of the reaction.
|
25
|
+
#
|
20
26
|
def initialize(message, data)
|
21
27
|
@message = message
|
22
28
|
_set_data(data)
|
data/lib/discorb/role.rb
CHANGED
@@ -42,7 +42,14 @@ module Discorb
|
|
42
42
|
|
43
43
|
include Comparable
|
44
44
|
|
45
|
+
#
|
46
|
+
# Initializes a new role.
|
45
47
|
# @private
|
48
|
+
#
|
49
|
+
# @param [Discorb::Client] client The client.
|
50
|
+
# @param [Discorb::Guild] guild The guild the role belongs to.
|
51
|
+
# @param [Hash] data The data of the role.
|
52
|
+
#
|
46
53
|
def initialize(client, guild, data)
|
47
54
|
@client = client
|
48
55
|
@guild = guild
|
@@ -176,7 +183,12 @@ module Discorb
|
|
176
183
|
# @!attribute [r] integration?
|
177
184
|
# @return [Boolean] Whether the role is an integration role.
|
178
185
|
|
186
|
+
#
|
187
|
+
# Initializes a new tag.
|
179
188
|
# @private
|
189
|
+
#
|
190
|
+
# @param [Hash] data The data of the tag.
|
191
|
+
#
|
180
192
|
def initialize(data)
|
181
193
|
@bot_id = Snowflake.new(data[:bot_id])
|
182
194
|
@integration_id = Snowflake.new(data[:integration_id])
|
data/lib/discorb/sticker.rb
CHANGED
@@ -29,16 +29,27 @@ module Discorb
|
|
29
29
|
attr_reader :available
|
30
30
|
alias available? available
|
31
31
|
|
32
|
-
@
|
32
|
+
# @private
|
33
|
+
# @return [{Integer => Symbol}] The mapping of sticker types.
|
34
|
+
STICKER_TYPE = {
|
33
35
|
1 => :official,
|
34
36
|
2 => :guild,
|
35
37
|
}.freeze
|
36
|
-
|
38
|
+
|
39
|
+
# @private
|
40
|
+
# @return [{Integer => Symbol}] The mapping of sticker format.
|
41
|
+
STICKER_FORMAT = {
|
37
42
|
1 => :png,
|
38
43
|
2 => :apng,
|
39
44
|
3 => :lottie,
|
40
|
-
}
|
45
|
+
}.freeze
|
46
|
+
#
|
47
|
+
# Initialize a new sticker.
|
41
48
|
# @private
|
49
|
+
#
|
50
|
+
# @param [Discorb::Client] client The client.
|
51
|
+
# @param [Hash] data The sticker data.
|
52
|
+
#
|
42
53
|
def initialize(client, data)
|
43
54
|
@client = client
|
44
55
|
_set_data(data)
|
@@ -51,15 +62,6 @@ module Discorb
|
|
51
62
|
# @!attribute [r] guild
|
52
63
|
# @macro client_cache
|
53
64
|
# @return [Discorb::Guild] The guild the sticker is in.
|
54
|
-
@sticker_type = {
|
55
|
-
1 => :official,
|
56
|
-
2 => :guild,
|
57
|
-
}.freeze
|
58
|
-
@sticker_format = {
|
59
|
-
1 => :png,
|
60
|
-
2 => :apng,
|
61
|
-
3 => :lottie,
|
62
|
-
}
|
63
65
|
|
64
66
|
def guild
|
65
67
|
@client.guilds[@guild_id]
|
@@ -121,7 +123,13 @@ module Discorb
|
|
121
123
|
# @return [Discorb::Asset] The banner of the pack.
|
122
124
|
attr_reader :banner
|
123
125
|
|
126
|
+
#
|
127
|
+
# Initialize a new sticker pack.
|
124
128
|
# @private
|
129
|
+
#
|
130
|
+
# @param [Discorb::Client] client The client.
|
131
|
+
# @param [Hash] data The sticker pack data.
|
132
|
+
#
|
125
133
|
def initialize(client, data)
|
126
134
|
@client = client
|
127
135
|
@id = Snowflake.new(data[:id])
|
@@ -141,8 +149,8 @@ module Discorb
|
|
141
149
|
@id = Snowflake.new(data[:id])
|
142
150
|
@name = data[:name]
|
143
151
|
@tags = data[:tags].split(",")
|
144
|
-
@type =
|
145
|
-
@format =
|
152
|
+
@type = STICKER_TYPE[data[:type]]
|
153
|
+
@format = STICKER_FORMAT[data[:format]]
|
146
154
|
@description = data[:description]
|
147
155
|
@available = data[:available]
|
148
156
|
if @type == :official
|
data/lib/discorb/user.rb
CHANGED
@@ -29,7 +29,13 @@ module Discorb
|
|
29
29
|
# @!attribute [r] mention
|
30
30
|
# @return [String] The user's mention.
|
31
31
|
|
32
|
+
#
|
33
|
+
# Initializes a new user.
|
32
34
|
# @private
|
35
|
+
#
|
36
|
+
# @param [Discorb::Client] client The client.
|
37
|
+
# @param [Hash] data The user data.
|
38
|
+
#
|
33
39
|
def initialize(client, data)
|
34
40
|
@client = client
|
35
41
|
@data = {}
|
@@ -79,7 +85,12 @@ module Discorb
|
|
79
85
|
|
80
86
|
alias app_owner? bot_owner?
|
81
87
|
|
88
|
+
#
|
89
|
+
# Returns the dm channel id of the user.
|
82
90
|
# @private
|
91
|
+
#
|
92
|
+
# @return [Async::Task<Discorb::Snowflake>] A task that resolves to the channel id.
|
93
|
+
#
|
83
94
|
def channel_id
|
84
95
|
Async do
|
85
96
|
next @dm_channel_id if @dm_channel_id
|
data/lib/discorb/voice_state.rb
CHANGED
@@ -46,7 +46,13 @@ module Discorb
|
|
46
46
|
# @macro client_cache
|
47
47
|
# @return [Discorb::User] The user this voice state is for.
|
48
48
|
|
49
|
+
#
|
50
|
+
# Initialize a new voice state.
|
49
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
|
+
#
|
50
56
|
def initialize(client, data)
|
51
57
|
@client = client
|
52
58
|
_set_data(data)
|
@@ -135,7 +141,14 @@ module Discorb
|
|
135
141
|
2 => :guild_only,
|
136
142
|
}
|
137
143
|
|
144
|
+
#
|
145
|
+
# Initialize a new instance of the StageInstance class.
|
138
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
|
+
#
|
139
152
|
def initialize(client, data, no_cache: false)
|
140
153
|
@client = client
|
141
154
|
@data = data
|
@@ -182,7 +195,7 @@ module Discorb
|
|
182
195
|
Async do
|
183
196
|
payload = {}
|
184
197
|
payload[:topic] = topic if topic != Discorb::Unset
|
185
|
-
payload[:privacy_level] =
|
198
|
+
payload[:privacy_level] = PRIVACY_LEVEL.key(privacy_level) if privacy_level != Discorb::Unset
|
186
199
|
@client.http.request(
|
187
200
|
Route.new("/stage-instances/#{@channel_id}", "//stage-instances/:channel_id", :patch), payload, audit_log_reason: reason,
|
188
201
|
).wait
|
@@ -216,7 +229,7 @@ module Discorb
|
|
216
229
|
@guild_id = Snowflake.new(data[:guild_id])
|
217
230
|
@channel_id = Snowflake.new(data[:channel_id])
|
218
231
|
@topic = data[:topic]
|
219
|
-
@privacy_level =
|
232
|
+
@privacy_level = PRIVACY_LEVEL[data[:privacy_level]]
|
220
233
|
@discoverable_disabled = data[:discoverable_disabled]
|
221
234
|
end
|
222
235
|
|
@@ -246,7 +259,12 @@ module Discorb
|
|
246
259
|
attr_reader :custom
|
247
260
|
alias custom? custom
|
248
261
|
|
262
|
+
#
|
263
|
+
# Initialize a new instance of the VoiceRegion class.
|
249
264
|
# @private
|
265
|
+
#
|
266
|
+
# @param [Hash] data The data of the voice region.
|
267
|
+
#
|
250
268
|
def initialize(data)
|
251
269
|
@id = data[:id]
|
252
270
|
@name = data[:name]
|