31 lines
590 B
Go
Raw Normal View History

2024-05-03 21:25:42 +02:00
package services
2024-05-03 22:05:35 +02:00
import (
"fmt"
2024-05-03 22:05:35 +02:00
"github.com/bwmarrin/discordgo"
2024-05-04 13:23:57 +02:00
"os"
"time"
2024-05-03 22:05:35 +02:00
)
2024-05-03 21:25:42 +02:00
2024-05-04 13:23:57 +02:00
var errorChannelID string
2024-05-03 22:05:35 +02:00
func HandleError(err error, s *discordgo.Session) {
2024-05-04 13:23:57 +02:00
errorChannelID = os.Getenv("ERROR_CHANNEL_ID")
_, err = s.ChannelMessageSendComplex(errorChannelID, &discordgo.MessageSend{
2024-05-03 22:05:35 +02:00
Content: "@here",
Embed: &discordgo.MessageEmbed{
Title: "Error",
Color: 0xff0000,
Timestamp: time.Now().Format(time.RFC3339),
2024-05-03 22:05:35 +02:00
Fields: []*discordgo.MessageEmbedField{
{
Value: "```" + err.Error() + "```",
},
},
},
})
if err != nil {
fmt.Println(err)
}
2024-05-03 21:25:42 +02:00
}