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, #username, #verified

Instance Method Summary collapse

Methods inherited from User

#bot_owner?, #inspect, #to_s

Methods included from Messageable

#fetch_message, #fetch_messages, #post, #typing

Methods inherited from DiscordModel

#==, #eql?, #hash

Instance Method Details

#edit(name: :unset, avatar: :unset) -> Object

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Note:

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

Edit the client user.

Parameters:

  • name (String) (defaults to: :unset)

    The new username.

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

    The new avatar.

Raises:



152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/discorb/user.rb', line 152

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