~witcher/discord_covid19

c29a6ee873196dadac9c89ff4dcaa9338019172e — Witcher01 3 years ago 74b033b
added embed for trackedDistricts
1 files changed, 8 insertions(+), 7 deletions(-)

M discord.go
M discord.go => discord.go +8 -7
@@ 187,17 187,18 @@ func getTrackedDistricts(ctx *dgc.Ctx) {
		return
	}

	var sb strings.Builder
	names := make([]string, len(districts))
	for i, district := range districts {
		sb.WriteString(district.Name)
		names[i] = district.Name
	}

		// only append a comma if it's not the last element
		if i < len(districts)-1 {
			sb.WriteString(", ")
		}
	embed := discordgo.MessageEmbed{
		Title:       "Tracked districts",
		Description: strings.Join(names, ", "),
		Timestamp:   time.Now().Format(time.RFC3339),
	}

	if err := ctx.RespondText(sb.String()); err != nil {
	if err := ctx.RespondEmbed(&embed); err != nil {
		log.Error(err)
	}
}