diff --git a/discord/discord.go b/discord/discord.go index 3b4df3b..5adb143 100644 --- a/discord/discord.go +++ b/discord/discord.go @@ -13,10 +13,12 @@ import ( "github.com/bonedaddy/go-indexed/bclient" "github.com/bonedaddy/go-indexed/db" "github.com/bwmarrin/discordgo" + "golang.org/x/text/message" ) var ( rateLimitMsg = "You are being rate limited. Users are allowed 1 blockchain query per command every 60 seconds" + printer *message.Printer ) // Client wraps bclient and discordgo to provide a discord bot for indexed finance @@ -31,6 +33,10 @@ type Client struct { wg *sync.WaitGroup } +func init() { + printer = message.NewPrinter(message.MatchLanguage("en")) +} + // NewClient provides a wrapper around discordgo func NewClient(ctx context.Context, cfg *Config, bc *bclient.Client, db *db.Database) (*Client, error) { wg := &sync.WaitGroup{} diff --git a/discord/governance.go b/discord/governance.go index 4d4f63b..2011352 100644 --- a/discord/governance.go +++ b/discord/governance.go @@ -161,5 +161,5 @@ func (c *Client) governanceTokenTotalSupply(ctx *dgc.Ctx) { return } supplyF, _ := utils.ToDecimal(supply, 18).Float64() - ctx.RespondText(fmt.Sprintf("ndx token total supply: %0.2f", supplyF)) + ctx.RespondText(printer.Sprintf("ndx token total supply: %0.2f", supplyF)) } diff --git a/discord/pool.go b/discord/pool.go index 665c8cd..d94e04d 100644 --- a/discord/pool.go +++ b/discord/pool.go @@ -72,7 +72,7 @@ func (c *Client) poolTotalValueLocked(ctx *dgc.Ctx) { ctx.RespondText("failed to get total value locked") return } - ctx.RespondText(fmt.Sprintf("total value locked for %s: %0.2f", poolName, tvl)) + ctx.RespondText(printer.Sprintf("total value locked for %s: $%0.2f", poolName, tvl)) } func (c *Client) poolTotalSupply(ctx *dgc.Ctx) { @@ -92,5 +92,5 @@ func (c *Client) poolTotalSupply(ctx *dgc.Ctx) { return } supplyF, _ := utils.ToDecimal(supply, 18).Float64() - ctx.RespondText(fmt.Sprintf("total supply for %s: %0.2f", poolName, supplyF)) + ctx.RespondText(printer.Sprintf("total supply for %s: %0.2f", poolName, supplyF)) } diff --git a/go.mod b/go.mod index d0eda5f..65265f8 100644 --- a/go.mod +++ b/go.mod @@ -13,6 +13,7 @@ require ( github.com/wcharczuk/go-chart/v2 v2.1.0 golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 golang.org/x/net v0.0.0-20201224014010-6772e930b67b // indirect + golang.org/x/text v0.3.3 gopkg.in/yaml.v2 v2.3.0 gorm.io/driver/postgres v1.0.6 gorm.io/driver/sqlite v1.1.4