disrb 0.1.2.1 → 0.1.2.2
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/lib/disrb/guild.rb +43 -43
- data/lib/disrb/message.rb +16 -16
- data/lib/disrb/user.rb +10 -10
- data/lib/disrb.rb +15 -15
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65d508f2f29da21da961a646ad0eb6920d5d26fd3b7ad833b1c3dd391c5df495
|
4
|
+
data.tar.gz: 7cd5482b028e9ef689fb8952cf9e8f6c4fc34ee95c7ea43fb999caf17b1d2174
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c923c3f794126970b909adbf71621b57f3cba24b29eaae333f60878b5b81089822441b7345063cb5b177283c9792a551171ad4b99a5e6c6fd449eb1d4288a55a
|
7
|
+
data.tar.gz: 9337da2c386247cce3b904308474ff187d60086ec8d1988d5b438065c0a13e8ff646ae34f82ef6c939312d4f9fef214e1dd8da7f53699d69e22a71ee42337fae
|
data/lib/disrb/guild.rb
CHANGED
@@ -26,7 +26,7 @@ class DiscordApi
|
|
26
26
|
data = JSON.generate(output)
|
27
27
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
28
28
|
response = DiscordApi.post(url, data, headers)
|
29
|
-
return response
|
29
|
+
return response if response.status == 200
|
30
30
|
|
31
31
|
@logger.error("Could not create guild. Response: #{response.body}")
|
32
32
|
response
|
@@ -39,7 +39,7 @@ class DiscordApi
|
|
39
39
|
url = "#{@base_url}/guilds/#{guild_id}#{query_string}"
|
40
40
|
headers = { 'Authorization' => @authorization_header }
|
41
41
|
response = DiscordApi.get(url, headers)
|
42
|
-
return response
|
42
|
+
return response if response.status == 200
|
43
43
|
|
44
44
|
@logger.error("Could not get guild with Guild ID #{guild_id}. Response: #{response.body}")
|
45
45
|
response
|
@@ -49,7 +49,7 @@ class DiscordApi
|
|
49
49
|
url = URI("#{@base_url}/guilds/#{guild_id}/preview")
|
50
50
|
headers = { 'Authorization': @authorization_header }
|
51
51
|
response = DiscordApi.get(url, headers)
|
52
|
-
return response
|
52
|
+
return response if response.status == 200
|
53
53
|
|
54
54
|
@logger.error("Could not get guild preview with Guild ID #{guild_id}. Response: #{response.body}")
|
55
55
|
response
|
@@ -95,7 +95,7 @@ class DiscordApi
|
|
95
95
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
96
96
|
headers['X-Audit-Log-Reason'] = audit_reason unless audit_reason.nil?
|
97
97
|
response = DiscordApi.patch(url, headers, data)
|
98
|
-
return response
|
98
|
+
return response if response.status == 200
|
99
99
|
|
100
100
|
@logger.error("Could not modify guild with Guild ID #{guild_id}. Response: #{response.body}")
|
101
101
|
response
|
@@ -105,7 +105,7 @@ class DiscordApi
|
|
105
105
|
url = "#{@base_url}/guilds/#{guild_id}"
|
106
106
|
headers = { 'Authorization': @authorization_header }
|
107
107
|
response = DiscordApi.delete(url, headers)
|
108
|
-
return response
|
108
|
+
return response if response.status == 204
|
109
109
|
|
110
110
|
@logger.error("Could not delete guild with Guild ID #{guild_id}. Response: #{response.body}")
|
111
111
|
response
|
@@ -115,7 +115,7 @@ class DiscordApi
|
|
115
115
|
url = "#{@base_url}/guilds/#{guild_id}/channels"
|
116
116
|
headers = { 'Authorization': @authorization_header }
|
117
117
|
response = DiscordApi.get(url, headers)
|
118
|
-
return response
|
118
|
+
return response if response.status == 200
|
119
119
|
|
120
120
|
@logger.error("Could not get guild channels with Guild ID #{guild_id}. Response: #{response.body}")
|
121
121
|
response
|
@@ -152,7 +152,7 @@ class DiscordApi
|
|
152
152
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
153
153
|
headers['X-Audit-Log-Reason'] = audit_reason unless audit_reason.nil?
|
154
154
|
response = DiscordApi.post(url, data, headers)
|
155
|
-
return response
|
155
|
+
return response if response.status == 200
|
156
156
|
|
157
157
|
@logger.error("Could not create guild channel in Guild ID #{guild_id}. Response: #{response.body}")
|
158
158
|
response
|
@@ -173,7 +173,7 @@ class DiscordApi
|
|
173
173
|
data = JSON.generate(output)
|
174
174
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
175
175
|
response = DiscordApi.patch(url, headers, data)
|
176
|
-
return response
|
176
|
+
return response if response.status == 200
|
177
177
|
|
178
178
|
@logger.error("Could not modify guild channel positions with Guild ID #{guild_id}. Response: #{response.body}")
|
179
179
|
response
|
@@ -183,7 +183,7 @@ class DiscordApi
|
|
183
183
|
url = "#{@base_url}/guilds/#{guild_id}/threads/active"
|
184
184
|
headers = { 'Authorization': @authorization_header }
|
185
185
|
response = DiscordApi.get(url, headers)
|
186
|
-
return response
|
186
|
+
return response if response.status == 200
|
187
187
|
|
188
188
|
@logger.error("Could not list active guild threads with Guild ID #{guild_id}. Response: #{response.body}")
|
189
189
|
response
|
@@ -193,7 +193,7 @@ class DiscordApi
|
|
193
193
|
url = "#{@base_url}/guilds/#{guild_id}/members/#{user_id}"
|
194
194
|
headers = { 'Authorization' => @authorization_header }
|
195
195
|
response = DiscordApi.get(url, headers)
|
196
|
-
return response
|
196
|
+
return response if response.status == 200
|
197
197
|
|
198
198
|
@logger.error("Could not get guild member with Guild ID #{guild_id} and User ID #{user_id}. Response:" \
|
199
199
|
"#{response.body}")
|
@@ -208,7 +208,7 @@ class DiscordApi
|
|
208
208
|
url = "#{@base_url}/guilds/#{guild_id}/members#{query_string}"
|
209
209
|
headers = { 'Authorization': @authorization_header }
|
210
210
|
response = DiscordApi.get(url, headers)
|
211
|
-
return response
|
211
|
+
return response if response.status == 200
|
212
212
|
|
213
213
|
@logger.error("Could not list members with Guild ID #{guild_id}. Response: #{response.body}")
|
214
214
|
response
|
@@ -222,7 +222,7 @@ class DiscordApi
|
|
222
222
|
url = "#{@base_url}/guilds/#{guild_id}/members/search#{query_string}"
|
223
223
|
headers = { 'Authorization': @authorization_header }
|
224
224
|
response = DiscordApi.get(url, headers)
|
225
|
-
return response
|
225
|
+
return response if response.status == 200
|
226
226
|
|
227
227
|
@logger.error("Could not search members with Guild ID #{guild_id}. Response: #{response.body}")
|
228
228
|
response
|
@@ -269,7 +269,7 @@ class DiscordApi
|
|
269
269
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
270
270
|
headers['X-Audit-Log-Reason'] = audit_reason unless audit_reason.nil?
|
271
271
|
response = DiscordApi.patch(url, data, headers)
|
272
|
-
return response
|
272
|
+
return response if response.status == 200
|
273
273
|
|
274
274
|
@logger.error("Could not modify guild member with Guild ID #{guild_id} and User ID #{user_id}. " \
|
275
275
|
"Response: #{response.body}")
|
@@ -288,7 +288,7 @@ class DiscordApi
|
|
288
288
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
289
289
|
headers['X-Audit-Log-Reason'] = audit_reason unless audit_reason.nil?
|
290
290
|
response = DiscordApi.patch(url, data, headers)
|
291
|
-
return response
|
291
|
+
return response if response.status == 200
|
292
292
|
|
293
293
|
@logger.error("Could not modify current member in guild with Guild ID #{guild_id}. Response: #{response.body}")
|
294
294
|
response
|
@@ -307,7 +307,7 @@ class DiscordApi
|
|
307
307
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
308
308
|
headers['X-Audit-Log-Reason'] = audit_reason unless audit_reason.nil?
|
309
309
|
response = DiscordApi.patch(url, data, headers)
|
310
|
-
return response
|
310
|
+
return response if response.status == 200
|
311
311
|
|
312
312
|
@logger.error("Could not modify current user nick in guild with ID #{guild_id}. Response: #{response.body}")
|
313
313
|
response
|
@@ -318,7 +318,7 @@ class DiscordApi
|
|
318
318
|
headers = { 'Authorization': @authorization_header }
|
319
319
|
headers['X-Audit-Log-Reason'] = audit_reason unless audit_reason.nil?
|
320
320
|
response = DiscordApi.put(url, nil, headers)
|
321
|
-
return response
|
321
|
+
return response if response.status == 204
|
322
322
|
|
323
323
|
@logger.error("Could not add role with ID #{role_id}, to user with ID #{user_id} in guild with ID #{guild_id}." \
|
324
324
|
" Response: #{response.body}")
|
@@ -330,7 +330,7 @@ class DiscordApi
|
|
330
330
|
headers = { 'Authorization': @authorization_header }
|
331
331
|
headers['x-Audit-Log-Reason'] = audit_reason unless audit_reason.nil?
|
332
332
|
response = DiscordApi.delete(url, headers)
|
333
|
-
return response
|
333
|
+
return response if response.status == 204
|
334
334
|
|
335
335
|
@logger.error("Could not remove role with ID #{role_id}, from user with ID #{user_id}" \
|
336
336
|
" in guild with ID #{guild_id}. Response: #{response.body}")
|
@@ -342,7 +342,7 @@ class DiscordApi
|
|
342
342
|
headers = { 'Authorization' => @authorization_header }
|
343
343
|
headers['X-Audit-Log-Reason'] = audit_reason unless audit_reason.nil?
|
344
344
|
response = DiscordApi.delete(url, headers)
|
345
|
-
return response
|
345
|
+
return response if response.status == 204
|
346
346
|
|
347
347
|
@logger.error("Could not remove user with ID #{user_id} from guild with ID #{guild_id}. Response: #{response.body}")
|
348
348
|
response
|
@@ -357,7 +357,7 @@ class DiscordApi
|
|
357
357
|
url = "#{@base_url}/guilds/#{guild_id}/bans#{query_string}"
|
358
358
|
headers = { 'Authorization' => @authorization_header }
|
359
359
|
response = DiscordApi.get(url, headers)
|
360
|
-
return response
|
360
|
+
return response if response.status == 200
|
361
361
|
|
362
362
|
@logger.error("Could not get guild bans with Guild ID #{guild_id}. Response: #{response.body}")
|
363
363
|
response
|
@@ -367,7 +367,7 @@ class DiscordApi
|
|
367
367
|
url = "#{@base_url}/guilds/#{guild_id}/bans/#{user_id}"
|
368
368
|
headers = { 'Authorization': @authorization_header }
|
369
369
|
response = DiscordApi.get(url, headers)
|
370
|
-
return response
|
370
|
+
return response if response.status == 200
|
371
371
|
|
372
372
|
if response.status == 404
|
373
373
|
@logger.warn("No ban found for user with ID #{user_id} in guild with ID #{guild_id}.")
|
@@ -390,7 +390,7 @@ class DiscordApi
|
|
390
390
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
391
391
|
headers['X-Audit-Log-Reason'] = audit_reason unless audit_reason.nil?
|
392
392
|
response = DiscordApi.put(url, data, headers)
|
393
|
-
return response
|
393
|
+
return response if response.status == 204
|
394
394
|
|
395
395
|
@logger.error("Could not create guild ban for user with ID #{user_id} in guild with ID #{guild_id}." \
|
396
396
|
" Response: #{response.body}")
|
@@ -402,7 +402,7 @@ class DiscordApi
|
|
402
402
|
headers = { 'Authorization': @authorization_header }
|
403
403
|
headers['X-Audit-Log-Reason'] = audit_reason unless audit_reason.nil?
|
404
404
|
response = DiscordApi.delete(url, headers)
|
405
|
-
return response
|
405
|
+
return response if response.status == 204
|
406
406
|
|
407
407
|
@logger.error("Could not remove guild ban for user with ID #{user_id} in guild with ID #{guild_id}" \
|
408
408
|
" Response: #{response.body}")
|
@@ -418,7 +418,7 @@ class DiscordApi
|
|
418
418
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
419
419
|
headers['X-Audit-Log-Reason'] = audit_reason unless audit_reason.nil?
|
420
420
|
response = DiscordApi.post(url, data, headers)
|
421
|
-
return response
|
421
|
+
return response if response.status == 200
|
422
422
|
|
423
423
|
if response.status == 500_000
|
424
424
|
@logger.error("No users were banned in bulk ban in guild with ID #{guild_id}. Response: #{response.body}")
|
@@ -432,7 +432,7 @@ class DiscordApi
|
|
432
432
|
url = "#{@base_url}/guilds/#{guild_id}/roles"
|
433
433
|
headers = { 'Authorization': @authorization_header }
|
434
434
|
response = DiscordApi.get(url, headers)
|
435
|
-
return response
|
435
|
+
return response if response.status == 200
|
436
436
|
|
437
437
|
@logger.error("Could not get guild roles with Guild ID #{guild_id}. Response: #{response.body}")
|
438
438
|
response
|
@@ -442,7 +442,7 @@ class DiscordApi
|
|
442
442
|
url = "#{@base_url}/guilds/#{guild_id}/roles/#{role_id}"
|
443
443
|
headers = { 'Authorization': @authorization_header }
|
444
444
|
response = DiscordApi.get(url, headers)
|
445
|
-
return response
|
445
|
+
return response if response.status == 200
|
446
446
|
|
447
447
|
@logger.error("Could not get role with ID #{role_id} in guild with ID #{guild_id}. Response: #{response.body}")
|
448
448
|
response
|
@@ -467,7 +467,7 @@ class DiscordApi
|
|
467
467
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
468
468
|
headers['X-Audit-Log-Reason'] = audit_reason unless audit_reason.nil?
|
469
469
|
response = DiscordApi.post(url, data, headers)
|
470
|
-
return response
|
470
|
+
return response if response.status == 200
|
471
471
|
|
472
472
|
@logger.error("Could not create guild role in guild with ID #{guild_id}. Response: #{response.body}")
|
473
473
|
response
|
@@ -486,7 +486,7 @@ class DiscordApi
|
|
486
486
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
487
487
|
headers['X-Audit-Log-Reason'] = audit_reason unless audit_reason.nil?
|
488
488
|
response = DiscordApi.patch(url, data, headers)
|
489
|
-
return response
|
489
|
+
return response if response.status == 200
|
490
490
|
|
491
491
|
@logger.error("Could not modify guild role positions in guild with ID #{guild_id}. Response: #{response.body}")
|
492
492
|
response
|
@@ -512,7 +512,7 @@ class DiscordApi
|
|
512
512
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
513
513
|
headers['X-Audit-Log-Reason'] = audit_reason unless audit_reason.nil?
|
514
514
|
response = DiscordApi.patch(url, data, headers)
|
515
|
-
return response
|
515
|
+
return response if response.status == 200
|
516
516
|
|
517
517
|
@logger.error("Could not modify guild role with ID #{role_id} in guild with ID #{guild_id}." \
|
518
518
|
" Response: #{response.body}")
|
@@ -538,7 +538,7 @@ class DiscordApi
|
|
538
538
|
headers = { 'Authorization': @authorization_header }
|
539
539
|
headers['X-Audit-Log-Reason'] = audit_reason unless audit_reason.nil?
|
540
540
|
response = DiscordApi.delete(url, headers)
|
541
|
-
return response
|
541
|
+
return response if response.status == 204
|
542
542
|
|
543
543
|
@logger.error("Failed to delete guild role. Response: #{response.body}")
|
544
544
|
response
|
@@ -552,7 +552,7 @@ class DiscordApi
|
|
552
552
|
url = "#{@base_url}/guilds/#{guild_id}/prune#{query_string}"
|
553
553
|
headers = { 'Authorization': @authorization_header }
|
554
554
|
response = DiscordApi.get(url, headers)
|
555
|
-
return response
|
555
|
+
return response if response.status == 200
|
556
556
|
|
557
557
|
@logger.error("Failed to get guild prune count. Response: #{response.body}")
|
558
558
|
response
|
@@ -573,7 +573,7 @@ class DiscordApi
|
|
573
573
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
574
574
|
headers['X-Audit-Log-Reason'] = audit_reason unless audit_reason.nil?
|
575
575
|
response = DiscordApi.post(url, data, headers)
|
576
|
-
return response
|
576
|
+
return response if response.status == 200
|
577
577
|
|
578
578
|
@logger.error("Failed to begin guild prune. Response: #{response.body}")
|
579
579
|
response
|
@@ -583,7 +583,7 @@ class DiscordApi
|
|
583
583
|
url = "#{@base_url}/guilds/#{guild_id}/regions"
|
584
584
|
headers = { 'Authorization': @authorization_header }
|
585
585
|
response = DiscordApi.get(url, headers)
|
586
|
-
return response
|
586
|
+
return response if response.status == 200
|
587
587
|
|
588
588
|
@logger.error("Failed to get guild voice regions. Response: #{response.body}")
|
589
589
|
response
|
@@ -593,7 +593,7 @@ class DiscordApi
|
|
593
593
|
url = "#{@base_url}/guilds/#{guild_id}/invites"
|
594
594
|
headers = { 'Authorization': @authorization_header }
|
595
595
|
response = DiscordApi.get(url, headers)
|
596
|
-
return response
|
596
|
+
return response if response.status == 200
|
597
597
|
|
598
598
|
@logger.error("Failed to get guild invites. Response: #{response.body}")
|
599
599
|
response
|
@@ -619,7 +619,7 @@ class DiscordApi
|
|
619
619
|
headers = { 'Authorization': @authorization_header }
|
620
620
|
headers['X-Audit-Log-Reason'] = audit_reason unless audit_reason.nil?
|
621
621
|
response = DiscordApi.delete(url, headers)
|
622
|
-
return response
|
622
|
+
return response if response.status == 204
|
623
623
|
|
624
624
|
@logger.error("Failed to delete guild integration. Response: #{response.body}")
|
625
625
|
response
|
@@ -629,7 +629,7 @@ class DiscordApi
|
|
629
629
|
url = "#{@base_url}/guilds/#{guild_id}/widget"
|
630
630
|
headers = { 'Authorization': @authorization_header }
|
631
631
|
response = DiscordApi.get(url, headers)
|
632
|
-
return response
|
632
|
+
return response if response.status == 200
|
633
633
|
|
634
634
|
@logger.error("Failed to get guild widget settings. Response: #{response.body}")
|
635
635
|
response
|
@@ -644,7 +644,7 @@ class DiscordApi
|
|
644
644
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
645
645
|
headers['X-Audit-Log-Reason'] = audit_reason unless audit_reason.nil?
|
646
646
|
response = DiscordApi.patch(url, data, headers)
|
647
|
-
return response
|
647
|
+
return response if response.status == 200
|
648
648
|
|
649
649
|
@logger.error("Failed to modify guild widget. Response: #{response.body}")
|
650
650
|
response
|
@@ -654,7 +654,7 @@ class DiscordApi
|
|
654
654
|
url = "#{@base_url}/guilds/#{guild_id}/widget.json"
|
655
655
|
headers = { 'Authorization': @authorization_header }
|
656
656
|
response = DiscordApi.get(url, headers)
|
657
|
-
return response
|
657
|
+
return response if response.status == 200
|
658
658
|
|
659
659
|
@logger.error("Failed to get guild widget. Response: #{response.body}")
|
660
660
|
response
|
@@ -664,7 +664,7 @@ class DiscordApi
|
|
664
664
|
url = "#{@base_url}/guilds/#{guild_id}/vanity-url"
|
665
665
|
headers = { 'Authorization': @authorization_header }
|
666
666
|
response = DiscordApi.get(url, headers)
|
667
|
-
return response
|
667
|
+
return response if response.status == 200
|
668
668
|
|
669
669
|
@logger.error("Failed to get guild vanity URL. Response: #{response.body}")
|
670
670
|
response
|
@@ -699,7 +699,7 @@ class DiscordApi
|
|
699
699
|
url = "#{@base_url}/guilds/#{guild_id}/welcome-screen"
|
700
700
|
headers = { 'Authorization': @authorization_header }
|
701
701
|
response = DiscordApi.get(url, headers)
|
702
|
-
return response
|
702
|
+
return response if response.status == 200
|
703
703
|
|
704
704
|
@logger.error("Failed to get guild welcome screen. Response: #{response.body}")
|
705
705
|
response
|
@@ -721,7 +721,7 @@ class DiscordApi
|
|
721
721
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
722
722
|
headers['X-Audit-Log-Reason'] = audit_reason unless audit_reason.nil?
|
723
723
|
response = DiscordApi.patch(url, data, headers)
|
724
|
-
return response
|
724
|
+
return response if response.status == 200
|
725
725
|
|
726
726
|
@logger.error("Failed to modify guild welcome screen. Response: #{response.body}")
|
727
727
|
response
|
@@ -731,7 +731,7 @@ class DiscordApi
|
|
731
731
|
url = "#{@base_url}/guilds/#{guild_id}/onboarding"
|
732
732
|
headers = { 'Authorization': @authorization_header }
|
733
733
|
response = DiscordApi.get(url, headers)
|
734
|
-
return response
|
734
|
+
return response if response.status == 200
|
735
735
|
|
736
736
|
@logger.error("Failed to get guild onboarding. Response: #{response.body}")
|
737
737
|
response
|
@@ -754,7 +754,7 @@ class DiscordApi
|
|
754
754
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
755
755
|
headers['X-Audit-Log-Reason'] = audit_reason unless audit_reason.nil?
|
756
756
|
response = DiscordApi.put(url, data, headers)
|
757
|
-
return response
|
757
|
+
return response if response.status == 200
|
758
758
|
|
759
759
|
@logger.error("Failed to modify guild onboarding. Response: #{response.body}")
|
760
760
|
response
|
@@ -781,7 +781,7 @@ class DiscordApi
|
|
781
781
|
data = JSON.generate(output)
|
782
782
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
783
783
|
response = DiscordApi.put(url, data, headers)
|
784
|
-
return response
|
784
|
+
return response if response.status == 200
|
785
785
|
|
786
786
|
@logger.error("Failed to modify guild incident actions. Response: #{response.body}")
|
787
787
|
response
|
data/lib/disrb/message.rb
CHANGED
@@ -23,7 +23,7 @@ class DiscordApi
|
|
23
23
|
url = "#{@base_url}/channels/#{channel_id}/messages#{query_string}"
|
24
24
|
headers = { 'Authorization': @authorization_header }
|
25
25
|
response = DiscordApi.get(url, headers)
|
26
|
-
return response
|
26
|
+
return response if response.status == 200
|
27
27
|
|
28
28
|
@logger.error("Failed to get messages from channel with ID #{channel_id}. Response: #{response.body}")
|
29
29
|
response
|
@@ -33,7 +33,7 @@ class DiscordApi
|
|
33
33
|
url = "#{@base_url}/channels/#{channel_id}/messages/#{message_id}"
|
34
34
|
headers = { 'Authorization': @authorization_header }
|
35
35
|
response = DiscordApi.get(url, headers)
|
36
|
-
return response
|
36
|
+
return response if response.status == 200
|
37
37
|
|
38
38
|
@logger.error("Failed to get message with ID #{message_id} from channel with ID #{channel_id}. " \
|
39
39
|
"Response: #{response.body}")
|
@@ -65,7 +65,7 @@ class DiscordApi
|
|
65
65
|
data = JSON.generate(output)
|
66
66
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
67
67
|
response = DiscordApi.post(url, data, headers)
|
68
|
-
return response
|
68
|
+
return response if response.status == 200
|
69
69
|
|
70
70
|
@logger.error("Failed to create message in channel #{channel_id}. Response: #{response.body}")
|
71
71
|
response
|
@@ -75,7 +75,7 @@ class DiscordApi
|
|
75
75
|
url = "#{@base_url}/channels/#{channel_id}/messages/#{message_id}/crosspost"
|
76
76
|
headers = { 'Authorization': @authorization_header }
|
77
77
|
response = DiscordApi.post(url, nil, headers)
|
78
|
-
return response
|
78
|
+
return response if response.status == 200
|
79
79
|
|
80
80
|
@logger.error("Failed to crosspost message with ID #{message_id} in channel with ID #{channel_id}. " \
|
81
81
|
"Response: #{response.body}")
|
@@ -86,7 +86,7 @@ class DiscordApi
|
|
86
86
|
url = "#{@base_url}/channels/#{channel_id}/messages/#{message_id}/reactions/#{emoji_id}/@me"
|
87
87
|
headers = { 'Authorization': @authorization_header }
|
88
88
|
response = DiscordApi.put(url, nil, headers)
|
89
|
-
return response
|
89
|
+
return response if response.status == 204
|
90
90
|
|
91
91
|
@logger.error("Failed to create reaction with emoji ID #{emoji_id} in channel with ID #{channel_id} " \
|
92
92
|
"for message with ID #{message_id}. Response: #{response.body}")
|
@@ -97,7 +97,7 @@ class DiscordApi
|
|
97
97
|
url = "#{@base_url}/channels/#{channel_id}/messages/#{message_id}/reactions/#{emoji_id}/@me"
|
98
98
|
headers = { 'Authorization': @authorization_header }
|
99
99
|
response = DiscordApi.delete(url, headers)
|
100
|
-
return response
|
100
|
+
return response if response.status == 204
|
101
101
|
|
102
102
|
@logger.error("Failed to delete own reaction with emoji ID #{emoji_id} in channel with ID #{channel_id} " \
|
103
103
|
"for message with ID #{message_id}. Response: #{response.body}")
|
@@ -108,7 +108,7 @@ class DiscordApi
|
|
108
108
|
url = "#{@base_url}/channels/#{channel_id}/messages/#{message_id}/reactions/#{emoji_id}/#{user_id}"
|
109
109
|
headers = { 'Authorization': @authorization_header }
|
110
110
|
response = DiscordApi.delete(url, headers)
|
111
|
-
return response
|
111
|
+
return response if response.status == 204
|
112
112
|
|
113
113
|
@logger.error("Failed to delete user reaction with emoji ID #{emoji_id} in channel with ID #{channel_id} " \
|
114
114
|
"for message with ID #{message_id} by user with ID #{user_id}. Response: #{response.body}")
|
@@ -124,7 +124,7 @@ class DiscordApi
|
|
124
124
|
url = "#{@base_url}/channels/#{channel_id}/messages/#{message_id}/reactions/#{emoji_id}#{query_string}"
|
125
125
|
headers = { 'Authorization': @authorization_header }
|
126
126
|
response = DiscordApi.get(url, headers)
|
127
|
-
return response
|
127
|
+
return response if response.status == 200
|
128
128
|
|
129
129
|
@logger.error("Failed to get reactions for emoji with ID #{emoji_id} in channel with ID #{channel_id} " \
|
130
130
|
"for message with ID #{message_id}. Response: #{response.body}")
|
@@ -135,7 +135,7 @@ class DiscordApi
|
|
135
135
|
url = "#{@base_url}/channels/#{channel_id}/messages/#{message_id}/reactions"
|
136
136
|
headers = { 'Authorization': @authorization_header }
|
137
137
|
response = DiscordApi.delete(url, headers)
|
138
|
-
return response
|
138
|
+
return response if response.status == 204
|
139
139
|
|
140
140
|
@logger.error("Failed to delete all reactions in channel with ID #{channel_id} for message with ID #{message_id}" \
|
141
141
|
". Response: #{response.body}")
|
@@ -145,7 +145,7 @@ class DiscordApi
|
|
145
145
|
url = "#{@base_url}/channels/#{channel_id}/messages/#{message_id}/reactions/#{emoji_id}"
|
146
146
|
headers = { 'Authorization': @authorization_header }
|
147
147
|
response = DiscordApi.delete(url, headers)
|
148
|
-
return response
|
148
|
+
return response if response.status == 204
|
149
149
|
|
150
150
|
@logger.error("Failed to delete all reactions for emoji with ID #{emoji_id} in channel with ID #{channel_id} for " \
|
151
151
|
"message with ID #{message_id}. Response: #{response.body}")
|
@@ -171,7 +171,7 @@ class DiscordApi
|
|
171
171
|
data = JSON.generate(output)
|
172
172
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
173
173
|
response = DiscordApi.patch(url, data, headers)
|
174
|
-
return response
|
174
|
+
return response if response.status == 200
|
175
175
|
|
176
176
|
@logger.error("Failed to edit message with ID #{message_id} in channel with ID #{channel_id}. " \
|
177
177
|
"Response: #{response.body}")
|
@@ -183,7 +183,7 @@ class DiscordApi
|
|
183
183
|
headers = { 'Authorization': @authorization_header }
|
184
184
|
headers[:'X-Audit-Log-Reason'] = audit_reason unless audit_reason.nil?
|
185
185
|
response = DiscordApi.delete(url, headers)
|
186
|
-
return response
|
186
|
+
return response if response.status == 204
|
187
187
|
|
188
188
|
@logger.error("Failed to delete message with ID #{message_id} in channel with ID #{channel_id}. " \
|
189
189
|
"Response: #{response.body}")
|
@@ -197,7 +197,7 @@ class DiscordApi
|
|
197
197
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
198
198
|
headers[:'X-Audit-Log-Reason'] = audit_reason unless audit_reason.nil?
|
199
199
|
response = DiscordApi.post(url, data, headers)
|
200
|
-
return response
|
200
|
+
return response if response.status == 204
|
201
201
|
|
202
202
|
@logger.error("Failed to bulk delete messages in channel with ID #{channel_id}. Response: #{response.body}")
|
203
203
|
response
|
@@ -211,7 +211,7 @@ class DiscordApi
|
|
211
211
|
url = "#{@base_url}/channels/#{channel_id}/messages/pins#{query_string}"
|
212
212
|
headers = { 'Authorization': @authorization_header }
|
213
213
|
response = DiscordApi.get(url, headers)
|
214
|
-
return response
|
214
|
+
return response if response.status == 200
|
215
215
|
|
216
216
|
@logger.error("Failed to get pinned messages in channel with ID #{channel_id}. Response: #{response.body}")
|
217
217
|
response
|
@@ -222,7 +222,7 @@ class DiscordApi
|
|
222
222
|
headers = { 'Authorization': @authorization_header }
|
223
223
|
headers[:'X-Audit-Log-Reason'] = audit_reason unless audit_reason.nil?
|
224
224
|
response = DiscordApi.put(url, nil, headers)
|
225
|
-
return response
|
225
|
+
return response if response.status == 204
|
226
226
|
|
227
227
|
@logger.error("Failed to pin message with ID #{message_id} in channel with ID #{channel_id}. " \
|
228
228
|
"Response: #{response.body}")
|
@@ -234,7 +234,7 @@ class DiscordApi
|
|
234
234
|
headers = { 'Authorization': @authorization_header }
|
235
235
|
headers[:'X-Audit-Log-Reason'] = audit_reason unless audit_reason.nil?
|
236
236
|
response = DiscordApi.delete(url, headers)
|
237
|
-
return response
|
237
|
+
return response if response.status == 204
|
238
238
|
|
239
239
|
@logger.error("Failed to unpin message with ID #{message_id} in channel with ID #{channel_id}. " \
|
240
240
|
"Response: #{response.body}")
|
data/lib/disrb/user.rb
CHANGED
@@ -9,7 +9,7 @@ class DiscordApi
|
|
9
9
|
url = "#{@base_url}/users/@me"
|
10
10
|
headers = { 'Authorization': @authorization_header }
|
11
11
|
response = DiscordApi.get(url, headers)
|
12
|
-
return response
|
12
|
+
return response if response.status == 200
|
13
13
|
|
14
14
|
@logger.error("Failed to get current user. Response: #{response.body}")
|
15
15
|
response
|
@@ -19,7 +19,7 @@ class DiscordApi
|
|
19
19
|
url = "#{@base_url}/users/#{user_id}"
|
20
20
|
headers = { 'Authorization': @authorization_header }
|
21
21
|
response = DiscordApi.get(url, headers)
|
22
|
-
return response
|
22
|
+
return response if response.status == 200
|
23
23
|
|
24
24
|
@logger.error("Failed to get user with ID #{user_id}. Response: #{response.body}")
|
25
25
|
response
|
@@ -42,7 +42,7 @@ class DiscordApi
|
|
42
42
|
data = JSON.generate(output)
|
43
43
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
44
44
|
response = DiscordApi.patch(url, data, headers)
|
45
|
-
return response
|
45
|
+
return response if response.status == 200
|
46
46
|
|
47
47
|
@logger.error("Failed to modify current user. Response: #{response.body}")
|
48
48
|
response
|
@@ -63,7 +63,7 @@ class DiscordApi
|
|
63
63
|
'Discord API doesn\'t allow you to fetch more than 200 guilds. Some guilds might not be listed.')
|
64
64
|
return response
|
65
65
|
end
|
66
|
-
return response
|
66
|
+
return response if response.status == 200
|
67
67
|
|
68
68
|
@logger.error("Failed to get current user's guilds. Response: #{response.body}")
|
69
69
|
response
|
@@ -73,7 +73,7 @@ class DiscordApi
|
|
73
73
|
url = "#{@base_url}/users/@me/guilds/#{guild_id}"
|
74
74
|
headers = { 'Authorization': @authorization_header }
|
75
75
|
response = DiscordApi.delete(url, headers)
|
76
|
-
return response
|
76
|
+
return response if response.status == 204
|
77
77
|
|
78
78
|
@logger.error("Failed to leave guild with ID #{guild_id}. Response: #{response.body}")
|
79
79
|
response
|
@@ -84,7 +84,7 @@ class DiscordApi
|
|
84
84
|
data = JSON.generate({ recipient_id: recipient_id })
|
85
85
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
86
86
|
response = DiscordApi.post(url, data, headers)
|
87
|
-
return response
|
87
|
+
return response if response.status == 200
|
88
88
|
|
89
89
|
@logger.error("Failed to create DM with recipient ID #{recipient_id}. Response: #{response.body}")
|
90
90
|
response
|
@@ -98,7 +98,7 @@ class DiscordApi
|
|
98
98
|
data = JSON.generate(output)
|
99
99
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
100
100
|
response = DiscordApi.post(url, data, headers)
|
101
|
-
return response
|
101
|
+
return response if response.status == 200
|
102
102
|
|
103
103
|
@logger.error("Failed to create group DM. Response: #{response.body}")
|
104
104
|
response
|
@@ -108,7 +108,7 @@ class DiscordApi
|
|
108
108
|
url = "#{@base_url}/users/@me/connections"
|
109
109
|
headers = { 'Authorization': @authorization_header }
|
110
110
|
response = DiscordApi.get(url, headers)
|
111
|
-
return response
|
111
|
+
return response if response.status == 200
|
112
112
|
|
113
113
|
@logger.error("Failed to get current user's connections. Response: #{response.body}")
|
114
114
|
response
|
@@ -118,7 +118,7 @@ class DiscordApi
|
|
118
118
|
url = "#{@base_url}/users/@me/applications/#{application_id}/role-connection"
|
119
119
|
headers = { 'Authorization': @authorization_header }
|
120
120
|
response = DiscordApi.get(url, headers)
|
121
|
-
return response
|
121
|
+
return response if response.status == 200
|
122
122
|
|
123
123
|
@logger.error("Failed to get current user's application role connection for application ID #{application_id}. " \
|
124
124
|
"Response: #{response.body}")
|
@@ -139,7 +139,7 @@ class DiscordApi
|
|
139
139
|
data = JSON.generate(output)
|
140
140
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
141
141
|
response = DiscordApi.put(url, data, headers)
|
142
|
-
return response
|
142
|
+
return response if response.status == 200
|
143
143
|
|
144
144
|
@logger.error("Failed to update current user's application role connection for application ID #{application_id}. " \
|
145
145
|
"Response: #{response.body}")
|
data/lib/disrb.rb
CHANGED
@@ -110,7 +110,7 @@ class DiscordApi
|
|
110
110
|
data = JSON.generate(output)
|
111
111
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
112
112
|
response = DiscordApi.post(url, data, headers)
|
113
|
-
return response
|
113
|
+
return response if response.status == 201 || response.status == 200
|
114
114
|
|
115
115
|
@logger.error("Failed to create guild application command in guild with ID #{guild_id}. Response: #{response.body}")
|
116
116
|
response
|
@@ -150,7 +150,7 @@ class DiscordApi
|
|
150
150
|
data = JSON.generate(output)
|
151
151
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
152
152
|
response = DiscordApi.post(url, data, headers)
|
153
|
-
return response
|
153
|
+
return response if response.status == 201 || response.status == 200
|
154
154
|
|
155
155
|
@logger.error("Failed to create global application command. Response: #{response.body}")
|
156
156
|
response
|
@@ -192,7 +192,7 @@ class DiscordApi
|
|
192
192
|
data = JSON.generate(output)
|
193
193
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
194
194
|
response = DiscordApi.patch(url, data, headers)
|
195
|
-
return response
|
195
|
+
return response if response.status == 200
|
196
196
|
|
197
197
|
@logger.error("Failed to edit global application command with ID #{command_id}. Response: #{response.body}")
|
198
198
|
response
|
@@ -218,7 +218,7 @@ class DiscordApi
|
|
218
218
|
data = JSON.generate(output)
|
219
219
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
220
220
|
response = DiscordApi.patch(url, data, headers)
|
221
|
-
return response
|
221
|
+
return response if response.status == 200
|
222
222
|
|
223
223
|
@logger.error("Failed to edit guild application command with ID #{command_id}. Response: #{response.body}")
|
224
224
|
response
|
@@ -228,7 +228,7 @@ class DiscordApi
|
|
228
228
|
url = "#{@base_url}/applications/#{@application_id}/commands/#{command_id}"
|
229
229
|
headers = { 'Authorization': @authorization_header }
|
230
230
|
response = DiscordApi.delete(url, headers)
|
231
|
-
return response
|
231
|
+
return response if response.status == 204
|
232
232
|
|
233
233
|
@logger.error("Failed to delete global application command with ID #{command_id}. Response: #{response.body}")
|
234
234
|
response
|
@@ -238,7 +238,7 @@ class DiscordApi
|
|
238
238
|
url = "#{@base_url}/applications/#{@application_id}/guilds/#{guild_id}/commands/#{command_id}"
|
239
239
|
headers = { 'Authorization': @authorization_header }
|
240
240
|
response = DiscordApi.delete(url, headers)
|
241
|
-
return response
|
241
|
+
return response if response.status == 204
|
242
242
|
|
243
243
|
@logger.error("Failed to delete guild application command with ID #{command_id} in guild with ID #{guild_id}. " \
|
244
244
|
"Response: #{response.body}")
|
@@ -251,7 +251,7 @@ class DiscordApi
|
|
251
251
|
url = "#{@base_url}/applications/#{@application_id}/guilds/#{guild_id}/commands#{query_string}"
|
252
252
|
headers = { 'Authorization': @authorization_header }
|
253
253
|
response = DiscordApi.get(url, headers)
|
254
|
-
return response
|
254
|
+
return response if response.status == 200
|
255
255
|
|
256
256
|
@logger.error("Failed to get guild application commands for guild with ID #{guild_id}. Response: #{response.body}")
|
257
257
|
response
|
@@ -264,7 +264,7 @@ class DiscordApi
|
|
264
264
|
url = "#{@base_url}/applications/#{@application_id}/commands#{query_string}"
|
265
265
|
headers = { 'Authorization': @authorization_header }
|
266
266
|
response = DiscordApi.get(url, headers)
|
267
|
-
return response
|
267
|
+
return response if response.status == 200
|
268
268
|
|
269
269
|
@logger.error("Failed to get global application commands. Response: #{response.body}")
|
270
270
|
response
|
@@ -274,7 +274,7 @@ class DiscordApi
|
|
274
274
|
url = "#{@base_url}/applications/#{@application_id}/commands/#{command_id}"
|
275
275
|
headers = { 'Authorization': @authorization_header }
|
276
276
|
response = DiscordApi.get(url, headers)
|
277
|
-
return response
|
277
|
+
return response if response.status == 200
|
278
278
|
|
279
279
|
@logger.error("Failed to get global application command with ID #{command_id}. Response: #{response.body}")
|
280
280
|
response
|
@@ -284,7 +284,7 @@ class DiscordApi
|
|
284
284
|
url = "#{@base_url}/applications/#{@application_id}/guilds/#{guild_id}/commands/#{command_id}"
|
285
285
|
headers = { 'Authorization': @authorization_header }
|
286
286
|
response = DiscordApi.get(url, headers)
|
287
|
-
return response
|
287
|
+
return response if response.status == 200
|
288
288
|
|
289
289
|
@logger.error("Failed to get guild application command with ID #{command_id}. Response: #{response.body}")
|
290
290
|
response
|
@@ -295,7 +295,7 @@ class DiscordApi
|
|
295
295
|
data = JSON.generate(commands)
|
296
296
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
297
297
|
response = DiscordApi.put(url, data, headers)
|
298
|
-
return response
|
298
|
+
return response if response.status == 200
|
299
299
|
|
300
300
|
@logger.error("Failed to bulk overwrite global application commands. Response: #{response.body}")
|
301
301
|
response
|
@@ -306,7 +306,7 @@ class DiscordApi
|
|
306
306
|
data = JSON.generate(commands)
|
307
307
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
308
308
|
response = DiscordApi.put(url, data, headers)
|
309
|
-
return response
|
309
|
+
return response if response.status == 200
|
310
310
|
|
311
311
|
@logger.error("Failed to bulk overwrite guild application commands in guild with ID #{guild_id}. " \
|
312
312
|
"Response: #{response.body}")
|
@@ -317,7 +317,7 @@ class DiscordApi
|
|
317
317
|
url = "#{@base_url}/applications/#{@application_id}/guilds/#{guild_id}/commands/permissions"
|
318
318
|
headers = { 'Authorization': @authorization_header }
|
319
319
|
response = DiscordApi.get(url, headers)
|
320
|
-
return response
|
320
|
+
return response if response.status == 200
|
321
321
|
|
322
322
|
@logger.error("Failed to get guild application command permissions for guild with ID #{guild_id}. " \
|
323
323
|
"Response: #{response.body}")
|
@@ -328,7 +328,7 @@ class DiscordApi
|
|
328
328
|
url = "#{@base_url}/applications/#{@application_id}/guilds/#{guild_id}/commands/#{command_id}/permissions"
|
329
329
|
headers = { 'Authorization': @authorization_header }
|
330
330
|
response = DiscordApi.get(url, headers)
|
331
|
-
return response
|
331
|
+
return response if response.status == 200
|
332
332
|
|
333
333
|
@logger.error("Failed to get appliaction command permissions for command with ID #{command_id} in guild with ID " \
|
334
334
|
"#{guild_id}. Response: #{response.body}")
|
@@ -340,7 +340,7 @@ class DiscordApi
|
|
340
340
|
data = JSON.generate(permissions)
|
341
341
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
342
342
|
response = DiscordApi.put(url, data, headers)
|
343
|
-
return response
|
343
|
+
return response if response.status == 200
|
344
344
|
|
345
345
|
@logger.error("Failed to edit application command permissions for command with ID #{command_id} in guild with ID " \
|
346
346
|
"#{guild_id}. Response: #{response.body}")
|