Module: Discordrb::UserAttributes

Included in:
Light::LightProfile, User
Defined in:
lib/discordrb/data/user.rb

Overview

Mixin for the attributes users should have

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#avatar_idString

Returns the ID of this user's current avatar, can be used to generate an avatar URL.

See Also:


22
23
24
# File 'lib/discordrb/data/user.rb', line 22

def avatar_id
  @avatar_id
end

#bot_accounttrue, false (readonly) Also known as: bot_account?


17
18
19
# File 'lib/discordrb/data/user.rb', line 17

def 
  @bot_account
end

#discriminatorString (readonly) Also known as: discrim, tag, discord_tag


11
12
13
# File 'lib/discordrb/data/user.rb', line 11

def discriminator
  @discriminator
end

#usernameString (readonly) Also known as: name


7
8
9
# File 'lib/discordrb/data/user.rb', line 7

def username
  @username
end

Instance Method Details

#avatar_url(format = nil) ⇒ String

Utility function to get a user's avatar URL.


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

def avatar_url(format = nil)
  return API::User.default_avatar(@discriminator) unless @avatar_id

  API::User.avatar_url(@id, @avatar_id, format)
end

#distinctString

Utility function to get Discord's distinct representation of a user, i.e. username + discriminator


32
33
34
# File 'lib/discordrb/data/user.rb', line 32

def distinct
  "#{@username}##{@discriminator}"
end

#mentionString

Utility function to mention users in messages


26
27
28
# File 'lib/discordrb/data/user.rb', line 26

def mention
  "<@#{@id}>"
end