Class: RubyCord::Guild::Member
- Inherits:
-
User
- Object
- DiscordModel
- User
- RubyCord::Guild::Member
- Defined in:
- lib/rubycord/guild/member.rb
Instance Attribute Summary collapse
- #activities ⇒ nil, Array<RubyCord::User::Activity> readonly
- #activity ⇒ nil, RubyCord::User::Activity readonly
- #custom_avatar ⇒ RubyCord::Asset? readonly
-
#deaf ⇒ Boolean
(also: #deaf?)
readonly
Whether the member is deafened.
-
#display_avatar ⇒ RubyCord::Asset
readonly
The display avatar of the member.
- #guild ⇒ nil, RubyCord::Guild readonly
-
#hoisted? ⇒ Boolean
readonly
Whether the member has a hoisted role.
- #hoisted_role ⇒ nil, RubyCord::Guild::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
-
#owner? ⇒ Boolean
readonly
Whether the member is the owner of the guild.
-
#pending ⇒ Boolean
(also: #pending?)
readonly
Whether the member is pending (Not passed member screening).
-
#permissions ⇒ RubyCord::Permission
(also: #guild_permissions)
readonly
The permissions of the member.
-
#premium_since ⇒ Time
readonly
The time the member boosted the guild.
- #presence ⇒ nil, RubyCord::User::Presence readonly
- #roles ⇒ nil, Array<RubyCord::Guild::Role> readonly
- #status ⇒ nil, Symbol readonly
-
#voice_state ⇒ RubyCord::Guild::VoiceChannel::VoiceState
readonly
The voice state of the member.
Attributes inherited from User
#avatar, #bot, #created_at, #discriminator, #flag, #global_name, #id, #username, #verified
Instance Method Summary collapse
-
#add_role(role, reason: nil) ⇒ Async::Task<void>
Add a role to the member.
-
#ban(delete_message_days: 0, reason: nil) ⇒ Async::Task<RubyCord::Guild::Ban>
Ban the member.
-
#can_manage?(role) ⇒ Boolean
Checks if the member can manage the given role.
-
#edit(nick: RubyCord::Unset, role: RubyCord::Unset, mute: RubyCord::Unset, deaf: RubyCord::Unset, channel: RubyCord::Unset, communication_disabled_until: RubyCord::Unset, timeout_until: RubyCord::Unset, reason: nil) ⇒ Async::Task<void>
(also: #modify)
Edit the member.
-
#inspect ⇒ String
Object class and attributes.
-
#kick(reason: nil) ⇒ Async::Task<void>
Kick the member.
-
#remove_role(role, reason: nil) ⇒ Async::Task<void>
Remove a role to the member.
-
#timeout(time, reason: nil) ⇒ Async::Task<void>
(also: #disable_communication)
Timeout the member.
-
#to_s ⇒ String
Format the user as
Display name (@Username)
orDisplay name#Discriminator
style.
Methods inherited from User
Methods included from Internal::Messageable
#delete_message, #edit_message, #fetch_message, #fetch_messages, #fetch_pins, #pin_message, #post, #typing, #unpin_message
Methods inherited from DiscordModel
Instance Attribute Details
#activities ⇒ nil, Array<RubyCord::User::Activity> (readonly)
This method returns an object from client cache. it will return nil
if the object is not in cache.
|
# File 'lib/rubycord/guild/member.rb', line 32
|
#activity ⇒ nil, RubyCord::User::Activity (readonly)
This method returns an object from client cache. it will return nil
if the object is not in cache.
|
# File 'lib/rubycord/guild/member.rb', line 32
|
#custom_avatar ⇒ RubyCord::Asset? (readonly)
19 20 21 |
# File 'lib/rubycord/guild/member.rb', line 19 def custom_avatar @custom_avatar end |
#deaf ⇒ Boolean (readonly) Also known as: deaf?
Returns Whether the member is deafened.
26 27 28 |
# File 'lib/rubycord/guild/member.rb', line 26 def deaf @deaf end |
#display_avatar ⇒ RubyCord::Asset (readonly)
Returns The display avatar of the member.
21 22 23 |
# File 'lib/rubycord/guild/member.rb', line 21 def display_avatar @display_avatar end |
#guild ⇒ nil, RubyCord::Guild (readonly)
This method returns an object from client cache. it will return nil
if the object is not in cache.
|
# File 'lib/rubycord/guild/member.rb', line 32
|
#hoisted? ⇒ Boolean (readonly)
Returns Whether the member has a hoisted role.
|
# File 'lib/rubycord/guild/member.rb', line 32
|
#hoisted_role ⇒ nil, RubyCord::Guild::Role (readonly)
This method returns an object from client cache. it will return nil
if the object is not in cache.
|
# File 'lib/rubycord/guild/member.rb', line 32
|
#joined_at ⇒ Time (readonly)
Returns The time the member joined the guild.
16 17 18 |
# File 'lib/rubycord/guild/member.rb', line 16 def joined_at @joined_at end |
#mention ⇒ String (readonly)
Returns The mention of the member.
|
# File 'lib/rubycord/guild/member.rb', line 32
|
#mute ⇒ Boolean (readonly) Also known as: mute?
Returns Whether the member is muted.
23 24 25 |
# File 'lib/rubycord/guild/member.rb', line 23 def mute @mute end |
#name ⇒ String (readonly)
Returns The display name of the member.
|
# File 'lib/rubycord/guild/member.rb', line 32
|
#nick ⇒ String? (readonly)
14 15 16 |
# File 'lib/rubycord/guild/member.rb', line 14 def nick @nick end |
#owner? ⇒ Boolean (readonly)
Returns Whether the member is the owner of the guild.
|
# File 'lib/rubycord/guild/member.rb', line 32
|
#pending ⇒ Boolean (readonly) Also known as: pending?
Returns Whether the member is pending (Not passed member screening).
29 30 31 |
# File 'lib/rubycord/guild/member.rb', line 29 def pending @pending end |
#permissions ⇒ RubyCord::Permission (readonly) Also known as: guild_permissions
Returns The permissions of the member.
|
# File 'lib/rubycord/guild/member.rb', line 32
|
#premium_since ⇒ Time (readonly)
Returns The time the member boosted the guild.
11 12 13 |
# File 'lib/rubycord/guild/member.rb', line 11 def premium_since @premium_since end |
#presence ⇒ nil, RubyCord::User::Presence (readonly)
This method returns an object from client cache. it will return nil
if the object is not in cache.
|
# File 'lib/rubycord/guild/member.rb', line 32
|
#roles ⇒ nil, Array<RubyCord::Guild::Role> (readonly)
This method returns an object from client cache. it will return nil
if the object is not in cache.
|
# File 'lib/rubycord/guild/member.rb', line 32
|
#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/rubycord/guild/member.rb', line 32
|
#voice_state ⇒ RubyCord::Guild::VoiceChannel::VoiceState (readonly)
Returns The voice state of the member.
|
# File 'lib/rubycord/guild/member.rb', line 32
|
Instance Method Details
#add_role(role, reason: nil) ⇒ Async::Task<void>
Add a role to the member.
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/rubycord/guild/member.rb', line 168 def add_role(role, reason: nil) Async do @client .http .request( RubyCord::Internal::Route.new( "/guilds/#{@guild_id}/members/#{@id}/roles/#{role.is_a?(Role) ? role.id : role}", "//guilds/:guild_id/members/:user_id/roles/:role_id", :put ), nil, audit_log_reason: reason ) .wait end end |
#ban(delete_message_days: 0, reason: nil) ⇒ Async::Task<RubyCord::Guild::Ban>
Ban the member.
304 305 306 307 308 309 310 311 312 |
# File 'lib/rubycord/guild/member.rb', line 304 def ban(delete_message_days: 0, reason: nil) Async do guild.ban_member( self, delete_message_days:, reason: ).wait end end |
#can_manage?(role) ⇒ Boolean
Checks if the member can manage the given role.
321 322 323 324 325 326 |
# File 'lib/rubycord/guild/member.rb', line 321 def can_manage?(role) return true if owner? top_role = roles.max_by(&:position) top_role.position > role.position end |
#edit(nick: RubyCord::Unset, role: RubyCord::Unset, mute: RubyCord::Unset, deaf: RubyCord::Unset, channel: RubyCord::Unset, communication_disabled_until: RubyCord::Unset, timeout_until: RubyCord::Unset, reason: nil) ⇒ Async::Task<void> Also known as: modify
The arguments of this method are defaultly set to RubyCord::Unset
.
Specify value to set the value, if not don't specify or specify RubyCord::Unset
.
Edit the member.
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/rubycord/guild/member.rb', line 227 def edit( nick: RubyCord::Unset, role: RubyCord::Unset, mute: RubyCord::Unset, deaf: RubyCord::Unset, channel: RubyCord::Unset, communication_disabled_until: RubyCord::Unset, timeout_until: RubyCord::Unset, reason: nil ) Async do payload = {} payload[:nick] = nick if nick != RubyCord::Unset payload[:roles] = role if role != RubyCord::Unset payload[:mute] = mute if mute != RubyCord::Unset payload[:deaf] = deaf if deaf != RubyCord::Unset communication_disabled_until = timeout_until if timeout_until != RubyCord::Unset if communication_disabled_until != RubyCord::Unset payload[ :communication_disabled_until ] = communication_disabled_until&.iso8601 end payload[:channel_id] = channel&.id if channel != RubyCord::Unset @client .http .request( RubyCord::Internal::Route.new( "/guilds/#{@guild_id}/members/#{@id}", "//guilds/:guild_id/members/:user_id", :patch ), payload, audit_log_reason: reason ) .wait end end |
#inspect ⇒ String
Returns Object class and attributes.
155 156 157 |
# File 'lib/rubycord/guild/member.rb', line 155 def inspect "#<#{self.class} #{self} id=#{@id}>" end |
#kick(reason: nil) ⇒ Async::Task<void>
Kick the member.
291 292 293 |
# File 'lib/rubycord/guild/member.rb', line 291 def kick(reason: nil) Async { guild.kick_member(self, reason:).wait } end |
#remove_role(role, reason: nil) ⇒ Async::Task<void>
Remove a role to the member.
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/rubycord/guild/member.rb', line 194 def remove_role(role, reason: nil) Async do @client .http .request( RubyCord::Internal::Route.new( "/guilds/#{@guild_id}/members/#{@id}/roles/#{role.is_a?(Role) ? role.id : role}", "//guilds/:guild_id/members/:user_id/roles/:role_id", :delete ), {}, audit_log_reason: reason ) .wait end end |
#timeout(time, reason: nil) ⇒ Async::Task<void> Also known as: disable_communication
Timeout the member.
277 278 279 |
# File 'lib/rubycord/guild/member.rb', line 277 def timeout(time, reason: nil) edit(communication_disabled_until: time, reason:) end |
#to_s ⇒ String
Format the user as Display name (@Username)
or Display name#Discriminator
style.
89 90 91 92 93 94 95 |
# File 'lib/rubycord/guild/member.rb', line 89 def to_s if @discriminator == "0" "#{name} (@#{@username})" else "#{username}##{discriminator}" end end |