module Discordrb::UserAttributes

Mixin for the attributes users should have

Attributes

avatar_id[RW]

@return [String] the ID of this user's current avatar, can be used to generate an avatar URL. @see avatar_url

bot_account[R]

@return [true, false] whether this user is a Discord bot account

bot_account?[R]

@return [true, false] whether this user is a Discord bot account

discord_tag[R]

@return [String] this user's discriminator which is used internally to identify users with identical usernames.

discrim[R]

@return [String] this user's discriminator which is used internally to identify users with identical usernames.

discriminator[R]

@return [String] this user's discriminator which is used internally to identify users with identical usernames.

name[R]

@return [String] this user's username

tag[R]

@return [String] this user's discriminator which is used internally to identify users with identical usernames.

username[R]

@return [String] this user's username

Public Instance Methods

avatar_url(format = nil) click to toggle source

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.

# File lib/discordrb/data.rb, line 140
def avatar_url(format = nil)
  return API::User.default_avatar(@discriminator) unless @avatar_id

  API::User.avatar_url(@id, @avatar_id, format)
end
distinct() click to toggle source

Utility function to get Discord's distinct representation of a user, i.e. username + discriminator @return [String] distinct representation of user

# File lib/discordrb/data.rb, line 133
def distinct
  "#{@username}##{@discriminator}"
end
mention() click to toggle source

Utility function to mention users in messages @return [String] the mention code in the form of <@id>

# File lib/discordrb/data.rb, line 127
def mention
  "<@#{@id}>"
end