/TypeRacerStats

Primary LanguagePythonMIT LicenseMIT

TypeRacerStats

TypeRacerStats is a Discord bot partnered with with TypeRacer and was made with the Discord.py API wrapper, TypeRacer APIs, TypeRacerData APIs, SQLite, and various Python libraries (can be found in requirements.txt). It comes with over 85 commands to provide extensive statistics and features for users. Many of them are designed to help with improvement on the site. Run -help or refer to the commands section below.

Commands

Some commands are mu, which means they provide statistics regardless of the TypeRacer universe—separate environments of TypeRacer with distinct texts, leaderboards, and scores—selected.

Another feature that some commands have is the ability to li your Discord account to a TypeRacer account; for commands with said feature, linked users will not have to type their TypeRacer username every time. This can be done using the -link [typeracer_username] command.

Finally, some commands' functionalities are limited according to the bot permissions a user has: regular, bot admin, or bot owner.

Info

Info commands provide information for the bot.
Name Example Function Aliases
-help [command]
View1
Returns information for given command. Case sensitive and aliases may be used in place of [command]. h
-info
View2
Returns information about the bot. abt, about
-invite
View3
Returns an invite link for the bot. Refer to the Invite/Permissions section below for permissions. None
-donate
View4
Returns donation link to support the bot. support

Configuration

Configuration commands allow server admins to change the bot's prefix and users to configure the settings of their Discord account with regards to the bot.
Name Example Function Aliases
-setprefix [prefix]
View5
Sets the bot's prefix on the server. sp
-register [typeracer_username]
View6
Links Discord account to TypeRacer account. mu link, link*
-setuniverse [universe]
View7
Links Discord account to provided TypeRacer universe; defaults to play universe. mu li su
-toggledessle
View8
Toggles Desslejusted option for realspeed, lastrace, realspeedaverage, and raw. li td

Basic

