Skip to content

Repository files navigation

VlrBot

Summary

A Valorant bot developed by a Computer Science student as a practical application of Data Engineering and Software Architecture. This project is maintained alongside university commitments, following a weekly sprint cycle to ensure continuous improvement and code quality. It uses web scraping with Selenium on vlr.gg to archive data from VCT matches. It analyzes this data and makes it available for visualization via Discord and a Streamlit Website. We use a PostgreSQL database (hosted on Neon Tech's free plan) to store information about teams and matches.

v3.0.0

Data changes: Our ecosystem now searches for the new data twice a day. Scraping scheduled for 2:00 UTC and 14:00 UTC, while the bot and website reload data at 7:30 UTC and 19:30 UTC. All of this to ensure that the data is up to date before the matches, allowing users to consult it before or during a match.

Visualization: Website (Linked in the "About" section of the repository) is now available. It features the same commands from the original Discord Bot, but with interactive dashboards for better visualization.


Features & Showcase

The ecosystem now provides two distinct interfaces for data consumption, adapting to the user's needs.

Accessing commands

  • Bot: Using slash commands (/[command_name])
  • Website: Using the sidebar (top-left):

Search Assistance (/help_times)

  • Bot: To ensure precision, this command lists all available teams and their corresponding tags, helping users find exactly what they are looking for.

  • Website: A short explanation (in Portuguese) about how to use the website and its commands, while still dynamically showing each team's tag grouped by region.

team tags EMEA command help

Team Analysis (/info_time)

  • Bot: The core command of the bot. It provides a multi-page "book" interface with deep insights into VCT teams.

    • Page 1: Performance Summary: Shows average stats from the latest tournament (e.g., Rating, ACS, KAST, ADR) and the team's match history
    • Pages 2-8: Map Performance: Displays win rates for the last 3 compositions used in the current map pool, including Attack vs. Defense efficiency.
    • Page 9: Historical records: Average stats but using the mean of all registered tournaments.
Team Stats Overview Map Statistics Historical records
  • Website: Displays the same data structured into interactive dashboards (excluding the Historical Records page).
Team Stats Overview Tem Stats Overview 2 (last matches)
General Map Performance Split Map Performance

Head-to-Head Comparison (/times_vs)

An advanced comparison command that merges data from two distinct /info_time targets into a single, unified Embed Book for enhanced matchup visualization.

  • First Page: Performance Summary (Overview): Side-by-side metric comparison from the latest tournament and recent match histories.
  • Intermediary Pages: Map Performance: Matchup-specific analytics comparing win rates and side advantages (Attack vs. Defense efficiency) on selected maps.
  • Final Page: Historical Records: Lifetime average stats compared across all database records.
First Response Dropdown type 1 working Versus Embed Book Dropdown type 0 working

Note: Above is the first response of the bot, prompt-asking for the maps for comparison with Menu(tipo=1)

Teams Stats Comparison Map comparison Historical records comparison

Note: Above is each page of the Versus Embed Book

  • Website: A seamless interface allowing the selection of both teams and displaying interactive side-by-side dashboards:

Vs. Overview 1 Vs. Overview 2
Vs. General Map Performance Vs. Split Map Performance

Files & Directory Structure

File/Folder Type Summary
Starting v2 .ipynb Initial planning and first steps for the SQL database.
Auto .py Web scraping logic featuring vlr_stealer and stats_manager classes.
DB_handler .py INSERT logic handled by the DB_handler class.
Auto_scraper.py .py Integration of auto.py and DB_handler.py (Scraping then inserting into DB).
Disc_buttons .py Interactive buttons for navigating Discord embeds.
Main .py Discord interface and bot command handling.
Site .py Main entry point for the Streamlit web application.
Website dir/ .py Modular components and utility files for the website.
Data Loader .py Handles data retrieval and caching operations.
Pages .py Contains rendering functions for each individual page of the web application.
Brain .py Back-end logic: handles database, caching, and data analysis.
Scraper .yml Automation logic for GitHub Actions.
Agents dir/ .png PNG files used to create Discord emojis for each agent.
Teams dir/ .png PNG files used to create Discord emojis for each team.
Screenshots dir/ .png Screenshots of the bot working. All of them, except info_time3, were already shown above.
Documentation dir/ .md Project documentation and UML Diagram.
Requirements .md Functional and Non-Functional Requirements.
Classes .md Class Diagram representing the system structure.
Sequence .md Sequence Diagram showing object interactions.
Deployment .md Deployment Diagram showing infrastructure and cloud services.
Privacy .md Privacy Policy regarding data handling.
Terms .md Terms of Service for bot and dashboard usage.
DB Sch .svg Database Schema diagram.
SQL_Script .sql Database creation script.

Architecture & Deployment

Below is the deployment architecture of the system, ilustrating how the different cloud services and containers interact:

Deployment Architecture Diagram

further diagrams or detailed description is contained in docs\ files. Consult File Structure to find them.


Database

Database Schema

Data Mapping Note: stats_players table may raise errors during insertion if a record contains "N/A". This usually happens when a team changes its tag on vlr.gg (e.g., when DRX changed to KRX), causing a mismatch with the existing database records. While new players are added automatically, team tags must be updated manually in the times table to maintain Referential Integrity.

Hosted on PostgreSQL (Neon Tech free plan: 0.5GB storage, 100 CU-hours). The database consists of 9 tables. Descriptions of Portuguese attributes:

  • Agentes: Agents ('nome' = name)
  • Mapas_lista: Map list
  • Composicoes: Team compositions
  • Mapas_jogados: Played maps ('vencedor_mapa' = map winner)
  • Partidas: Matches ('vencedor_time_letra' = winning team letter)
  • Campeonatos: Tournaments ('completo' = completed)
  • Times: Teams ('regiao' = region)

Technical Details:

  • Emojis: Attributes like emoji and emoji_discord follow the Discord format: <:mibr:1370182490953748490>.
  • Pickban Log: Formatted as JSON: { "Abans": [12, 2], "Bbans": [7, 9], "Apicks": [5], "Bpicks": [4], "decider": 1 }, where numbers refer to mapas_lista.id.
  • Team References: atk_str, vencedor_mapa, and vencedor_time_letra use 'A' or 'B' values.
  • Round History: rounds_string resembles BBBBABBBABBBXAABAAAABAB. 'A'/'B' indicates the winner of that round; 'X' at position 13 marks half-time, and at position 26 marks overtime.
  • Percentage-based attributes: Stored as decimals (e.g., 0.55 for 55%). Examples are HS and KAST.

Environment Variables (.env)

  • DISCORD_TOKEN: Your Discord bot token.
  • DATABASE_URL: Your PostgreSQL connection string.
  • GUILD_ID: Server ID for testing (remove guild=... from commands to sync globally, though this is slower).
  • CREATOR_ID: Your Discord ID (restricts RAM cache updates to the owner).

How to Run

  1. Clone the repository.
  2. Install dependencies: pip install -r requirements.txt.
  3. Set up the Database (see QuickBuild).
  4. Create a .env file with your credentials (rename .env.example and fill it in).
  5. Run python src/auto_scraper.py to populate your database.
  6. Run python src/main.py to start the bot.

QuickBuild of Database

To replicate the database on Neon Tech:

  1. Access Neon Tech Console.
  2. Create a new project.
  3. Open the SQL Editor.
  4. Copy and execute the SQL script provided to generate the tables and foreign keys.
  5. Copy your connection string from the dashboard. Note: Ensure sslmode=require is present in the URL.
  6. Manual Data Seeding: Some tables do not auto-populate in this version. You should checkout the discBot_prototype branch and use migrar.ipynb to populate the times, mapas_lista, and agentes tables. Note that some records (like campeonatos) must be added manually. You will also need to manually update these tables when new maps or agents are released, or when the map pool changes.

Project Management & Roadmap

This project follows Agile/Scrum principles for development. You can track real-time progress, upcoming features, and technical backlogs on our board, or join our community to chat and get direct support:

GitHub Project Board           Discord Server


Current Focus:

  • Expanding capabilities by implementing and structuring new commands.

About

Valorant Discord Bot for professional match analysis. Built with Python, Selenium, and PostgreSQL to provide deep insights into VCT team stats and map performance.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages