[coords translation] replace extractAllCoordsFromMessage helper with Regexp.FindAllString

This commit is contained in:
Dawid Wysokiński 2021-01-08 20:39:48 +01:00
parent f91141c3fa
commit dd112e6536
1 changed files with 1 additions and 9 deletions

View File

@ -83,7 +83,7 @@ func (s *Session) translateCoords(ctx *commandCtx, m *discordgo.MessageCreate) {
if ctx.server.CoordsTranslation == "" {
return
}
coords := extractAllCoordsFromMessage(m.Content)
coords := coordsRegex.FindAllString(m.Content, -1)
coordsLen := len(coords)
if coordsLen > 0 {
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)
}
}
func extractAllCoordsFromMessage(msg string) []string {
coords := []string{}
for _, bytes := range coordsRegex.FindAll([]byte(msg), -1) {
coords = append(coords, string(bytes))
}
return coords
}