Browse Source

Cleaning up commandwork

master
Gregory Rudolph 2 years ago
parent
commit
c2646ad280
Signed by: rudi
GPG Key ID: EF64F3CBD1A1EBDD
  1. 5
      discordMessage.go

5
discordMessage.go

@ -66,17 +66,18 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
s.ChannelMessageDelete(m.ChannelID, m.ID) s.ChannelMessageDelete(m.ChannelID, m.ID)
} }
} }
parts := strings.Split(m.Content, " ")
if strings.Contains(m.Content, s.State.User.ID) { if strings.Contains(m.Content, s.State.User.ID) {
b := BotCommand{ b := BotCommand{
Session: s, Session: s,
Message: m, Message: m,
Parts: strings.Split(m.Content, " ")[2:], Parts: parts[2:],
} }
log.LogDebug("%+v", b.Parts) log.LogDebug("%+v", b.Parts)
for _, cmd := range commands { for _, cmd := range commands {
for _, keyword := range cmd.Keywords { for _, keyword := range cmd.Keywords {
log.LogDebug("Checking if %+v contains %+v", m.Content, keyword) 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) log.LogDebug("%+v found!", keyword)
b.Command = keyword b.Command = keyword
if !cmd.RequiresAdmin { if !cmd.RequiresAdmin {

Loading…
Cancel
Save