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
+37
View File
@@ -0,0 +1,37 @@
package commands
import (
"context"
"fmt"
"github.com/disgoorg/disgo/discord"
"github.com/disgoorg/disgo/events"
)
type ShuffleCommand struct {
deps *Dependencies
}
func NewShuffleCommand(deps *Dependencies) *ShuffleCommand {
return &ShuffleCommand{deps: deps}
}
func (c *ShuffleCommand) Definition() discord.ApplicationCommandCreate {
return discord.SlashCommandCreate{
Name: "shuffle",
Description: "Shuffles the upcoming tracks in the queue",
}
}
func (c *ShuffleCommand) Execute(ctx context.Context, event *events.ApplicationCommandInteractionCreate) error {
gid, err := requirePlaybackAccess(c.deps.Discord, event)
if err != nil {
return err
}
count := c.deps.Music.Guild(gid).Shuffle()
if count == 0 {
return reply(event, "The queue is empty, nothing to shuffle.")
}
return reply(event, fmt.Sprintf("Shuffled **%d** queued track(s).", count))
}