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.
Instance Attribute Summary
Attributes inherited from User
#game, #status, #stream_type, #stream_url
Attributes included from UserAttributes
#avatar_id, #bot_account, #discriminator, #username
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.
-
#initialize(data, bot) ⇒ Profile
constructor
A new instance of Profile.
-
#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!, #on, #pm, #send_file, #webhook?
Methods included from UserAttributes
#avatar_url, #distinct, #mention
Methods included from IDObject
#==, #creation_time, synthesise
Constructor Details
#initialize(data, bot) ⇒ Profile
Returns a new instance of Profile.
801 802 803 |
# File 'lib/discordrb/data.rb', line 801 def initialize(data, bot) super(data, bot) end |
Instance Method Details
#avatar=(avatar) ⇒ Object
Changes the bot's avatar.
822 823 824 825 826 827 828 829 830 831 832 833 |
# File 'lib/discordrb/data.rb', line 822 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.
807 808 809 |
# File 'lib/discordrb/data.rb', line 807 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.
857 858 859 |
# File 'lib/discordrb/data.rb', line 857 def dnd update_profile_status_setting('dnd') end |
#idle ⇒ Object
Only usable on User accounts.
Sets the user status setting to Idle.
851 852 853 |
# File 'lib/discordrb/data.rb', line 851 def idle update_profile_status_setting('idle') end |
#inspect ⇒ Object
The inspect method is overwritten to give more useful output
870 871 872 |
# File 'lib/discordrb/data.rb', line 870 def inspect "<Profile user=#{super}>" end |
#invisible ⇒ Object
Only usable on User accounts.
Sets the user status setting to Invisible.
865 866 867 |
# File 'lib/discordrb/data.rb', line 865 def invisible update_profile_status_setting('invisible') end |
#online ⇒ Object
Only usable on User accounts.
Sets the user status setting to Online.
845 846 847 |
# File 'lib/discordrb/data.rb', line 845 def online update_profile_status_setting('online') end |
#username=(username) ⇒ Object Also known as: name=
Sets the bot's username.
813 814 815 |
# File 'lib/discordrb/data.rb', line 813 def username=(username) update_profile_data(username: username) end |