Module: OnyxCord::Bot::OAuth

Included in:
OnyxCord::Bot
Defined in:
lib/onyxcord/core/bot/oauth.rb

Instance Method Summary collapse

Instance Method Details

#create_oauth_application(name, redirect_uris) ⇒ Array(String, String)

Creates a new application to do OAuth authorization with. This allows you to use OAuth to authorize users using Discord. For information how to use this, see the docs: https://discord.com/developers/docs/topics/oauth2

Parameters:

  • name (String)

    What your application should be called.

  • redirect_uris (Array<String>)

    URIs that Discord should redirect your users to after authorizing.

Returns:

  • (Array(String, String))

    your applications' client ID and client secret to be used in OAuth authorization.



11
12
13
14
# File 'lib/onyxcord/core/bot/oauth.rb', line 11

def create_oauth_application(name, redirect_uris)
  response = OnyxCord::Internal::JSON.parse(REST.create_oauth_application(@token, name, redirect_uris))
  [response['id'], response['secret']]
end

#update_oauth_application(name, redirect_uris, description = '', icon = nil) ⇒ Object

Changes information about your OAuth application

Parameters:

  • name (String)

    What your application should be called.

  • redirect_uris (Array<String>)

    URIs that Discord should redirect your users to after authorizing.

  • description (String) (defaults to: '')

    A string that describes what your application does.

  • icon (String, nil) (defaults to: nil)

    A data URI for your icon image (for example a base 64 encoded image), or nil if no icon should be set or changed.



22
23
24
# File 'lib/onyxcord/core/bot/oauth.rb', line 22

def update_oauth_application(name, redirect_uris, description = '', icon = nil)
  REST.update_oauth_application(@token, name, redirect_uris, description, icon)
end