/discord-sports-notification

A Discord bot for sending sports notifications

Primary LanguagePythonMIT LicenseMIT

A Discord bot for sending sports notifications, made in Python. A message is sent notifying users in a channel when an almost-completed sports game has a close score between the teams. 98% umpball-free. The last 2% is the hardest to get. That's why they leave it in the milk.

Installation

Build From Source

  1. Install git and docker-compose.
  2. Clone the repo.
git clone https://github.com/wazam/discord-sports-notification.git
  1. Change to the current working directory.
cd ./discord-sports-notification
  1. Add your Discord bot's secret_token and Server's channel_ID to the environment section of the docker-compose.yml file.
  2. If you want to change these default values, then modify them by adding additional environment variables to the docker-compose.yml file.
  3. Run the docker-compose.yml file to build and run the app.
docker-compose up -d

Docker-Compose

---
version: "3"
services:
  app:
    image: ghcr.io/wazam/discord-sports-notification:main
    container_name: discord-sports-notification
    environment:
      - DISCORD_SECRET_TOKEN={{YOUR_VALUE}}
      - DISCORD_CHANNEL_ID={{YOUR_VALUE}}

Additional Steps

  • Enable the Discord bot's privileged intents in dev portal settings.
  • Add the bot to your server with the proper permissions.

Example Notifications

Bot Commands

  • help list of all commands
  • games or today amount of sports games today
  • baseball or mlb list of mlb games today
  • basketball or nba list of nba games today
  • weather {{your zip/post code or city/area name}} current weather conditions

Environment Variables

Mandatory

  • DISCORD_SECRET_TOKEN={{YOUR_VALUE}}
    • Discord Bot's Client Secret Token (from Developer Portal).
  • DISCORD_CHANNEL_ID={{YOUR_VALUE}}
    • Discord Text Channel ID (right-click, "Copy ID").

Optional

  • BOT_REFRESH=300
    • Set the interval in seconds to scrape game information for notification conditions.
  • BOT_PREFIX=!
    • Set the command prefix to be used for the bot, in between the quotation marks.
    • Slash commands are available by default now for the bot.
  • NBA_ENABLED=True
    • Enable/Disable support for NBA notifications.
  • NBA_PERIOD=4
    • Set the earliest period that a notification can activate for.
    • Notification is not sent if period in game is less than this number.
  • NBA_PT_DIFFERENTIAL=5
    • Set the highest point differential between the teams that a notification can activate for.
    • Notification is not sent if point differential between teams is higher than this number.
  • NBA_MINS_LEFT=4
    • Set the last minutes that a notification can activate for.
    • Notification is not sent if remaining minutes in period is more than this number.
  • MLB_ENABLED=True
    • Enable/Disable support for MLB notifications.
  • MLB_INNING=9
    • Set the earliest inning that a notification can activate for.
    • Notification is not sent if inning is less than this number.
  • MLB_RUN_DIFFERENTIAL=1
    • Set the highest run differential between the teams that a notification can activate for.
    • Notification is not sent if run differential is higher than this number.
  • MLB_BASERUNNERS='RISP'
    • Set the minimum amount of baserunners that a notification can activate for.
    • Notification is not sent until this situation occurs on the bases.
    • Options: 'RISP' for 2nd/3rd, 'Men_On' for 1st, 'Empty' for no requirement.
  • OPENWEATHERMAP_API_KEY={{YOUR_VALUE}}
  • TZ=America/New_York
    • Sets localtime for bot based on prefered tz name.

Supported Sports

League Available Planned
NBA (National Basketball Association)
MLB (Major League Baseball)
NFL (National Football League)
NHL (National Hockey League)
NCAA Men's Baseball
NCAA Men's Basketball
NCAA Football
MLS (Major League Soccer)
EPL (English Premier League)

Disclaimers