Class: Discorb::ClientUser

Inherits:
User show all
Defined in:
lib/discorb/user.rb

Overview

Represents a client user.

Instance Attribute Summary

Attributes inherited from User

#avatar, #bot, #created_at, #discriminator, #flag, #id, #mention, #username, #verified

Instance Method Summary collapse

Methods inherited from User

#bot_owner?, #inspect, #to_s

Methods included from Messageable

#delete_message, #edit_message, #fetch_message, #fetch_messages, #fetch_pins, #pin_message, #post, #typing, #unpin_message

Methods inherited from DiscordModel

#==, #eql?, #inspect

Instance Method Details

#edit(name: Discorb::Unset, avatar: Discorb::Unset) -> Async::Task<void>

Note:

The arguments of this method are defaultly set to Discorb::Unset. Specify value to set the value, if not don't specify or specify Discorb::Unset.

Edit the client user.

Parameters:

  • name (String) (defaults to: Discorb::Unset)

    The new username.

  • avatar (Discorb::Image) (defaults to: Discorb::Unset)

    The new avatar.

Returns:

  • (Async::Task<void>)

    The task.



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/discorb/user.rb', line 186

def edit(name: Discorb::Unset, avatar: Discorb::Unset)
  Async do
    payload = {}
    payload[:username] = name unless name == Discorb::Unset
    if avatar == Discorb::Unset
      # Nothing
    elsif avatar.nil?
      payload[:avatar] = nil
    else
      payload[:avatar] = avatar.to_s
    end
    @client
      .http
      .request(Route.new("/users/@me", "//users/@me", :patch), payload)
      .wait
    self
  end
end