Files

42 lines
947 B
Go

package commands
import (
"context"
"fmt"
"github.com/disgoorg/disgo/discord"
"github.com/disgoorg/disgo/events"
)
type SkipCommand struct {
deps *Dependencies
}
func NewSkipCommand(deps *Dependencies) *SkipCommand {
return &SkipCommand{deps: deps}
}
func (c *SkipCommand) Definition() discord.ApplicationCommandCreate {
return discord.SlashCommandCreate{
Name: "skip",
Description: "Skips the current track",
}
}
func (c *SkipCommand) Execute(ctx context.Context, event *events.ApplicationCommandInteractionCreate) error {
gid, err := requirePlaybackAccess(c.deps.Discord, event)
if err != nil {
return err
}
track, hasNext, err := c.deps.Music.Guild(gid).Skip(ctx)
if err != nil {
return replyWithError(event, "Could not skip the current track.", err)
}
if !hasNext {
return reply(event, "Skipped. Queue is empty.")
}
return reply(event, fmt.Sprintf("Skipped. Now playing: **%s**", track.Info.Title))
}