|
| 1 | +AccessToken |
| 2 | +============================= |
| 3 | + |
| 4 | +.. currentmodule:: discord-oauth2.py |
| 5 | + |
| 6 | +.. class:: AccessToken() |
| 7 | + |
| 8 | + .. attribute:: client |
| 9 | + |
| 10 | + The client which generated this AccessToken |
| 11 | + |
| 12 | + :type: :class:`discordoauth2.Client` |
| 13 | + |
| 14 | + .. atribute:: token |
| 15 | + |
| 16 | + The raw token for this AccessToken, you can use :class:`discordoauth2.Client.from_access_token` to use it again. |
| 17 | + |
| 18 | + :type: str |
| 19 | + |
| 20 | + .. atribute:: expires |
| 21 | + |
| 22 | + The number of seconds until it expires from when the instance was created. |
| 23 | + |
| 24 | + :type: int |
| 25 | + |
| 26 | + .. atribute:: scope |
| 27 | + |
| 28 | + A list of scopes that are provided. |
| 29 | + |
| 30 | + :type: list[str] |
| 31 | + |
| 32 | + .. atribute:: refresh_token |
| 33 | + |
| 34 | + The refresh_token for this AccessToken, you can use :class:`discordoauth2.Client.refresh_token` to use this authorization again after it expires. |
| 35 | + |
| 36 | + :type: str |
| 37 | + |
| 38 | + .. atribute:: webhook |
| 39 | + |
| 40 | + The webhook URL if they was a webhook scope. |
| 41 | + |
| 42 | + :type: str |
| 43 | + |
| 44 | + .. atribute:: guild |
| 45 | + |
| 46 | + The guild ID if a bot was added to a guild. |
| 47 | + |
| 48 | + :type: int |
| 49 | + |
| 50 | + .. method:: fetch_identify() |
| 51 | + |
| 52 | + Returns a dictionary with a `user object <https://discord.com/developers/docs/resources/user#user-object-user-structure>`__ which includes email if the email scope is provided |
| 53 | + |
| 54 | + :returns: :class:`dict` |
| 55 | + :raises discordoauth2.exceptions.HTTPException: The request failed |
| 56 | + :raises discordoauth2.exceptions.Forbidden: The AccessToken doesn't have the identify scope. |
| 57 | + :raises discordoauth2.exceptions.RateLimited: You're being rate limited. |
| 58 | + |
| 59 | + .. method:: fetch_connections() |
| 60 | + |
| 61 | + Returns a list of `connection objects <https://discord.com/developers/docs/resources/user#connection-object-connection-structure>`__ |
| 62 | + |
| 63 | + :returns: :class:`list` |
| 64 | + :raises discordoauth2.exceptions.HTTPException: The request failed |
| 65 | + :raises discordoauth2.exceptions.Forbidden: The AccessToken doesn't have the connections scope. |
| 66 | + :raises discordoauth2.exceptions.RateLimited: You're being rate limited. |
| 67 | + |
| 68 | + |
| 69 | + .. method:: fetch_guilds() |
| 70 | + |
| 71 | + Returns a list of partial `guild objects <https://discord.com/developers/docs/resources/guild#guild-object>`__ |
| 72 | + |
| 73 | + :returns: :class:`list` |
| 74 | + :raises discordoauth2.exceptions.HTTPException: The request failed |
| 75 | + :raises discordoauth2.exceptions.Forbidden: The AccessToken doesn't have the guilds scope. |
| 76 | + :raises discordoauth2.exceptions.RateLimited: You're being rate limited. |
| 77 | + |
| 78 | + .. method:: fetch_guild_member(guild_id) |
| 79 | + |
| 80 | + Returns a parial `guild member object <https://discord.com/developers/docs/resources/guild#guild-member-object-guild-member-structure>`__ |
| 81 | + |
| 82 | + :param int guild_id: The guild ID to retrieve member data from. |
| 83 | + |
| 84 | + :returns: :class:`dict` |
| 85 | + :raises discordoauth2.exceptions.HTTPException: The request failed, possibly because the member is not in the guild. |
| 86 | + :raises discordoauth2.exceptions.Forbidden: The AccessToken doesn't have the guilds.member.read scope. |
| 87 | + :raises discordoauth2.exceptions.RateLimited: You're being rate limited. |
| 88 | + |
| 89 | + .. method:: join_guild(guild_id, nick = None, role_ids = None, mute = False, deaf = False) |
| 90 | + |
| 91 | + 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. |
| 92 | + |
| 93 | + :param int guild_id: The guild ID to retrieve member data from. |
| 94 | + :param str nick: The nickname the member should have when they join. |
| 95 | + :param list[int] role_ids: a List of role IDs to assign them when they join. |
| 96 | + :param bool mute: Wether they should be server muted when they join. |
| 97 | + :param bool deaf: Wether they should be server deafend when they join. |
| 98 | + |
| 99 | + :returns: :class:`dict` |
| 100 | + :raises discordoauth2.exceptions.HTTPException: The request failed |
| 101 | + :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. |
| 102 | + :raises discordoauth2.exceptions.RateLimited: You're being rate limited. |
| 103 | + |
| 104 | +.. class:: PartialAccessToken() |
| 105 | + |
| 106 | + .. attribute:: client |
| 107 | + |
| 108 | + The client which generated this AccessToken |
| 109 | + |
| 110 | + :type: :class:`discordoauth2.Client` |
| 111 | + |
| 112 | + .. atribute:: token |
| 113 | + |
| 114 | + The raw token for this AccessToken, you can use :class:`discordoauth2.Client.from_access_token` to use it again. |
| 115 | + |
| 116 | + :type: str |
| 117 | + |
| 118 | + .. method:: fetch_identify() |
| 119 | + |
| 120 | + Returns a dictionary with a `user object <https://discord.com/developers/docs/resources/user#user-object-user-structure>`__ which includes email if the email scope is provided |
| 121 | + |
| 122 | + :returns: :class:`dict` |
| 123 | + :raises discordoauth2.exceptions.HTTPException: The request failed |
| 124 | + :raises discordoauth2.exceptions.Forbidden: The AccessToken doesn't have the identify scope. |
| 125 | + :raises discordoauth2.exceptions.RateLimited: You're being rate limited. |
| 126 | + |
| 127 | + .. method:: fetch_connections() |
| 128 | + |
| 129 | + Returns a list of `connection objects <https://discord.com/developers/docs/resources/user#connection-object-connection-structure>`__ |
| 130 | + |
| 131 | + :returns: :class:`list` |
| 132 | + :raises discordoauth2.exceptions.HTTPException: The request failed |
| 133 | + :raises discordoauth2.exceptions.Forbidden: The AccessToken doesn't have the connections scope. |
| 134 | + :raises discordoauth2.exceptions.RateLimited: You're being rate limited. |
| 135 | + |
| 136 | + |
| 137 | + .. method:: fetch_guilds() |
| 138 | + |
| 139 | + Returns a list of partial `guild objects <https://discord.com/developers/docs/resources/guild#guild-object>`__ |
| 140 | + |
| 141 | + :returns: :class:`list` |
| 142 | + :raises discordoauth2.exceptions.HTTPException: The request failed |
| 143 | + :raises discordoauth2.exceptions.Forbidden: The AccessToken doesn't have the guilds scope. |
| 144 | + :raises discordoauth2.exceptions.RateLimited: You're being rate limited. |
| 145 | + |
| 146 | + .. method:: fetch_guild_member(guild_id) |
| 147 | + |
| 148 | + Returns a parial `guild member object <https://discord.com/developers/docs/resources/guild#guild-member-object-guild-member-structure>`__ |
| 149 | + |
| 150 | + :param int guild_id: The guild ID to retrieve member data from. |
| 151 | + |
| 152 | + :returns: :class:`dict` |
| 153 | + :raises discordoauth2.exceptions.HTTPException: The request failed, possibly because the member is not in the guild. |
| 154 | + :raises discordoauth2.exceptions.Forbidden: The AccessToken doesn't have the guilds.member.read scope. |
| 155 | + :raises discordoauth2.exceptions.RateLimited: You're being rate limited. |
| 156 | + |
| 157 | + .. method:: join_guild(guild_id, nick = None, role_ids = None, mute = False, deaf = False) |
| 158 | + |
| 159 | + 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. |
| 160 | + |
| 161 | + :param int guild_id: The guild ID to retrieve member data from. |
| 162 | + :param str nick: The nickname the member should have when they join. |
| 163 | + :param list[int] role_ids: a List of role IDs to assign them when they join. |
| 164 | + :param bool mute: Wether they should be server muted when they join. |
| 165 | + :param bool deaf: Wether they should be server deafend when they join. |
| 166 | + |
| 167 | + :returns: :class:`dict` |
| 168 | + :raises discordoauth2.exceptions.HTTPException: The request failed |
| 169 | + :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. |
| 170 | + :raises discordoauth2.exceptions.RateLimited: You're being rate limited. |
0 commit comments