Class: RubyCord::User
- Inherits:
-
DiscordModel
- Object
- DiscordModel
- RubyCord::User
- Includes:
- Internal::Messageable
- Defined in:
- lib/rubycord/user.rb
Overview
Represents a user of discord.
Direct Known Subclasses
Defined Under Namespace
Classes: Activity, Avatar, Flag, Presence
Instance Attribute Summary collapse
-
#avatar ⇒ RubyCord::Asset, RubyCord::DefaultAvatar
readonly
The user's avatar.
-
#bot ⇒ Boolean
(also: #bot?)
readonly
Whether the user is a bot.
-
#created_at ⇒ Time
readonly
The time the user was created.
-
#discriminator ⇒ String
readonly
deprecated
Deprecated.
This will be removed in the future because of discord changes.
-
#flag ⇒ RubyCord::User::Flag
readonly
The user's flags.
-
#global_name ⇒ String
readonly
The user's global name.
-
#id ⇒ RubyCord::Snowflake
readonly
The user's ID.
-
#mention ⇒ String
readonly
The user's mention.
-
#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) ⇒ Async::Task<Boolean>
(also: #app_owner?)
Whether the user is a owner of the client.
-
#inspect ⇒ String
Object class and attributes.
-
#to_s ⇒ String
(also: #to_s_user)
Format the user as
Global name (@Username)
orUsername#Discriminator
style.
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
#avatar ⇒ RubyCord::Asset, RubyCord::DefaultAvatar (readonly)
Returns The user's avatar.
25 26 27 |
# File 'lib/rubycord/user.rb', line 25 def avatar @avatar end |
#bot ⇒ Boolean (readonly) Also known as: bot?
Returns Whether the user is a bot.
27 28 29 |
# File 'lib/rubycord/user.rb', line 27 def bot @bot end |
#created_at ⇒ Time (readonly)
Returns The time the user was created.
30 31 32 |
# File 'lib/rubycord/user.rb', line 30 def created_at @created_at end |
#discriminator ⇒ String (readonly)
This will be removed in the future because of discord changes.
Returns The user's discriminator. ("0" for new users, "7740" for old users.).
21 22 23 |
# File 'lib/rubycord/user.rb', line 21 def discriminator @discriminator end |
#flag ⇒ RubyCord::User::Flag (readonly)
Returns The user's flags.
18 19 20 |
# File 'lib/rubycord/user.rb', line 18 def flag @flag end |
#global_name ⇒ String (readonly)
Returns The user's global name. ("Nanashi." for new users, old users have no global name.).
23 24 25 |
# File 'lib/rubycord/user.rb', line 23 def global_name @global_name end |
#id ⇒ RubyCord::Snowflake (readonly)
Returns The user's ID.
16 17 18 |
# File 'lib/rubycord/user.rb', line 16 def id @id end |
#mention ⇒ String (readonly)
Returns The user's mention.
|
# File 'lib/rubycord/user.rb', line 32
|
#username ⇒ String (readonly) Also known as: name
Returns The user's username. ("sevenc_nanashi" for new users, "Nanashi." for old users.).
13 14 15 |
# File 'lib/rubycord/user.rb', line 13 def username @username end |
#verified ⇒ Boolean (readonly)
Returns Whether the user is verified.
11 12 13 |
# File 'lib/rubycord/user.rb', line 11 def verified @verified end |
Instance Method Details
#bot_owner?(strict: false) ⇒ Async::Task<Boolean> Also known as: app_owner?
Whether the user is a owner of the client.
81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/rubycord/user.rb', line 81 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 ⇒ String
Returns Object class and attributes.
69 70 71 |
# File 'lib/rubycord/user.rb', line 69 def inspect "#<#{self.class} #{self}>" end |
#to_s ⇒ String Also known as: to_s_user
Format the user as Global name (@Username)
or Username#Discriminator
style.
54 55 56 57 58 59 60 |
# File 'lib/rubycord/user.rb', line 54 def to_s if @discriminator == "0" "#{@global_name} (@#{@username})" else "#{@username}##{@discriminator}" end end |