grim/wasdead

Fix the help message for the help command
draft
2019-04-08, Gary Kramlich
c06bc2e462ed
Fix the help message for the help command
package discord
import (
"fmt"
"regexp"
"strings"
"github.com/bwmarrin/discordgo"
log "github.com/sirupsen/logrus"
)
var splitRegex = regexp.MustCompile(`\s+`)
func (c *DiscordClient) messageHandler(s *discordgo.Session, m *discordgo.MessageCreate) {
// ignore messages for ourselves
if m.Author.ID == s.State.User.ID {
return
}
if !strings.HasPrefix(m.Content, c.mentionString) {
return
}
args := splitRegex.Split(m.Content, -1)[1:]
// call parse commands
output, err := c.processCommand(args, m)
if err != nil {
log.Warnf("error processing %#v: %v", m.Content, err)
output = fmt.Sprintf("error: %v", err)
}
switch output.(type) {
case string:
c.sendChannel(m.ChannelID, output.(string))
case *discordgo.MessageEmbed:
c.client.ChannelMessageSendEmbed(m.ChannelID, output.(*discordgo.MessageEmbed))
}
}