Basic commands do not require a user's information to be downloaded to provide statistics.
Name Example Function Aliases
-stats [user]
View9
Returns basic stats for given user. mu li prof, profile
-getdata [user]
View10
Downloads given user's data; Advanced commands may be used after. li dl, gd, download,
-today [user] <date>
View11
Downloads given user's data for specified date. yesterday, yday, yd are special aliases. li day, yesterday, yday, yd
-realspeed [user] <race_num> or -realspeed [url]
View12
Returns realspeeds for given race. mu li rs
-realspeedaverage [user] <first_race> <last_race>
View13
Returns the realspeed average for given race interval.
ba may request up to 150 races. mu li
rsa, rsa*
-raw [user] <race_num> or -raw [url]
View14
Returns realspeeds and raw speed (speed with correction time omitted) for given race. mu li None
-lastrace [user] <race_num> or -lastrace [url]
View15
Returns all users' realspeeds ranked by unlagged for given race. mu li lr, last
-adjustedgraph [user] <race_num> or -adjustedgraph [url]
View42
Returns specified race's adjusted WPM over time. mu li ag
-matchgraph [user] <race_num> or -matchgraph [url]
View43
Returns specified race's unlagged WPM over time for everyone in the race. mu li mg
-leaderboard [category] <amount>
View16
Returns a leaderboard for given category: races/points/textstyped/textbests/toptens. lb
-competition <category>
View17
Returns the daily competition for specified category: points/races/wpm; defaults to points mu comp, c
-lastonline [user]
View18
Returns the last time a user played. mu li lo, ls, lastseen
-medals [user]
View19
Returns the medals a user has. li None
-toptens [user]
View20
Returns the number of text top 10s a user holds. li
ba can request JSON breakdowns with 10*.
10, 10*, toptens*
-timebetween [url] [url
View51
Returns the time between 2 races li mu diff

Advanced (all require -getdata)

Advanced commands provide detailed statistical calculations, graphs, and services aimed to help users improve their typing speed and TypeRacer statistics.
Name Example Function Aliases
-top [user] [wpm/points/weightedwpm]
View21
Returns user's top 10 races sorted by specified category. li best
-worst [user] [wpm/points/weightedwpm]
View22
Returns user's worst 10 races sorted by specified cateogry. li bottom
-racedetails [user]
View23
Returns detailed breakdown of user's races. li rd
-textbests [user]
View24
Returns user's top 5 texts, worst 5 texts, and text bests average (average of best in each text). li tb
-breakdown [user]
View43
Returns detailed breakdown of text bests. li bd
-personalbest [user] <text_ID>
View25
Returns user's average, best, and worst on specified text_id. Defaults to last-raced text if none provided. li pb
-unraced [user] <length>
View26
Returns 5 randomly unraced texts under length characters. li ur
-textsunder [user] [wpm] <length>
View26
Returns 5 randomly raced texts under wpm wpm and length characters. li tu
-textslessequal [user] [num] [wpm/points/times]
View27
Returns number of texts typed more than or equal to num in specified category. tle, tor, to
-racesover [user] [num] [wpm/points]
View28
Returns number of races greater than num in specified category. ro
-milestone [user] [num] [races/points/wpm]
View29
Returns the time it took for user to achieve specified milestone. ms
-marathon [user] <seconds>
View30
Returns the most races a user completed in seconds seconds and its breakdown; defaults to 86400 (1 day). li 42
-sessionstats [user] <seconds>
View31
Returns the longest session a user completed with breaks at most seconds seconds; defaults to 1800 (30 mins.). li ss
-fastestcompletion [user] [num_races]
View32
Returns the fastest a user completed num_races races and its breakdown. li fc
-boxplot [user] <user_2> ... <user_4>
View33
Returns WPM boxplot of given user(s). Outliers are removed. li bp
-histogram [user]
View34
Returns WPM boxplot of given user. li hg
-raceline <time> [user] <user_2> ... <user_10>
View35
Returns races over time graph for given user(s); optional time parameter returns graph with only the races completed after it. li rl
-pointline <time> [user] <user_2> ... <user_10>
View50
Returns points over time graph for given user(s); optional time parameter returns graph with only the races completed after it; pl* is a special alias to graph retroactive points. li pl, pl*
-improvement [user] <time/races>
View36
Returns WPM over specified category for given user. li imp
-week [user] <yyyy-mm-dd>
View47
Returns the given user's stats on a given week; defaults to current UTC week; w* is a special alias. li w, w*
-month [user] <yyyy-mm>
View48
Returns the given user's stats on a given month; defaults to current UTC month; m* is a special alias. li m, m*
-year [user] <yyyy>
View49
Returns the given user's stats on a given year; defaults to current UTC year; y* is a special alias.. li y, y*

Other

Other commands provide resources, information, and links related to TypeRacer.
Name Example Function Aliases
-search [query]
View37
Returns quotes containing given search query; each query must be at least 3 words long; query is case insensitive
ba can request 1 word queries
None
-levenshtein [query]
View38
Returns top 5 quotes with substring containing the least Levenshtein to given query; query must be at most 40 chars.
ba can request any length
leven
-searchid [text_id]
View39
Returns text matching specified text_id. mu id
-unixreference <timestamp>
View40
Converts a provided UNIX timestamp to UTC time; scientific notation may be used. No parameters provided returns a conversion table. unix
-serverinfo
View41
Returns basic information about the server the bot is in. sinfo
-art <artist>
View44
Randomly returns a work of art 😺 None
-clip [clip]
View45
Returns a specified clip None
-botleaderboard <discord_id>
View46
Returns leaderboard of bot usage blb, botlb

Maintenance

There are three things the bot must do to keep the data and itself maintained. All of these are done automatically and routinely by the bot in the background, so the bot remains 100% functional while the processes take place. These processes can be found in TypeRacerStats/TypeRacerStats/Core/Common/maintenance.py.

  1. Update TypeRacer users' data every 24 hours even if they have not called -getdata that day.
  2. Drop the temporary tables created from -today and -competition calls every 24 hours.
  3. Scrape all text pit stop pages for texts' top 10 data once a week.

Credits

Thank you to:

Invite/Permissions

The bot can be invited using this link. The default prefix is -, and it can be changed with -changeprefix [prefix].

Text Permissions

  • Send Messages
  • Embed Links
  • Attach Files
  • Read Message History
  • Use External Emojis
  • Add Reactions

Support

If you want to contribute towards hosting fees, refer to the following link.

Each month of hosting costs 6 USD, so the perks tiers are incremented by 6 each:

  • Tier 1 ($0.01 - $5.99): Name listed on info command and access to echo command
  • Tier 2 ($6.00 - $11.99): Set custom embed color with setcolor
  • Tier 3 ($12.00 - $17.99): Custom command added to the bot
  • Tier 4 ($18.00+): Access to commands via bot DM
Supporter commands coming soon!