mirror of
https://github.com/diamondburned/arikawa.git
synced 2024-11-01 04:24:19 +00:00
35 lines
927 B
Go
35 lines
927 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"log"
|
||
|
"os"
|
||
|
|
||
|
"github.com/diamondburned/arikawa/v3/api"
|
||
|
"github.com/diamondburned/arikawa/v3/api/cmdroute"
|
||
|
"github.com/diamondburned/arikawa/v3/gateway"
|
||
|
"github.com/diamondburned/arikawa/v3/state"
|
||
|
"github.com/diamondburned/arikawa/v3/utils/json/option"
|
||
|
)
|
||
|
|
||
|
var commands = []api.CreateCommandData{{Name: "ping", Description: "Ping!"}}
|
||
|
|
||
|
func main() {
|
||
|
r := cmdroute.NewRouter()
|
||
|
r.AddFunc("ping", func(ctx context.Context, data cmdroute.CommandData) *api.InteractionResponseData {
|
||
|
return &api.InteractionResponseData{Content: option.NewNullableString("Pong!")}
|
||
|
})
|
||
|
|
||
|
s := state.New("Bot " + os.Getenv("BOT_TOKEN"))
|
||
|
s.AddInteractionHandler(r)
|
||
|
s.AddIntents(gateway.IntentGuilds)
|
||
|
|
||
|
if err := cmdroute.OverwriteCommands(s, commands); err != nil {
|
||
|
log.Fatalln("cannot update commands:", err)
|
||
|
}
|
||
|
|
||
|
if err := s.Connect(context.TODO()); err != nil {
|
||
|
log.Println("cannot connect:", err)
|
||
|
}
|
||
|
}
|