Skip to content

Commit 5c96783

Browse files
committed
added examples and fixed a few more docs
1 parent b6c0a2f commit 5c96783

File tree

2 files changed

+53
-5
lines changed

2 files changed

+53
-5
lines changed

docs/source/client.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Client
6262

6363
.. warning::
6464

65-
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.``
65+
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.``
6666

6767
.. method:: revoke_token(token, token_type=None)
6868

docs/source/index.rst

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Table of Contents
66

77
.. toctree::
88

9-
:maxdepth: 2
9+
:maxdepth: 1
1010

1111
client
1212
access_token
@@ -17,16 +17,16 @@ Quickstart
1717
Installing
1818
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1919

20-
I've finally published the library to PyPi! So now you can use pip.
20+
You can install the library with pip using this command:
2121

2222
.. code::
2323
2424
pip install discord-oauth2.py
2525
26-
Example With Flask
26+
Fetching User Data Flask Example
2727
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2828

29-
Don't forget to replace all the client information on line 20 and 21 with your application's own information. You can leave bot token empty if your not adding members to guilds.
29+
Don't forget to replace all the client information below with your application's own information. You can leave bot token empty if your not adding members to guilds or updating linked roles metadata.
3030

3131
.. code::
3232
@@ -49,4 +49,52 @@ Don't forget to replace all the client information on line 20 and 21 with your a
4949
5050
return f"""{identify}<br><br>{connections}<br><br>{guilds}"""
5151
52+
app.run("0.0.0.0", 8080)
53+
54+
Linked Roles Flask Example
55+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
56+
57+
Don't forget to replace all the client information below with your application's own information.
58+
59+
.. code::
60+
61+
import discordoauth2
62+
from flask import Flask, request
63+
from datetime import datetime
64+
65+
client = discordoauth2.Client(849930878276993044, secret="very-secret-code",
66+
redirect="https://findingfakeurlsisprettyhard.tv/oauth2", bot_token="bot-token-only-required-for-guild-joining")
67+
68+
client.update_linked_roles_metadata([
69+
{
70+
"type": 2,
71+
"key": "level",
72+
"name": "Level",
73+
"description": "The user's XP level."
74+
},
75+
{
76+
"type": 6,
77+
"key": "join",
78+
"name": "Joined",
79+
"description": "The date the user joined."
80+
},
81+
{
82+
"type": 7,
83+
"key": "supporter",
84+
"name": "Supporter",
85+
"description": "Wether the user has supported us."
86+
}
87+
])
88+
89+
app = Flask(__name__)
90+
91+
@app.route("/oauth2")
92+
def oauth2():
93+
code = request.args.get("code")
94+
95+
access = client.exchange_code(code)
96+
access.update_metadata("Example Game", username="TreeBen77", level=24, join=datetime.now(), supporter=True)
97+
98+
return f"updated your metadata!"
99+
52100
app.run("0.0.0.0", 8080)

0 commit comments

Comments
 (0)