dsu3 0.8.2 → 0.9.1

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: b88a7d6933638d26698a37973d16bf72916bbf720997b6b7c02bc1a7b3c06bac
4
- data.tar.gz: 2ce56289607005aa9bec7ff8f1de789c04d1d85d79696f959ad6adad7bb6cee6
3
+ metadata.gz: 82851e7f871ff43245228fa78712507d4eb513ec33afcc6a5ff5276f4a419d14
4
+ data.tar.gz: 129b9a23a0c359968c32d6251dcb5a5952805fc4c3877f49ac8e596959bda430
5
5
  SHA512:
6
- metadata.gz: 262ad2cf3570362858cc7af875372cded40430516136074b57ec04043303cc1a3d8236ca334dbb9067f4c90a9f7a52ffcf29620c1b606a3e073d01db4a715cb5
7
- data.tar.gz: 3f7b61ad802971c06b92e33f3eee39b3d89f3571e88076263a749f2290ab6ebf67e455c7d93853387b1c5cfc2a0d60ec2476c740ef91a237abd208a636d9a7f9
6
+ metadata.gz: fa6331b0ab524ba4884a4ae5e2aa15aec99b7b008ffd9549b955741135e04bd3320a34b821939c3e142e3428b16c9c0c8fe23c79d855040c8e99df5b44d9428c
7
+ data.tar.gz: 666626ee1b2e92bf22d80b5cc2135ff17dc8ef24b51fbe13e3d616e893d8e53432cc542ac656817418a70d1e8c5d812992285e9e55dbb464d5c4bdf3d3df9295
data/README.md CHANGED
@@ -12,4 +12,5 @@ execute
12
12
  dsu3 path/to/token/file
13
13
  ```
14
14
  to run irb with dsu3 already required and a net instance already initialised
15
+
15
16
  more info is available here www.rubydoc.info/gems/dsu3
@@ -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)
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.2'
4
+ VERSION = '0.9.1'
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.2
4
+ version: 0.9.1
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