In this guide, you'll learn how to use adam, a discord bot framework written in Go. The aim here is to get you familiar with adam, but not to provide a full reference. Use the documentation for that. If you are unfamiliar with Go, start by taking the Go Tour. With that said, let's get your first bot up and running.
Depending on your use case, a bot's codebase can grow very large. Therefore, it is important to properly organize your bot. We recommend you group your code into three main folders:
cmd
: This contains your main
package. Here you initialize everything, add your plugins, and start the bot.
plugins
: This is where your plugins go. Use one package per command/module.
pkg
: This is where all your library code goes. Basically, everything that fits in neither cmd
nor plugin
.
Note, however, that this layout is not the holy grail of layouts. If you only want to run a small bot with a handful of commands, you might be better of with a custom layout. Still, this is a good start if you are unsure about how to structure your bot.
After you have run go mod init
and added adam as a dependency using go get github.com/mavolin/adam
, you can create a bot in your main
package using bot.New
. You now need to think about what parts of the bot you want to make configurable, as a lot of configuration is done through the bot.Options
you pass to bot.New
.
After creating your bot, you can add plugins to it.
Head over to the next page, to see how to build your first command.