This repository has been archived on 2024-05-11. You can view files and clone it, but cannot push or open issues or pull requests.
Corn-Utility/main.go
toast 025ee367e0
All checks were successful
Build and push container image / build (push) Successful in 1m13s
Lowercase the container name
2024-01-29 19:52:39 +11:00

65 lines
1.7 KiB
Go

package main
import (
botEvents "corn-util/bot/events"
"corn-util/bot/loaders"
"os"
"os/signal"
"runtime"
"strings"
"syscall"
"github.com/disgoorg/disgo"
"github.com/disgoorg/disgo/bot"
"github.com/disgoorg/disgo/discord"
"github.com/disgoorg/disgo/events"
"github.com/disgoorg/disgo/httpserver"
"github.com/disgoorg/log"
"github.com/disgoorg/snowflake/v2"
)
func main() {
client, err := disgo.New(loaders.TokenLoader("bot"),
bot.WithHTTPServerConfigOpts(loaders.TokenLoader("botPublicKey"),
httpserver.WithAddress(":23242"),
httpserver.WithURL("/"),
),
bot.WithEventListeners(&events.ListenerAdapter{OnApplicationCommandInteraction: botEvents.ListenForCommand}),
)
if err != nil {
panic(err)
}
if err = client.OpenHTTPServer(); err != nil {
panic(err)
}
if loaders.IsCmdsDeployable() {
log.Infof("Commands deployment is enabled, deploying...")
if _, err := client.Rest().SetGlobalCommands(client.ApplicationID(), commandsJSON()); err != nil {
log.Errorf("failed to set global commands: %v", err)
}
} else {
log.Infof("Commands deployment is disabled")
}
log.Infof("Client ready!")
log.Infof("Running Disgo %v & Go %v", disgo.Version, strings.TrimPrefix(runtime.Version(), "go"))
client.Rest().CreateWebhookMessage(snowflake.MustParse(loaders.TokenLoader("hookId")), loaders.TokenLoader("hookToken"), discord.WebhookMessageCreate{Content: "Container has been reloaded."}, true, 0)
/* go func() {
ticker := time.NewTicker(30 * time.Second)
defer ticker.Stop()
for {
select {
case <-ticker.C:
utils.BanRecordsSheet()
}
}
}() */
s := make(chan os.Signal, 1)
signal.Notify(s, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)
<-s
}