Module: Discordrb::UserAttributes
- Included in:
- Light::LightProfile, User
- Defined in:
- lib/discordrb/data/user.rb
Overview
Mixin for the attributes users should have
Constant Summary collapse
- FLAGS =
rubocop:disable Naming/VariableNumber
{ staff: 1 << 0, partner: 1 << 1, hypesquad: 1 << 2, bug_hunter_level_1: 1 << 3, hypesquad_online_house_1: 1 << 6, hypesquad_online_house_2: 1 << 7, hypesquad_online_house_3: 1 << 8, premium_early_supporter: 1 << 9, team_pseudo_user: 1 << 10, bug_hunter_level_2: 1 << 14, verified_bot: 1 << 16, verified_developer: 1 << 17, certified_moderator: 1 << 18, bot_http_interactions: 1 << 19 }.freeze
Instance Attribute Summary collapse
-
#avatar_id ⇒ String
The ID of this user's current avatar, can be used to generate an avatar URL.
-
#bot_account ⇒ true, false
(also: #bot_account?)
readonly
Whether this user is a Discord bot account.
-
#discriminator ⇒ String
(also: #discrim, #tag, #discord_tag)
readonly
This user's discriminator which is used internally to identify users with identical usernames.
-
#public_flags ⇒ Integer
readonly
The public flags on a user's account.
-
#username ⇒ String
(also: #name)
readonly
This user's username.
Instance Method Summary collapse
-
#avatar_url(format = nil) ⇒ String
Utility function to get a user's avatar URL.
-
#distinct ⇒ String
Utility function to get Discord's distinct representation of a user, i.e.
-
#mention ⇒ String
Utility function to mention users in messages.
Instance Attribute Details
#avatar_id ⇒ String
Returns the ID of this user's current avatar, can be used to generate an avatar URL.
41 42 43 |
# File 'lib/discordrb/data/user.rb', line 41 def avatar_id @avatar_id end |
#bot_account ⇒ true, false (readonly) Also known as: bot_account?
Returns whether this user is a Discord bot account.
36 37 38 |
# File 'lib/discordrb/data/user.rb', line 36 def bot_account @bot_account end |
#discriminator ⇒ String (readonly) Also known as: discrim, tag, discord_tag
Returns this user's discriminator which is used internally to identify users with identical usernames.
30 31 32 |
# File 'lib/discordrb/data/user.rb', line 30 def discriminator @discriminator end |
#public_flags ⇒ Integer (readonly)
Returns the public flags on a user's account.
65 66 67 |
# File 'lib/discordrb/data/user.rb', line 65 def public_flags @public_flags end |
#username ⇒ String (readonly) Also known as: name
Returns this user's username.
26 27 28 |
# File 'lib/discordrb/data/user.rb', line 26 def username @username end |
Instance Method Details
#avatar_url(format = nil) ⇒ String
Utility function to get a user's avatar URL.
58 59 60 61 62 |
# File 'lib/discordrb/data/user.rb', line 58 def avatar_url(format = nil) return API::User.default_avatar(@discriminator) unless @avatar_id API::User.avatar_url(@id, @avatar_id, format) end |
#distinct ⇒ String
Utility function to get Discord's distinct representation of a user, i.e. username + discriminator
51 52 53 |
# File 'lib/discordrb/data/user.rb', line 51 def distinct "#{@username}##{@discriminator}" end |
#mention ⇒ String
Utility function to mention users in messages
45 46 47 |
# File 'lib/discordrb/data/user.rb', line 45 def mention "<@#{@id}>" end |