Package: discord.web
Discord.WebAn asynchronous wrapper for the Discord Oauth2 APIExplore the docs Â»Table of ContentsAbout The ProjectBuilt WithGetting StartedPrerequisitesInstallationUsageRoadmapContributingLicenseContactAcknowledgementsAbout The ProjectDiscord-Web is an easy way to interface with the Discord Oauth api. If you're new the realm of developing for discord, you may not know what the Oauth2 api may be used for. Well, a good example would be a Login backend on your bot's website to allow for some advanced dashboard creation. Creating these requests yourself can be time-consuming! Here's where Discord-Web comes into play. We handle the requests for you, returning easy to manage Python Objects such as theOauth2Memberobject and theOauth2Guild.Built WithPythonaiohttpdiscord.pyGetting StartedWelcome to the Getting Started Section. Here, we explain how you can get started with thediscord-weblibrary.PrerequisitesHere's a list of prerequisites that you will need for the discord-web library to work. Keep in mind that all of these (with the exception ofaiohttp[speedups]) are installed when installingdiscord.webdiscord.pypipinstalldiscord.pyaiohttppipinstallaiohttpInstalling the speedups for aiohttpIf you wish, you can install the speedups package for aiohttp, which allows aiohttp to run requests much faster.aiohttp speedupspipinstallaiohttp[speedups]InstallationInstalling thediscord.weblibrary is a breeze. Here we list both ways of installing the library (the stable version and the development version)pipinstalldiscord.webpipinstallgit+https://github.com/quiktea/discord.web/UsageFirst of all, you need to create an application on theDiscord Developer Portal. Once you do that, click on the OAuth2 tab and follow the example below:Initialising an OAuth2 ClientTo initialise an OAuth2 Client, simply follow the example below:fromdiscord_web.oauth2importOauth2Clientclient=Oauth2Client(client_id,"client_secret","redirect_uri",["scope1","scope2"])Generating an Access TokenTo access a user's info, you need what's called anAccess Token. To get an access token, you first need the code given to you by the OAuth2 login url that you created on theDiscord Developer Portal. After a user logins in using your URL, they will be redirected to theredirect_urithat you provided on the Developer Portal. After getting redirected, the URL on your end will be returned with thecodeURL parameter, which looks like so:https://example.com/?code=CODE. You will need to access this code. In Django, you would access it like so:request.GET.get("code"). This is the code that you pass into theexchange_codefunction. The function will then return anAccessTokenobject which holds information such as therefresh_tokenand theaccess_token. To access the access token, simply reference theaccess_tokenproperty of your AccessToken class.For more examples, please refer to theDocumentationRoadmapSee theopen issuesfor a list of proposed features (and known issues).ContributingContributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make aregreatly appreciated.Fork the ProjectCreate your Feature Branch (git checkout -b feature/AmazingFeature)Commit your Changes (git commit -m 'Add some AmazingFeature')Push to the Branch (git push origin feature/AmazingFeature)Open a Pull RequestLicenseDistributed under the MIT License. SeeLICENSEfor more information.ContactDiscord -discord.web-https://discord.gg/JmhWrK99GSProject Link:https://github.com/quiktea/discord.webAcknowledgementsPythonaiohttpdiscord.pyRapptz (Danny)