This is a cog for discord.py that allows users to view and compare their iRacing data directly inside of discord.
This uses My iRacing Cog under the hood
Like this bot? You can buy me a beer here
This bot has 2 primary functions, it can show you the current weekly combos of what track your favorite series are on, and compare you to your friends through the leaderboards and other statistics. You can find examples of these actions and the commands to do these actions below.
- The iRacing API is slow to update.
When you finish a race it can take a day or sometimes more to appear in their API, which means the bot will not have that information either.
When in doubt, run
!update
- Please do not spam
!update
and!updateserver
. 99% of the time the iRacing API just hasn't updated yet, so you will never get live to the minute data, that just isn't a capability of the current iRacing API.
Want the bot in your discord? Click this link to add it: https://discord.com/oauth2/authorize?client_id=706222703664693308&scope=bot
Come to the discord here for support
This will give a list of all current active series names and IDs(which are used for the favorite series commands).
This will set the favorite series for your server. Server IDs in this case is a list of comma separated
Series IDs that can be found from the !allseries
command. Setting favorite series is necessary to
use the !currentseries
command.
Once favorite series have been set through !setfavseries
this command prints images
showing the current tracks for each of the favorite series for this race week and the next race week.
This is similar to !setfavseries
except it just adds a single series to the favorites list.
This removes a single favorite from the saved favorite series
Use this command to save your iRacing ID to your discord ID. If you already have one saved this will overwrite it
Use this command to save your name and iRacing ID to your discord ID. The name you submit must be exactly the same as your name on iRacing, including any numbers If you already have one saved this will overwrite it
This gives detailed information on the last 10 races of the given user. If no iRacing Client ID is provided, it will default to the saved ID of the user who called it. If the user who called it has not saved their ID, then they must provide an ID when calling.
This will update the saved information for just the user who called the command.
This will update the saved information for all users in the discord for use of the !leaderboard
command.
All discords are automatically updated every hour, so often this is unnecessary to run.
NOTE: The iRacing API does not update frequently, so even if you finished a race recently and expect to see changes, it can take up to a day for those to come through on the bot.
This prints a leaderboard of all users with saved IDs(through the !saveid
command) for the given category and type.
Category can be any of road
, oval
, dirtroad
, and dirtoval
, but it defaults to road
.
Type is either career
or yearly
, and it defaults to career. career
will show all time data,
and yearly
will only show data from the current year.
NOTE: This can be called with a category and no type, but if you want to call with a type, you need to pass a category.
For instance, I can call !leaderboard oval
, but if I want the road leaderboard yearly I need to specify: !leaderboard road yearly
, !leaderboard yearly
is NOT valid.
This prints a graph of all saved user's iratings over the last 6 months.
Category can be any of road
, oval
, dirtroad
, and dirtoval
, and defaults to road
.
This will give an overview of the career stats of the player with the given iRacing Client ID. If an iRacing Client ID is not provided, then it will use the saved ID for the user who called the command. If the user has not saved their ID, they must provide an iRacing Client ID.
This will give an overview of the yearly stats of the player with the given iRacing Client ID. If an iRacing Client ID is not provided, then it will use the saved ID for the user who called the command. If the user has not saved their ID, they must provide an iRacing Client ID.
This will remove the @ mentioned user from the leaderboard. The user must be @ mentioned(meaning you have to type @ and select them from the list). It will not work if you type in just their name or iRacing ID.
- Install python 3.8 (I use pyenv for this)
- Make sure you have pipenv installed wherever you plan to run the bot.
- Once you have cloned the bot, from inside the root folder of the bot, run
pipenv install
- Note - Make sure your pipenv install is running the correct python version. For example if you have 3.8.6 installed, you may want to do
pipenv install --python 3.8.6
just to be sure you don't accidentally use the system python
- Note - Make sure your pipenv install is running the correct python version. For example if you have 3.8.6 installed, you may want to do
- You will need to do a special installation for
wkhtmltopdf
which is part of what is used to generate images. Follow the instructions from step 2 here for your platform. - You will also need to install the chromium chromedriver:
Linux: sudo apt install chromium-chromedriver
Mac: brew install chromedriver -cask
- You will need a
.env
file in the root of this project that looks like this:
IRACING_USERNAME=your username here
IRACING_PASSWORD=your password here
BOT_TOKEN=your bot's token from discord
This will allow the bot to actually hit the iracing servers using your login information.
- From the root of the bot repo, run
pipenv shell
if you aren't already in the shell, and thenpython bot.py
- You did it! The bot should be running locally now and once you invite it to your server, you can use it
- If you want to keep the bot running 24/7, you should be able to get it running with PM2
- If the images seem to be failing, make sure you followed the instructions to install wkhtmltopdf correctly.
- If there seems to be something strange happening, make sure you pull master for the bot, the cog, and pyracing. I know this setup is insane, and I intend to merge the bot and the cog eventually.
- Make sure your iracing credentials are correct, and sometimes you may need to go to the member website and do a captcha if the bot seems stuck getting failures.
- There will be a bunch of noisy log output. This is because I am using LogDNA for my bot in production and
built it to use that, I will be removing this requirement as it causes a lot of noise if it isn't set up,
but you don't have to worry about it. If by some chance you also use LogDNA, you can set the
LOG_LOCATION
andLOGDNA_INGESTION_KEY
in the.env
where the location isdev
orprod
or something like that, and it will link up to your LogDNA account.