Class: DDAPI::User

Inherits:
Object
  • Object
show all
Defined in:
lib/dd-api/classes.rb

Overview

Represents a DRPG user.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, app) ⇒ User

Returns a new instance of User.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/dd-api/classes.rb', line 61

def initialize(data, app)
  @data = data['data']
  @id = data['id']
  @name = @data['name']
  @level = @data['level']
  @hp = @data['hp']
  @max_hp = @data['maxhp']
  @gold = @data['gold']
  @xp = @data['xp']
  @kills = @data['kills']
  @deaths = @data['deaths']
  @weapon_id = @data['weapon']
  @donated = @data['donate']
  @guild = @data['guild']
  @app = app
end

Instance Attribute Details

#deathsInteger Also known as: frags

Returns How much deaths that user has.

Returns:

  • (Integer)

    How much deaths that user has



34
35
36
# File 'lib/dd-api/classes.rb', line 34

def deaths
  @deaths
end

#donatedtrue, false Also known as: donated?

Returns whether the user donated to Discord Dungeons or not.

Returns:

  • (true, false)

    whether the user donated to Discord Dungeons or not.



58
59
60
# File 'lib/dd-api/classes.rb', line 58

def donated
  @donated
end

#goldInteger

Returns How much gold that user has.

Returns:

  • (Integer)

    How much gold that user has



41
42
43
# File 'lib/dd-api/classes.rb', line 41

def gold
  @gold
end

#hpInteger Also known as: health

Returns How much health that user has.

Returns:

  • (Integer)

    How much health that user has



30
31
32
# File 'lib/dd-api/classes.rb', line 30

def hp
  @hp
end

#idInteger

Returns The ID of the user.

Returns:

  • (Integer)

    The ID of the user.



55
56
57
# File 'lib/dd-api/classes.rb', line 55

def id
  @id
end

#killsInteger

Returns How much kills that user has.

Returns:

  • (Integer)

    How much kills that user has



38
39
40
# File 'lib/dd-api/classes.rb', line 38

def kills
  @kills
end

#levelInteger

Returns The level at that time, of the user.

Returns:

  • (Integer)

    The level at that time, of the user.



48
49
50
# File 'lib/dd-api/classes.rb', line 48

def level
  @level
end

#max_hpInteger Also known as: max_health

Returns How much maximun health that user has.

Returns:

  • (Integer)

    How much maximun health that user has



51
52
53
# File 'lib/dd-api/classes.rb', line 51

def max_hp
  @max_hp
end

#nameSrting Also known as: nickname

Returns The name of the user.

Returns:

  • (Srting)

    The name of the user.



26
27
28
# File 'lib/dd-api/classes.rb', line 26

def name
  @name
end

#xpInteger Also known as: experience

Returns How much experience that user has.

Returns:

  • (Integer)

    How much experience that user has



44
45
46
# File 'lib/dd-api/classes.rb', line 44

def xp
  @xp
end

Instance Method Details

#guildGuild?

Returns the user’s guild.

Returns:

  • (Guild, nil)

    the user’s guild



79
80
81
82
83
84
85
# File 'lib/dd-api/classes.rb', line 79

def guild
  if @guild != ""
    @app.guild(@guild)
  else
    nil
  end
end

#inspectObject

The inspect method is overwritten to give more useful output



88
89
90
# File 'lib/dd-api/classes.rb', line 88

def inspect
  "#<DDAPI::User name=#{@name} id=#{@id} level=#{@level}>"
end