Dawid Wysokiński
e9c5e06407
All checks were successful
continuous-integration/drone/push Build is passing
44 lines
717 B
Go
44 lines
717 B
Go
package discord
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"gitea.dwysokinski.me/twhelp/dcbot/internal/domain"
|
|
)
|
|
|
|
const (
|
|
embedDescriptionCharLimit = 4096
|
|
)
|
|
|
|
func messageFromError(err error) string {
|
|
var userErr domain.Error
|
|
if !errors.As(err, &userErr) {
|
|
return "something went wrong, please try again later"
|
|
}
|
|
return userErr.UserError()
|
|
}
|
|
|
|
func formatTimestamp(t time.Time) string {
|
|
return t.Format(time.RFC3339)
|
|
}
|
|
|
|
func buildLink(text string, url string) string {
|
|
if url == "" {
|
|
return text
|
|
}
|
|
return fmt.Sprintf("[`%s`](%s)", text, url)
|
|
}
|
|
|
|
func buildChannelMention(id string) string {
|
|
return "<#" + id + ">"
|
|
}
|
|
|
|
func boolToEmoji(val bool) string {
|
|
if val {
|
|
return ":white_check_mark:"
|
|
}
|
|
return ":x:"
|
|
}
|