discordrb 1.7.2 → 1.7.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of discordrb might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f91839616b4ad8e792ebfbd149f2ecfcdc50e614
4
- data.tar.gz: 45afd38f057ffb4d9366eac1bf404bfca064363e
3
+ metadata.gz: bcde95d0c926eba8368ed3553686b396a4a500db
4
+ data.tar.gz: 387df5587eaeab2eb24a8cb085ea4e951ffff3bf
5
5
  SHA512:
6
- metadata.gz: cf7c6250b3fc4bb927d76d7696d9f980559c1018e15a063306bba71d5c172dbd4c00ea01e26d85732fc2d056a1315ecaf672fc6e141d69d669b316d72c61efd6
7
- data.tar.gz: 786ff878add75d25bdd5f49169f0ecd21515da2371e826dde0b5356d19bdcd293aab6bb842fb3b74109e03a72ee36f518b28fed85deca435e9b8b9bf5a3bb314
6
+ metadata.gz: 3374e7195c49d28d84cd936ff1e44b5232bbc65ad7df4fae6e9a22c2047730086b254af9e4ffde0d38c9b9a203be80fd8b1d86ef659816f9ee17fe6f3d39ca72
7
+ data.tar.gz: 271acc3f47814bf89b188fe02038d106a16c016b10eca67630a423e416a32c21815e743204a9028ed20991b4af5217860511690e04223c2e303d70da1c0205c4
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.7.3
4
+ * The server banlist can now be accessed more nicely using `Server#bans`.
5
+ * Some abstractions for OAuth application creation were added - `bot.create_oauth_application` and `bot.update_oauth_application`. See the docs about how to use them.
6
+
3
7
  ## 1.7.2
4
8
  * The `bot` object can now be read from all events, not just from command ones.
5
9
  * You can now set the `filter_volume` on VoiceBot, which corresponds to the old way of doing volume handling, in case the new way is too slow for you.
@@ -128,6 +128,28 @@ module Discordrb::API
128
128
  )
129
129
  end
130
130
 
131
+ # Create an OAuth application
132
+ def create_oauth_application(token, name, redirect_uris)
133
+ request(
134
+ :post,
135
+ "#{APIBASE}/oauth2/applications",
136
+ { name: name, redirect_uris: redirect_uris }.to_json,
137
+ Authorization: token,
138
+ content_type: :json
139
+ )
140
+ end
141
+
142
+ # Change an OAuth application's properties
143
+ def update_oauth_application(token, name, redirect_uris, description = '', icon = nil)
144
+ request(
145
+ :put,
146
+ "#{APIBASE}/oauth2/applications",
147
+ { name: name, redirect_uris: redirect_uris, description: description, icon: icon }.to_json,
148
+ Authorization: token,
149
+ content_type: :json
150
+ )
151
+ end
152
+
131
153
  # Create a server
132
154
  def create_server(token, name, region = :london)
133
155
  request(
@@ -363,6 +363,26 @@ module Discordrb
363
363
  server
364
364
  end
365
365
 
366
+ # Creates a new application to do OAuth authorization with. This allows you to use OAuth to authorize users using
367
+ # Discord. For information how to use this, see this example: https://github.com/vishnevskiy/discord-oauth2-example
368
+ # @param name [String] What your application should be called.
369
+ # @param redirect_uris [Array<String>] URIs that Discord should redirect your users to after authorizing.
370
+ # @return [Array(String, String)] your applications' client ID and client secret to be used in OAuth authorization.
371
+ def create_oauth_application(name, redirect_uris)
372
+ response = JSON.parse(API.create_oauth_application(@token, name, redirect_uris))
373
+ [response['id'], response['secret']]
374
+ end
375
+
376
+ # Changes information about your OAuth application
377
+ # @param name [String] What your application should be called.
378
+ # @param redirect_uris [Array<String>] URIs that Discord should redirect your users to after authorizing.
379
+ # @param description [String] A string that describes what your application does.
380
+ # @param icon [String, nil] A data URI for your icon image (for example a base 64 encoded image), or nil if no icon
381
+ # should be set or changed.
382
+ def update_oauth_application(name, redirect_uris, description = '', icon = nil)
383
+ API.update_oauth_application(@token, name, redirect_uris, description, icon)
384
+ end
385
+
366
386
  # Gets the user from a mention of the user.
367
387
  # @param mention [String] The mention, which should look like <@12314873129>.
368
388
  # @return [User] The user identified by the mention, or `nil` if none exists.
@@ -910,6 +910,12 @@ module Discordrb
910
910
  role
911
911
  end
912
912
 
913
+ # @return [Array<User>] a list of banned users on this server.
914
+ def bans
915
+ users = JSON.parse(API.bans(@bot.token, @id))
916
+ users.map { |e| User.new(e['user'], @bot) }
917
+ end
918
+
913
919
  # Bans a user from this server.
914
920
  # @param user [User] The user to ban.
915
921
  # @param message_days [Integer] How many days worth of messages sent by the user should be deleted.
@@ -51,6 +51,7 @@ module Discordrb::Events
51
51
 
52
52
  # Generic event class that can be extended
53
53
  class Event
54
+ # @return [Bot] the bot used to initialize this event.
54
55
  attr_reader :bot
55
56
  end
56
57
 
@@ -1,5 +1,5 @@
1
1
  # Discordrb and all its functionality, in this case only the version.
2
2
  module Discordrb
3
3
  # The current version of discordrb.
4
- VERSION = '1.7.2'.freeze
4
+ VERSION = '1.7.3'.freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: discordrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.2
4
+ version: 1.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - meew0
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-25 00:00:00.000000000 Z
11
+ date: 2016-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faye-websocket