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
+47
View File
@@ -0,0 +1,47 @@
package commands
import (
"context"
"fmt"
"github.com/disgoorg/disgo/discord"
"github.com/disgoorg/disgo/events"
)
type RemoveCommand struct {
deps *Dependencies
}
func NewRemoveCommand(deps *Dependencies) *RemoveCommand {
return &RemoveCommand{deps: deps}
}
func (c *RemoveCommand) Definition() discord.ApplicationCommandCreate {
return discord.SlashCommandCreate{
Name: "remove",
Description: "Removes a track from the queue",
Options: []discord.ApplicationCommandOption{
discord.ApplicationCommandOptionInt{
Name: "position",
Description: "Position in the queue, as shown by /queue (1 is next)",
Required: true,
MinValue: intPtr(1),
},
},
}
}
func (c *RemoveCommand) Execute(ctx context.Context, event *events.ApplicationCommandInteractionCreate) error {
gid, err := requirePlaybackAccess(c.deps.Discord, event)
if err != nil {
return err
}
position := event.SlashCommandInteractionData().Int("position")
track, ok := c.deps.Music.Guild(gid).RemoveQueued(position - 1)
if !ok {
return rejectEphemeral(event, fmt.Sprintf("There's no track at position %d in the queue.", position))
}
return reply(event, fmt.Sprintf("Removed **%s** from the queue.", track.Info.Title))
}