Class: LibDiscord::User

Inherits:
Resource show all
Defined in:
lib/lib_discord/user.rb

Overview

Users Resource

Do not instantiate a User directly. Instead request one from an instance of Client.

client = LibDiscord::Client.new("Bot auth.token")
u = client["user"]

Instance Method Summary collapse

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from LibDiscord::Resource

Instance Method Details

#create_dm(json:) ⇒ Response

Parameters:

  • json (#to_json)

    JSON serializable payload

Returns:

Raises:

See Also:



113
114
115
# File 'lib/lib_discord/user.rb', line 113

def create_dm(json:)
  send_request(:post, "/users/@me/channels", json:)
end

#create_group_dm(json:) ⇒ Response

Parameters:

  • json (#to_json)

    JSON serializable payload

Returns:

Raises:

See Also:



127
128
129
# File 'lib/lib_discord/user.rb', line 127

def create_group_dm(json:)
  send_request(:post, "/users/@me/channels", json:)
end

#get_current_userResponse

Returns:

Raises:

See Also:



25
26
27
# File 'lib/lib_discord/user.rb', line 25

def get_current_user
  send_request(:get, "/users/@me")
end

#get_current_user_application_role_connection(application_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



153
154
155
# File 'lib/lib_discord/user.rb', line 153

def get_current_user_application_role_connection(application_id:)
  send_request(:get, "/users/@me/applications/#{application_id}/role-connections")
end

#get_current_user_connectionsResponse

Returns:

Raises:

See Also:



138
139
140
# File 'lib/lib_discord/user.rb', line 138

def get_current_user_connections
  send_request(:get, "/users/@me/connections")
end

#get_current_user_guild_member(guild_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



84
85
86
# File 'lib/lib_discord/user.rb', line 84

def get_current_user_guild_member(guild_id:)
  send_request(:get, "/users/@me/guilds/#{guild_id}/member")
end

#get_current_user_guilds(params: {}) ⇒ Response

Parameters:

  • params (Hash) (defaults to: {})

    optional HTTP query parameters

Returns:

Raises:

  • (TimeoutError)

    if the HTTP request times out

  • (ConstraintError)

    if params cannot be coerced into a valid query parameters string

See Also:



69
70
71
# File 'lib/lib_discord/user.rb', line 69

def get_current_user_guilds(params: {})
  send_request(:get, "/users/@me/guilds", params:)
end

#get_user(user_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



40
41
42
# File 'lib/lib_discord/user.rb', line 40

def get_user(user_id:)
  send_request(:get, "/users/#{user_id}")
end

#leave_guild(guild_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



99
100
101
# File 'lib/lib_discord/user.rb', line 99

def leave_guild(guild_id:)
  send_request(:delete, "/users/@me/guilds/#{guild_id}")
end

#modify_current_user(json:) ⇒ Response

Parameters:

  • json (#to_json)

    JSON serializable payload

Returns:

Raises:

See Also:



54
55
56
# File 'lib/lib_discord/user.rb', line 54

def modify_current_user(json:)
  send_request(:patch, "/users/@me", json:)
end

#update_current_user_application_role_connection(application_id:, json:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



170
171
172
# File 'lib/lib_discord/user.rb', line 170

def update_current_user_application_role_connection(application_id:, json:)
  send_request(:put, "/users/@me/applications/#{application_id}/role-connection", json:)
end