|
|
|
@ -15,6 +15,8 @@ import (
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Adds the Command at the address passed in to the Commands array on the CommandManager.
|
|
|
|
|
|
|
|
// - Will error if the command's name or any of the aliases already exist.
|
|
|
|
func (c *CommandManager) AddCommand(command *Command) error {
|
|
|
|
func (c *CommandManager) AddCommand(command *Command) error {
|
|
|
|
var aliases = []string{command.Name}
|
|
|
|
var aliases = []string{command.Name}
|
|
|
|
if command.Aliases != nil {
|
|
|
|
if command.Aliases != nil {
|
|
|
|
@ -33,6 +35,7 @@ func (c *CommandManager) AddCommand(command *Command) error {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Removes the command named from the Commands array
|
|
|
|
func (c *CommandManager) RemoveCommand(name string) error {
|
|
|
|
func (c *CommandManager) RemoveCommand(name string) error {
|
|
|
|
deleted := false
|
|
|
|
deleted := false
|
|
|
|
if _, ok := c.Commands[name]; ok {
|
|
|
|
if _, ok := c.Commands[name]; ok {
|
|
|
|
@ -45,6 +48,7 @@ func (c *CommandManager) RemoveCommand(name string) error {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Checks if the user ID is in the Owners array
|
|
|
|
func (c *CommandManager) IsOwner(id string) bool {
|
|
|
|
func (c *CommandManager) IsOwner(id string) bool {
|
|
|
|
for _, o := range c.Owners {
|
|
|
|
for _, o := range c.Owners {
|
|
|
|
if o == id {
|
|
|
|
if o == id {
|
|
|
|
@ -54,6 +58,12 @@ func (c *CommandManager) IsOwner(id string) bool {
|
|
|
|
return false
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// The OnMessage event handler
|
|
|
|
|
|
|
|
// Checks if the message has one of the specified prefixes
|
|
|
|
|
|
|
|
// Checks if the message contains one of the commands
|
|
|
|
|
|
|
|
// Processes the arguments to pass into the command
|
|
|
|
|
|
|
|
// Checks the permissions for the command
|
|
|
|
|
|
|
|
// Runs the command function with the current Context
|
|
|
|
func (c *CommandManager) OnMessage(session *discordgo.Session, m *discordgo.MessageCreate) {
|
|
|
|
func (c *CommandManager) OnMessage(session *discordgo.Session, m *discordgo.MessageCreate) {
|
|
|
|
if m.Author.Bot && c.IgnoreBots {
|
|
|
|
if m.Author.Bot && c.IgnoreBots {
|
|
|
|
return // If the author is a bot and ignore bots is set then just exit
|
|
|
|
return // If the author is a bot and ignore bots is set then just exit
|
|
|
|
|