discorb 0.0.4 → 0.0.8
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.
- checksums.yaml +4 -4
- data/Changelog.md +14 -2
- data/Gemfile.lock +1 -1
- data/README.md +4 -3
- data/discorb.gemspec +3 -3
- data/docs/events.md +50 -54
- data/docs/voice_events.md +32 -32
- data/examples/components/authorization_button.rb +2 -2
- data/examples/components/select_menu.rb +2 -2
- data/examples/extension/message_expander.rb +1 -1
- data/examples/simple/eval.rb +2 -2
- data/examples/simple/ping_pong.rb +1 -1
- data/examples/simple/rolepanel.rb +3 -3
- data/examples/simple/wait_for_message.rb +1 -1
- data/lib/discorb/channel.rb +36 -32
- data/lib/discorb/client.rb +11 -11
- data/lib/discorb/common.rb +1 -1
- data/lib/discorb/emoji.rb +2 -2
- data/lib/discorb/gateway.rb +10 -8
- data/lib/discorb/guild.rb +38 -38
- data/lib/discorb/guild_template.rb +3 -3
- data/lib/discorb/{internet.rb → http.rb} +2 -2
- data/lib/discorb/integration.rb +1 -1
- data/lib/discorb/interaction.rb +6 -6
- data/lib/discorb/invite.rb +1 -1
- data/lib/discorb/member.rb +3 -3
- data/lib/discorb/message.rb +11 -11
- data/lib/discorb/modules.rb +7 -7
- data/lib/discorb/role.rb +3 -3
- data/lib/discorb/sticker.rb +2 -2
- data/lib/discorb/user.rb +2 -2
- data/lib/discorb/voice_state.rb +2 -2
- data/lib/discorb/webhook.rb +11 -13
- data/lib/discorb.rb +1 -1
- metadata +6 -6
data/docs/voice_events.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
### Voice Channel Events
|
6
6
|
|
7
|
-
#### `voice_channel_connect(
|
7
|
+
#### `voice_channel_connect(state)`
|
8
8
|
|
9
9
|
Fires when someone joins a voice channel.
|
10
10
|
|
@@ -12,7 +12,7 @@ Fires when someone joins a voice channel.
|
|
12
12
|
| --- | --- | --- |
|
13
13
|
| state | {Discorb::VoiceState} | The voice state of the user that joined. |
|
14
14
|
|
15
|
-
#### `voice_channel_disconnect(
|
15
|
+
#### `voice_channel_disconnect(state)`
|
16
16
|
|
17
17
|
Fires when someone leaves a voice channel.
|
18
18
|
|
@@ -20,7 +20,7 @@ Fires when someone leaves a voice channel.
|
|
20
20
|
| --- | --- | --- |
|
21
21
|
| state | {Discorb::VoiceState} | The voice state of the user that left. |
|
22
22
|
|
23
|
-
#### `voice_channel_move(
|
23
|
+
#### `voice_channel_move(before, after)`
|
24
24
|
|
25
25
|
Fires when someone moves to a different voice channel.
|
26
26
|
|
@@ -29,7 +29,7 @@ Fires when someone moves to a different voice channel.
|
|
29
29
|
| before | {Discorb::VoiceState} | The voice state of the user before the move. |
|
30
30
|
| after | {Discorb::VoiceState} | The voice state of the user after the move. |
|
31
31
|
|
32
|
-
#### `voice_channel_update(
|
32
|
+
#### `voice_channel_update(before, after)`
|
33
33
|
|
34
34
|
Fires when a voice channel is connected, disconnected, or updated.
|
35
35
|
|
@@ -40,7 +40,7 @@ Fires when a voice channel is connected, disconnected, or updated.
|
|
40
40
|
|
41
41
|
### Mute Events
|
42
42
|
|
43
|
-
#### `voice_mute_disable(
|
43
|
+
#### `voice_mute_disable(state)`
|
44
44
|
|
45
45
|
Fires when a user's voice mute is disabled.
|
46
46
|
|
@@ -48,7 +48,7 @@ Fires when a user's voice mute is disabled.
|
|
48
48
|
| --- | --- | --- |
|
49
49
|
| `state` | {Discorb::VoiceState} | The voice state. |
|
50
50
|
|
51
|
-
#### `voice_mute_enable(
|
51
|
+
#### `voice_mute_enable(state)`
|
52
52
|
|
53
53
|
Fires when a user's voice mute is enabled.
|
54
54
|
|
@@ -56,7 +56,7 @@ Fires when a user's voice mute is enabled.
|
|
56
56
|
| --- | --- | --- |
|
57
57
|
| `state` | {Discorb::VoiceState} | The voice state. |
|
58
58
|
|
59
|
-
#### `voice_mute_update(
|
59
|
+
#### `voice_mute_update(before, after)`
|
60
60
|
|
61
61
|
Fires when a user's voice mute is enabled or disabled.
|
62
62
|
|
@@ -65,7 +65,7 @@ Fires when a user's voice mute is enabled or disabled.
|
|
65
65
|
| `before` | {Discorb::VoiceState} | The voice state before the update. |
|
66
66
|
| `after` | {Discorb::VoiceState} | The voice state after the update. |
|
67
67
|
|
68
|
-
#### `voice_server_mute_enable(
|
68
|
+
#### `voice_server_mute_enable(state)`
|
69
69
|
|
70
70
|
Fires when a user's server voice mute is enabled.
|
71
71
|
|
@@ -73,7 +73,7 @@ Fires when a user's server voice mute is enabled.
|
|
73
73
|
| --- | --- | --- |
|
74
74
|
| `state` | {Discorb::VoiceState} | The voice state. |
|
75
75
|
|
76
|
-
#### `voice_server_mute_disable(
|
76
|
+
#### `voice_server_mute_disable(state)`
|
77
77
|
|
78
78
|
Fires when a user's server voice mute is disabled.
|
79
79
|
|
@@ -81,7 +81,7 @@ Fires when a user's server voice mute is disabled.
|
|
81
81
|
| --- | --- | --- |
|
82
82
|
| `state` | {Discorb::VoiceState} | The voice state. |
|
83
83
|
|
84
|
-
#### `voice_server_mute_update(
|
84
|
+
#### `voice_server_mute_update(before, after)`
|
85
85
|
|
86
86
|
Fires when a user's server voice mute is enabled or disabled.
|
87
87
|
|
@@ -90,7 +90,7 @@ Fires when a user's server voice mute is enabled or disabled.
|
|
90
90
|
| `before` | {Discorb::VoiceState} | The voice state before the update. |
|
91
91
|
| `after` | {Discorb::VoiceState} | The voice state after the update. |
|
92
92
|
|
93
|
-
#### `voice_self_mute_enable(
|
93
|
+
#### `voice_self_mute_enable(state)`
|
94
94
|
|
95
95
|
Fires when a user's self voice mute is enabled.
|
96
96
|
|
@@ -98,7 +98,7 @@ Fires when a user's self voice mute is enabled.
|
|
98
98
|
| --- | --- | --- |
|
99
99
|
| `state` | {Discorb::VoiceState} | The voice state. |
|
100
100
|
|
101
|
-
#### `voice_self_mute_disable(
|
101
|
+
#### `voice_self_mute_disable(state)`
|
102
102
|
|
103
103
|
Fires when a user's self voice mute is disabled.
|
104
104
|
|
@@ -106,7 +106,7 @@ Fires when a user's self voice mute is disabled.
|
|
106
106
|
| --- | --- | --- |
|
107
107
|
| `state` | {Discorb::VoiceState} | The voice state. |
|
108
108
|
|
109
|
-
#### `voice_self_mute_update(
|
109
|
+
#### `voice_self_mute_update(before, after)`
|
110
110
|
|
111
111
|
Fires when a user's self voice mute is enabled or disabled.
|
112
112
|
|
@@ -117,7 +117,7 @@ Fires when a user's self voice mute is enabled or disabled.
|
|
117
117
|
|
118
118
|
### Deaf Events
|
119
119
|
|
120
|
-
#### `voice_deaf_enable(
|
120
|
+
#### `voice_deaf_enable(state)`
|
121
121
|
|
122
122
|
Fires when a user's voice deaf is enabled.
|
123
123
|
|
@@ -125,7 +125,7 @@ Fires when a user's voice deaf is enabled.
|
|
125
125
|
| --- | --- | --- |
|
126
126
|
| `state` | {Discorb::VoiceState} | The voice state. |
|
127
127
|
|
128
|
-
#### `voice_deaf_disable(
|
128
|
+
#### `voice_deaf_disable(state)`
|
129
129
|
|
130
130
|
Fires when a user's voice deaf is disabled.
|
131
131
|
|
@@ -133,7 +133,7 @@ Fires when a user's voice deaf is disabled.
|
|
133
133
|
| --- | --- | --- |
|
134
134
|
| `state` | {Discorb::VoiceState} | The voice state. |
|
135
135
|
|
136
|
-
#### `voice_deaf_update(
|
136
|
+
#### `voice_deaf_update(before, after)`
|
137
137
|
|
138
138
|
Fires when a user's voice deaf is enabled or disabled.
|
139
139
|
|
@@ -142,7 +142,7 @@ Fires when a user's voice deaf is enabled or disabled.
|
|
142
142
|
| `before` | {Discorb::VoiceState} | The voice state before the update. |
|
143
143
|
| `after` | {Discorb::VoiceState} | The voice state after the update. |
|
144
144
|
|
145
|
-
#### `voice_server_deaf_enable(
|
145
|
+
#### `voice_server_deaf_enable(state)`
|
146
146
|
|
147
147
|
Fires when a user's server voice deaf is enabled.
|
148
148
|
|
@@ -150,7 +150,7 @@ Fires when a user's server voice deaf is enabled.
|
|
150
150
|
| --- | --- | --- |
|
151
151
|
| `state` | {Discorb::VoiceState} | The voice state. |
|
152
152
|
|
153
|
-
#### `voice_server_deaf_disable(
|
153
|
+
#### `voice_server_deaf_disable(state)`
|
154
154
|
|
155
155
|
Fires when a user's server voice deaf is disabled.
|
156
156
|
|
@@ -158,7 +158,7 @@ Fires when a user's server voice deaf is disabled.
|
|
158
158
|
| --- | --- | --- |
|
159
159
|
| `state` | {Discorb::VoiceState} | The voice state. |
|
160
160
|
|
161
|
-
#### `voice_server_deaf_update(
|
161
|
+
#### `voice_server_deaf_update(before, after)`
|
162
162
|
|
163
163
|
Fires when a user's server voice deaf is enabled or disabled.
|
164
164
|
|
@@ -167,7 +167,7 @@ Fires when a user's server voice deaf is enabled or disabled.
|
|
167
167
|
| `before` | {Discorb::VoiceState} | The voice state before the update. |
|
168
168
|
| `after` | {Discorb::VoiceState} | The voice state after the update. |
|
169
169
|
|
170
|
-
#### `voice_self_deaf_enable(
|
170
|
+
#### `voice_self_deaf_enable(state)`
|
171
171
|
|
172
172
|
Fires when a user's self voice deaf is enabled.
|
173
173
|
|
@@ -175,7 +175,7 @@ Fires when a user's self voice deaf is enabled.
|
|
175
175
|
| --- | --- | --- |
|
176
176
|
| `state` | {Discorb::VoiceState} | The voice state. |
|
177
177
|
|
178
|
-
#### `voice_self_deaf_disable(
|
178
|
+
#### `voice_self_deaf_disable(state)`
|
179
179
|
|
180
180
|
Fires when a user's self voice deaf is disabled.
|
181
181
|
|
@@ -183,7 +183,7 @@ Fires when a user's self voice deaf is disabled.
|
|
183
183
|
| --- | --- | --- |
|
184
184
|
| `state` | {Discorb::VoiceState} | The voice state. |
|
185
185
|
|
186
|
-
#### `voice_self_deaf_update(
|
186
|
+
#### `voice_self_deaf_update(before, after)`
|
187
187
|
|
188
188
|
| Parameter | Type | Description |
|
189
189
|
| --- | --- | --- |
|
@@ -192,7 +192,7 @@ Fires when a user's self voice deaf is disabled.
|
|
192
192
|
|
193
193
|
### Stream Events
|
194
194
|
|
195
|
-
#### `voice_stream_start(
|
195
|
+
#### `voice_stream_start(state)`
|
196
196
|
|
197
197
|
Fires when a stream is started.
|
198
198
|
|
@@ -200,7 +200,7 @@ Fires when a stream is started.
|
|
200
200
|
| --- | --- | --- |
|
201
201
|
| `state` | {Discorb::VoiceState} | The voice state. |
|
202
202
|
|
203
|
-
#### `voice_stream_end(
|
203
|
+
#### `voice_stream_end(state)`
|
204
204
|
|
205
205
|
Fires when a stream is ended.
|
206
206
|
|
@@ -208,7 +208,7 @@ Fires when a stream is ended.
|
|
208
208
|
| --- | --- | --- |
|
209
209
|
| `state` | {Discorb::VoiceState} | The voice state. |
|
210
210
|
|
211
|
-
#### `voice_stream_update(
|
211
|
+
#### `voice_stream_update(before, after)`
|
212
212
|
|
213
213
|
Fires when a stream is started or ended.
|
214
214
|
|
@@ -219,7 +219,7 @@ Fires when a stream is started or ended.
|
|
219
219
|
|
220
220
|
### Video Events
|
221
221
|
|
222
|
-
#### `voice_video_start(
|
222
|
+
#### `voice_video_start(state)`
|
223
223
|
|
224
224
|
Fires when a video is started.
|
225
225
|
|
@@ -227,7 +227,7 @@ Fires when a video is started.
|
|
227
227
|
| --- | --- | --- |
|
228
228
|
| `state` | {Discorb::VoiceState} | The voice state. |
|
229
229
|
|
230
|
-
#### `voice_video_end(
|
230
|
+
#### `voice_video_end(state)`
|
231
231
|
|
232
232
|
Fires when a video is ended.
|
233
233
|
|
@@ -235,7 +235,7 @@ Fires when a video is ended.
|
|
235
235
|
| --- | --- | --- |
|
236
236
|
| `state` | {Discorb::VoiceState} | The voice state. |
|
237
237
|
|
238
|
-
#### `voice_video_update(
|
238
|
+
#### `voice_video_update(before, after)`
|
239
239
|
|
240
240
|
Fires when a video is started or ended.
|
241
241
|
|
@@ -246,7 +246,7 @@ Fires when a video is started or ended.
|
|
246
246
|
|
247
247
|
### Stage Instances Events
|
248
248
|
|
249
|
-
#### `stage_instance_create(
|
249
|
+
#### `stage_instance_create(instance)`
|
250
250
|
|
251
251
|
Fires when a new stage instance is created.
|
252
252
|
|
@@ -254,7 +254,7 @@ Fires when a new stage instance is created.
|
|
254
254
|
| --- | --- | --- |
|
255
255
|
| `instance` | {Discorb::StageInstance} | The created instance. |
|
256
256
|
|
257
|
-
#### `stage_instance_delete(
|
257
|
+
#### `stage_instance_delete(instance)`
|
258
258
|
|
259
259
|
Fires when a stage instance is deleted.
|
260
260
|
|
@@ -262,7 +262,7 @@ Fires when a stage instance is deleted.
|
|
262
262
|
| --- | --- | --- |
|
263
263
|
| `instance` | {Discorb::StageInstance} | The deleted instance. |
|
264
264
|
|
265
|
-
#### `stage_instance_update(
|
265
|
+
#### `stage_instance_update(before, after)`
|
266
266
|
|
267
267
|
Fires when a stage instance is updated.
|
268
268
|
|
@@ -273,7 +273,7 @@ Fires when a stage instance is updated.
|
|
273
273
|
|
274
274
|
### Misc Events
|
275
275
|
|
276
|
-
#### `voice_state_update(
|
276
|
+
#### `voice_state_update(before, after)`
|
277
277
|
|
278
278
|
Fired when a user changes voice state.
|
279
279
|
|
@@ -12,7 +12,7 @@ client.once :ready do
|
|
12
12
|
puts "Logged in as #{client.user}"
|
13
13
|
end
|
14
14
|
|
15
|
-
client.on :message do |
|
15
|
+
client.on :message do |message|
|
16
16
|
next if message.author.bot?
|
17
17
|
next unless message.content.start_with?("!auth ")
|
18
18
|
|
@@ -32,7 +32,7 @@ client.on :message do |_task, message|
|
|
32
32
|
)
|
33
33
|
end
|
34
34
|
|
35
|
-
client.on :button_click do |
|
35
|
+
client.on :button_click do |response|
|
36
36
|
if response.custom_id.start_with?("auth:")
|
37
37
|
id = response.custom_id.delete_prefix("auth:")
|
38
38
|
response.fired_by.add_role(id).wait
|
@@ -36,7 +36,7 @@ client.once :ready do
|
|
36
36
|
puts "Logged in as #{client.user}"
|
37
37
|
end
|
38
38
|
|
39
|
-
client.on :message do |
|
39
|
+
client.on :message do |message|
|
40
40
|
next if message.author.bot?
|
41
41
|
next unless message.content == "!ruby"
|
42
42
|
|
@@ -46,7 +46,7 @@ client.on :message do |_task, message|
|
|
46
46
|
)
|
47
47
|
end
|
48
48
|
|
49
|
-
client.on :select_menu_select do |
|
49
|
+
client.on :select_menu_select do |response|
|
50
50
|
next unless response.custom_id == "sections"
|
51
51
|
|
52
52
|
id = response.value.delete_prefix("sections:")
|
@@ -8,7 +8,7 @@ module MessageExpander
|
|
8
8
|
"(?<guild>[0-9]{18})/(?<channel>[0-9]{18})/(?<message>[0-9]{18})(?!>)"
|
9
9
|
)
|
10
10
|
|
11
|
-
event :message do |
|
11
|
+
event :message do |message|
|
12
12
|
next if message.author.bot?
|
13
13
|
|
14
14
|
message.content.to_enum(:scan, @message_regex).map { Regexp.last_match }.each do |match|
|
data/examples/simple/eval.rb
CHANGED
@@ -2,11 +2,11 @@ require "discorb"
|
|
2
2
|
|
3
3
|
client = Discorb::Client.new
|
4
4
|
|
5
|
-
client.once :ready do
|
5
|
+
client.once :ready do
|
6
6
|
puts "Logged in as #{client.user}"
|
7
7
|
end
|
8
8
|
|
9
|
-
client.on :message do |
|
9
|
+
client.on :message do |message|
|
10
10
|
next if message.author.bot?
|
11
11
|
next unless message.content.start_with?("eval ")
|
12
12
|
|
@@ -13,7 +13,7 @@ client.once :ready do
|
|
13
13
|
puts "Logged in as #{client.user}"
|
14
14
|
end
|
15
15
|
|
16
|
-
client.on :reaction_add do |
|
16
|
+
client.on :reaction_add do |event|
|
17
17
|
next unless event.emoji.value.end_with?(0x0000fe0f.chr("utf-8") + 0x000020e3.chr("utf-8"))
|
18
18
|
next if event.member.bot?
|
19
19
|
|
@@ -28,7 +28,7 @@ client.on :reaction_add do |_task, event|
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
client.on :reaction_remove do |
|
31
|
+
client.on :reaction_remove do |event|
|
32
32
|
next unless event.emoji.value.end_with?(0x0000fe0f.chr("utf-8") + 0x000020e3.chr("utf-8"))
|
33
33
|
next if event.member.bot?
|
34
34
|
|
@@ -43,7 +43,7 @@ client.on :reaction_remove do |_task, event|
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
client.on :message do |
|
46
|
+
client.on :message do |message|
|
47
47
|
next unless message.content.start_with?("/rp ")
|
48
48
|
next if message.author.bot?
|
49
49
|
|
data/lib/discorb/channel.rb
CHANGED
@@ -175,7 +175,7 @@ module Discorb
|
|
175
175
|
#
|
176
176
|
def delete!(reason: nil)
|
177
177
|
Async do
|
178
|
-
@client.
|
178
|
+
@client.http.delete(base_url.wait.to_s, audit_log_reason: reason).wait
|
179
179
|
@deleted = true
|
180
180
|
self
|
181
181
|
end
|
@@ -203,7 +203,7 @@ module Discorb
|
|
203
203
|
}
|
204
204
|
payload[:lock_permissions] = lock_permissions
|
205
205
|
payload[:parent_id] = parent&.id if parent != :unset
|
206
|
-
@client.
|
206
|
+
@client.http.patch("/guilds/#{@guild_id}/channels", payload, audit_log_reason: reason).wait
|
207
207
|
end
|
208
208
|
end
|
209
209
|
|
@@ -295,7 +295,7 @@ module Discorb
|
|
295
295
|
default_auto_archive_duration ||= archive_in
|
296
296
|
payload[:default_auto_archive_duration] = default_auto_archive_duration if default_auto_archive_duration != :unset
|
297
297
|
|
298
|
-
@client.
|
298
|
+
@client.http.patch("/channels/#{@id}", payload, audit_log_reason: reason).wait
|
299
299
|
self
|
300
300
|
end
|
301
301
|
end
|
@@ -317,7 +317,7 @@ module Discorb
|
|
317
317
|
payload = {}
|
318
318
|
payload[:name] = name
|
319
319
|
payload[:avatar] = avatar.to_s if avatar
|
320
|
-
_resp, data = @client.
|
320
|
+
_resp, data = @client.http.post("/channels/#{@id}/webhooks", payload).wait
|
321
321
|
Webhook.new([@client, data])
|
322
322
|
end
|
323
323
|
end
|
@@ -331,7 +331,7 @@ module Discorb
|
|
331
331
|
#
|
332
332
|
def fetch_webhooks
|
333
333
|
Async do
|
334
|
-
_resp, data = @client.
|
334
|
+
_resp, data = @client.http.get("/channels/#{@id}/webhooks").wait
|
335
335
|
data.map { |webhook| Webhook.new([@client, webhook]) }
|
336
336
|
end
|
337
337
|
end
|
@@ -358,7 +358,7 @@ module Discorb
|
|
358
358
|
|
359
359
|
message_ids = messages.map { |m| Discorb::Utils.try(m, :id).to_s }
|
360
360
|
|
361
|
-
@client.
|
361
|
+
@client.http.post("/channels/#{@id}/messages/bulk-delete", { messages: message_ids }).wait
|
362
362
|
end
|
363
363
|
end
|
364
364
|
|
@@ -387,7 +387,7 @@ module Discorb
|
|
387
387
|
deny: deny_value,
|
388
388
|
type: target.is_a?(Member) ? 1 : 0,
|
389
389
|
}
|
390
|
-
@client.
|
390
|
+
@client.http.put("/channels/#{@id}/permissions/#{target.id}", payload, audit_log_reason: reason).wait
|
391
391
|
end
|
392
392
|
end
|
393
393
|
|
@@ -406,7 +406,7 @@ module Discorb
|
|
406
406
|
#
|
407
407
|
def delete_permissions(target, reason: nil)
|
408
408
|
Async do
|
409
|
-
@client.
|
409
|
+
@client.http.delete("/channels/#{@id}/permissions/#{target.id}", audit_log_reason: reason).wait
|
410
410
|
end
|
411
411
|
end
|
412
412
|
|
@@ -423,7 +423,7 @@ module Discorb
|
|
423
423
|
#
|
424
424
|
def fetch_invites
|
425
425
|
Async do
|
426
|
-
_resp, data = @client.
|
426
|
+
_resp, data = @client.http.get("/channels/#{@id}/invites").wait
|
427
427
|
data.map { |invite| Invite.new(@client, invite) }
|
428
428
|
end
|
429
429
|
end
|
@@ -444,7 +444,7 @@ module Discorb
|
|
444
444
|
#
|
445
445
|
def create_invite(max_age: nil, max_uses: nil, temporary: false, unique: false, reason: nil)
|
446
446
|
Async do
|
447
|
-
_resp, data = @client.
|
447
|
+
_resp, data = @client.http.post("/channels/#{@id}/invites", {
|
448
448
|
max_age: max_age,
|
449
449
|
max_uses: max_uses,
|
450
450
|
temporary: temporary,
|
@@ -464,7 +464,7 @@ module Discorb
|
|
464
464
|
#
|
465
465
|
def follow_from(target, reason: nil)
|
466
466
|
Async do
|
467
|
-
@client.
|
467
|
+
@client.http.post("/channels/#{target.id}/followers", { webhook_channel_id: @id }, audit_log_reason: reason).wait
|
468
468
|
end
|
469
469
|
end
|
470
470
|
|
@@ -478,7 +478,7 @@ module Discorb
|
|
478
478
|
#
|
479
479
|
def follow_to(target, reason: nil)
|
480
480
|
Async do
|
481
|
-
@client.
|
481
|
+
@client.http.post("/channels/#{@id}/followers", { webhook_channel_id: target.id }, audit_log_reason: reason).wait
|
482
482
|
end
|
483
483
|
end
|
484
484
|
|
@@ -491,7 +491,7 @@ module Discorb
|
|
491
491
|
#
|
492
492
|
def fetch_pins
|
493
493
|
Async do
|
494
|
-
_resp, data = @client.
|
494
|
+
_resp, data = @client.http.get("/channels/#{@id}/pins").wait
|
495
495
|
data.map { |pin| Message.new(@client, pin) }
|
496
496
|
end
|
497
497
|
end
|
@@ -506,7 +506,7 @@ module Discorb
|
|
506
506
|
#
|
507
507
|
def pin_message(message, reason: nil)
|
508
508
|
Async do
|
509
|
-
@client.
|
509
|
+
@client.http.put("/channels/#{@id}/pins/#{message.id}", {}, audit_log_reason: reason).wait
|
510
510
|
end
|
511
511
|
end
|
512
512
|
|
@@ -520,7 +520,7 @@ module Discorb
|
|
520
520
|
#
|
521
521
|
def unpin_message(message, reason: nil)
|
522
522
|
Async do
|
523
|
-
@client.
|
523
|
+
@client.http.delete("/channels/#{@id}/pins/#{message.id}", {}, audit_log_reason: reason).wait
|
524
524
|
end
|
525
525
|
end
|
526
526
|
|
@@ -540,12 +540,12 @@ module Discorb
|
|
540
540
|
def start_thread(name, message: nil, auto_archive_duration: 1440, public: true, reason: nil)
|
541
541
|
Async do
|
542
542
|
_resp, data = if message.nil?
|
543
|
-
@client.
|
543
|
+
@client.http.post("/channels/#{@id}/threads", {
|
544
544
|
name: name, auto_archive_duration: auto_archive_duration, type: public ? 11 : 10,
|
545
545
|
},
|
546
|
-
|
546
|
+
audit_log_reason: reason).wait
|
547
547
|
else
|
548
|
-
@client.
|
548
|
+
@client.http.post("/channels/#{@id}/messages/#{Utils.try(message, :id)}/threads", {
|
549
549
|
name: name, auto_archive_duration: auto_archive_duration,
|
550
550
|
}, audit_log_reason: reason).wait
|
551
551
|
end
|
@@ -564,7 +564,7 @@ module Discorb
|
|
564
564
|
#
|
565
565
|
def fetch_archived_public_threads
|
566
566
|
Async do
|
567
|
-
_resp, data = @client.
|
567
|
+
_resp, data = @client.http.get("/channels/#{@id}/threads/archived/public").wait
|
568
568
|
data.map { |thread| Channel.make_channel(@client, thread) }
|
569
569
|
end
|
570
570
|
end
|
@@ -578,7 +578,7 @@ module Discorb
|
|
578
578
|
#
|
579
579
|
def fetch_archived_private_threads
|
580
580
|
Async do
|
581
|
-
_resp, data = @client.
|
581
|
+
_resp, data = @client.http.get("/channels/#{@id}/threads/archived/private").wait
|
582
582
|
data.map { |thread| Channel.make_channel(@client, thread) }
|
583
583
|
end
|
584
584
|
end
|
@@ -599,7 +599,7 @@ module Discorb
|
|
599
599
|
before = 0
|
600
600
|
threads = []
|
601
601
|
loop do
|
602
|
-
_resp, data = @client.
|
602
|
+
_resp, data = @client.http.get("/channels/#{@id}/users/@me/threads/archived/private?before=#{before}").wait
|
603
603
|
threads += data[:threads].map { |thread| Channel.make_channel(@client, thread) }
|
604
604
|
before = data[:threads][-1][:id]
|
605
605
|
|
@@ -607,7 +607,7 @@ module Discorb
|
|
607
607
|
end
|
608
608
|
threads
|
609
609
|
else
|
610
|
-
_resp, data = @client.
|
610
|
+
_resp, data = @client.http.get("/channels/#{@id}/users/@me/threads/archived/private?limit=#{limit}&before=#{before}").wait
|
611
611
|
data.map { |thread| Channel.make_channel(@client, thread) }
|
612
612
|
end
|
613
613
|
end
|
@@ -670,7 +670,7 @@ module Discorb
|
|
670
670
|
payload[:user_limit] = user_limit if user_limit != :unset
|
671
671
|
payload[:rtc_region] = rtc_region if rtc_region != :unset
|
672
672
|
|
673
|
-
@client.
|
673
|
+
@client.http.patch("/channels/#{@id}", payload, audit_log_reason: reason).wait
|
674
674
|
self
|
675
675
|
end
|
676
676
|
end
|
@@ -734,7 +734,7 @@ module Discorb
|
|
734
734
|
payload[:position] = position if position != :unset
|
735
735
|
payload[:bitrate] = bitrate if bitrate != :unset
|
736
736
|
payload[:rtc_region] = rtc_region if rtc_region != :unset
|
737
|
-
@client.
|
737
|
+
@client.http.patch("/channels/#{@id}", payload, audit_log_reason: reason).wait
|
738
738
|
self
|
739
739
|
end
|
740
740
|
end
|
@@ -754,7 +754,7 @@ module Discorb
|
|
754
754
|
#
|
755
755
|
def start(topic, public: false, reason: nil)
|
756
756
|
Async do
|
757
|
-
_resp, data = @client.
|
757
|
+
_resp, data = @client.http.post("/stage-instances", { channel_id: @id, topic: topic, public: public ? 2 : 1 }, audit_log_reason: reason).wait
|
758
758
|
StageInstance.new(@client, data)
|
759
759
|
end
|
760
760
|
end
|
@@ -769,7 +769,7 @@ module Discorb
|
|
769
769
|
#
|
770
770
|
def fetch_stage_instance
|
771
771
|
Async do
|
772
|
-
_resp, data = @client.
|
772
|
+
_resp, data = @client.http.get("/stage-instances/#{@id}").wait
|
773
773
|
rescue Discorb::NotFoundError
|
774
774
|
nil
|
775
775
|
else
|
@@ -865,7 +865,7 @@ module Discorb
|
|
865
865
|
auto_archive_duration ||= archive_in
|
866
866
|
payload[:auto_archive_duration] = auto_archive_duration if auto_archive_duration != :unset
|
867
867
|
payload[:locked] = locked if locked != :unset
|
868
|
-
@client.
|
868
|
+
@client.http.patch("/channels/#{@id}", payload, audit_log_reason: reason).wait
|
869
869
|
self
|
870
870
|
end
|
871
871
|
end
|
@@ -947,9 +947,9 @@ module Discorb
|
|
947
947
|
def add_member(member = :me)
|
948
948
|
Async do
|
949
949
|
if member == :me
|
950
|
-
@client.
|
950
|
+
@client.http.post("/channels/#{@id}/thread-members/@me").wait
|
951
951
|
else
|
952
|
-
@client.
|
952
|
+
@client.http.post("/channels/#{@id}/thread-members/#{Utils.try(member, :id)}").wait
|
953
953
|
end
|
954
954
|
end
|
955
955
|
end
|
@@ -959,9 +959,9 @@ module Discorb
|
|
959
959
|
def remove_member(member = :me)
|
960
960
|
Async do
|
961
961
|
if member == :me
|
962
|
-
@client.
|
962
|
+
@client.http.delete("/channels/#{@id}/thread-members/@me").wait
|
963
963
|
else
|
964
|
-
@client.
|
964
|
+
@client.http.delete("/channels/#{@id}/thread-members/#{Utils.try(member, :id)}").wait
|
965
965
|
end
|
966
966
|
end
|
967
967
|
end
|
@@ -970,11 +970,15 @@ module Discorb
|
|
970
970
|
|
971
971
|
def fetch_members
|
972
972
|
Async do
|
973
|
-
_resp, data = @client.
|
973
|
+
_resp, data = @client.http.get("/channels/#{@id}/thread-members").wait
|
974
974
|
data.map { |d| @members[d[:id]] = Member.new(@client, d) }
|
975
975
|
end
|
976
976
|
end
|
977
977
|
|
978
|
+
class News < ThreadChannel
|
979
|
+
@channel_type = 10
|
980
|
+
end
|
981
|
+
|
978
982
|
class Public < ThreadChannel
|
979
983
|
@channel_type = 11
|
980
984
|
end
|