From c2646ad280dd5b564d0a50ec3240eb7b7820ab4d Mon Sep 17 00:00:00 2001 From: Rudi Date: Tue, 9 Aug 2022 13:45:38 -0400 Subject: [PATCH] Cleaning up commandwork --- discordMessage.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/discordMessage.go b/discordMessage.go index 3d922ba..7aba5b8 100644 --- a/discordMessage.go +++ b/discordMessage.go @@ -66,17 +66,18 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) { s.ChannelMessageDelete(m.ChannelID, m.ID) } } + parts := strings.Split(m.Content, " ") if strings.Contains(m.Content, s.State.User.ID) { b := BotCommand{ Session: s, Message: m, - Parts: strings.Split(m.Content, " ")[2:], + Parts: parts[2:], } log.LogDebug("%+v", b.Parts) for _, cmd := range commands { for _, keyword := range cmd.Keywords { log.LogDebug("Checking if %+v contains %+v", m.Content, keyword) - if strings.Contains(b.Parts[1], keyword) { + if strings.Contains(parts[1], keyword) { log.LogDebug("%+v found!", keyword) b.Command = keyword if !cmd.RequiresAdmin {