commands: Become case-insensitive on commands

master
Luther Wen Xu 2020-01-29 00:48:07 +07:00
parent e21aba4e60
commit 0e68c29b95
Signed by: chanbakjsd
GPG Key ID: B7D77E3E9D102B70
2 changed files with 6 additions and 4 deletions

@ -13,14 +13,15 @@ func Parse(s *discordgo.Session, m *discordgo.MessageCreate) {
return
}
if !strings.HasPrefix(m.Content, config.CommandPrefix) {
if !strings.HasPrefix(strings.ToLower(m.Content), config.CommandPrefix) {
return
}
commands := strings.Split(strings.TrimPrefix(m.Content, config.CommandPrefix), " ")
commands := strings.Split(m.Content[len(config.CommandPrefix):], " ")
first := strings.ToLower(commands[0])
for _, v := range list {
if v.Name == commands[0] {
if v.Name == first {
v.Handler(s, commands, m)
return
}

@ -3,6 +3,7 @@ package config
import (
"encoding/json"
"io/ioutil"
"strings"
)
type config struct {
@ -44,7 +45,7 @@ func init() {
GeneralChannelID = output.ActiveNerf.GeneralChannelID
NotInGeneralNerf = output.ActiveNerf.NotInGeneralNerf
Admins = output.Admins
CommandPrefix = output.CommandPrefix
CommandPrefix = strings.ToLower(output.CommandPrefix)
GuildID = output.GuildID
PrestigeRequirement = output.PrestigeRequirement
StarChannel = output.StarChannel