36 lines
814 B
Go
36 lines
814 B
Go
package commands
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/disgoorg/disgo/discord"
|
|
"github.com/disgoorg/disgo/events"
|
|
)
|
|
|
|
type PauseCommand struct {
|
|
deps *Dependencies
|
|
}
|
|
|
|
func NewPauseCommand(deps *Dependencies) *PauseCommand {
|
|
return &PauseCommand{deps: deps}
|
|
}
|
|
|
|
func (c *PauseCommand) Definition() discord.ApplicationCommandCreate {
|
|
return discord.SlashCommandCreate{
|
|
Name: "pause",
|
|
Description: "Pauses the current track",
|
|
}
|
|
}
|
|
|
|
func (c *PauseCommand) Execute(ctx context.Context, event *events.ApplicationCommandInteractionCreate) error {
|
|
gid, err := requirePlaybackAccess(c.deps.Discord, event)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := c.deps.Music.Guild(gid).SetPaused(ctx, true); err != nil {
|
|
return replyWithError(event, "Could not pause playback.", err)
|
|
}
|
|
return reply(event, "Paused.")
|
|
}
|