Class: Discorb::User
- Inherits:
 - 
      DiscordModel
      
        
- Object
 - DiscordModel
 - Discorb::User
 
 
- Includes:
 - Messageable
 
- Defined in:
 - lib/discorb/user.rb
 
Overview
Represents a user of discord.
Direct Known Subclasses
Defined Under Namespace
Classes: Flag
Instance Attribute Summary collapse
- 
  
    
      #avatar -> Discorb::Asset 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
The user's avatar.
 - 
  
    
      #bot -> Boolean 
    
    
      (also: #bot?)
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Whether the user is a bot.
 - 
  
    
      #discriminator -> String 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
The user's discriminator.
 - 
  
    
      #flag -> Discorb::User::Flag 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
The user's flags.
 - 
  
    
      #id -> Discorb::Snowflake 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
The user's ID.
 - 
  
    
      #username -> String 
    
    
      (also: #name)
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
The user's username.
 - 
  
    
      #verified -> Boolean 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Whether the user is verified.
 
Instance Method Summary collapse
- 
  
    
      #bot_owner?(strict: false) -> Boolean 
    
    
      (also: #app_owner?)
    
  
  
  
  
  
  
  
  
  
    
Whether the user is a owner of the client.
 - #inspect -> Object
 - 
  
    
      #to_s -> String 
    
    
  
  
  
  
  
  
  
  
  
    
Format the user as
Username#Discriminatorstyle. 
Methods included from Messageable
#fetch_message, #fetch_messages, #post, #typing
Methods inherited from DiscordModel
Instance Attribute Details
#avatar -> Discorb::Asset (readonly)
Returns The user's avatar.
      20 21 22  | 
    
      # File 'lib/discorb/user.rb', line 20 def avatar @avatar end  | 
  
#bot -> Boolean (readonly) Also known as: bot?
Returns Whether the user is a bot.
      22 23 24  | 
    
      # File 'lib/discorb/user.rb', line 22 def bot @bot end  | 
  
#discriminator -> String (readonly)
Returns The user's discriminator.
      18 19 20  | 
    
      # File 'lib/discorb/user.rb', line 18 def discriminator @discriminator end  | 
  
#flag -> Discorb::User::Flag (readonly)
Returns The user's flags.
      16 17 18  | 
    
      # File 'lib/discorb/user.rb', line 16 def flag @flag end  | 
  
#id -> Discorb::Snowflake (readonly)
Returns The user's ID.
      14 15 16  | 
    
      # File 'lib/discorb/user.rb', line 14 def id @id end  | 
  
#username -> String (readonly) Also known as: name
Returns The user's username.
      11 12 13  | 
    
      # File 'lib/discorb/user.rb', line 11 def username @username end  | 
  
#verified -> Boolean (readonly)
Returns Whether the user is verified.
      9 10 11  | 
    
      # File 'lib/discorb/user.rb', line 9 def verified @verified end  | 
  
Instance Method Details
#bot_owner?(strict: false) -> Boolean Also known as: app_owner?
This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.
This method calls HTTP request.
Whether the user is a owner of the client.
      57 58 59 60 61 62 63 64 65 66 67 68  | 
    
      # File 'lib/discorb/user.rb', line 57 def bot_owner?(strict: false) Async do app = @client.fetch_application.wait if app.team.nil? app.owner == self elsif strict app.team.owner == self else app.team.members.any? { |m| m.user == self } end end end  | 
  
#inspect -> Object
      44 45 46  | 
    
      # File 'lib/discorb/user.rb', line 44 def inspect "#<#{self.class} #{self}>" end  | 
  
#to_s -> String
Format the user as Username#Discriminator style.
      40 41 42  | 
    
      # File 'lib/discorb/user.rb', line 40 def to_s "#{@username}##{@discriminator}" end  |