This bot was created to serve my local Smash Ultimate Scene Alulu. I have since been approached by another local tournament organizer to spin up an instance for their scene as well. This led to me rewriting the bot to be less specific to Alulu so it can be easily deployed to other servers.
The primary function of the bot is to query the start.gg API the day after the tournament is held, then to mention everyone in our results channel on Discord with the top 8 placements. I've succeeded in doing this by utilizing Cron as well as by hosting the bot on an Ubuntu server with Vultr.
I also integrated the Top8er API so that I could generate a top 8 graphic along with the usual top 8 placements message. A big thank you to @ShonTitor for explaining their project and API to me, as well as helping me realize this new exciting feature!
The bot is written in TypeScript, and uses discord.js to integrate with the Discord app, as well as GraphQL to interact with the start.gg API.
- Clone the repository
- Run
npm install
||yarn install
- Create a
.env
file in the root directory of the project and copy the format ofenv.temp
usingcp .env.temp .env
. You will need to fill in the following values:
TOURNAMENT_NAME
- The name of your tournamentTOURNAMENT_COORDS
- The coordinate of your tournament. This can be found easily using google. This is used inutils/getTournamentByCoords
CRON_JOB_CADENCE
- The string for the Cron Job. Check out Cron for more information.DISCORD_TOKEN
- The token for your Discord botCLIENT_ID
- The client ID for your Discord botGUILD_ID
- The guild ID for your Discord bot (The server for which the bot will live in)CHANNEL_ID
- The channel ID for your Discord bot (The channel for which the bot will post in)STARTGG_KEY
- The token for your start.gg API keySTARTGG_URI
- The URI for your start.gg API key, all requests go through the same URI 'https://api.start.gg/gql/alpha'. You can choose to keep the URI here in the.env
file as I have, or you can instead replace any usage ofprocess.env.STARTGG_URI
with the URI itself.SMTP_USERNAME
- The username for your email client (if you choose to use the email alert system)SMTP_PASSWORD
- The password for your email clientSMTP_RECIPIENT
- The email address that will receive the alertsTOP8ER_URI
- The URI for the Top8er API. This is used to generate the top 8 graphic. Please reach out to @ShonTitor for this URI as well as for permission to use the API.
- Ensure that you are using the correct version of Node as specified by the
.nvmrc
file found in the root of this directory. If you are using nvm you can simply runnvm use
to use the correct version of Node. - Before you can run the bot locally, be sure to run
npm build
in order to compile all TypeScript files into JavaScript files. This will create adist
folder in the root of the project, which is where the compiled JavaScript files will live. - Finally, run
npm start
to start the bot locally. If all has worked correctly, the bot should be online in your Discord server. - In order to add any commands you may have created, run
yarn deploy:commands
, otherwise the bot will only have access to the commands that are already deployed to the server.
All instances are hosted on Vultr using their lowest specs (Cloud Compute, General Purpose Server, 25 GB NVMe). I also opted for Ubuntu 23.04 x64 as my OS.
Each Ubuntu instance is provisioned with Docker. This allows me to easily update the bot without having to manually restart it. I have a GitHub action defined that ssh's into my server, identifies and stops the current container, pulls the latest changes from the main branch, then builds a new container and starts it. This is all done automatically when a git pull is made to main.
The bot has a few commands that can be used in the Discord server. These commands are:
/get_event_standing
- This command expects a week of Alulu to query, and optionally accepts the number of results you'd like to see, otherwise it returns the top 3 placements for that given tournament.
Check the issues on GitHub for what is currently being worked on or is coming down the pipeline.