Module: Vox::HTTP::Routes::User
- Defined in:
- lib/vox/http/routes/user.rb
Overview
Mixin for user routes.
Instance Method Summary collapse
-
#create_dm(recipient_id) ⇒ Hash<Symbol, Object>
Create a new DM channel with a user.
-
#create_group_dm(access_tokens, nicks: :undef) ⇒ Object
Create a new DM with multiple users.
-
#get_current_user ⇒ Hash<Symbol, Object>
Get information about the current user.
-
#get_current_user_guilds(before: :undef, after: :undef, limit: :undef) ⇒ Array<Hash<Symbol, Object>>
List the guilds that the current user is in.
-
#get_user(user_id) ⇒ Hash<Symbol, Object] The [user](https://discord.com/developers/docs/resources/user#user-object) object for the target user.
Get information about a user by ID.
-
#get_user_connections ⇒ Array<Hash<Symbol, Object>>
Get a list of connection objects for the current user.
-
#get_user_dms ⇒ Array<Hash<Symbol, Object>>
Get a list of the current user’s DM channels.
-
#leave_guild(guild_id) ⇒ nil
Leave a guild.
-
#modify_current_user(username: :undef, avatar: :undef) ⇒ Hash<Symbol, Object>
Modify the current user.
Instance Method Details
#create_dm(recipient_id) ⇒ Hash<Symbol, Object>
Create a new DM channel with a user.
83 84 85 |
# File 'lib/vox/http/routes/user.rb', line 83 def create_dm(recipient_id) request(Route.new(:POST, '/users/@me/channels'), json: { recipient_id: recipient_id }) end |
#create_group_dm(access_tokens, nicks: :undef) ⇒ Object
This endpoint was intended for a now deprecated SDK. DMs created with this endpoint are not visible in the Discord client.
This endpoint is limited to 10 active group DMs.
Create a new DM with multiple users.
96 97 98 99 |
# File 'lib/vox/http/routes/user.rb', line 96 def create_group_dm(access_tokens, nicks: :undef) json = filter_undef({ access_tokens: access_tokens, nicks: nicks }) request(Route.new(:POST, '/users/@me/channels'), json: json) end |
#get_current_user ⇒ Hash<Symbol, Object>
Get information about the current user.
20 21 22 |
# File 'lib/vox/http/routes/user.rb', line 20 def get_current_user request(Route.new(:GET, '/users/@me')) end |
#get_current_user_guilds(before: :undef, after: :undef, limit: :undef) ⇒ Array<Hash<Symbol, Object>>
List the guilds that the current user is in.
57 58 59 60 |
# File 'lib/vox/http/routes/user.rb', line 57 def get_current_user_guilds(before: :undef, after: :undef, limit: :undef) params = filter_undef({ before: before, after: after, limit: limit }) request(Route.new(:GET, '/users/@me/guilds'), query: params) end |
#get_user(user_id) ⇒ Hash<Symbol, Object] The [user](https://discord.com/developers/docs/resources/user#user-object) object for the target user.
Get information about a user by ID.
28 29 30 |
# File 'lib/vox/http/routes/user.rb', line 28 def get_user(user_id) request(Route.new(:GET, '/users/%{user_id}', user_id: user_id)) end |
#get_user_connections ⇒ Array<Hash<Symbol, Object>>
Get a list of connection objects for the current user.
106 107 108 |
# File 'lib/vox/http/routes/user.rb', line 106 def get_user_connections request(Route.new(:GET, '/users/@me/connections')) end |
#get_user_dms ⇒ Array<Hash<Symbol, Object>>
Get a list of the current user’s DM channels.
74 75 76 |
# File 'lib/vox/http/routes/user.rb', line 74 def get_user_dms request(Route.new(:GET, '/users/@me/channels')) end |
#leave_guild(guild_id) ⇒ nil
Leave a guild.
66 67 68 |
# File 'lib/vox/http/routes/user.rb', line 66 def leave_guild(guild_id) request(Route.new(:DELETE, '/users/@me/guilds/%{guild_id}', guild_id: guild_id)) end |
#modify_current_user(username: :undef, avatar: :undef) ⇒ Hash<Symbol, Object>
Modify the current user.
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/vox/http/routes/user.rb', line 38 def modify_current_user(username: :undef, avatar: :undef) avatar = if avatar != :undef && !avatar.nil? image_data = avatar.io.read "data:#{avatar.content_type};base64,#{Base64.encode64(image_data)}" else :undef end json = filter_undef({ username: username, avatar: avatar }) request(Route.new(:PATCH, '/users/@me'), json: json) end |