Flask-Discord-Extended
The Python OAuth2 and Discord Bot Commands for Flask applications.
Installation
To install current latest release you can use following command:
python3 -m pip install Flask-Discord-Extended
Code Example
from flask_discord_extended import FlaskDiscord
from flask import Flask
import os
app = Flask(__name__)
os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "true"
app.config["DISCORD_CLIENT_ID"] = "" # Discord Client Id
app.config["DISCORD_CLIENT_SECRET"] = "" # Discord Client Secret
app.config["DISCORD_OAUTH"] = True # Set True if you need Oauth feature
app.config["DISCORD_OAUTH_SCOPE"] = ['identify'] # Scopes for Oauth
app.config["DISCORD_OAUTH_REDIRECT_URI"] = "" # Redirect Uri for Oauth
app.config["DISCORD_AUTHORIZATION"] = "" # Bot aothorization token
Discord = FlaskDiscord(app)
@app.route('/')
def index():
return """
<form action = "/discord-login" method = "GET">
<button type = "submit" style = "padding: 15px; background:rgb(88, 101, 242); cursor: pointer; color: white; border: 0px; border-radius:5px">LogIn With Discord</button>
<form>
"""
@app.route('/discord-login')
def login():
# Redirects to Discord login
return Discord.Oauth.redirect_login()
@app.route('/callback')
def test():
user = Discord.Oauth.callback()
"""
Each function from the Utilities returns an json response object
The bot whose authorization code is set to the app needs to be in the same server
with the user
"""
Discord.Utilities.add_role(guild="GUILD_ID", user_id=user["id"], role="ROLE_ID")
Discord.Utilities.remove_role(guild="GUILD_ID", user_id=user["id"], role="997877802265235586")
Discord.Utilities.get_guild_member_data(guild="GUILD_ID", user_id=user["id"])
Discord.Utilities.set_nickname(guild="GUILD_ID", user_id=user["id"], nickname="Any nickname")
Discord.Utilities.send_dm(user_id=user["id"], content="Content")
return user
if __name__ == "__main__":
app.run(debug=True)
Requirements
- Flask
- requests_oauthlib
Metadata
Release files for Flask-Discord-Extended 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| Flask-Discord-Extended-0.0.6.tar.gz | 5.5 kB | Without provenance | Details for Flask-Discord-Extended-0.0.6.tar.gz |
Release files / Flask-Discord-Extended-0.0.6.tar.gz
| Download URL | Flask-Discord-Extended-0.0.6.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a433e429bc8512f64a6e485028ae03835b1e4a5121b546d1280f811cd30be19e
|
|
BLAKE2b-256 checksum How to use checksums |
b22d12529073948e1d2b88a89cb7699eea60a2c6d52a46ac06baeefd34e671ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.0
|
Security for Flask-Discord-Extended 0.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.