Skip to content

Instantly share code, notes, and snippets.

@theabhishek2511
Last active October 2, 2017 01:31
Show Gist options
  • Save theabhishek2511/c602de1794ac150e9bf0ed4cccaf83cf to your computer and use it in GitHub Desktop.
Save theabhishek2511/c602de1794ac150e9bf0ed4cccaf83cf to your computer and use it in GitHub Desktop.
copied from the dev server
Bot accounts are live, and official API documentation is coming soon!
But, before we release it en-mass, you can try it out by manually creating an OAuth2 Application and converting an existing bot user to it, or creating a new bot user for it. The guide below assumes you're on OSX/Linux (or have curl/cygwin on windows) There will be a to do UI for all this in the documentation. If you are unfamiliar with the concepts in the tutorial below, wait for the documentation to come out!
How to create an application (this is the same API used to create an Application in Stanislav's example above)
curl -H 'Authorization: YOUR_TOKEN' \
-H "Content-Type: application/json" \
-X POST -d '{"name": "YOUR BOT NAME HERE"}' \
https://discordapp.com/api/oauth2/applications
You should get back:
{"secret": "XXX", "redirect_uris": [], "description": "", "name": "YOUR BOT NAME HERE", "id": "YYY", "icon": null}
Keep the secret secret, and the id safe. You've successfully created your Application!
Now, you can either convert a user to a bot, or create a new bot account (note the id is your applicationid`):
curl -H 'Authorization: YOUR TOKEN' \
-H "Content-Type: application/json" \
-X POST -d '{"token": "YOUR BOT USERS TOKEN"}' \
https://discordapp.com/api/oauth2/applications/:id/bot
You should get back:
{"username": "Mewsick", "bot": true, "token": "YOUR BOTS NEW TOKEN", "avatar": "338f4d9d97056ae22c4a3feab5f0da07",
"discriminator": "1550", "id": "132254000253894656"}
To create a fresh bot account, just don't provide a token. It will use your application name as the username for the bot.
NOTE:
* Converting a user account to a bot account is irreversible. USE CAUTION!
* Bot accounts:
- do not have a password, or e-mail. This means you cannot reset the password to regain the token (a way to reset this token will be available soon)
- are unable to accept invites, and are only able to join a guild via the oauth 2 flow (more on this soon).
- are unable to have friends.
* However, bot accounts:
- are able to be connected to multiple voice channels at the same time.
- have a fancy [bot] tag beside their name.
- will have higher per-server rate limits.
- and be able to do much more (as we roll out this feature).
So, you've created a bot, and you want to add it to servers now. How this happens is simple, just make a link to the authorize page with your application's id & the bot scope.
https://discordapp.com/oauth2/authorize?&client_id=YYYY&scope=bot
(You can invite my bot to your server by using this link to check it out: https://discordapp.com/oauth2/authorize?&client_id=157730590492196864&scope=bot)
Additional URL parameters:
* permissions: An integer containing the permission bits set that you want the bot to have.
* guild_id: If you know the specific guild ID you want the bot to join.
* ... there are more, that will be released with the official docs!
Tokens! Library authors, when sending the Authorization token header, make sure you prefix the token with Bot, for example:
Authorization: Bot YOUR_TOKEN_HERE (where the token is your bot's token)
In the future, bot users will need to send this in the header, additionally it will ensure that the user is a bot user.
If you are getting error 403s when converting a bot account, and you double checked your tokens, make sure the bot doesn't own any OAuth applications:
curl -H 'Authorization: BOT_TOKEN' https://discordapp.com/api/oauth2/applications
If any are listed here, remove them:
curl -H 'Authorization: BOT_TOKEN' -X DELETE https://discordapp.com/api/oauth2/applications/:id
Warning: Bot accounts are early access. Support from libraries is not guaranteed, and there will be issues/bugs. Converting to a bot account is irreversible. If you don't know how to follow the above instructions, or the implications of using a bot account, I highly recommend you wait until the feature is more polished, and the libraries have had time to support and test bot accounts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment