Interactions is a simple, batteries included HTTP interactions library for Discord. It is designed to make is fast and easy to create a new Discord server integration using Discords new interactions system.
Add Interactions to your project
go get -u github.com/Postcord/interactions
package main
import (
"log""os""github.com/Postcord/interactions""github.com/Postcord/objects"
)
funcmain() {
app, err:=interactions.New(&interactions.Config{
PublicKey: os.Getenv("DISCORD_PUBLIC_KEY"),
Token: "Bot "+os.Getenv("DISCORD_TOKEN"),
})
iferr!=nil {
panic("failed to create interactions client")
}
app.CommandHandler(testHandler)
log.Println("test-bot is now running")
http.ListenAndServe(":8080", app.HTTPHandler())
}
functestHandler(ctx*objects.Interaction) *objects.InteractionResponse {
return&objects.InteractionResponse{
Type: objects.ResponseChannelMessageWithSource,
Data: &objects.InteractionApplicationCommandCallbackData{
Content: "Hello world!",
Flags: objects.ResponseFlagEphemeral,
},
}
}If you're looking for a more batteries included solution that includes command and interaction routing. Check out our router package.
Documentation is still a work in progress.