Class: Discordrb::Profile
Overview
This class is a special variant of User that represents the bot's user profile (things like email addresses and the avatar). It can be accessed using Bot#profile.
Instance Attribute Summary
Attributes inherited from User
#avatar_id, #discriminator, #game, #id, #roles, #self_mute, #status, #username, #voice_channel
Instance Method Summary collapse
-
#avatar=(avatar) ⇒ Object
Changes the bot's avatar.
-
#bot? ⇒ true
Whether or not the user is the bot.
-
#email=(email) ⇒ Object
Sets the bot's email address.
-
#initialize(data, bot, email, password) ⇒ Profile
constructor
A new instance of Profile.
-
#password=(password) ⇒ Object
Changes the bot's password.
-
#username=(username) ⇒ Object
Sets the bot's username.
Methods inherited from User
#==, #add_role, #avatar, #avatar_url, #await, #mention, #permission?, #pm, #remove_role
Constructor Details
#initialize(data, bot, email, password) ⇒ Profile
Returns a new instance of Profile.
224 225 226 227 228 |
# File 'lib/discordrb/data.rb', line 224 def initialize(data, bot, email, password) super(data, bot) @email = email @password = password end |
Instance Method Details
#avatar=(avatar) ⇒ Object
Changes the bot's avatar.
257 258 259 260 261 262 263 264 265 |
# File 'lib/discordrb/data.rb', line 257 def avatar=(avatar) if avatar.is_a? File avatar_string = 'data:image/jpg;base64,' avatar_string += Base64.strict_encode64(avatar.read) update_server_data(avatar: avatar_string) else update_server_data(avatar: avatar) end end |
#bot? ⇒ true
Whether or not the user is the bot. The Profile can only ever be the bot user, so this always returns true.
232 233 234 |
# File 'lib/discordrb/data.rb', line 232 def bot? true end |
#email=(email) ⇒ Object
Sets the bot's email address. If you use this method, make sure that the login email in the script matches this one afterwards, so the bot doesn't have any trouble logging in in the future.
245 246 247 |
# File 'lib/discordrb/data.rb', line 245 def email=(email) update_server_data(email: email) end |
#password=(password) ⇒ Object
Changes the bot's password. This will invalidate all tokens so you will have to relog the bot.
251 252 253 |
# File 'lib/discordrb/data.rb', line 251 def password=(password) update_server_data(new_password: password) end |
#username=(username) ⇒ Object
Sets the bot's username.
238 239 240 |
# File 'lib/discordrb/data.rb', line 238 def username=(username) update_server_data(username: username) end |