Skip to content

Commit

Permalink
chore: strings.Title was deprecated so replaced with code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ADRFranklin committed Mar 31, 2024
1 parent 8752d82 commit 56e8926
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bot/commands/cmd_ltf.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (cm *CommandManager) ltf(
"123456789987654321",
})
if err != nil {
cm.replyDirectly(interaction, fmt.Sprintf(errors.Wrap(err, "failed to get messages for user").Error()))
cm.replyDirectly(interaction, fmt.Sprint(errors.Wrap(err, "failed to get messages for user").Error()))
return
}

Expand Down
5 changes: 4 additions & 1 deletion bot/commands/cmd_mpname.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"strings"

"github.com/bwmarrin/discordgo"
"golang.org/x/text/cases"
"golang.org/x/text/language"

"github.com/Southclaws/cj/types"
)
Expand Down Expand Up @@ -70,7 +72,8 @@ func mpname() string {
second := seconds[rand.Intn(len(seconds))]
mp[0] = []byte(strings.ToUpper(first))[0]
mp[1] = []byte(strings.ToUpper(second))[0]
return fmt.Sprintf("%s: %s %s Multiplayer", string(mp), strings.Title(first), strings.Title(second))
title := cases.Title(language.English)
return fmt.Sprintf("%s: %s %s Multiplayer", string(mp), title.String(first), title.String(second))
}

func (cm *CommandManager) commandMP(
Expand Down
4 changes: 2 additions & 2 deletions bot/commands/cmd_mytop.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ func (cm *CommandManager) commandMyTop(
cm.sendThinkingResponse(interaction)
rank, err := cm.Storage.GetUserRank(interaction.Member.User.ID)
if err != nil {
cm.editOriginalResponse(interaction, fmt.Sprintf(errors.Wrap(err, "failed to get user's rank").Error()))
cm.editOriginalResponse(interaction, fmt.Sprint(errors.Wrap(err, "failed to get user's rank").Error()))
return
}
messageCount, err := cm.Storage.GetUserMessageCount(interaction.Member.User.ID)
if err != nil {
cm.editOriginalResponse(interaction, fmt.Sprintf(errors.Wrap(err, "failed to get user's message count").Error()))
cm.editOriginalResponse(interaction, fmt.Sprint(errors.Wrap(err, "failed to get user's message count").Error()))
return
}

Expand Down
8 changes: 4 additions & 4 deletions bot/commands/cmd_rep.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (cm *CommandManager) commandRep(
// Only post emoji that we have access to
func validateEmoji(input string, serverEmoji []*discordgo.Emoji) bool {
isValid := discordemojimap.ContainsEmoji(input)
if isValid == false {
if !isValid {
for _, v := range serverEmoji {
if v.MessageFormat() == input {
return true
Expand Down Expand Up @@ -75,7 +75,7 @@ func FormatUserReactions(reactions *[]storage.ReactionCounter, author *discordgo
break
}
embed.Fields = append(embed.Fields, &discordgo.MessageEmbedField{
Name: fmt.Sprintf("%s", reaction.Reaction),
Name: fmt.Sprintf("%s\u200b", reaction.Reaction),
Value: fmt.Sprintf("%dx", reaction.Counter),
Inline: true,
})
Expand All @@ -86,8 +86,8 @@ func FormatUserReactions(reactions *[]storage.ReactionCounter, author *discordgo
// fields (with 1 and 3 fields the formatting is fine)
if len(*reactions)%3 == 2 {
embed.Fields = append(embed.Fields, &discordgo.MessageEmbedField{
Name: "€", // Note: the content of this seemingly empty string is u0080
Value: "€", // Note: the content of this seemingly empty string is u0080
Name: "\u0080", // Note: the content of this seemingly empty string is u0080
Value: "\u0080", // Note: the content of this seemingly empty string is u0080
Inline: true,
})
}
Expand Down
5 changes: 4 additions & 1 deletion bot/commands/cmd_rpname.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"strings"

"github.com/bwmarrin/discordgo"
"golang.org/x/text/cases"
"golang.org/x/text/language"

"github.com/Southclaws/cj/types"
)
Expand Down Expand Up @@ -76,7 +78,8 @@ func rpname() string {
second := rpseconds[rand.Intn(len(rpseconds))]
mp[0] = []byte(strings.ToUpper(first))[0]
mp[1] = []byte(strings.ToUpper(second))[0]
return fmt.Sprintf("%s: %s %s Roleplay", string(mp), strings.Title(first), strings.Title(second))
title := cases.Title(language.English)
return fmt.Sprintf("%s: %s %s Roleplay", string(mp), title.String(first), title.String(second))
}

func (cm *CommandManager) commandRP(
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ require (
github.com/robfig/cron v1.2.0
github.com/stretchr/testify v1.8.1
go.uber.org/zap v1.27.0
golang.org/x/text v0.14.0
gopkg.in/xmlpath.v2 v2.0.0-20150820204837-860cbeca3ebc
)

Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
Expand Down

0 comments on commit 56e8926

Please sign in to comment.