package commands import ( "strings" "github.com/bwmarrin/discordgo" "gitea.teamortix.com/chanbakjsd/Milen/util" ) type command struct { Name string Usage string Processor func(*discordgo.Session, *discordgo.MessageCreate, []string) MinimumArgument int ExactArgument bool } var commands = []command{ command{"autorole", " ", handleAutorole, 3, true}, } func Event(dg *discordgo.Session, m *discordgo.MessageCreate) { if m.Author.Bot { return } if !strings.HasPrefix(m.Content, "milen ") { return } split := strings.Split(m.Content, " ") for _, v := range commands { if split[1] != v.Name { continue } if (v.ExactArgument && len(split) != v.MinimumArgument+2) || (!v.ExactArgument && len(split) < v.MinimumArgument+2) { util.SendFailEmbed(dg, m.ChannelID, "Incorrect Usage", "Usage: `milen "+v.Name+" "+v.Usage+"`") return } if len(split) == 2 { v.Processor(dg, m, []string{}) return } v.Processor(dg, m, split[2:]) return } }