Browse Source

Debugging

master
Gregory Rudolph 4 years ago
parent
commit
fd5d3ce0e7
Signed by: rudi
GPG Key ID: EF64F3CBD1A1EBDD
  1. 7
      discordMessage.go

7
discordMessage.go

@ -53,23 +53,30 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("%+v please say \"!d bump\" without the quotes to bump our server :)", m.Author.Mention())) s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("%+v please say \"!d bump\" without the quotes to bump our server :)", m.Author.Mention()))
} }
if strings.Contains(m.Content, s.State.User.ID) { if strings.Contains(m.Content, s.State.User.ID) {
log.LogDebug("%+v contained %+v", m.Content, s.State.User.ID)
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)
if strings.Contains(m.Content, keyword) { if strings.Contains(m.Content, keyword) {
log.LogDebug("%+v found!", keyword)
b.Command = keyword b.Command = keyword
if !cmd.RequiresAdmin { if !cmd.RequiresAdmin {
log.LogDebug("%+v does not require admin, running!")
if !cmd.Exec(b) { if !cmd.Exec(b) {
s.ChannelMessageSend(config.AdminChannel, fmt.Sprintf("There was an error running %+v\n%+v", cmd.Name, cmd.Help)) s.ChannelMessageSend(config.AdminChannel, fmt.Sprintf("There was an error running %+v\n%+v", cmd.Name, cmd.Help))
} else { } else {
log.LogInfo("Ran command %+v for %+v", cmd.Name, m.Author.Username) log.LogInfo("Ran command %+v for %+v", cmd.Name, m.Author.Username)
} }
} else { } else {
log.LogDebug("%+v does require admin, checking!")
if isAdmin(m.Member) { if isAdmin(m.Member) {
if !cmd.Exec(b) { if !cmd.Exec(b) {
s.ChannelMessageSend(config.AdminChannel, fmt.Sprintf("There was an error running %+v\n%+v", cmd.Name, cmd.Help)) s.ChannelMessageSend(config.AdminChannel, fmt.Sprintf("There was an error running %+v\n%+v", cmd.Name, cmd.Help))
} else { } else {
log.LogInfo("Ran command %+v for %+v", cmd.Name, m.Author.Username) log.LogInfo("Ran command %+v for %+v", cmd.Name, m.Author.Username)
} }
} else {
log.LogInfo("%+v tried to run an admin command (%+v) but isn't an admin.", m.Author.Username, keyword)
} }
} }
} }

Loading…
Cancel
Save