discorb 0.19.0 → 0.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build_version.yml +2 -2
- data/.rubocop.yml +12 -75
- data/Changelog.md +10 -0
- data/Rakefile +482 -454
- data/lib/discorb/allowed_mentions.rb +68 -72
- data/lib/discorb/app_command/command.rb +466 -398
- data/lib/discorb/app_command/common.rb +65 -25
- data/lib/discorb/app_command/handler.rb +304 -266
- data/lib/discorb/app_command.rb +5 -5
- data/lib/discorb/application.rb +198 -197
- data/lib/discorb/asset.rb +101 -101
- data/lib/discorb/attachment.rb +134 -119
- data/lib/discorb/audit_logs.rb +412 -385
- data/lib/discorb/automod.rb +279 -269
- data/lib/discorb/channel/base.rb +107 -108
- data/lib/discorb/channel/category.rb +32 -32
- data/lib/discorb/channel/container.rb +44 -44
- data/lib/discorb/channel/dm.rb +26 -28
- data/lib/discorb/channel/guild.rb +311 -246
- data/lib/discorb/channel/stage.rb +156 -140
- data/lib/discorb/channel/text.rb +430 -336
- data/lib/discorb/channel/thread.rb +374 -325
- data/lib/discorb/channel/voice.rb +85 -79
- data/lib/discorb/channel.rb +5 -5
- data/lib/discorb/client.rb +635 -621
- data/lib/discorb/color.rb +178 -182
- data/lib/discorb/common.rb +168 -164
- data/lib/discorb/components/button.rb +107 -106
- data/lib/discorb/components/select_menu.rb +157 -145
- data/lib/discorb/components/text_input.rb +103 -106
- data/lib/discorb/components.rb +68 -66
- data/lib/discorb/dictionary.rb +135 -135
- data/lib/discorb/embed.rb +404 -398
- data/lib/discorb/emoji.rb +309 -302
- data/lib/discorb/emoji_table.rb +16099 -8857
- data/lib/discorb/error.rb +131 -131
- data/lib/discorb/event.rb +360 -314
- data/lib/discorb/event_handler.rb +39 -39
- data/lib/discorb/exe/about.rb +17 -17
- data/lib/discorb/exe/irb.rb +72 -67
- data/lib/discorb/exe/new.rb +323 -315
- data/lib/discorb/exe/run.rb +69 -68
- data/lib/discorb/exe/setup.rb +57 -55
- data/lib/discorb/exe/show.rb +12 -12
- data/lib/discorb/extend.rb +25 -45
- data/lib/discorb/extension.rb +89 -83
- data/lib/discorb/flag.rb +126 -128
- data/lib/discorb/gateway.rb +984 -804
- data/lib/discorb/gateway_events.rb +670 -638
- data/lib/discorb/gateway_requests.rb +45 -48
- data/lib/discorb/guild.rb +2115 -1626
- data/lib/discorb/guild_template.rb +280 -241
- data/lib/discorb/http.rb +247 -232
- data/lib/discorb/image.rb +42 -42
- data/lib/discorb/integration.rb +169 -161
- data/lib/discorb/intents.rb +161 -163
- data/lib/discorb/interaction/autocomplete.rb +76 -62
- data/lib/discorb/interaction/command.rb +279 -224
- data/lib/discorb/interaction/components.rb +114 -104
- data/lib/discorb/interaction/modal.rb +36 -32
- data/lib/discorb/interaction/response.rb +379 -336
- data/lib/discorb/interaction/root.rb +271 -257
- data/lib/discorb/interaction.rb +5 -5
- data/lib/discorb/invite.rb +154 -153
- data/lib/discorb/member.rb +344 -311
- data/lib/discorb/message.rb +615 -544
- data/lib/discorb/message_meta.rb +197 -186
- data/lib/discorb/modules.rb +371 -290
- data/lib/discorb/permission.rb +305 -291
- data/lib/discorb/presence.rb +352 -346
- data/lib/discorb/rate_limit.rb +81 -76
- data/lib/discorb/reaction.rb +55 -54
- data/lib/discorb/role.rb +272 -240
- data/lib/discorb/shard.rb +76 -74
- data/lib/discorb/sticker.rb +193 -171
- data/lib/discorb/user.rb +205 -188
- data/lib/discorb/utils/colored_puts.rb +16 -16
- data/lib/discorb/utils.rb +12 -16
- data/lib/discorb/voice_state.rb +305 -281
- data/lib/discorb/webhook.rb +537 -507
- data/lib/discorb.rb +62 -56
- data/sig/discorb/application.rbs +2 -0
- data/sig/discorb/automod.rbs +10 -1
- data/sig/discorb/guild.rbs +2 -0
- data/sig/discorb/message.rbs +2 -0
- data/sig/discorb/user.rbs +22 -20
- metadata +2 -2
data/lib/discorb/event.rb
CHANGED
@@ -1,314 +1,360 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Discorb
|
4
|
-
#
|
5
|
-
# Represents an event in guild.
|
6
|
-
#
|
7
|
-
class ScheduledEvent < DiscordModel
|
8
|
-
# @private
|
9
|
-
# @return [{Integer => Symbol}] The mapping of privacy level.
|
10
|
-
PRIVACY_LEVEL = {
|
11
|
-
|
12
|
-
}.
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
}.
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
# @return [
|
65
|
-
attr_reader :
|
66
|
-
|
67
|
-
|
68
|
-
# @return [
|
69
|
-
attr_reader :
|
70
|
-
# @return [
|
71
|
-
attr_reader :
|
72
|
-
# @return [
|
73
|
-
attr_reader :
|
74
|
-
|
75
|
-
|
76
|
-
#
|
77
|
-
|
78
|
-
#
|
79
|
-
|
80
|
-
|
81
|
-
#
|
82
|
-
#
|
83
|
-
#
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
#
|
108
|
-
#
|
109
|
-
# @
|
110
|
-
#
|
111
|
-
# @param [
|
112
|
-
# @param [
|
113
|
-
# @param [
|
114
|
-
#
|
115
|
-
# @
|
116
|
-
#
|
117
|
-
# @
|
118
|
-
# @
|
119
|
-
# @
|
120
|
-
#
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
channel_id: channel&.id,
|
150
|
-
entity_type:
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
#
|
226
|
-
#
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
#
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
#
|
242
|
-
#
|
243
|
-
# @
|
244
|
-
#
|
245
|
-
# @
|
246
|
-
#
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Discorb
|
4
|
+
#
|
5
|
+
# Represents an event in guild.
|
6
|
+
#
|
7
|
+
class ScheduledEvent < DiscordModel
|
8
|
+
# @private
|
9
|
+
# @return [{Integer => Symbol}] The mapping of privacy level.
|
10
|
+
PRIVACY_LEVEL = { 2 => :guild_only }.freeze
|
11
|
+
# @private
|
12
|
+
# @return [{Integer => Symbol}] The mapping of status.
|
13
|
+
STATUS = {
|
14
|
+
1 => :scheduled,
|
15
|
+
2 => :active,
|
16
|
+
3 => :completed,
|
17
|
+
4 => :canceled
|
18
|
+
}.freeze
|
19
|
+
# @private
|
20
|
+
# @return [{Integer => Symbol}] The mapping of entity_type.
|
21
|
+
ENTITY_TYPE = { 1 => :stage_instance, 2 => :voice, 3 => :external }.freeze
|
22
|
+
|
23
|
+
# @!visibility private
|
24
|
+
def initialize(client, data)
|
25
|
+
@client = client
|
26
|
+
@data = data
|
27
|
+
_set_data(data)
|
28
|
+
end
|
29
|
+
|
30
|
+
#
|
31
|
+
# Represents the metadata of the event.
|
32
|
+
#
|
33
|
+
class Metadata
|
34
|
+
# @return [String, nil] The location of the event. Only present if the event is a external event.
|
35
|
+
attr_reader :location
|
36
|
+
|
37
|
+
# @!visibility private
|
38
|
+
def initialize(data)
|
39
|
+
@location = data[:location]
|
40
|
+
end
|
41
|
+
|
42
|
+
def inspect
|
43
|
+
"#<#{self.class.name} #{@name}>"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# @return [Discorb::Snowflake] The ID of the event.
|
48
|
+
attr_reader :id
|
49
|
+
# @return [String] The name of the event.
|
50
|
+
attr_reader :name
|
51
|
+
# @return [String] The description of the event.
|
52
|
+
attr_reader :description
|
53
|
+
|
54
|
+
# @return [Time] The time the event starts.
|
55
|
+
attr_reader :scheduled_start_time
|
56
|
+
alias start_time scheduled_start_time
|
57
|
+
alias start_at scheduled_start_time
|
58
|
+
# @return [Time] The time the event ends.
|
59
|
+
attr_reader :scheduled_end_time
|
60
|
+
alias end_time scheduled_end_time
|
61
|
+
alias end_at scheduled_end_time
|
62
|
+
# @return [:guild_only] The privacy level of the event.
|
63
|
+
attr_reader :privacy_level
|
64
|
+
# @return [:scheduled, :active, :completed, :canceled] The status of the event.
|
65
|
+
attr_reader :status
|
66
|
+
# @return [:stage_instance, :voice, :external] The type of the event.
|
67
|
+
attr_reader :entity_type
|
68
|
+
# @return [Discorb::Snowflake] The ID of the entity the event is for.
|
69
|
+
attr_reader :entity_id
|
70
|
+
# @return [Discorb::ScheduledEvent::Metadata] The metadata of the event.
|
71
|
+
attr_reader :metadata
|
72
|
+
# @return [Integer] The user count of the event.
|
73
|
+
attr_reader :user_count
|
74
|
+
|
75
|
+
# @!attribute [r] guild
|
76
|
+
# @return [Discorb::Guild, nil] The guild of the event.
|
77
|
+
# @!attribute [r] channel
|
78
|
+
# @return [Discorb::Channel, nil] The channel of the event.
|
79
|
+
# Only present if the event will do in stage instance or voice channel.
|
80
|
+
# @!attribute [r] creator
|
81
|
+
# @return [Discorb::User] The user who created the event.#
|
82
|
+
# @!attribute [r] time
|
83
|
+
# @return [Range<Time>] The time range of the event.
|
84
|
+
|
85
|
+
def guild
|
86
|
+
@client.guilds[@guild_id]
|
87
|
+
end
|
88
|
+
|
89
|
+
def channel
|
90
|
+
@client.channels[@channel_id]
|
91
|
+
end
|
92
|
+
|
93
|
+
def creator
|
94
|
+
@creator || @client.users[@creator_id]
|
95
|
+
end
|
96
|
+
|
97
|
+
def time
|
98
|
+
@scheduled_start_time..@scheduled_end_time
|
99
|
+
end
|
100
|
+
|
101
|
+
#
|
102
|
+
# Create a scheduled event for the guild.
|
103
|
+
# @async
|
104
|
+
#
|
105
|
+
# @param [:stage_instance, :voice, :external] type The type of event to create.
|
106
|
+
# @param [String] name The name of the event.
|
107
|
+
# @param [String] description The description of the event.
|
108
|
+
# @param [Time] start_time The start time of the event.
|
109
|
+
# @param [Time, nil] end_time The end time of the event. Defaults to `nil`.
|
110
|
+
# @param [Discorb::Channel, Discorb::Snowflake, nil] channel The channel to run the event in.
|
111
|
+
# @param [String, nil] location The location of the event. Defaults to `nil`.
|
112
|
+
# @param [:guild_only] privacy_level The privacy level of the event. This must be `:guild_only`.
|
113
|
+
# @param [:active, :completed, :canceled] status The status of the event.
|
114
|
+
#
|
115
|
+
# @return [Async::Task<Discorb::ScheduledEvent>] The event that was created.
|
116
|
+
#
|
117
|
+
# @see Event#start
|
118
|
+
# @see Event#cancel
|
119
|
+
# @see Event#complete
|
120
|
+
#
|
121
|
+
def edit(
|
122
|
+
type: Discorb::Unset,
|
123
|
+
name: Discorb::Unset,
|
124
|
+
description: Discorb::Unset,
|
125
|
+
start_time: Discorb::Unset,
|
126
|
+
end_time: Discorb::Unset,
|
127
|
+
privacy_level: Discorb::Unset,
|
128
|
+
location: Discorb::Unset,
|
129
|
+
channel: Discorb::Unset,
|
130
|
+
status: Discorb::Unset
|
131
|
+
)
|
132
|
+
Async do
|
133
|
+
payload =
|
134
|
+
case type == Discorb::Unset ? @entity_type : type
|
135
|
+
when :stage_instance
|
136
|
+
unless channel
|
137
|
+
raise ArgumentError,
|
138
|
+
"channel must be provided for stage_instance events"
|
139
|
+
end
|
140
|
+
|
141
|
+
{
|
142
|
+
name: name,
|
143
|
+
description: description,
|
144
|
+
scheduled_start_time: start_time.iso8601,
|
145
|
+
scheduled_end_time: end_time&.iso8601,
|
146
|
+
privacy_level:
|
147
|
+
Discorb::ScheduledEvent::PRIVACY_LEVEL.key(privacy_level) ||
|
148
|
+
Discorb::Unset,
|
149
|
+
channel_id: channel&.id,
|
150
|
+
entity_type:
|
151
|
+
Discorb::ScheduledEvent::ENTITY_TYPE.key(:stage_instance),
|
152
|
+
status:
|
153
|
+
Discorb::ScheduledEvent::STATUS.key(status) || Discorb::Unset
|
154
|
+
}.reject { |_, v| v == Discorb::Unset }
|
155
|
+
when :voice
|
156
|
+
unless channel
|
157
|
+
raise ArgumentError, "channel must be provided for voice events"
|
158
|
+
end
|
159
|
+
|
160
|
+
{
|
161
|
+
name: name,
|
162
|
+
description: description,
|
163
|
+
scheduled_start_time: start_time.iso8601,
|
164
|
+
scheduled_end_time: end_time&.iso8601,
|
165
|
+
privacy_level:
|
166
|
+
Discorb::ScheduledEvent::PRIVACY_LEVEL.key(privacy_level) ||
|
167
|
+
Discorb::Unset,
|
168
|
+
channel_id: channel&.id,
|
169
|
+
entity_type: Discorb::ScheduledEvent::ENTITY_TYPE.key(:voice),
|
170
|
+
status:
|
171
|
+
Discorb::ScheduledEvent::STATUS.key(status) || Discorb::Unset
|
172
|
+
}.reject { |_, v| v == Discorb::Unset }
|
173
|
+
when :external
|
174
|
+
unless location
|
175
|
+
raise ArgumentError,
|
176
|
+
"location must be provided for external events"
|
177
|
+
end
|
178
|
+
unless end_time
|
179
|
+
raise ArgumentError,
|
180
|
+
"end_time must be provided for external events"
|
181
|
+
end
|
182
|
+
|
183
|
+
{
|
184
|
+
name: name,
|
185
|
+
description: description,
|
186
|
+
channel_id: nil,
|
187
|
+
scheduled_start_time: start_time.iso8601,
|
188
|
+
scheduled_end_time: end_time.iso8601,
|
189
|
+
privacy_level:
|
190
|
+
Discorb::ScheduledEvent::PRIVACY_LEVEL.key(privacy_level) ||
|
191
|
+
Discorb::Unset,
|
192
|
+
entity_type: Discorb::ScheduledEvent::ENTITY_TYPE.key(:external),
|
193
|
+
entity_metadata: {
|
194
|
+
location: location
|
195
|
+
},
|
196
|
+
status:
|
197
|
+
Discorb::ScheduledEvent::STATUS.key(status) || Discorb::Unset
|
198
|
+
}.reject { |_, v| v == Discorb::Unset }
|
199
|
+
else
|
200
|
+
raise ArgumentError, "Invalid scheduled event type: #{type}"
|
201
|
+
end
|
202
|
+
@client
|
203
|
+
.http
|
204
|
+
.request(
|
205
|
+
Route.new(
|
206
|
+
"/guilds/#{@guild_id}/scheduled-events/#{@id}",
|
207
|
+
"//guilds/:guild_id/scheduled-events/:scheduled_event_id",
|
208
|
+
:patch
|
209
|
+
),
|
210
|
+
payload
|
211
|
+
)
|
212
|
+
.wait
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
alias modify edit
|
217
|
+
|
218
|
+
#
|
219
|
+
# Starts the event. Shortcut for `edit(status: :active)`.
|
220
|
+
#
|
221
|
+
def start
|
222
|
+
edit(status: :active)
|
223
|
+
end
|
224
|
+
|
225
|
+
#
|
226
|
+
# Completes the event. Shortcut for `edit(status: :completed)`.
|
227
|
+
#
|
228
|
+
def complete
|
229
|
+
edit(status: :completed)
|
230
|
+
end
|
231
|
+
|
232
|
+
alias finish complete
|
233
|
+
|
234
|
+
#
|
235
|
+
# Cancels the event. Shortcut for `edit(status: :canceled)`.
|
236
|
+
#
|
237
|
+
def cancel
|
238
|
+
edit(status: :canceled)
|
239
|
+
end
|
240
|
+
|
241
|
+
#
|
242
|
+
# Deletes the event.
|
243
|
+
# @async
|
244
|
+
#
|
245
|
+
# @return [Async::Task<void>] The task.
|
246
|
+
#
|
247
|
+
def delete
|
248
|
+
Async do
|
249
|
+
@client
|
250
|
+
.http
|
251
|
+
.request(
|
252
|
+
Route.new(
|
253
|
+
"/guilds/#{@guild_id}/scheduled-events/#{@id}",
|
254
|
+
"//guilds/:guild_id/scheduled-events/:scheduled_event_id",
|
255
|
+
:delete
|
256
|
+
)
|
257
|
+
)
|
258
|
+
.wait
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
alias destroy delete
|
263
|
+
|
264
|
+
#
|
265
|
+
# Fetches the event users.
|
266
|
+
# @async
|
267
|
+
#
|
268
|
+
# @note You can fetch all of members by not specifying a parameter.
|
269
|
+
#
|
270
|
+
# @param [Integer] limit The maximum number of users to fetch. Defaults to `100`.
|
271
|
+
# @param [#to_s] after The ID of the user to start fetching from. Defaults to `nil`.
|
272
|
+
# @param [#to_s] before The ID of the user to stop fetching at. Defaults to `nil`.
|
273
|
+
# @param [Boolean] with_member Whether to include the member object of the event. Defaults to `false`.
|
274
|
+
# This should be used for manual fetching of members.
|
275
|
+
#
|
276
|
+
# @return [Async::Task<Array<Discorb::Member>>] The event users.
|
277
|
+
#
|
278
|
+
def fetch_users(limit = nil, before: nil, after: nil, with_member: true)
|
279
|
+
Async do
|
280
|
+
if limit.nil?
|
281
|
+
after = 0
|
282
|
+
res = []
|
283
|
+
loop do
|
284
|
+
_resp, users =
|
285
|
+
@client
|
286
|
+
.http
|
287
|
+
.request(
|
288
|
+
Route.new(
|
289
|
+
"/guilds/#{@guild_id}/scheduled-events/#{@id}/users?limit=100&after=#{after}&with_member=true",
|
290
|
+
"//guilds/:guild_id/scheduled-events/:scheduled_event_id/users",
|
291
|
+
:get
|
292
|
+
)
|
293
|
+
)
|
294
|
+
.wait
|
295
|
+
break if users.empty?
|
296
|
+
|
297
|
+
res +=
|
298
|
+
users.map do |u|
|
299
|
+
Member.new(@client, @guild_id, u[:user], u[:member])
|
300
|
+
end
|
301
|
+
after = users.last[:user][:id]
|
302
|
+
end
|
303
|
+
res
|
304
|
+
else
|
305
|
+
params =
|
306
|
+
{
|
307
|
+
limit: limit,
|
308
|
+
before: Discorb::Utils.try(before, :id),
|
309
|
+
after: Discorb::Utils.try(after, :id),
|
310
|
+
with_member: with_member
|
311
|
+
}.filter { |_k, v| !v.nil? }.to_h
|
312
|
+
_resp, messages =
|
313
|
+
@client
|
314
|
+
.http
|
315
|
+
.request(
|
316
|
+
Route.new(
|
317
|
+
"/channels/#{channel_id.wait}/messages?#{URI.encode_www_form(params)}",
|
318
|
+
"//channels/:channel_id/messages",
|
319
|
+
:get
|
320
|
+
)
|
321
|
+
)
|
322
|
+
.wait
|
323
|
+
messages.map do |m|
|
324
|
+
Message.new(@client, m.merge({ guild_id: @guild_id.to_s }))
|
325
|
+
end
|
326
|
+
end
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
alias fetch_members fetch_users
|
331
|
+
|
332
|
+
private
|
333
|
+
|
334
|
+
def _set_data(data)
|
335
|
+
@id = Snowflake.new(data[:id])
|
336
|
+
@guild_id = Snowflake.new(data[:guild_id])
|
337
|
+
@channel_id = data[:channel_id] && Snowflake.new(data[:channel_id])
|
338
|
+
@creator_id = data[:creator_id] && Snowflake.new(data[:creator_id])
|
339
|
+
@name = data[:name]
|
340
|
+
@description = data[:description]
|
341
|
+
@scheduled_start_time = Time.iso8601(data[:scheduled_start_time])
|
342
|
+
@scheduled_end_time =
|
343
|
+
data[:scheduled_end_time] && Time.iso8601(data[:scheduled_end_time])
|
344
|
+
@privacy_level = :guild_only # data[:privacy_level]
|
345
|
+
@status = STATUS[data[:status]]
|
346
|
+
@entity_type = ENTITY_TYPE[data[:entity_type]]
|
347
|
+
@entity_id = data[:entity_id] && Snowflake.new(data[:entity_id])
|
348
|
+
@entity_metadata =
|
349
|
+
data[:entity_metadata] && Metadata.new(data[:entity_metadata])
|
350
|
+
@creator =
|
351
|
+
@client.users[@creator_id] ||
|
352
|
+
(data[:creator] && User.new(@client, data[:creator]))
|
353
|
+
@user_count = data[:user_count]
|
354
|
+
end
|
355
|
+
|
356
|
+
class << self
|
357
|
+
attr_reader :status, :entity_type, :privacy_level
|
358
|
+
end
|
359
|
+
end
|
360
|
+
end
|