package services

import (
	"fmt"
	"github.com/bwmarrin/discordgo"
	"os"
	"time"
)

var errorChannelID string

func HandleError(err error, s *discordgo.Session) {
	errorChannelID = os.Getenv("ERROR_CHANNEL_ID")
	_, err = s.ChannelMessageSendComplex(errorChannelID, &discordgo.MessageSend{
		Content: "@here",
		Embed: &discordgo.MessageEmbed{
			Title:     "Error",
			Color:     0xff0000,
			Timestamp: time.Now().Format(time.RFC3339),
			Fields: []*discordgo.MessageEmbedField{
				{
					Value: "```" + err.Error() + "```",
				},
			},
		},
	})
	if err != nil {
		fmt.Println(err)
	}
}
