Class: Discordrb::Application

Inherits:
Object
  • Object
show all
Includes:
IDObject
Defined in:
lib/discordrb/data/application.rb

Overview

OAuth Application information

Instance Attribute Summary collapse

Attributes included from IDObject

#id

Instance Method Summary collapse

Methods included from IDObject

#==, #creation_time, synthesise

Constructor Details

#initialize(data, bot) ⇒ Application

Returns a new instance of Application.



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/discordrb/data/application.rb', line 25

def initialize(data, bot)
  @bot = bot

  @name = data['name']
  @id = data['id'].to_i
  @description = data['description']
  @icon_id = data['icon']
  @rpc_origins = data['rpc_origins']
  @flags = data['flags']
  @owner = @bot.ensure_user(data['owner'])
end

Instance Attribute Details

#descriptionString (readonly)

Returns the application description.

Returns:

  • (String)

    the application description



12
13
14
# File 'lib/discordrb/data/application.rb', line 12

def description
  @description
end

#flagsInteger (readonly)

Returns:



18
19
20
# File 'lib/discordrb/data/application.rb', line 18

def flags
  @flags
end

#nameString (readonly)

Returns the application name.

Returns:

  • (String)

    the application name



9
10
11
# File 'lib/discordrb/data/application.rb', line 9

def name
  @name
end

#ownerUser (readonly)

Gets the user object of the owner. May be limited to username, discriminator, ID, and avatar if the bot cannot reach the owner.

Returns:

  • (User)

    the user object of the owner



23
24
25
# File 'lib/discordrb/data/application.rb', line 23

def owner
  @owner
end

#rpc_originsArray<String> (readonly)

Returns the application's origins permitted to use RPC.

Returns:

  • (Array<String>)

    the application's origins permitted to use RPC



15
16
17
# File 'lib/discordrb/data/application.rb', line 15

def rpc_origins
  @rpc_origins
end

Instance Method Details

#icon_urlString?

Utility function to get a application's icon URL.

Returns:

  • (String, nil)

    the URL of the icon image (nil if no image is set).



39
40
41
42
43
# File 'lib/discordrb/data/application.rb', line 39

def icon_url
  return nil if @icon_id.nil?

  API.app_icon_url(@id, @icon_id)
end

#inspectObject

The inspect method is overwritten to give more useful output



46
47
48
# File 'lib/discordrb/data/application.rb', line 46

def inspect
  "<Application name=#{@name} id=#{@id}>"
end