Class: Discordrb::Profile

Inherits:
User
  • Object
show all
Defined in:
lib/discordrb/data/profile.rb

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

UserAttributes::FLAGS

Instance Attribute Summary

Attributes inherited from User

#activities, #client_status, #status

Attributes included from UserAttributes

#avatar_decoration, #avatar_id, #bot_account, #collectibles, #discriminator, #global_name, #primary_server, #public_flags, #system_account, #username, #webhook_account

Attributes included from IDObject

#id

Instance Method Summary collapse

Methods inherited from User

#await, #await!, #banner_id, #dnd?, #game, #idle?, #offline?, #on, #online?, #pm, #send_file, #stream_type, #stream_url

Methods included from UserAttributes

#avatar_url, #banner_url, #display_name, #distinct, #mention

Methods included from IDObject

#==, #creation_time, synthesise

Instance Method Details

#avatar=(avatar) ⇒ Object

Changes the bot's avatar.

Parameters:

  • avatar (String, File, #read, nil)

    A file to be used as the avatar, either something readable (e.g. File Object) or a data URI.



24
25
26
27
28
29
30
# File 'lib/discordrb/data/profile.rb', line 24

def avatar=(avatar)
  if avatar.respond_to?(:read)
    update_profile_data(avatar: Discordrb.encode64(avatar))
  else
    update_profile_data(avatar: avatar)
  end
end

#banner=(banner) ⇒ Object

Changes the bot's banner.

Parameters:

  • banner (String, File, #read, nil)

    A file to be used as the banner, either something readable (e.g. File Object) or a data URI.



35
36
37
38
39
40
41
# File 'lib/discordrb/data/profile.rb', line 35

def banner=(banner)
  if banner.respond_to?(:read)
    update_profile_data(banner: Discordrb.encode64(banner))
  else
    update_profile_data(banner: banner)
  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.

Returns:

  • (true)


9
10
11
# File 'lib/discordrb/data/profile.rb', line 9

def current_bot?
  true
end

#inspectObject

The inspect method is overwritten to give more useful output



53
54
55
# File 'lib/discordrb/data/profile.rb', line 53

def inspect
  "<Profile user=#{super}>"
end

#username=(username) ⇒ Object Also known as: name=

Sets the bot's username.

Parameters:

  • username (String)

    The new username.



15
16
17
# File 'lib/discordrb/data/profile.rb', line 15

def username=(username)
  update_profile_data(username: username)
end