Goff/internal/exts/logging/logging.go
WayfinderAK cf6b7eae81
Some checks failed
Build and Push Container / docker (push) Has been cancelled
Migrate deployment to Gitea Actions and Portainer
2026-03-22 11:43:22 -08:00

37 lines
762 B
Go

package logging
import (
"fmt"
"github.com/bwmarrin/discordgo"
"gitea.wayfinderak.com/wayfinderak/goff/internal/postgres"
)
var LoggingChannel = make(chan *LogEvent, 10)
type LogEvent struct {
// Embed with log message
Embed discordgo.MessageEmbed
// Guild to log event in
GuildID string
// Discordgo Session. Needed for sending messages
Session *discordgo.Session
}
func LoggingHandler(lc chan *LogEvent) {
for event := range lc {
var channelID string
row := postgres.DB.QueryRow("SELECT logging_channel FROM guilds where id=$1", event.GuildID)
err := row.Scan(&channelID)
if err != nil {
fmt.Println(err)
return
}
if channelID == "" {
return
}
_, _ = event.Session.ChannelMessageSendEmbed(channelID, &event.Embed)
}
}