forked from chanbakjsd/TerraOceanPlugin
43 lines
1006 B
Go
43 lines
1006 B
Go
|
package message
|
||
|
|
||
|
import (
|
||
|
"runtime/debug"
|
||
|
|
||
|
"github.com/bwmarrin/discordgo"
|
||
|
|
||
|
"TerraOceanBot/discord/config"
|
||
|
)
|
||
|
|
||
|
func AuditInfo(s *discordgo.Session, message string) {
|
||
|
InitNewEmbed(config.AuditInfoTitle, message, config.AuditInfoColour).
|
||
|
Send(s, config.AuditChannel)
|
||
|
}
|
||
|
|
||
|
func AuditError(s *discordgo.Session, sourceChannel string, err error) {
|
||
|
if sourceChannel != "" {
|
||
|
InitNewErrorEmbed(config.InternalErrorDescription).
|
||
|
Send(s, sourceChannel)
|
||
|
}
|
||
|
sendError(s, config.AuditChannel, err)
|
||
|
}
|
||
|
|
||
|
func AuditErrorPM(s *discordgo.Session, sourceUser string, err error) {
|
||
|
channel, channelErr := s.UserChannelCreate(sourceUser)
|
||
|
if channelErr != nil {
|
||
|
AuditError(s, "", channelErr)
|
||
|
AuditError(s, "", err)
|
||
|
return
|
||
|
}
|
||
|
AuditError(s, channel.ID, err)
|
||
|
}
|
||
|
|
||
|
func sendError(s *discordgo.Session, channelID string, err error) {
|
||
|
stack := string(debug.Stack())
|
||
|
if len(stack) > 1000 {
|
||
|
stack = stack[:1000] + "..."
|
||
|
}
|
||
|
InitNewErrorEmbed(err.Error()).
|
||
|
AddField(config.ErrorStack, stack).
|
||
|
Send(s, channelID)
|
||
|
}
|