Class: Discordrb::Profile

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

Overview

A class that represents the bot user itself and has methods to change stuff

Instance Attribute Summary

Attributes inherited from User

#avatar, #discriminator, #game, #id, #roles, #self_deaf, #self_mute, #server_deaf, #server_mute, #status, #username, #voice_channel

Instance Method Summary collapse

Methods inherited from User

#await, #delete_roles, #mention, #merge_roles, #move, #permission?, #pm, #update_roles

Constructor Details

#initialize(data, bot, email, password) ⇒ Profile



130
131
132
133
134
# File 'lib/discordrb/data.rb', line 130

def initialize(data, bot, email, password)
  super(data, bot)
  @email = email
  @password = password
end

Instance Method Details

#avatar=(avatar) ⇒ Object



152
153
154
155
156
157
158
159
160
# File 'lib/discordrb/data.rb', line 152

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?Boolean



136
137
138
# File 'lib/discordrb/data.rb', line 136

def bot?
  true
end

#email=(email) ⇒ Object



144
145
146
# File 'lib/discordrb/data.rb', line 144

def email=(email)
  update_server_data(email: email)
end

#password=(password) ⇒ Object



148
149
150
# File 'lib/discordrb/data.rb', line 148

def password=(password)
  update_server_data(new_password: password)
end

#update_data(new_data) ⇒ Object



162
163
164
165
166
167
# File 'lib/discordrb/data.rb', line 162

def update_data(new_data)
  @email = new_data[:email] || @email
  @password = new_data[:new_password] || @password
  @username = new_data[:username] || @username
  @avatar = new_data[:avatar] || @avatar
end

#username=(username) ⇒ Object



140
141
142
# File 'lib/discordrb/data.rb', line 140

def username=(username)
  update_server_data(username: username)
end