diff --git a/lib/command_user.go b/lib/command_user.go new file mode 100644 index 0000000..9de2263 --- /dev/null +++ b/lib/command_user.go @@ -0,0 +1,41 @@ +package bot + +import ( + "errors" + + "github.com/bwmarrin/discordgo" +) + +type UserCommand struct { + Name string + NameLocalizations *map[discordgo.Locale]string + DefaultMemberPermissions *int64 + NSFW *bool + Description string + DescriptionLocalizations *map[discordgo.Locale]string + Handler Handler +} + +func (c *UserCommand) ApplicationCommand() *discordgo.ApplicationCommand { + return &discordgo.ApplicationCommand{ + Type: discordgo.UserApplicationCommand, + Name: c.Name, + NameLocalizations: c.NameLocalizations, + DefaultMemberPermissions: c.DefaultMemberPermissions, + NSFW: c.NSFW, + Description: c.Description, + DescriptionLocalizations: c.DescriptionLocalizations, + } +} + +func (c *UserCommand) Validate() (bool, error) { + switch { + case c.Name == "": + return false, errors.New("Required property \"Name\" is empty") + case c.Description == "": + return false, errors.New("Required property \"Description\" is empty") + case c.Handler == nil: + return false, errors.New("Required property \"Handler\" is empty") + } + return true, nil +}