package util import ( "fmt" "runtime/debug" "github.com/bwmarrin/discordgo" ) var ReportTarget string func ReportError(dg *discordgo.Session, toReport error) { msg := "```\n" + toReport.Error() + "\n" + string(debug.Stack()) + "```" if dg == nil { fmt.Println(msg) fmt.Println("DiscordGo not provided") return } channel, err := dg.UserChannelCreate(ReportTarget) if err != nil { fmt.Println(msg) fmt.Println(err) return } _, err = dg.ChannelMessageSend(channel.ID, msg) if err != nil { fmt.Println(msg) fmt.Println(err) } } func SendCheckError(dg *discordgo.Session, channelID string, message string) { _, err := dg.ChannelMessageSend(channelID, message) if err != nil { ReportError(dg, err) return } }