Discord College Football Bot
A Discord bot written in Go that provides up-to-date college football scores and schedules. It responds to commands to show recent or upcoming games for specific teams using the College Football Data API.
Features
- Retrieves college football scores by team, including live scores (for Patreon members)
- Provides upcoming game schedules if a game hasn’t started
- Designed to run on a Discord server, responds to commands in real-time
Commands
- !s
<team_name>
— Retrieves the score for the most recent game or the upcoming game schedule if the game hasn’t started.
Example:
!s Alabama
Setup
Prerequisites
- Go (1.19 or later)
- College Football Data API key: Sign up at College Football Data and obtain an API key.
- Discord Bot Token: Set up a bot on the Discord Developer Portal to obtain a token.
Installation
-
Clone the repository:
git clone https://github.com/yourusername/discord-cfb-bot.git cd discord-cfb-bot
-
Configure API keys:
- In
config/config.go
, set theCFBDAPIKey
with your College Football Data API key and your Discord bot token.
- In
-
Run the bot:
- To test locally:
go run main.go
- To run in the background:
- Use
nohup
,screen
,tmux
, or create asystemd
service (see below for options).
- Use
- To test locally:
Running the Bot in the Background
You can keep the bot running in the background by using tools like nohup
, screen
, or tmux
. For production servers, consider creating a systemd
service.
Example with nohup
:
nohup go run main.go > bot.log 2>&1 &
Deployment with systemd
(Linux)
-
Create a
systemd
service file at/etc/systemd/system/discord-cfb-bot.service
:[Unit] Description=Discord College Football Bot After=network.target [Service] ExecStart=/usr/local/go/bin/go run /path/to/main.go WorkingDirectory=/path/to/discord-cfb-bot StandardOutput=append:/path/to/bot.log StandardError=append:/path/to/bot.log Restart=always User=yourusername [Install] WantedBy=multi-user.target
-
Enable and start the service:
sudo systemctl enable discord-cfb-bot sudo systemctl start discord-cfb-bot
Usage
Invite the bot to your server and type commands in any text channel where the bot has permissions. For example:
!s Texas A&M
The bot will reply with the score or the upcoming game schedule for the team.
Project Structure
main.go
: Entry point of the botconfig/config.go
: Configuration file for the API keys and other settingsclients/cfbd_client.go
: Client for interacting with the College Football Data APIbot/bot.go
: Discord bot setup and command handling
Contributions
Contributions are welcome! Feel free to submit a pull request to improve the bot or add new features.
License
This project is licensed under the MIT License. See the LICENSE file for details.