Use discord embeds

This commit is contained in:
Daniel Mason 2021-09-01 21:37:02 +12:00
parent 3fc389f1d6
commit df3c0b9ed4
Signed by: idanoo
GPG key ID: 387387CDBC02F132
2 changed files with 11 additions and 20 deletions

View file

@ -45,7 +45,8 @@ func formatCsvDiscordRow(data string) string {
c := make([]string, 0)
c = append(c, fields...)
return fmt.Sprintf("**%s** %s on _%s_ - _%s_", c[1], c[2], c[4], c[5])
endtime := strings.Split(c[5], ", ")
return fmt.Sprintf("**%s** %s on _%s_ - _%s_", c[1], c[2], c[4], endtime[1])
}
// formatCsvTwitterRow Format the string to a tidy string for the interwebs
@ -61,7 +62,8 @@ func formatCsvTwitterRow(data string) string {
c := make([]string, 0)
c = append(c, fields...)
return fmt.Sprintf("**%s** - %s\n_%s_ - _%s_", c[1], c[2], c[4], c[5])
endtime := strings.Split(c[5], ", ")
return fmt.Sprintf("**%s** - %s _%s_ - _%s_", c[1], c[2], c[4], endtime[1])
}
func getPostableDiscordData() string {
@ -78,7 +80,7 @@ func getPostableDiscordData() string {
}
}
return strings.Join(rows, "\n\n")
return strings.Join(rows, "\n")
}
func getPostableTwitterData() string {

View file

@ -22,25 +22,14 @@ func postToDiscord(webhookString string, msg string) {
return
}
// message, err := webhook.SendContent(msg)
// if err != nil {
// log.Print(err)
// return
// }
// // message, err = webhook.SendEmbeds(api.NewEmbedBuilder().
// // SetDescription(msg).
// // Build(),
// // )
// if err != nil {
// log.Print(err)
// return
// }
_, err = webhook.SendMessage(api.NewWebhookMessageCreateBuilder().
SetContent(msg).
_, err = webhook.SendEmbeds(api.NewEmbedBuilder().
SetDescription(msg).
Build(),
)
if err != nil {
log.Print(err)
return
}
if err != nil {
log.Print(err)