Skip to content

v0.20.0

Compare
Choose a tag to compare
@github-actions github-actions released this 22 Jul 10:36
· 5 commits to master since this release

Sub Command Support [#14]

Finally, you can now register and use sub command groups!

Simply add a sub command option to your command in the Options implementation of your command.

Example:

func (c *SubsCommand) Options() []*discordgo.ApplicationCommandOption {
	return []*discordgo.ApplicationCommandOption{
		{
			Type:        discordgo.ApplicationCommandOptionSubCommandGroup,
			Name:        "group",
			Description: "Some sub command gorup",
			Options: []*discordgo.ApplicationCommandOption{
				// ...
			},
		},
	}
}

Now, you can add a SubCommandGroup handler to your HandleSubCommands method to register sub commands in the group.

Example:

func (c *SubsCommand) Run(ctx ken.Context) (err error) {
	err = ctx.HandleSubCommands(
		ken.SubCommandGroup{"group", []ken.CommandHandler{
			ken.SubCommandHandler{"one", c.one},
			ken.SubCommandHandler{"two", c.two},
		}},
	)
	return
}

The full example can be found in examples/subcommandgroups.

Minor Changes

Update

go get -v -u github.com/zekrotja/ken@v0.20.0