dsu3 0.8.3 → 0.9.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 436b6a875e8e3780bdcf84904378b75ec9e294f7de1acb1975dbf6e52461b46c
4
- data.tar.gz: 73ad93f5b871e90d9766a50219b1d107920987548c25a43b7e3624f13f5f51a7
3
+ metadata.gz: 640c9953a32bc972d54f3d032163474bfc5f58add8d4f59a9064bacc0512e4e3
4
+ data.tar.gz: 4fbc03d22f27b90ba2917eb81fb612691fe2be6bd35a6cd725d4d6f2de052496
5
5
  SHA512:
6
- metadata.gz: 4855468d31c0eda96977ece189d65aeba170ca459dc2f17dcd02a09752c394184e26f5cd6364402abd9941f50c16976f4812177acbcae561c6391d7941773ff7
7
- data.tar.gz: 3e3f208f7cfca6f3a218e8fa354d556e8b7071f7fb35eb2dc78d1bd84a43e71e3e22571d9652f6d5c40e5d4eaca73ce8161eda36efeb860927399b1d925787e5
6
+ metadata.gz: d4b473f3733e34377baf5316e3537aa9368cbf2db4987c5f3b446107925b4f8660f9ca3956f2c3c38a9ecdda45336e276f2a451449216ed2b325079606114371
7
+ data.tar.gz: 222a46f109dbd7f684d1c86ad1e72c2d730e0e88ca038263f63c3390fb9812bef7702101d6672a93ab4dd1aaeff51b6dbaba717df0a1273226ce9f5645ab98a8
data/bin/dsu3 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'dsu3'
4
4
 
5
- @net = DSU3::Net.new(*File.readlines(ARGV.shift))
5
+ @net = DSU3::Net.new(*File.readlines(ARGV.shift).map(&:chop))
6
6
 
7
7
  require 'irb'
8
8
  IRB.start
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DSU3
4
+ module API
5
+ # Guilds resource
6
+ module Guild
7
+ module_function
8
+
9
+ # Verifies the server member
10
+ # @param [String] token Discord account token
11
+ # @param [String, Integer] guild Guild ID
12
+ # @param [String] invite Invite code
13
+ def verify(token, guild, invite)
14
+ DSU3::API.request(
15
+ token, :get,
16
+ "guilds/#{guild}/member-verification",
17
+ { params: { with_guild: false, invite_code: invite } }
18
+ )
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DSU3
4
+ module API
5
+ # Invites resource
6
+ module Invite
7
+ module_function
8
+
9
+ # Joins guild
10
+ # @param [String] token Discord account token
11
+ # @param [String] invite Invite code
12
+ def join(token, invite)
13
+ DSU3::API.request(
14
+ token, :post, "invites/#{invite}",
15
+ { x_context_properties: 'eyJsb2NhdGlvbiI6Ik1hcmtkb3duIExpbmsifQ==' },
16
+ '{}'
17
+ )
18
+ end
19
+ end
20
+ end
21
+ end
data/lib/dsu3/api.rb CHANGED
@@ -6,6 +6,8 @@ require 'uri'
6
6
 
7
7
  require 'dsu3/props'
8
8
  require 'dsu3/api/channel'
9
+ require 'dsu3/api/guild'
10
+ require 'dsu3/api/invite'
9
11
 
10
12
  module DSU3
11
13
  # Namespace for all methods representing Discord API endpoints
@@ -40,22 +42,12 @@ module DSU3
40
42
  if e.is_a?(RestClient::TooManyRequests)
41
43
  LOGGER.warn('ratelimit exceeded')
42
44
  elsif e.response.headers[:content_type] == 'application/json'
45
+ data = JSON.parse(e.response.body)
43
46
  LOGGER.error("#{data['code']}: #{data['message']}")
44
47
  else
45
48
  LOGGER.error(e.message)
46
49
  end
47
50
  e.response
48
51
  end
49
-
50
- # Joins guild
51
- # @param [String] token Discord account token
52
- # @param [String] invite Invite code
53
- def join(token, invite)
54
- request(
55
- token, :post, "invites/#{invite}",
56
- { x_context_properties: 'eyJsb2NhdGlvbiI6Ik1hcmtkb3duIExpbmsifQ==' },
57
- '{}'
58
- )
59
- end
60
52
  end
61
53
  end
data/lib/dsu3/net.rb CHANGED
@@ -32,10 +32,10 @@ module DSU3
32
32
  end
33
33
  end
34
34
 
35
- # (see DSU3::API#join)
35
+ # (see DSU3::API::Invite#join)
36
36
  def join(invite)
37
37
  @tokens.each do |token|
38
- DSU3::API.join(token, invite)
38
+ DSU3::API::Invites.join(token, invite)
39
39
  sleep(0.5)
40
40
  end
41
41
  end
@@ -44,5 +44,13 @@ module DSU3
44
44
  def react(channel, message, emoji)
45
45
  @tokens.each { |token| DSU3::API::Channel.react(token, channel, message, emoji) }
46
46
  end
47
+
48
+ # (see DSU3::API::Guild#verify)
49
+ def verify(guild, invite)
50
+ @tokens.each do |token|
51
+ DSU3::API::Guild.verify(token, guild, invite)
52
+ sleep(0.5)
53
+ end
54
+ end
47
55
  end
48
56
  end
data/lib/dsu3/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DSU3
4
- VERSION = '0.8.3'
4
+ VERSION = '0.9.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dsu3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artur Sheremetjev IV
@@ -37,6 +37,8 @@ files:
37
37
  - lib/dsu3.rb
38
38
  - lib/dsu3/api.rb
39
39
  - lib/dsu3/api/channel.rb
40
+ - lib/dsu3/api/guild.rb
41
+ - lib/dsu3/api/invite.rb
40
42
  - lib/dsu3/net.rb
41
43
  - lib/dsu3/props.rb
42
44
  - lib/dsu3/version.rb