make score in Session.handleTribeCommand more readable (add commas)

This commit is contained in:
Dawid Wysokiński 2021-02-06 10:36:13 +01:00
parent a6e1894ae1
commit dc70752cfe
8 changed files with 12 additions and 9 deletions

View File

@ -37,5 +37,5 @@ func BuildLink(text string, url string) string {
if url == "" {
return text
}
return fmt.Sprintf("[``%s``](%s)", text, url)
return fmt.Sprintf("[`%s`](%s)", text, url)
}

View File

@ -745,10 +745,9 @@ func (s *Session) handleObservationsCommand(ctx *commandCtx, m *discordgo.Messag
if version != nil {
tribeURL = tw.BuildTribeURL(observation.Server, version.Host, observation.TribeID)
}
msg.Append(fmt.Sprintf("**%d** | %d - %s - [``%s``](%s)\n", i+1, observation.ID,
msg.Append(fmt.Sprintf("**%d** | %d - %s - %s\n", i+1, observation.ID,
observation.Server,
tag,
tribeURL))
BuildLink(tag, tribeURL)))
}
}
s.SendEmbed(m.ChannelID, NewEmbed().

View File

@ -13,6 +13,7 @@ import (
"github.com/tribalwarshelp/shared/tw"
"github.com/bwmarrin/discordgo"
"github.com/dustin/go-humanize"
"github.com/tribalwarshelp/golang-sdk/sdk"
)
@ -463,7 +464,7 @@ func (s *Session) handleTribeCommand(ctx *commandCtx, m *discordgo.MessageCreate
msg.Append(ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
MessageID: message.TribeMessageLine,
DefaultMessage: message.FallbackMsg(message.TribeMessageLine,
"**{{.Index}}**. [``{{.PlayerName}}``]({{.PlayerURL}}) (Tribe: [``{{.TribeTag}}``]({{.TribeURL}}) | Rank: **{{.Rank}}** | Score: **{{.Score}}**)\n"),
"**{{.Index}}**. [`{{.PlayerName}}`]({{.PlayerURL}}) (Tribe: [`{{.TribeTag}}`]({{.TribeURL}}) | Rank: **{{.Rank}}** | Score: **{{.Score}}**)\n"),
TemplateData: map[string]interface{}{
"Index": offset + i + 1,
"PlayerName": player.Name,
@ -471,7 +472,7 @@ func (s *Session) handleTribeCommand(ctx *commandCtx, m *discordgo.MessageCreate
"TribeTag": tribeTag,
"TribeURL": tribeURL,
"Rank": rank,
"Score": score,
"Score": humanize.Comma(int64(score)),
},
}))
}

1
go.mod
View File

@ -4,6 +4,7 @@ go 1.15
require (
github.com/bwmarrin/discordgo v0.22.0
github.com/dustin/go-humanize v1.0.0
github.com/go-pg/pg/extra/pgdebug v0.2.0
github.com/go-pg/pg/v10 v10.7.3
github.com/joho/godotenv v1.3.0

2
go.sum
View File

@ -12,6 +12,8 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=

View File

@ -35,7 +35,7 @@
"tribe.title.orderedByPoints": "Ordered by points",
"tribe.tribesNotFound": "{{.Mention}} Tribes not found.",
"tribe.exceededMaximumNumberOfPages": "{{.Mention}} You have exceeded the maximum number of pages ({{.Page}}/{{.MaxPage}}).",
"tribe.messageLine": "**{{.Index}}**. [``{{.PlayerName}}``]({{.PlayerURL}}) (Tribe: [``{{.TribeTag}}``]({{.TribeURL}}) | Rank: **{{.Rank}}** | Score: **{{.Score}}**)\n",
"tribe.messageLine": "**{{.Index}}**. [`{{.PlayerName}}`]({{.PlayerURL}}) (Tribe: [`{{.TribeTag}}`]({{.TribeURL}}) | Rank: **{{.Rank}}** | Score: **{{.Score}}**)\n",
"addGroup.groupLimitHasBeenReached": "{{.Mention}} The group limit has been reached ({{.Total}}/{{.Limit}}).",
"addGroup.success": "{{.Mention}} A new group has been created (ID: {{.ID}}).",

View File

@ -35,7 +35,7 @@
"tribe.title.orderedByPoints": "geranschikt op points",
"tribe.tribesNotFound": "{{.Mention}} Stammen niet gevonden.",
"tribe.exceededMaximumNumberOfPages": "{{.Mention}} Je hebt de maximale aantal pagina's overschreden ({{.Page}}/{{.MaxPage}}).",
"tribe.messageLine": "**{{.Index}}**. [``{{.PlayerName}}``]({{.PlayerURL}}) (Stam: [``{{.TribeTag}}``]({{.TribeURL}}) | Rang: **{{.Rank}}** | Score: **{{.Score}}**)\n",
"tribe.messageLine": "**{{.Index}}**. [`{{.PlayerName}}`]({{.PlayerURL}}) (Stam: [`{{.TribeTag}}`]({{.TribeURL}}) | Rang: **{{.Rank}}** | Score: **{{.Score}}**)\n",
"addGroup.groupLimitHasBeenReached": "{{.Mention}} De groeplimiet is bereikt ({{.Total}}/{{.Limit}}).",
"addGroup.success": "{{.Mention}} Een nieuwe groep is gemaakt (ID: {{.ID}}).",

View File

@ -35,7 +35,7 @@
"tribe.title.orderedByPoints": "Gracze posortowani według punktów",
"tribe.tribesNotFound": "{{.Mention}} Plemię nie zostało znalezione.",
"tribe.exceededMaximumNumberOfPages": "{{.Mention}} Przekroczyłeś limit stron ({{.Page}}/{{.MaxPage}}).",
"tribe.messageLine": "**{{.Index}}**. [``{{.PlayerName}}``]({{.PlayerURL}}) (Plemię: [``{{.TribeTag}}``]({{.TribeURL}}) | Ranking: **{{.Rank}}** | Wynik: **{{.Score}}**)\n",
"tribe.messageLine": "**{{.Index}}**. [`{{.PlayerName}}`]({{.PlayerURL}}) (Plemię: [`{{.TribeTag}}`]({{.TribeURL}}) | Ranking: **{{.Rank}}** | Wynik: **{{.Score}}**)\n",
"addGroup.groupLimitHasBeenReached": "{{.Mention}} Osiągnięto limit grup ({{.Total}}/{{.Limit}}).",
"addGroup.success": "{{.Mention}} Nowa grupa została utworzona (ID: {{.ID}}).",