Skip to content

Commit

Permalink
update sub command example
Browse files Browse the repository at this point in the history
  • Loading branch information
zekroTJA committed Oct 13, 2021
1 parent 831edca commit ab0fe10
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions examples/subcommands/commands/subs.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ func (c *SubsCommand) IsDmCapable() bool {
}

func (c *SubsCommand) Run(ctx *ken.Ctx) (err error) {
if err = ctx.Defer(); err != nil {
return
}

err = ctx.HandleSubCommands(
ken.SubCommandHandler{"one", c.one},
ken.SubCommandHandler{"two", c.two},
Expand All @@ -79,6 +75,9 @@ func (c *SubsCommand) Run(ctx *ken.Ctx) (err error) {
}

func (c *SubsCommand) one(ctx *ken.SubCommandCtx) (err error) {
if err = ctx.Defer(); err != nil {
return
}
arg := ctx.Options().GetByName("arg").StringValue()
err = ctx.FollowUpEmbed(&discordgo.MessageEmbed{
Description: "one: " + arg,
Expand All @@ -91,8 +90,8 @@ func (c *SubsCommand) two(ctx *ken.SubCommandCtx) (err error) {
if argV, ok := ctx.Options().GetByNameOptional("arg"); ok {
arg = int(argV.IntValue())
}
err = ctx.FollowUpEmbed(&discordgo.MessageEmbed{
err = ctx.RespondEmbed(&discordgo.MessageEmbed{
Description: fmt.Sprintf("two: %d", arg),
}).Error
})
return
}

0 comments on commit ab0fe10

Please sign in to comment.