2024-11-21 21:25:52 -03:00
|
|
|
package bot
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
|
|
"github.com/bwmarrin/discordgo"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type MessageCommand struct {
|
|
|
|
|
Name string
|
|
|
|
|
NameLocalizations *map[discordgo.Locale]string
|
|
|
|
|
DefaultMemberPermissions *int64
|
|
|
|
|
NSFW *bool
|
|
|
|
|
Description string
|
|
|
|
|
DescriptionLocalizations *map[discordgo.Locale]string
|
2024-11-22 19:06:58 -03:00
|
|
|
Handler Handler[MessageCommandCtx]
|
2024-11-21 21:25:52 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *MessageCommand) ApplicationCommand() *discordgo.ApplicationCommand {
|
|
|
|
|
return &discordgo.ApplicationCommand{
|
|
|
|
|
Type: discordgo.MessageApplicationCommand,
|
|
|
|
|
Name: c.Name,
|
|
|
|
|
NameLocalizations: c.NameLocalizations,
|
|
|
|
|
DefaultMemberPermissions: c.DefaultMemberPermissions,
|
|
|
|
|
NSFW: c.NSFW,
|
|
|
|
|
Description: c.Description,
|
|
|
|
|
DescriptionLocalizations: c.DescriptionLocalizations,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-22 19:10:58 -03:00
|
|
|
func (c *MessageCommand) Validate() error {
|
2024-11-21 21:25:52 -03:00
|
|
|
switch {
|
|
|
|
|
case c.Name == "":
|
2024-11-22 19:10:58 -03:00
|
|
|
return errors.New("Required property \"Name\" is empty")
|
2024-11-21 21:25:52 -03:00
|
|
|
case c.Description == "":
|
2024-11-22 19:10:58 -03:00
|
|
|
return errors.New("Required property \"Description\" is empty")
|
2024-11-21 21:25:52 -03:00
|
|
|
case c.Handler == nil:
|
2024-11-22 19:10:58 -03:00
|
|
|
return errors.New("Required property \"Handler\" is empty")
|
2024-11-21 21:25:52 -03:00
|
|
|
}
|
2024-11-22 19:10:58 -03:00
|
|
|
return nil
|
2024-11-21 21:25:52 -03:00
|
|
|
}
|
2024-11-22 19:06:58 -03:00
|
|
|
|
|
|
|
|
type MessageCommandCtx struct {
|
|
|
|
|
Ctx
|
|
|
|
|
}
|