module Discordrb::UserAttributes
Mixin for the attributes users should have
Constants
- FLAGS
rubocop:disable Naming/VariableNumber
Attributes
@return [String] the ID of this user’s current avatar, can be used to generate an avatar URL. @see avatar_url
@return [true, false] whether this user is a Discord bot account
@return [true, false] whether this user is a Discord bot account
@return [String] this user’s discriminator which is used internally to identify users with identical usernames.
@return [String] this user’s discriminator which is used internally to identify users with identical usernames.
@return [String] this user’s discriminator which is used internally to identify users with identical usernames.
@return [String, nil] this user’s global name
@return [String] this user’s username
@return [Integer] the public flags on a user’s account
@return [String] this user’s discriminator which is used internally to identify users with identical usernames.
@return [String] this user’s username
@return [true, false] whether this is fake user for a webhook message
@return [true, false] whether this is fake user for a webhook message
@return [true, false] whether this is fake user for a webhook message
Public Instance Methods
Utility function to get a user’s avatar URL. @param format [String, nil] If ‘nil`, the URL will default to `webp` for static avatars, and will detect if the user has a `gif` avatar. You can otherwise specify one of `webp`, `jpg`, `png`, or `gif` to override this. Will always be PNG for default avatars. @return [String] the URL to the avatar image. TODO: Maybe change this method again after discriminator removal ?
# File lib/discordrb/data/user.rb, line 79 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
Utility function to get Discord’s display name of a user not in server @return [String] the name the user displays as (global_name
if they have one, username otherwise)
# File lib/discordrb/data/user.rb, line 54 def display_name global_name || username end
Utility function to get Discord’s distinct representation of a user, i.e. username + discriminator @return [String] distinct representation of user TODO: Maybe change this method again after discriminator removal ?
# File lib/discordrb/data/user.rb, line 67 def distinct if @discriminator && @discriminator != '0' "#{@username}##{@discriminator}" else @username.to_s end end
Utility function to mention users in messages @return [String] the mention code in the form of <@id>
# File lib/discordrb/data/user.rb, line 60 def mention "<@#{@id}>" end