Module: Discordrb::UserAttributes

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

Overview

Mixin for the attributes users should have

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#avatar_idString (readonly)

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

Returns:

  • (String)

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

See Also:



107
108
109
# File 'lib/discordrb/data.rb', line 107

def avatar_id
  @avatar_id
end

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

Returns whether this user is a Discord bot account.

Returns:

  • (true, false)

    whether this user is a Discord bot account



102
103
104
# File 'lib/discordrb/data.rb', line 102

def 
  @bot_account
end

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

Returns this user's discriminator which is used internally to identify users with identical usernames.

Returns:

  • (String)

    this user's discriminator which is used internally to identify users with identical usernames.



96
97
98
# File 'lib/discordrb/data.rb', line 96

def discriminator
  @discriminator
end

#usernameString (readonly) Also known as: name

Returns this user's username.

Returns:

  • (String)

    this user's username



92
93
94
# File 'lib/discordrb/data.rb', line 92

def username
  @username
end

Instance Method Details

#avatar_urlString

Utility function to get a user's avatar URL.

Returns:

  • (String)

    the URL to the avatar image.



123
124
125
# File 'lib/discordrb/data.rb', line 123

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

#distinctString

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

Returns:

  • (String)

    distinct representation of user



117
118
119
# File 'lib/discordrb/data.rb', line 117

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

#mentionString

Utility function to mention users in messages

Returns:

  • (String)

    the mention code in the form of <@id>



111
112
113
# File 'lib/discordrb/data.rb', line 111

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