[coords translation] replace extractAllCoordsFromMessage helper with Regexp.FindAllString
This commit is contained in:
parent
f91141c3fa
commit
dd112e6536
|
@ -83,7 +83,7 @@ func (s *Session) translateCoords(ctx *commandCtx, m *discordgo.MessageCreate) {
|
||||||
if ctx.server.CoordsTranslation == "" {
|
if ctx.server.CoordsTranslation == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
coords := extractAllCoordsFromMessage(m.Content)
|
coords := coordsRegex.FindAllString(m.Content, -1)
|
||||||
coordsLen := len(coords)
|
coordsLen := len(coords)
|
||||||
if coordsLen > 0 {
|
if coordsLen > 0 {
|
||||||
version, err := s.cfg.API.Version.Read(tw.VersionCodeFromServerKey(ctx.server.CoordsTranslation))
|
version, err := s.cfg.API.Version.Read(tw.VersionCodeFromServerKey(ctx.server.CoordsTranslation))
|
||||||
|
@ -147,11 +147,3 @@ func (s *Session) translateCoords(ctx *commandCtx, m *discordgo.MessageCreate) {
|
||||||
MessageEmbed)
|
MessageEmbed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func extractAllCoordsFromMessage(msg string) []string {
|
|
||||||
coords := []string{}
|
|
||||||
for _, bytes := range coordsRegex.FindAll([]byte(msg), -1) {
|
|
||||||
coords = append(coords, string(bytes))
|
|
||||||
}
|
|
||||||
return coords
|
|
||||||
}
|
|
||||||
|
|
Reference in New Issue