You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Goff/utils/logging.go

35 lines
696 B

package utils
import (
"fmt"
"github.com/bwmarrin/discordgo"
)
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 := Database.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)
}
}