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, #read)

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



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

#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

#dndObject Also known as: busy

Note:

Only usable on User accounts.

Sets the user status setting to Do Not Disturb.



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

def dnd
  update_profile_status_setting('dnd')
end

#idleObject

Note:

Only usable on User accounts.

Sets the user status setting to Idle.



48
49
50
# File 'lib/discordrb/data/profile.rb', line 48

def idle
  update_profile_status_setting('idle')
end

#inspectObject

The inspect method is overwritten to give more useful output



67
68
69
# File 'lib/discordrb/data/profile.rb', line 67

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

#invisibleObject

Note:

Only usable on User accounts.

Sets the user status setting to Invisible.



62
63
64
# File 'lib/discordrb/data/profile.rb', line 62

def invisible
  update_profile_status_setting('invisible')
end

#onlineObject

Note:

Only usable on User accounts.

Sets the user status setting to Online.



42
43
44
# File 'lib/discordrb/data/profile.rb', line 42

def online
  update_profile_status_setting('online')
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