Module: Discordrb::API::User
- Defined in:
- lib/discordrb/api/user.rb
Overview
API calls for User object
Class Method Summary collapse
-
.avatar_url(user_id, avatar_id) ⇒ Object
Make an avatar URL from the user and avatar IDs.
-
.change_own_nickname(token, server_id, nick) ⇒ Object
Change the current bot's nickname on a server.
-
.change_status_setting(token, status) ⇒ Object
Change user status setting.
-
.connections(token) ⇒ Object
Get information about a user's connections https://discordapp.com/developers/docs/resources/user#get-users-connections.
-
.create_pm(token, recipient_id) ⇒ Object
Create a DM to another user https://discordapp.com/developers/docs/resources/user#create-dm.
- .leave_server(token, server_id) ⇒ Object
-
.profile(token) ⇒ Object
Get profile data https://discordapp.com/developers/docs/resources/user#get-current-user.
- .resolve(token, user_id) ⇒ Object
-
.servers(token) ⇒ Object
Get the servers a user is connected to https://discordapp.com/developers/docs/resources/user#get-current-user-guilds.
- .update_profile(token, email, password, new_username, avatar, new_password = nil) ⇒ Object
-
.user_dms(token) ⇒ Object
Get the DMs for the current user https://discordapp.com/developers/docs/resources/user#get-user-dms.
Class Method Details
.avatar_url(user_id, avatar_id) ⇒ Object
Make an avatar URL from the user and avatar IDs
132 133 134 |
# File 'lib/discordrb/api/user.rb', line 132 def avatar_url(user_id, avatar_id) "#{Discordrb::API.api_base}/users/#{user_id}/avatars/#{avatar_id}.jpg" end |
.change_own_nickname(token, server_id, nick) ⇒ Object
Change the current bot's nickname on a server
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/discordrb/api/user.rb', line 30 def change_own_nickname(token, server_id, nick) Discordrb::API.request( :guilds_sid_members_me_nick, server_id, # This is technically a guild endpoint :patch, "#{Discordrb::API.api_base}/guilds/#{server_id}/members/@me/nick", { nick: nick }.to_json, Authorization: token, content_type: :json ) end |
.change_status_setting(token, status) ⇒ Object
Change user status setting
119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/discordrb/api/user.rb', line 119 def change_status_setting(token, status) Discordrb::API.request( :users_me_settings, nil, :patch, "#{Discordrb::API.api_base}/users/@me/settings", { status: status }.to_json, Authorization: token, content_type: :json ) end |
.connections(token) ⇒ Object
Get information about a user's connections https://discordapp.com/developers/docs/resources/user#get-users-connections
108 109 110 111 112 113 114 115 116 |
# File 'lib/discordrb/api/user.rb', line 108 def connections(token) Discordrb::API.request( :users_me_connections, nil, :get, "#{Discordrb::API.api_base}/users/@me/connections", Authorization: token ) end |
.create_pm(token, recipient_id) ⇒ Object
Create a DM to another user https://discordapp.com/developers/docs/resources/user#create-dm
94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/discordrb/api/user.rb', line 94 def create_pm(token, recipient_id) Discordrb::API.request( :users_me_channels, nil, :post, "#{Discordrb::API.api_base}/users/@me/channels", { recipient_id: recipient_id }.to_json, Authorization: token, content_type: :json ) end |
.leave_server(token, server_id) ⇒ Object
70 71 72 73 74 75 76 77 78 |
# File 'lib/discordrb/api/user.rb', line 70 def leave_server(token, server_id) Discordrb::API.request( :users_me_guilds_sid, nil, :delete, "#{Discordrb::API.api_base}/users/@me/guilds/#{server_id}", Authorization: token ) end |
.profile(token) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/discordrb/api/user.rb', line 19 def profile(token) Discordrb::API.request( :users_me, nil, :get, "#{Discordrb::API.api_base}/users/@me", Authorization: token ) end |
.resolve(token, user_id) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/discordrb/api/user.rb', line 7 def resolve(token, user_id) Discordrb::API.request( :users_uid, nil, :get, "#{Discordrb::API.api_base}/users/#{user_id}", Authorization: token ) end |
.servers(token) ⇒ Object
Get the servers a user is connected to https://discordapp.com/developers/docs/resources/user#get-current-user-guilds
58 59 60 61 62 63 64 65 66 |
# File 'lib/discordrb/api/user.rb', line 58 def servers(token) Discordrb::API.request( :users_me_guilds, nil, :get, "#{Discordrb::API.api_base}/users/@me/guilds", Authorization: token ) end |
.update_profile(token, email, password, new_username, avatar, new_password = nil) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/discordrb/api/user.rb', line 44 def update_profile(token, email, password, new_username, avatar, new_password = nil) Discordrb::API.request( :users_me, nil, :patch, "#{Discordrb::API.api_base}/users/@me", { avatar: avatar, email: email, new_password: new_password, password: password, username: new_username }.to_json, Authorization: token, content_type: :json ) end |
.user_dms(token) ⇒ Object
Get the DMs for the current user https://discordapp.com/developers/docs/resources/user#get-user-dms
82 83 84 85 86 87 88 89 90 |
# File 'lib/discordrb/api/user.rb', line 82 def user_dms(token) Discordrb::API.request( :users_me_channels, nil, :get, "#{Discordrb::API.api_base}/users/@me/channels", Authorization: token ) end |