Implement slash commands for playback control

This commit is contained in:
2026-09-21 18:48:17 +02:00
parent 347faf6b94
commit d05e721284
15 changed files with 809 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
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))
}