disrb 0.1.1 → 0.1.1.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/README.md +4 -2
- data/lib/disrb/guild.rb +50 -5
- data/lib/disrb/message.rb +13 -13
- data/lib/disrb/user.rb +4 -0
- data/lib/disrb.rb +9 -1
- 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: ecf60885f01f0ba754ad0a67f675413d09c33870ee4ec5e46bbb9ff84fb80d9d
|
4
|
+
data.tar.gz: 2744718f229ff9b5a789a94d50292a2113b988afb5d47f46edb71429753cea44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd9a84148138aa689686aa061bdf0e0343b285ed8012a89ca5b282178e05a681b064eed32bf6ea5409d66ca506a4be975729602a0e2a201597d699202a6df1ca
|
7
|
+
data.tar.gz: 44e7a2d3a1c4e978d31d14f58891f4802a73f74a94d8f455a15f5a829ee8215c9ec22e33251f1b811a8ddbf0aff9bfc25115e991a56a174fbd5999d2f7f15a27
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# discord.rb indev
|
2
2
|
|
3
|
+
[Changelog](CHANGELOG.md) | [Licensed under the MIT License](LICENSE)
|
4
|
+
|
3
5
|

|
4
6
|
|
5
7
|
W.I.P. Discord API wrapper written in Ruby for fun.
|
@@ -22,8 +24,8 @@ The test.rb file creates two commands "test" and "test2", that return "Hi" and "
|
|
22
24
|
- [ ] Add support for all Discord Gateway events and properly handle the connection
|
23
25
|
- [ ] Documentation (v0.1.2)
|
24
26
|
- [x] Transition to Faraday for HTTP requests (v0.1.1)
|
25
|
-
- [
|
26
|
-
- [
|
27
|
+
- [x] Functions where all options are optional, check if atleast one is provided (v0.1.1.1)
|
28
|
+
- [x] Prefer to use keyword arguments over positional arguments if there are more than 1 optional arguments (v0.1.1.1)
|
27
29
|
- [ ] Beta release (v0.3.0)
|
28
30
|
- [ ] Component support and builder
|
29
31
|
- [ ] Sharding support
|
data/lib/disrb/guild.rb
CHANGED
@@ -33,11 +33,10 @@ class DiscordApi
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def get_guild(guild_id, with_counts = nil)
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
36
|
+
query_string_hash = {}
|
37
|
+
query_string_hash[:with_counts] = with_counts unless with_counts.nil?
|
38
|
+
query_string = DiscordApi.handle_query_strings(query_string_hash)
|
39
|
+
url = "#{@base_url}/guilds/#{guild_id}#{query_string}"
|
41
40
|
headers = { 'Authorization' => @authorization_header }
|
42
41
|
response = DiscordApi.get(url, headers)
|
43
42
|
return response unless response.status != 200
|
@@ -62,6 +61,10 @@ class DiscordApi
|
|
62
61
|
system_channel_flags: nil, rules_channel_id: nil, public_updates_channel_id: nil,
|
63
62
|
preferred_locale: nil, features: nil, description: nil, premium_progress_bar_enabled: nil,
|
64
63
|
safety_alerts_channel_id: nil, audit_reason: nil)
|
64
|
+
if args[1..-2].all?(&:nil?)
|
65
|
+
@logger.warn("No modifications for guild with ID #{guild_id} provided. Skipping.")
|
66
|
+
return nil
|
67
|
+
end
|
65
68
|
output = {}
|
66
69
|
output[:name] = name unless name.nil?
|
67
70
|
unless region.nil?
|
@@ -156,6 +159,11 @@ class DiscordApi
|
|
156
159
|
end
|
157
160
|
|
158
161
|
def modify_guild_channel_positions(guild_id, channel_id, position: nil, lock_permissions: nil, parent_id: nil)
|
162
|
+
if args[2..].all?(&:nil?)
|
163
|
+
@logger.warn("No modifications for guild channel positions with guild ID #{guild_id} and channel ID " \
|
164
|
+
"#{channel_id} provided. Skipping.")
|
165
|
+
return nil
|
166
|
+
end
|
159
167
|
output = {}
|
160
168
|
output[:id] = channel_id
|
161
169
|
output[:position] = position unless position.nil?
|
@@ -243,6 +251,11 @@ class DiscordApi
|
|
243
251
|
|
244
252
|
def modify_guild_member(guild_id, user_id, nick: nil, roles: nil, mute: nil, deaf: nil, channel_id: nil,
|
245
253
|
communication_disabled_until: nil, flags: nil, audit_reason: nil)
|
254
|
+
if args[2..-2].all?(&:nil?)
|
255
|
+
@logger.warn("No modifications for guild member with guild ID #{guild_id} and user ID #{user_id} provided. " \
|
256
|
+
'Skipping.')
|
257
|
+
return nil
|
258
|
+
end
|
246
259
|
output = {}
|
247
260
|
output[:nick] = nick unless nick.nil?
|
248
261
|
output[:roles] = roles unless roles.nil?
|
@@ -264,6 +277,10 @@ class DiscordApi
|
|
264
277
|
end
|
265
278
|
|
266
279
|
def modify_current_member(guild_id, nick: nil, audit_reason: nil)
|
280
|
+
if nick.nil?
|
281
|
+
@logger.warn("No modifications for current member in guild ID #{guild_id} provided. Skipping.")
|
282
|
+
return nil
|
283
|
+
end
|
267
284
|
output = {}
|
268
285
|
output[:nick] = nick unless nick.nil?
|
269
286
|
url = "#{@base_url}/guilds/#{guild_id}/members/@me"
|
@@ -279,6 +296,10 @@ class DiscordApi
|
|
279
296
|
|
280
297
|
def modify_current_user_nick(guild_id, nick: nil, audit_reason: nil)
|
281
298
|
@logger.warn('The "Modify Current User Nick" endpoint has been deprecated and should not be used!')
|
299
|
+
if nick.nil?
|
300
|
+
@logger.warn("No modifications for current user nick in guild ID #{guild_id} provided. Skipping.")
|
301
|
+
return nil
|
302
|
+
end
|
282
303
|
output = {}
|
283
304
|
output[:nick] = nick unless nick.nil?
|
284
305
|
url = "#{@base_url}/guilds/#{guild_id}/users/@me/nick"
|
@@ -453,6 +474,10 @@ class DiscordApi
|
|
453
474
|
end
|
454
475
|
|
455
476
|
def modify_guild_role_positions(guild_id, id, position: nil, audit_reason: nil)
|
477
|
+
if position.nil?
|
478
|
+
@logger.warn("No role positions provided for guild with ID #{guild_id}. Skipping function.")
|
479
|
+
return nil
|
480
|
+
end
|
456
481
|
output = {}
|
457
482
|
output[:id] = id
|
458
483
|
output[:position] = position unless position.nil?
|
@@ -469,6 +494,11 @@ class DiscordApi
|
|
469
494
|
|
470
495
|
def modify_guild_role(guild_id, role_id, name: nil, permissions: nil, color: nil, hoist: nil, icon: nil,
|
471
496
|
unicode_emoji: nil, mentionable: nil, audit_reason: nil)
|
497
|
+
if args[2..-2].all?(&:nil?)
|
498
|
+
@logger.warn("No modifications for guild role with ID #{role_id} in guild with ID #{guild_id} provided. " \
|
499
|
+
'Skipping.')
|
500
|
+
return nil
|
501
|
+
end
|
472
502
|
output = {}
|
473
503
|
output[:name] = name unless name.nil?
|
474
504
|
output[:permissions] = permissions unless permissions.nil?
|
@@ -677,6 +707,11 @@ class DiscordApi
|
|
677
707
|
|
678
708
|
def modify_guild_welcome_screen(guild_id, enabled: nil, welcome_channels: nil, description: nil,
|
679
709
|
audit_reason: nil)
|
710
|
+
if args[1..-2].all?(&:nil?)
|
711
|
+
@logger.warn("No modifications for guild welcome screen with guild ID #{guild_id} provided. " \
|
712
|
+
'Skipping.')
|
713
|
+
return nil
|
714
|
+
end
|
680
715
|
output = {}
|
681
716
|
output[:enabled] = enabled unless enabled.nil?
|
682
717
|
output[:welcome_channels] = welcome_channels unless welcome_channels.nil?
|
@@ -704,6 +739,11 @@ class DiscordApi
|
|
704
739
|
|
705
740
|
def modify_guild_onboarding(guild_id, prompts: nil, default_channel_ids: nil, enabled: nil, mode: nil,
|
706
741
|
audit_reason: nil)
|
742
|
+
if args[1..-2].all?(&:nil?)
|
743
|
+
@logger.warn("No modifications for guild onboarding with guild ID #{guild_id} provided. " \
|
744
|
+
'Skipping.')
|
745
|
+
return nil
|
746
|
+
end
|
707
747
|
output = {}
|
708
748
|
output[:prompts] = prompts unless prompts.nil?
|
709
749
|
output[:default_channel_ids] = default_channel_ids unless default_channel_ids.nil?
|
@@ -721,6 +761,11 @@ class DiscordApi
|
|
721
761
|
end
|
722
762
|
|
723
763
|
def modify_guild_incident_actions(guild_id, invites_disabled_until: nil, dms_disabled_until: nil)
|
764
|
+
if args[1..].all?(&:nil?)
|
765
|
+
@logger.warn("No modifications for guild incident actions with guild ID #{guild_id} provided. " \
|
766
|
+
'Skipping.')
|
767
|
+
return nil
|
768
|
+
end
|
724
769
|
output = {}
|
725
770
|
if invites_disabled_until == false
|
726
771
|
output[:invites_disabled_until] = nil
|
data/lib/disrb/message.rb
CHANGED
@@ -11,19 +11,19 @@ class DiscordApi
|
|
11
11
|
return
|
12
12
|
end
|
13
13
|
output = {}
|
14
|
-
output[:content] = content
|
15
|
-
output[:nonce] = nonce
|
16
|
-
output[:tts] = tts
|
17
|
-
output[:embeds] = embeds
|
18
|
-
output[:allowed_mentions] = allowed_mentions
|
19
|
-
output[:message_reference] = message_reference
|
20
|
-
output[:components] = components
|
21
|
-
output[:sticker_ids] = sticker_ids
|
22
|
-
output[:files] = files
|
23
|
-
output[:attachments] = attachments
|
24
|
-
output[:flags] = flags
|
25
|
-
output[:enforce_nonce] = enforce_nonce
|
26
|
-
output[:poll] = poll
|
14
|
+
output[:content] = content unless content.nil?
|
15
|
+
output[:nonce] = nonce unless nonce.nil?
|
16
|
+
output[:tts] = tts unless tts.nil?
|
17
|
+
output[:embeds] = embeds unless embeds.nil?
|
18
|
+
output[:allowed_mentions] = allowed_mentions unless allowed_mentions.nil?
|
19
|
+
output[:message_reference] = message_reference unless message_reference.nil?
|
20
|
+
output[:components] = components unless components.nil?
|
21
|
+
output[:sticker_ids] = sticker_ids unless sticker_ids.nil?
|
22
|
+
output[:files] = files unless files.nil?
|
23
|
+
output[:attachments] = attachments unless attachments.nil?
|
24
|
+
output[:flags] = flags unless flags.nil?
|
25
|
+
output[:enforce_nonce] = enforce_nonce unless enforce_nonce.nil?
|
26
|
+
output[:poll] = poll unless poll.nil?
|
27
27
|
url = "#{@base_url}/channels/#{channel_id}/messages"
|
28
28
|
data = JSON.generate(output)
|
29
29
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
data/lib/disrb/user.rb
CHANGED
@@ -26,6 +26,10 @@ class DiscordApi
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def modify_current_user(username: nil, avatar: nil, banner: nil)
|
29
|
+
if args.all?(&:nil?)
|
30
|
+
@logger.warn('No modifications provided for current user. Skipping function.')
|
31
|
+
return nil
|
32
|
+
end
|
29
33
|
output = {}
|
30
34
|
output[:username] = username unless username.nil?
|
31
35
|
output[:avatar] = avatar unless avatar.nil?
|
data/lib/disrb.rb
CHANGED
@@ -103,7 +103,7 @@ class DiscordApi
|
|
103
103
|
output[:description_localizations] = description_localizations unless description_localizations.nil?
|
104
104
|
output[:options] = options unless options.nil?
|
105
105
|
output[:default_permission] = default_permission unless default_permission.nil?
|
106
|
-
output[:type] = type unless
|
106
|
+
output[:type] = type unless type.nil?
|
107
107
|
output[:nsfw] = nsfw unless nsfw.nil?
|
108
108
|
output[:default_member_permissions] = default_member_permissions unless default_member_permissions.nil?
|
109
109
|
url = "#{@base_url}/applications/#{@application_id}/guilds/#{guild_id}/commands"
|
@@ -173,6 +173,10 @@ class DiscordApi
|
|
173
173
|
def edit_global_application_command(command_id, name: nil, name_localizations: nil, description: nil,
|
174
174
|
description_localizations: nil, options: nil, default_member_permissions: nil,
|
175
175
|
default_permission: nil, integration_types: nil, contexts: nil, nsfw: nil)
|
176
|
+
if args[1..].all?(&:nil?)
|
177
|
+
@logger.warn("No modifications provided for global application command with ID #{command_id}. Skipping.")
|
178
|
+
return nil
|
179
|
+
end
|
176
180
|
output = {}
|
177
181
|
output[:name] = name
|
178
182
|
output[:name_localizations] = name_localizations unless name_localizations.nil?
|
@@ -197,6 +201,10 @@ class DiscordApi
|
|
197
201
|
def edit_guild_application_command(guild_id, command_id, name: nil, name_localizations: nil, description: nil,
|
198
202
|
description_localizations: nil, options: nil, default_member_permissions: nil,
|
199
203
|
default_permission: nil, nsfw: nil)
|
204
|
+
if args[2..].all?(&:nil?)
|
205
|
+
@logger.warn("No modifications provided for guild application command with command ID #{command_id}. Skipping.")
|
206
|
+
return nil
|
207
|
+
end
|
200
208
|
output = {}
|
201
209
|
output[:name] = name
|
202
210
|
output[:name_localizations] = name_localizations unless name_localizations.nil?
|