Discord Golang bot is a simple Discord bot built using Golang, primarily for study purposes. The bot can respond to various commands and provide users with images of cats and birds.
- Respond to
ping
command. - Send a random cat image with the
meow
command. - Send a random bird image with the
birb
command. - Periodically update a voice channel's name with the current number of Guilty Gear STRIVE players.
- Ask AI questions via Gemini API with
/ask-ai
command. - Set your Gemini API key securely with
/set-gemini-key
command (stored in SQLite database).
To use this project, you need to follow these steps:
- Clone the repository:
git clone https://github.com/MiguelMachado-dev/disc-go-bot.git
- Change directory to the cloned repository:
cd disc-go-bot
- Install the dependencies:
go mod download
- Create a .env file in the root directory of the project and add your Discord bot token:
DISCORD_BOT_TOKEN=your_bot_token
- Build the application:
go build
- Run the application:
./disc-go-bot
The application will automatically create an SQLite database in the data
directory to store user Gemini API keys securely.
Now, your bot should be running and connected to Discord. Invite the bot to your server and start using the commands.
You can change some settings like prefix on .env
file.
>ping
: The bot will respond with "Pong!">meow
: The bot will send a random cat image.>birb
: The bot will send a random bird image./ask-ai
: Ask a question to the AI using the Gemini API (requires setting up your API key first)./set-gemini-key
: Set your personal Gemini API key (required to use the/ask-ai
command).
The bot will also automatically update the specified voice channel's name every few minutes (30 minutes as default) to display the current number of Guilty Gear players.
The project includes a Makefile to help you manage common tasks more easily. Here's a list of the available commands and a brief description of what they do:
APP_NAME
: The name of the application (default:disc-go-bot
).IMAGE_TAG
: The Docker image tag (default:latest
).DOCKERFILE_PATH
: The path to the Dockerfile (default:Dockerfile
).PORT
: The port on which the application will be exposed (default:8080
).
- The default target, runs the
build
target.
- Builds the application using the Go compiler.
- Builds the Docker image for the application using the specified Dockerfile.
- Runs the application in a Docker container, exposing the specified port. This target depends on the
docker-build
target.
- Stops and removes the running Docker container.
- Cleans up build artifacts by removing the generated executable.
- Executes the tests for the application using the Go test tool.
- Builds and runs the application locally.
To use the Makefile, simply run the desired target using the make
command followed by the target name:
make build
This project uses the following tools:
- Golang for backend development
- DiscordGo package that provides low level bindings to the Discord chat client API
- Colly Elegant Scraper and Crawler Framework for Golang
To contribute to this project, please follow these guidelines:
- Fork the repository
- Create a new branch:
git checkout -b feature/your-feature-name
- Make your changes and commit them using Conventional Commits
- Push to the branch:
git push origin feature/your-feature-name
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE.md file for details.
This project was created by MiguelMachado-dev.
Copy the .env.example
file to .env
and fill in the required environment variables:
DISCORD_BOT_TOKEN
: Your Discord bot tokenCOMMANDS_CHANNEL_ID
: The ID of the channel where commands will be enabledTWITCH_CLIENT_ID
: Your Twitch client ID (for Twitch integration)TWITCH_CLIENT_SECRET
: Your Twitch client secret (for Twitch integration)ENCRYPTION_KEY
: A 32-character random string used to encrypt sensitive data like API keys (REQUIRED)
To generate a secure random ENCRYPTION_KEY, you can use:
openssl rand -base64 32 | cut -c1-32