This commit is contained in:
unintendedfraud
2023-08-27 08:59:55 +02:00
parent 1ef2073a5c
commit 7522801c9a
-46
View File
@@ -5,8 +5,6 @@ import (
"hal/commands" "hal/commands"
"hal/env" "hal/env"
"hal/handlers" "hal/handlers"
"log"
"time"
tempest "github.com/Amatsagu/Tempest" tempest "github.com/Amatsagu/Tempest"
discordbot "github.com/bwmarrin/discordgo" discordbot "github.com/bwmarrin/discordgo"
@@ -34,50 +32,6 @@ func main() {
fmt.Println("error opening connection,", err) fmt.Println("error opening connection,", err)
return return
} }
client := tempest.CreateClient(tempest.ClientOptions{
ApplicationId: env.AppID,
PublicKey: env.PublicKey,
Token: discordToken,
PreCommandExecutionHandler: func(itx tempest.CommandInteraction) *tempest.ResponseData {
log.Printf("running [%s] slash command", itx.Data.Name)
return nil
},
Cooldowns: &tempest.ClientCooldownOptions{
Duration: 5 * time.Second,
Ephemeral: true,
CooldownResponse: func(user tempest.User, timeLeft time.Duration) tempest.ResponseData {
return tempest.ResponseData{
Content: fmt.Sprintf("stop spamming, try again in %.2fs", timeLeft.Seconds()),
}
},
},
})
if err = initialize(client, env.ServerIDs); err != nil {
panic(err)
}
if err = client.RegisterCommand(commands.Pinned); err != nil {
panic(err)
}
if err = client.RegisterCommand(commands.PsgRefreshFixtures); err != nil {
panic(err)
}
if err = client.RegisterCommand(commands.PsgNextMatch); err != nil {
panic(err)
}
if err = client.SyncCommands(env.ServerIDs, nil, false); err != nil {
panic(err)
}
addr := fmt.Sprintf(":%s", env.Port)
fmt.Println("starting server at", addr)
if err := client.ListenAndServe(addr); err != nil {
panic(err)
}
} }
func initialize(c tempest.Client, serverIDs []tempest.Snowflake) error { func initialize(c tempest.Client, serverIDs []tempest.Snowflake) error {