2022-10-03 05:19:33 +00:00
|
|
|
package discord
|
|
|
|
|
|
|
|
import (
|
2022-10-27 09:56:40 +00:00
|
|
|
"fmt"
|
|
|
|
"time"
|
2023-07-13 04:22:52 +00:00
|
|
|
|
|
|
|
"gitea.dwysokinski.me/twhelp/dcbot/internal/domain"
|
2022-10-03 05:19:33 +00:00
|
|
|
)
|
|
|
|
|
2022-10-27 09:56:40 +00:00
|
|
|
const (
|
2023-07-13 04:22:52 +00:00
|
|
|
colorGrey = 0x808080
|
2022-10-27 09:56:40 +00:00
|
|
|
embedDescriptionCharLimit = 4096
|
|
|
|
)
|
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
2022-10-28 11:59:20 +00:00
|
|
|
|
2022-10-28 12:32:34 +00:00
|
|
|
func buildChannelMention(id string) string {
|
|
|
|
return "<#" + id + ">"
|
|
|
|
}
|
|
|
|
|
2022-10-28 11:59:20 +00:00
|
|
|
func boolToEmoji(val bool) string {
|
|
|
|
if val {
|
|
|
|
return ":white_check_mark:"
|
|
|
|
}
|
|
|
|
return ":x:"
|
|
|
|
}
|
2023-06-30 05:09:52 +00:00
|
|
|
|
|
|
|
func buildLangMessageID(languageTag string) string {
|
|
|
|
return "lang." + languageTag
|
|
|
|
}
|
2023-07-13 04:22:52 +00:00
|
|
|
|
|
|
|
func buildPlayerMarkdown(p domain.NullPlayerMeta) string {
|
|
|
|
if !p.Valid {
|
|
|
|
return "-"
|
|
|
|
}
|
|
|
|
|
|
|
|
tag := p.Player.Tribe.Tribe.Tag
|
|
|
|
if tag == "" {
|
|
|
|
tag = "-"
|
|
|
|
}
|
|
|
|
|
|
|
|
return buildLink(p.Player.Name, p.Player.ProfileURL) +
|
|
|
|
" [" +
|
|
|
|
buildLink(tag, p.Player.Tribe.Tribe.ProfileURL) +
|
|
|
|
"]"
|
|
|
|
}
|