30 lines
1.6 KiB
Markdown
30 lines
1.6 KiB
Markdown
This is a simple Go program that uses the DiscordGo library and some APIs to handle some commands from users in a Discord server. It responds to certain messages prefixed by the BotPrefix variable, which can be customized in the .env file. It uses the godotenv library to read these values from the environment.
|
|
|
|
The main file (main.go) sets up a Discord bot using a token and listens to incoming messages. It then checks for certain messages and sends a response depending on the command.
|
|
|
|
The program uses the following APIs:
|
|
|
|
Yo Mama API
|
|
Dad Joke API
|
|
Jingle Bells API
|
|
Ron Swanson Quotes API
|
|
|
|
Dependencies
|
|
|
|
This program has several dependencies, which are managed using Go modules. The dependencies are:
|
|
|
|
github.com/bwmarrin/discordgo: a Discord API library for Go
|
|
github.com/joho/godotenv: a library for loading environment variables from a file
|
|
github.com/sashabaranov/go-openai: a library for accessing the OpenAI GPT-3 API
|
|
|
|
These dependencies are automatically fetched and installed when the program is built or run.
|
|
How to run
|
|
|
|
To run the program, you need to have a valid Discord bot token. You can obtain this by creating a new bot application in the Discord Developer Portal. Once you have a token, you need to create a .env file in the same directory as the program, with the following variables:
|
|
|
|
TOKEN: the Discord bot token
|
|
BOTPREFIX: the prefix for bot commands (e.g. "!")
|
|
ChannelID: the ID of the channel where you want the bot to listen
|
|
OPENAI_API_KEY: an API key for the OpenAI GPT-3 API (optional)
|
|
|
|
Once you have set up the .env file, you can run the program by executing go run main.go in the terminal. |