Skip to content

Commit

Permalink
update user and message command
Browse files Browse the repository at this point in the history
  • Loading branch information
zekroTJA committed Nov 20, 2021
1 parent 4fdf58c commit c719b96
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
5 changes: 5 additions & 0 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ func toApplicationCommand(c Command) *discordgo.ApplicationCommand {
Name: cm.Name(),
Type: discordgo.UserApplicationCommand,
}
case MessageCommand:
return &discordgo.ApplicationCommand{
Name: cm.Name(),
Type: discordgo.MessageApplicationCommand,
}
default:
panic(fmt.Sprintf("Command type not implemented for command: %s", cm.Name()))
}
Expand Down
4 changes: 3 additions & 1 deletion examples/usercommands/commands/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ var (
_ ken.UserCommand = (*InfoUserCommand)(nil)
)

func (c *InfoUserCommand) TypeUser() {}

func (c *InfoUserCommand) Name() string {
return "info"
return "userinfo"
}

func (c *InfoUserCommand) Description() string {
Expand Down
13 changes: 7 additions & 6 deletions messagecommand.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ package ken
type MessageCommand interface {
Command

// Run is called on command invokation getting
// passed the invocation context.
// TypeMessage is used to differenciate between
// UserCommand and MessageCommand which have
// the same structure otherwise.
//
// When something goes wrong during command
// execution, you can return an error which is
// then handled by Ken's OnCommandError handler.
Run(ctx *Ctx) (err error)
// This method must only be implemented and
// will never be called by ken, so it can be
// completely empty.
TypeMessage()
}
13 changes: 7 additions & 6 deletions usercommand.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ package ken
type UserCommand interface {
Command

// Run is called on command invokation getting
// passed the invocation context.
// TypeUser is used to differenciate between
// UserCommand and MessageCommand which have
// the same structure otherwise.
//
// When something goes wrong during command
// execution, you can return an error which is
// then handled by Ken's OnCommandError handler.
Run(ctx *Ctx) (err error)
// This method must only be implemented and
// will never be called by ken, so it can be
// completely empty.
TypeUser()
}

0 comments on commit c719b96

Please sign in to comment.