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, active_developer: 1 << 22 }.freeze
Instance Attribute Summary collapse
-
#avatar_decoration ⇒ AvatarDecoration?
readonly
The current user's avatar decoration, or nil if the user doesn't have one.
-
#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.
-
#collectibles ⇒ Collectibles
readonly
The collectibles that this user has collected.
-
#discriminator ⇒ String
(also: #discrim, #tag, #discord_tag)
readonly
This user's discriminator which is used internally to identify users with identical usernames.
-
#global_name ⇒ String?
readonly
This user's global name.
-
#primary_server ⇒ PrimaryServer?
(also: #server_tag)
readonly
The server tag the user has adopted, or nil if the user doesn't have one displayed.
-
#public_flags ⇒ Integer
readonly
The public flags on a user's account.
-
#system_account ⇒ true, false
(also: #system_account?)
readonly
Whether the user is an offical Discord System user (part of the urgent message system).
-
#username ⇒ String
(also: #name)
readonly
This user's username.
-
#webhook_account ⇒ true, false
(also: #webhook_account?, #webhook?)
readonly
Whether this is fake user for a webhook message.
Instance Method Summary collapse
-
#avatar_url(format = nil) ⇒ String
Utility function to get a user's avatar URL.
-
#banner_url(format = nil) ⇒ String?
Utility function to get a user's banner URL.
-
#display_name ⇒ String
Utility function to get Discord's display name of a user not in server.
-
#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_decoration ⇒ AvatarDecoration? (readonly)
Returns the current user's avatar decoration, or nil if the user doesn't have one.
57 58 59 |
# File 'lib/discordrb/data/user.rb', line 57 def avatar_decoration @avatar_decoration end |
#avatar_id ⇒ String
Returns the ID of this user's current avatar, can be used to generate an avatar URL.
50 51 52 |
# File 'lib/discordrb/data/user.rb', line 50 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.
40 41 42 |
# File 'lib/discordrb/data/user.rb', line 40 def bot_account @bot_account end |
#collectibles ⇒ Collectibles (readonly)
Returns the collectibles that this user has collected.
60 61 62 |
# File 'lib/discordrb/data/user.rb', line 60 def collectibles @collectibles 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.
34 35 36 |
# File 'lib/discordrb/data/user.rb', line 34 def discriminator @discriminator end |
#global_name ⇒ String? (readonly)
Returns this user's global name.
31 32 33 |
# File 'lib/discordrb/data/user.rb', line 31 def global_name @global_name end |
#primary_server ⇒ PrimaryServer? (readonly) Also known as: server_tag
Returns the server tag the user has adopted, or nil if the user doesn't have one displayed.
63 64 65 |
# File 'lib/discordrb/data/user.rb', line 63 def primary_server @primary_server end |
#public_flags ⇒ Integer (readonly)
Returns the public flags on a user's account.
104 105 106 |
# File 'lib/discordrb/data/user.rb', line 104 def public_flags @public_flags end |
#system_account ⇒ true, false (readonly) Also known as: system_account?
Returns whether the user is an offical Discord System user (part of the urgent message system).
53 54 55 |
# File 'lib/discordrb/data/user.rb', line 53 def system_account @system_account end |
#username ⇒ String (readonly) Also known as: name
Returns this user's username.
27 28 29 |
# File 'lib/discordrb/data/user.rb', line 27 def username @username end |
#webhook_account ⇒ true, false (readonly) Also known as: webhook_account?, webhook?
Returns whether this is fake user for a webhook message.
44 45 46 |
# File 'lib/discordrb/data/user.rb', line 44 def webhook_account @webhook_account end |
Instance Method Details
#avatar_url(format = nil) ⇒ String
Utility function to get a user's avatar URL. TODO: Maybe change this method again after discriminator removal ?
93 94 95 96 97 98 99 100 101 |
# File 'lib/discordrb/data/user.rb', line 93 def avatar_url(format = nil) unless @avatar_id return API::User.default_avatar(@discriminator, legacy: true) if @discriminator && @discriminator != '0' return API::User.default_avatar(@id) end API::User.avatar_url(@id, @avatar_id, format) end |
#banner_url(format = nil) ⇒ String?
Utility function to get a user's banner URL.
You can otherwise specify one of webp
, jpg
, png
, or gif
to override this.
116 117 118 |
# File 'lib/discordrb/data/user.rb', line 116 def (format = nil) API::User.(@id, , format) if end |
#display_name ⇒ String
Utility function to get Discord's display name of a user not in server
68 69 70 |
# File 'lib/discordrb/data/user.rb', line 68 def display_name global_name || username end |
#distinct ⇒ String
Utility function to get Discord's distinct representation of a user, i.e. username + discriminator TODO: Maybe change this method again after discriminator removal ?
81 82 83 84 85 86 87 |
# File 'lib/discordrb/data/user.rb', line 81 def distinct if @discriminator && @discriminator != '0' "#{@username}##{@discriminator}" else @username.to_s end end |
#mention ⇒ String
Utility function to mention users in messages
74 75 76 |
# File 'lib/discordrb/data/user.rb', line 74 def mention "<@#{@id}>" end |