Skip to content

Repository files navigation

Postcord Interactions

Go Reference

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.

Getting Started

Add Interactions to your project

go get -u github.com/Postcord/interactions

Example

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,
},
}
}

Command Routing

If you're looking for a more batteries included solution that includes command and interaction routing. Check out our router package.

Documentation

Documentation is still a work in progress.

About

A simple Discord interactions server.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages