Inspiration

I embarked on this project to challenge myself to handle large datasets effectively and to build a discord bot. I had never built a discord bot before and the data I pulled from GitHub was massive but I wanted to challenge myself to tackle this hackathon's data challenge head-on.

What it does

My project is a discord bot that uses the game state files, identified by game IDs (e.g., 1597139) to respond to discord commands. Here's a breakdown of its slash commands:

/user: This command provides information about the user who triggered it. For instance, if a user named "lubwama" invokes it, the bot responds with details like the user's username and the date they joined the Discord server.

/ user
This command was run by lubwama, who joined on Sun Jul 30 2023 00:17:43 GMT+0300 (Arabian Standard Time)

/server: When executed, this command gives an overview of the server. For example, it might mention that the server's name is "GRID Esports chat" and it has a certain number of members.

/ server
This server is GRID Esports chat and has 2 members

/snoop: A deep-dive command designed to extract detailed statistics for a specific player. If a user queries for a player named "Mira", the bot will display data points such as kills, deaths, and assists for that player.

/ snoop
Player Name: Mira Kills: 17 Deaths: 32 Assists: 22

/game-progress: This command fetches an overview of the current game's progress. It showcases the game's title, format, start status, finish status, and a brief summary for each team, including their name, structures destroyed, and total kills.

/ game-progress
Game Progress Overview:

Title: dota
Format: best-of-5
Started: Yes
Finished: No

Team Name: PSG.LGD
Structures Destroyed: 36
Total Kills: 101

Team Name: Team Spirit
Structures Destroyed: 33
Total Kills: 86

/team-stats: It provides a snapshot of a specified team's statistics. When a user asks about "PSG.LGD", the bot might reveal the number of team members and list their names.

/team-stats
Team Name: PSG.LGD Number of Members: 5 Members: Miposhka, YATOROGOD, TORONTOTOKYO, Mira, CoLLapse
When /snoop is clicked the bot responds with:
Player Name: Mira Kills: 17 Deaths: 32 Assists: 22

/player-vs-player: A comparative command that pits two players against each other based on their in-game statistics. Users specify two players, and the bot compares their performance, finally rating which player is statistically superior.

/player-vs-player
Player: Mira
Kills: 17
Deaths: 32
Assists: 22

Player: CoLLapse
Kills: 18
Deaths: 16
Assists: 14

CoLLapse is rated higher than Mira.

/team-objectives: Focusing on team achievements, this command reveals the number of objectives a team has completed. It can provide data points like structures destroyed, structures captured, and total objectives.

/team-objectives:
Team Name: PSG.LGD
Structures Destroyed: 36
Structures Captured: 11
Total Objectives: 6

How I built it

I utilized the discord.js package and closely followed the Discord documentation's best practices. The project comprises three main components: Discord slash commands folder, discord deploy slash command.js, and index.js.

Challenges I ran into

Parsing the intricate events.jsonl file proved challenging for creating the /player-stats command. The file consisisted of very nested objects and had even more complex nesting inside each object in the file which also had more nestings. Am a never nester but i had to use three levels of looping and a recursive function inorder to get all the data i needed from the events file. As i developed the bot further and talked with grid staff on discord, i discovered that the state file was the final state of a game and the events file was how we arrived at the state step by step. I refactored the code and replaced /player-stats with /snoop

Accomplishments that I am proud of

Looping through nested data structures was complex, but my dedication paid off in the end.

What I learned

Through this project, I acquired a comprehensive understanding of Discord bot development using discord.js. Starting from basic commands, I progressively advanced to more sophisticated features, broadening my coding prowess.

Working with large data files, such as game events and state information, enhanced my data manipulation skills. I tackled nested structures and learned to extract specific data efficiently.

Overcoming challenges, like navigating complex nested data, honed my problem-solving skills. I developed strategies to efficiently extract and process information from intricate JSON structures.

What's next for pgl-arlington-major-2022-discord-bot(Game-ID-1597139)

Interactive Features: We're considering the integration of game prediction tools, allowing users to forecast game outcomes based on historical data and current player performance metrics. This feature can make game discussions on Discord even more engaging.

Integration with Other Platforms: Beyond Discord, we're exploring ways to incorporate the bot's capabilities into other platforms popular among gamers. Think Twitch, Steam, and even eSports betting platforms.

Built With

Share this project:

Updates