The bot can assign roles on your server on base Warzone KDR.
- Heroku account, to host the Discord bot.
- Discord bot
- Account in http://my.callofduty.com, with the purpose of getting the information of Warzone KDR of the users who want to assign a role.
- Basic knowledge of how a Discord bot works, basic Javascript.
!rank <platform> <GamerTag>
Example:
!rank activision MuTeX#6638739
activision
psn
xbl
battle
To install the bot you have to do several steps before and be able to configure it:
- To create a Discord bot you must have an account or be logged in if you already have one.
- The first step is to create a discord application so after that you can create a bot within this application, to create an application go to https://discord.com/developers/applications.
- Once you have the application created you can create a bot, in the page of the application created previously there is a menu that says bot, here you can create your bot.
- When you have created the bot, we need the
Token
to be able to use it in the Heroku instance, so keep it in a safe place. - When you create the bot we have to invite it to your server, for this we have to go to the menu of
OAuth2
where you can generate a link and invite the bot to your server. - Permissions have to be:
- Scop: bot
- Permissions:
- Send Messages
- Manage Roles
- Once the url is generated you can use it in your web browser where it tells you if you want to add the bot to your server.
There are many tutorials of "how to create a Discord bot". I used this https://discordpy.readthedocs.io/en/latest/discord.html
- You need to have a Heroku account, you can create one here https://signup.heroku.com/
- If you are connected to Heroku, you can create an instance for this project in Heroku by clicking on the following
- Once you have created the instance in Heroku, you can add the
ENV
variables that we will use from configurations for the Discord bot, which you can add in the configuration tab in the Heroku instance page. - You have to add the
ENV
variables in Heroku:- COD_ACCOUNT, is the email from the account you created on my.callofduty.com
- COD_PASSWORD, is the password from the account you created on my.callofduty.com
- TOKEN_DISCORD, is the
Token
Discord bot - LANG, is the language configuration for the Discord bot there are only English (en), Spanish (es) and French (fr).
- ROLES, this is a complicated part, I will explain here
- Once you set all the variables you will have to restart the instance of Heroku
It is something complex for those who do not know basic programming, my idea is that you can modify the bot settings, remove or modify parameters of roles.
Before the explain the roles, this roles must already be configured in your discord server.
These roles in Discord have to be below the permissions of the Discord bot that we just created
However, at the moment I find this solution, which is an Array of objects
which contains the name of the role, min of
KDR and max of KDR, example:
[
{
"name": "Pro Player",
"min": 2,
"max": 3,
"minMatches": 100
},
{
"name": "Insane Player",
"min": 3,
"max": 5,
"minMatches": 100
}
]
For those who do not know programming, if you want to add another role you would have to add below the object of "Insane Player", objects have to be separated by a " , "
So it should be displayed when adding a new role
[
{
"name": "Pro Player",
"min": 2,
"max": 3,
"minMatches": 100
},
{
"name": "Insane Player",
"min": 3,
"max": 5,
"minMatches": 100
},
{
"name": "The best player of world",
"min": 10,
"max": 20,
"minMatches": 500
}
]
You can test the roles you want to have for your bot, to know if they have the correct format and above all minify it to
be able to add it in the ENV
variables of Heroku as it has to be minified.
The tool you can use is https://codebeautify.org/jsonminifier, copying your roles and this tool will validate if there is an error, if there is no error you can click on "Minify/Compress", and the result will appear on the right:
[{"name":"Pro Player","min":2,"max":3, "minMatches": 100},{"name":"Insane Player","min":3,"max":5, "minMatches": 100},{"name":"The best player of world","min":10,"max":20, "minMatches": 500}]
This is what you are going to set in the ENV
named ROLES