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)) }