Skip to content

Commit ee5824c

Browse files
committed
added PartialAccessToken docs and update_linked_roles_metadata
1 parent 40b9d4e commit ee5824c

File tree

2 files changed

+158
-1
lines changed

2 files changed

+158
-1
lines changed

docs/source/access_token.rst

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,152 @@ AccessToken
161161
:raises discordoauth2.exceptions.HTTPException: The request failed, possibly because the member is not in the guild.
162162
:raises discordoauth2.exceptions.Forbidden: The AccessToken doesn't have the guilds.member.read scope.
163163
:raises discordoauth2.exceptions.RateLimited: You're being rate limited.
164+
165+
.. class:: PartialAccessToken()
166+
167+
.. attribute:: client
168+
169+
The client which generated this AccessToken
170+
171+
:type: :class:`discordoauth2.Client`
172+
173+
.. atribute:: token
174+
175+
The raw token for this AccessToken, you can use :class:`discordoauth2.Client.from_access_token` to use it again.
176+
177+
:type: str
178+
179+
.. atribute:: expires
180+
181+
The number of seconds until it expires from when the instance was created.
182+
183+
:type: int
184+
185+
.. atribute:: scope
186+
187+
A list of scopes that are provided.
188+
189+
:type: list[str]
190+
191+
.. atribute:: refresh_token
192+
193+
The refresh_token for this AccessToken, you can use :class:`discordoauth2.Client.refresh_token` to use this authorization again after it expires.
194+
195+
:type: str
196+
197+
.. atribute:: webhook
198+
199+
A `parital webhook object <https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-structure>`__ if they was a ``webhook.incoming`` scope.
200+
201+
:type: dict
202+
203+
.. atribute:: guild
204+
205+
A `partial guild object <https://discord.com/developers/docs/resources/guild#guild-object-guild-structure>`__ if a bot was added to a guild.
206+
207+
:type: dict
208+
209+
.. method:: fetch_identify()
210+
211+
Returns a dictionary with a `user object <https://discord.com/developers/docs/resources/user#user-object-user-structure>`__ which includes ``email`` and ``verified`` (verified email) if the ``email`` scope is provided
212+
213+
:returns: :class:`dict`
214+
:raises discordoauth2.exceptions.HTTPException: The request failed
215+
:raises discordoauth2.exceptions.Forbidden: The AccessToken doesn't have the identify scope.
216+
:raises discordoauth2.exceptions.RateLimited: You're being rate limited.
217+
218+
.. method:: fetch_connections()
219+
220+
Returns a list of `connection objects <https://discord.com/developers/docs/resources/user#connection-object-connection-structure>`__
221+
222+
:returns: :class:`list`
223+
:raises discordoauth2.exceptions.HTTPException: The request failed
224+
:raises discordoauth2.exceptions.Forbidden: The AccessToken doesn't have the connections scope.
225+
:raises discordoauth2.exceptions.RateLimited: You're being rate limited.
226+
227+
228+
.. method:: fetch_guilds()
229+
230+
Returns a list of partial `guild objects <https://discord.com/developers/docs/resources/guild#guild-object>`__
231+
232+
:returns: :class:`list`
233+
:raises discordoauth2.exceptions.HTTPException: The request failed
234+
:raises discordoauth2.exceptions.Forbidden: The AccessToken doesn't have the guilds scope.
235+
:raises discordoauth2.exceptions.RateLimited: You're being rate limited.
236+
237+
.. method:: fetch_guild_member(guild_id)
238+
239+
Returns a partial `guild member object <https://discord.com/developers/docs/resources/guild#guild-member-object-guild-member-structure>`__
240+
241+
:param int guild_id: The guild ID to retrieve member data from.
242+
243+
:returns: :class:`dict`
244+
:raises discordoauth2.exceptions.HTTPException: The request failed, possibly because the member is not in the guild.
245+
:raises discordoauth2.exceptions.Forbidden: The AccessToken doesn't have the guilds.member.read scope.
246+
:raises discordoauth2.exceptions.RateLimited: You're being rate limited.
247+
248+
.. method:: join_guild(guild_id, nick = None, role_ids = None, mute = False, deaf = False)
249+
250+
Adds the user to a guild. The application's bot must also be in the guild, have invite permissions and it's bot token must also be provided.
251+
252+
:param int guild_id: The guild ID to retrieve member data from.
253+
:param str nick: The nickname the member should have when they join.
254+
:param list[int] role_ids: a List of role IDs to assign them when they join.
255+
:param bool mute: Wether they should be server muted when they join.
256+
:param bool deaf: Wether they should be server deafend when they join.
257+
258+
:returns: :class:`dict`
259+
:raises discordoauth2.exceptions.HTTPException: The request failed
260+
:raises discordoauth2.exceptions.Forbidden: The AccessToken doesn't have the guilds.join scope or the bot isn't in the guild/have the correct permissions.
261+
:raises discordoauth2.exceptions.RateLimited: You're being rate limited.
262+
263+
.. method:: fetch_metadata()
264+
265+
Returns the user's `metadata object <https://discord.com/developers/docs/resources/user#application-role-connection-object>`__ for this application.
266+
267+
.. versionadded:: 1.1
268+
269+
:returns: :class:`dict`
270+
:raises discordoauth2.exceptions.HTTPException: The request failed, possibly because the member is not in the guild.
271+
:raises discordoauth2.exceptions.Forbidden: The AccessToken doesn't have the guilds.member.read scope.
272+
:raises discordoauth2.exceptions.RateLimited: You're being rate limited.
273+
274+
.. method:: update_metadata(platform_name=None, username=None, **metadata)
275+
276+
Updates and returns the user's `metadata object <https://discord.com/developers/docs/resources/user#application-role-connection-object>`__ for this application.
277+
278+
.. versionadded:: 1.1
279+
280+
:param str platform_name: Text that appears at the top of the app connection box, usally denoting the platform's name.
281+
:param str platform_username: Text that appears under the platform name, large, and usally denoting the user's name on the platform.
282+
:param dict metadata: List of keys and values to set the user's metadata. Supported types: :class:`bool`, :class:`datetime.datetime`, :class:`int`
283+
284+
:returns: :class:`dict`
285+
:raises discordoauth2.exceptions.HTTPException: The request failed, possibly because the member is not in the guild.
286+
:raises discordoauth2.exceptions.Forbidden: The AccessToken doesn't have the guilds.member.read scope.
287+
:raises discordoauth2.exceptions.RateLimited: You're being rate limited.
288+
289+
.. warning::
290+
291+
You must make sure to store the access token and refresh token, otherwise you won't be able to update or remove the metadata later.
292+
293+
.. method:: clear_metadata()
294+
295+
Removes the user's `metadata object <https://discord.com/developers/docs/resources/user#application-role-connection-object>`__ for this application.
296+
297+
.. versionadded:: 1.1
298+
299+
:returns: :class:`dict`
300+
:raises discordoauth2.exceptions.HTTPException: The request failed, possibly because the member is not in the guild.
301+
:raises discordoauth2.exceptions.Forbidden: The AccessToken doesn't have the guilds.member.read scope.
302+
:raises discordoauth2.exceptions.RateLimited: You're being rate limited.
303+
304+
.. method:: revoke()
305+
306+
Shorthand for :meth:`Client.revoke_token`, it will revoke the access token and any related refresh token.
307+
308+
.. versionadded:: 1.1
309+
310+
:raises discordoauth2.exceptions.HTTPException: The request failed, possibly because the member is not in the guild.
311+
:raises discordoauth2.exceptions.Forbidden: The AccessToken doesn't have the guilds.member.read scope.
312+
:raises discordoauth2.exceptions.RateLimited: You're being rate limited.

docs/source/client.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,12 @@ Client
7474

7575
.. warning::
7676

77-
If the application is owned by a team, you can only request for the `identify` scope. You can also request `applications.commands.update`, but the library does not support it yet.
77+
If the application is owned by a team, you can only request for the `identify` scope. You can also request `applications.commands.update`, but the library does not support it yet.
78+
79+
.. method:: update_linked_roles_metadata(metadata)
80+
81+
Updates the application's linked roles metadata, requires bot token to have been provided.
82+
83+
.. versionadded:: 1.1
84+
85+
:param dict metadata: Should be a list of `application role connection metadata<https://discord.com/developers/docs/resources/application-role-connection-metadata#application-role-connection-metadata-object>__`

0 commit comments

Comments
 (0)