This repository has been archived on 2022-10-02. You can view files and clone it, but cannot push or open issues or pull requests.
dcbot-old/discord/helpers.go

40 lines
684 B
Go
Raw Permalink Normal View History

2020-07-19 15:21:44 +00:00
package discord
import (
2020-08-09 15:20:23 +00:00
"fmt"
2020-07-19 15:21:44 +00:00
"strings"
"github.com/tribalwarshelp/dcbot/message"
)
func boolToEmoji(val bool) string {
if val {
return ":white_check_mark:"
}
return ":x:"
}
2020-07-19 15:21:44 +00:00
func getAvailableLanguages() string {
var langTags []string
2020-07-19 15:21:44 +00:00
for _, langTag := range message.LanguageTags() {
langTags = append(langTags, langTag.String())
}
return strings.Join(langTags, " | ")
}
2020-08-09 15:20:23 +00:00
func isValidLanguageTag(lang string) bool {
for _, langTag := range message.LanguageTags() {
if langTag.String() == lang {
return true
}
}
return false
}
func BuildLink(text string, url string) string {
2020-08-09 15:20:23 +00:00
if url == "" {
return text
}
return fmt.Sprintf("[`%s`](%s)", text, url)
2020-08-09 15:20:23 +00:00
}