Class: Discorb::Member
- Inherits:
 - 
      User
      
        
- Object
 - DiscordModel
 - User
 - Discorb::Member
 
 
- Defined in:
 - lib/discorb/member.rb
 
Overview
Represents a member of a guild.
Instance Attribute Summary collapse
- #activities -> nil, Array<Discorb::Activity> readonly
 - #activity -> nil, Discorb::Activity readonly
 - #custom_avatar -> Discorb::Asset? readonly
 - 
  
    
      #deaf -> Boolean 
    
    
      (also: #deaf?)
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Whether the member is deafened.
 - 
  
    
      #display_avatar -> Discorb::Asset 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
The display avatar of the member.
 - #guild -> nil, Discorb::Guild readonly
 - 
  
    
      #hoisted? -> Boolean 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Whether the member has a hoisted role.
 - #hoisted_role -> nil, Discorb::Role readonly
 - 
  
    
      #joined_at -> Time 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
The time the member joined the guild.
 - 
  
    
      #mention -> String 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
The mention of the member.
 - 
  
    
      #mute -> Boolean 
    
    
      (also: #mute?)
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Whether the member is muted.
 - 
  
    
      #name -> String 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
The display name of the member.
 - #nick -> String? readonly
 - 
  
    
      #pending -> Boolean 
    
    
      (also: #pending?)
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Whether the member is pending (Not passed member screening).
 - 
  
    
      #permissions -> Discorb::Permission 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
The permissions of the member.
 - 
  
    
      #premium_since -> Time 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
The time the member boosted the guild.
 - #presence -> nil, Discorb::Presence readonly
 - #roles -> nil, Array<Discorb::Role> readonly
 - #status -> nil, Symbol readonly
 - 
  
    
      #voice_state -> Discorb::VoiceState 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
The voice state of the member.
 
Attributes inherited from User
#avatar, #bot, #discriminator, #flag, #id, #username, #verified
Instance Method Summary collapse
- 
  
    
      #add_role(role, reason: nil) -> Object 
    
    
  
  
  
  
  
  
  
  
  
    
Add a role to the member.
 - 
  
    
      #ban(delete_message_days: 0, reason: nil) -> Discorb::Guild::Ban 
    
    
  
  
  
  
  
  
  
  
  
    
Ban the member.
 - 
  
    
      #edit(nick: :unset, role: :unset, mute: :unset, deaf: :unset, channel: :unset, reason: nil) -> Object 
    
    
      (also: #modify)
    
  
  
  
  
  
  
  
  
  
    
Edit the member.
 - #inspect -> Object
 - 
  
    
      #kick(reason: nil) -> Object 
    
    
  
  
  
  
  
  
  
  
  
    
Kick the member.
 - 
  
    
      #remove_role(role, reason: nil) -> Object 
    
    
  
  
  
  
  
  
  
  
  
    
Remove a role to the member.
 - 
  
    
      #to_s -> String 
    
    
  
  
  
  
  
  
  
  
  
    
Format the member to
@namestyle. 
Methods inherited from User
Methods included from Messageable
#fetch_message, #fetch_messages, #post, #typing
Methods inherited from DiscordModel
Instance Attribute Details
#activities -> nil, Array<Discorb::Activity> (readonly)
This method returns an object from client cache. it will return nil if the object is not in cache.
| 
       | 
    
      # File 'lib/discorb/member.rb', line 30
     | 
  
#activity -> nil, Discorb::Activity (readonly)
This method returns an object from client cache. it will return nil if the object is not in cache.
| 
       | 
    
      # File 'lib/discorb/member.rb', line 30
     | 
  
#custom_avatar -> Discorb::Asset? (readonly)
      17 18 19  | 
    
      # File 'lib/discorb/member.rb', line 17 def custom_avatar @custom_avatar end  | 
  
#deaf -> Boolean (readonly) Also known as: deaf?
Returns Whether the member is deafened.
      24 25 26  | 
    
      # File 'lib/discorb/member.rb', line 24 def deaf @deaf end  | 
  
#display_avatar -> Discorb::Asset (readonly)
Returns The display avatar of the member.
      19 20 21  | 
    
      # File 'lib/discorb/member.rb', line 19 def display_avatar @display_avatar end  | 
  
#guild -> nil, Discorb::Guild (readonly)
This method returns an object from client cache. it will return nil if the object is not in cache.
| 
       | 
    
      # File 'lib/discorb/member.rb', line 30
     | 
  
#hoisted? -> Boolean (readonly)
Returns Whether the member has a hoisted role.
| 
       | 
    
      # File 'lib/discorb/member.rb', line 30
     | 
  
#hoisted_role -> nil, Discorb::Role (readonly)
This method returns an object from client cache. it will return nil if the object is not in cache.
| 
       | 
    
      # File 'lib/discorb/member.rb', line 30
     | 
  
#joined_at -> Time (readonly)
Returns The time the member joined the guild.
      14 15 16  | 
    
      # File 'lib/discorb/member.rb', line 14 def joined_at @joined_at end  | 
  
#mention -> String (readonly)
Returns The mention of the member.
| 
       | 
    
      # File 'lib/discorb/member.rb', line 30
     | 
  
#mute -> Boolean (readonly) Also known as: mute?
Returns Whether the member is muted.
      21 22 23  | 
    
      # File 'lib/discorb/member.rb', line 21 def mute @mute end  | 
  
#name -> String (readonly)
Returns The display name of the member.
| 
       | 
    
      # File 'lib/discorb/member.rb', line 30
     | 
  
#nick -> String? (readonly)
      12 13 14  | 
    
      # File 'lib/discorb/member.rb', line 12 def nick @nick end  | 
  
#pending -> Boolean (readonly) Also known as: pending?
Returns Whether the member is pending (Not passed member screening).
      27 28 29  | 
    
      # File 'lib/discorb/member.rb', line 27 def pending @pending end  | 
  
#permissions -> Discorb::Permission (readonly)
Returns The permissions of the member.
| 
       | 
    
      # File 'lib/discorb/member.rb', line 30
     | 
  
#premium_since -> Time (readonly)
Returns The time the member boosted the guild.
      9 10 11  | 
    
      # File 'lib/discorb/member.rb', line 9 def premium_since @premium_since end  | 
  
#presence -> nil, Discorb::Presence (readonly)
This method returns an object from client cache. it will return nil if the object is not in cache.
| 
       | 
    
      # File 'lib/discorb/member.rb', line 30
     | 
  
#roles -> nil, Array<Discorb::Role> (readonly)
This method returns an object from client cache. it will return nil if the object is not in cache.
| 
       | 
    
      # File 'lib/discorb/member.rb', line 30
     | 
  
#status -> nil, Symbol (readonly)
This method returns an object from client cache. it will return nil if the object is not in cache.
| 
       | 
    
      # File 'lib/discorb/member.rb', line 30
     | 
  
#voice_state -> Discorb::VoiceState (readonly)
Returns The voice state of the member.
| 
       | 
    
      # File 'lib/discorb/member.rb', line 30
     | 
  
Instance Method Details
#add_role(role, reason: nil) -> Object
This method calls HTTP request.
This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.
Add a role to the member.
      141 142 143 144 145  | 
    
      # File 'lib/discorb/member.rb', line 141 def add_role(role, reason: nil) Async do @client.http.put("/guilds/#{@guild_id}/members/#{@id}/roles/#{role.is_a?(Role) ? role.id : role}", nil, audit_log_reason: reason).wait end end  | 
  
#ban(delete_message_days: 0, reason: nil) -> Discorb::Guild::Ban
Ban the member.
      207 208 209 210 211  | 
    
      # File 'lib/discorb/member.rb', line 207 def ban(delete_message_days: 0, reason: nil) Async do guild.ban_member(self, delete_message_days: , reason: reason).wait end end  | 
  
#edit(nick: :unset, role: :unset, mute: :unset, deaf: :unset, channel: :unset, reason: nil) -> Object Also known as: modify
This method calls HTTP request.
This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.
The arguments of this method are defaultly set to :unset. Specify value to set the value, if not don't specify or specify :unset.
Edit the member.
      174 175 176 177 178 179 180 181 182 183 184  | 
    
      # File 'lib/discorb/member.rb', line 174 def edit(nick: :unset, role: :unset, mute: :unset, deaf: :unset, channel: :unset, reason: nil) Async do payload = {} payload[:nick] = nick if nick != :unset payload[:roles] = role if role != :unset payload[:mute] = mute if mute != :unset payload[:deaf] = deaf if deaf != :unset payload[:channel_id] = channel&.id if channel != :unset @client.http.patch("/guilds/#{@guild_id}/members/#{@id}", payload, audit_log_reason: reason).wait end end  | 
  
#inspect -> Object
      129 130 131  | 
    
      # File 'lib/discorb/member.rb', line 129 def inspect "#<#{self.class} #{self} id=#{@id}>" end  | 
  
#kick(reason: nil) -> Object
Kick the member.
      193 194 195 196 197  | 
    
      # File 'lib/discorb/member.rb', line 193 def kick(reason: nil) Async do guild.kick_member(self, reason: reason).wait end end  | 
  
#remove_role(role, reason: nil) -> Object
This method calls HTTP request.
This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.
Remove a role to the member.
      155 156 157 158 159  | 
    
      # File 'lib/discorb/member.rb', line 155 def remove_role(role, reason: nil) Async do @client.http.delete("/guilds/#{@guild_id}/members/#{@id}/roles/#{role.is_a?(Role) ? role.id : role}", audit_log_reason: reason).wait end end  | 
  
#to_s -> String
Format the member to @name style.
      77 78 79  | 
    
      # File 'lib/discorb/member.rb', line 77 def to_s "@#{name}" end  |