Class: Discordrb::Profile
Overview
This class is a special variant of User that represents the bot’s user profile (things like own username and the avatar). It can be accessed using Bot#profile.
Constant Summary
Constants included from UserAttributes
Instance Attribute Summary
Attributes inherited from User
#activities, #client_status, #status
Attributes included from UserAttributes
#avatar_id, #bot_account, #discriminator, #global_name, #public_flags, #username, #webhook_account
Attributes included from IDObject
Instance Method Summary collapse
-
#avatar=(avatar) ⇒ Object
Changes the bot’s avatar.
-
#current_bot? ⇒ true
Whether or not the user is the bot.
-
#dnd ⇒ Object
(also: #busy)
Sets the user status setting to Do Not Disturb.
-
#idle ⇒ Object
Sets the user status setting to Idle.
-
#inspect ⇒ Object
The inspect method is overwritten to give more useful output.
-
#invisible ⇒ Object
Sets the user status setting to Invisible.
-
#online ⇒ Object
Sets the user status setting to Online.
-
#username=(username) ⇒ Object
(also: #name=)
Sets the bot’s username.
Methods inherited from User
#await, #await!, #dnd?, #game, #idle?, #offline?, #on, #online?, #pm, #send_file, #stream_type, #stream_url
Methods included from UserAttributes
#avatar_url, #display_name, #distinct, #mention
Methods included from IDObject
#==, #creation_time, synthesise
Instance Method Details
#avatar=(avatar) ⇒ Object
Changes the bot’s avatar.
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/discordrb/data/profile.rb', line 24 def avatar=(avatar) if avatar.respond_to? :read # Set the file to binary mode if supported, so we don't get problems with Windows avatar.binmode if avatar.respond_to?(:binmode) avatar_string = 'data:image/jpg;base64,' avatar_string += Base64.strict_encode64(avatar.read) update_profile_data(avatar: avatar_string) else update_profile_data(avatar: avatar) end end |
#current_bot? ⇒ true
Whether or not the user is the bot. The Profile can only ever be the bot user, so this always returns true.
9 10 11 |
# File 'lib/discordrb/data/profile.rb', line 9 def current_bot? true end |
#dnd ⇒ Object Also known as: busy
Only usable on User accounts.
Sets the user status setting to Do Not Disturb.
59 60 61 |
# File 'lib/discordrb/data/profile.rb', line 59 def dnd update_profile_status_setting('dnd') end |
#idle ⇒ Object
Only usable on User accounts.
Sets the user status setting to Idle.
53 54 55 |
# File 'lib/discordrb/data/profile.rb', line 53 def idle update_profile_status_setting('idle') end |
#inspect ⇒ Object
The inspect method is overwritten to give more useful output
72 73 74 |
# File 'lib/discordrb/data/profile.rb', line 72 def inspect "<Profile user=#{super}>" end |
#invisible ⇒ Object
Only usable on User accounts.
Sets the user status setting to Invisible.
67 68 69 |
# File 'lib/discordrb/data/profile.rb', line 67 def invisible update_profile_status_setting('invisible') end |
#online ⇒ Object
Only usable on User accounts.
Sets the user status setting to Online.
47 48 49 |
# File 'lib/discordrb/data/profile.rb', line 47 def online update_profile_status_setting('online') end |
#username=(username) ⇒ Object Also known as: name=
Sets the bot’s username.
15 16 17 |
# File 'lib/discordrb/data/profile.rb', line 15 def username=(username) update_profile_data(username: username) end |