Skip to content

A simple stats tracker that is supposed to help you find stats for anyone on Valorant

Notifications You must be signed in to change notification settings

Lifearafter/Valorant_Tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Valo Tracker - Discord Bot

Setup

To add the bot to a discord server

Simply use the following link to add the bot to the server
Discord Invite

Important Information

  • This bot is a prototype, not functionally finished.

  • I plan to add a few more commands to make the bot a bit more user-friendly, one such command being the !help.

  • The code provided should serve as a good bases to add a few more layers of functionality to the bot.

  • The code might also have some not yet identified bugs, so use at your own risk.

Commands

  • !track {username}#{tag}
    Explanation: Finds information regarding a particular user.

Development

Information about the bot

The bot mainly uses Henrik's Unofficial Valorant API to get player and match information for a specified Username and Tag, for example, Liferafter#7796.

The code request information twice from two end points, mainly

/valorant/v1/account/{name}/{tag}

and

/valorant/{version}/by-puuid/{mode}/{region}/{puuid}

All the information is formatted and sent to the discord channel where the command was invoked.

The all the methods of compMatchHistory return a boolean value, so that it is easier to manage my higly coupled code where another method cannot be invoked before another method is invoked.

The hieararchy that it follows is:

  1. getAccData()
  2. formatAccData()
  3. getMmrHistory()
  4. formatMmrData()
  5. getPrevMmr()

The code ended up being highly coupled because of how I instantiate import class attributes.

And also becuase of my attempt to reduce the amount of class being made to the API.

Side Note - It is not highly coupled interms of Software Design, since it is just one object, that has no relations to any other object. The objects methods are too dependent on the objects other methods, to the point that it makes the object itself a bit un-intuitive. And hence I used highly-coupled to describe the amount of dependence within the code; Since one buggy method would break the rest of the code.

Information about the Code

There are two parts to the bot itself, the discordUI.py and matchHistory.py.
There is also a third file for tests: tests_matchhistory.py.


discordUI.py Is the module that holds the code for all the interactions between discord and the bot.

There are two important aspects to that code:

  1. Initialized the commands module so that I could directly write commands, with the prefix "!"
  2. Bot connects to Discords API using the a Token that should be unique to the both.

Why are these important then?

The information about the prefix and commands module should help a person write more commands for their bots.

For more information visit the discord documentation.

Second, the bots Token isn't provided in the code uploaded to github, since all bots have unique tokens that connect to particular bots, my Token could be used for malicious purposes.

To add your own Token, crate a .env file, and add this line to it:

TOKEN = 'Your Token Here'

Make sure the .env file exists in the same directory as the discordUI.py.


matchHistory.py contains the class compMatchHistory which has all the methods needed for the current bot.

  • getAccData()
    • Returns a boolean value
      • True if executed properly
      • False if execution failed
    • Modifies accountData attribute of compMatchHistory
  • formatAccData()
    • Returns a boolean value
      • True if executed properly
      • False if execution failed
    • Modifies region and puuid attribute of compMatchHistory
  • getMmrHistory()
    • Returns a boolean value
      • True if executed properly
      • False if execution failed
    • Modifies mmrData attribute of compMatchHistory
  • formatMmrData()
    • Returns a boolean value
      • True if executed properly
      • False if execution failed
    • Modifies mmrChange and currentRank attribute of compMatchHistory
  • getPrevMmr()
    • Returns a boolean value
      • True if executed properly
      • False if execution failed
    • Modifies ranks attribute of compMatchHistory
  • checkErrorCode(jsonData)
    • Parameters: A Json response object
    • Returns a boolean value
      • True if executed properly
      • False if execution failed
    • Modifies statusRequest and errorMsg

Side Note - The Modifies information is only for when the object returns true, meaning it executes without any errors.


tests_matchHistory.py has prewritten tests to help anyone check if the code works properly if there were changes made to pre-existing methods in the compMatchHistory

The code basically just uses a bunch of assertEqual's to see if a function is working properly for a particular username and tag pair.

It would be needed for new methods implemented to have new tests for the code.

The tests themselves use the unittest module built into python.

The code coverage for current tests is 96%.


Dependecies

The current requirements.txt file contains all the third party modules, the code is dependent on.

You can simply pip-install those requirements.

Dockerfile

You can also use the Dockerfile in this repo to build and run a Docker Image. Use the commands below in the command prompt.

cd <PATH to Dir where DockerFile and code exists>
docker build --build-arg Token=<BOT TOKEN> -t <name>:<tag> .

About

A simple stats tracker that is supposed to help you find stats for anyone on Valorant

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published