Skip to content

Discord bot for Longhorn Riichi's recurring special tournament: UTA vs UTD.

License

Notifications You must be signed in to change notification settings

Longhorn-Riichi/UvUManager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UvUManager

A Discord bot for Longhorn Riichi's special tournament "UTA vs UTD". Functions include /register, /create_table, /pause_own_game, etc.

Repository Structure:

  • bot.py: entry point of the Discord bot; has the regular commands and command error handling
  • /ext/extensions: list of all modules for bot.py to load from /ext/, one per line
  • /modules/pymjsoul: a copy of mjsoul.py that provides MajsoulChannel, a class for interfacing with Mahjong Soul's API
  • /modules/mahjongsoul: contains a wrapper of MajsoulChannel for use in our bot (in /ext/extensions/UvUManager)

Setting up the bot

First, cp config.template.env config.env.

Discord Stuff

  1. set up a bot account on Discord's developer portal (New Application).
    • (SETTINGS -> Bot) Privileged Gateway Intents: MESSAGE CONTENT INTENT
  2. invite the bot to the respective servers. You can use the developer portal's OAuth2 URL Generator (SETTINGS -> OAuth2 -> URL Generator):
    • Scopes: bot
    • Bot Permissions: Send Messages, Manage Messages, Add Reactions
  3. fill in the Discord Stuff section of config.env. The bot token can be obtained through (SETTINGS -> Bot [-> Reset Token])

Google Sheets Stuff

  1. set up a Google Cloud project. Enable Google Sheets API access, and make a service account. Generate a JSON key for that service account and save it as gs_service_account.json in ext/UvUManager/
  2. make a suitable Google Spreadsheet (example) and share the Spreadsheet with that service account.
  3. fill in the Google Sheets Stuff section of config.env

Mahjong Soul Stuff

  1. fill in the Mahjong Soul Stuff section of config.env

Running the bot

  1. in a Unix shell:

     pipenv install
     pipenv shell
     ./start.sh
    
  2. in the relevant Discord server: run $sync to sync the slash commands for that server.

Automated Features

  1. pings the server every 4 hours to see if a reconnection is necessary.
  2. every ping, requests to set the finish_time of the tournament to be 90 days from the current time. Note that the deadline still needs to be extended manually (this can't be automated because only the contest creator can extend the deadline).

Relevant Links (References)