@@ 3,6 3,7 @@ package main
import (
"fmt"
"strings"
+ "time"
"github.com/bwmarrin/discordgo"
"github.com/lus/dgc"
@@ 156,17 157,27 @@ func getTrackedIncidences(ctx *dgc.Ctx) {
return
}
- var sb strings.Builder
- for i, district := range districts {
- sb.WriteString(fmt.Sprintf("%s: %.2f", district.Name, district.WeekIncidence))
+ var fields = make([]*discordgo.MessageEmbedField, len(districts))
- // only write a newline if it's not the last element
- if i < len(districts)-1 {
- sb.WriteRune('\n')
+ for i, district := range districts {
+ incidence := fmt.Sprintf("%.2f", district.WeekIncidence)
+ fields[i] = &discordgo.MessageEmbedField{
+ Name: district.Name,
+ Value: incidence,
+ Inline: false,
}
}
- ctx.RespondText(sb.String())
+ embed := discordgo.MessageEmbed{
+ Type: discordgo.EmbedTypeRich,
+ Title: "Incidences",
+ Timestamp: time.Now().Format(time.RFC3339),
+ Fields: fields,
+ }
+
+ if err := ctx.RespondEmbed(&embed); err != nil {
+ log.Error(err)
+ }
}
func getDistrictInformation(ctx *dgc.Ctx) {