From dd112e6536065c40665f9fa46c757b7557986c84 Mon Sep 17 00:00:00 2001 From: Kichiyaki Date: Fri, 8 Jan 2021 20:39:48 +0100 Subject: [PATCH] [coords translation] replace extractAllCoordsFromMessage helper with Regexp.FindAllString --- discord/coords_translation.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/discord/coords_translation.go b/discord/coords_translation.go index 22ed5ef..1075604 100644 --- a/discord/coords_translation.go +++ b/discord/coords_translation.go @@ -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 -}