Music: only /music remove and /music move are commands
Pause, skip, repeat and stop are already buttons on the now-playing message. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
1 parent
92c9f6b686
commit
88fc915f3b
5 files changed
+10
-65
No files matched your search
@@ -44,7 +44,7 @@ func fields() []*discordgo.MessageEmbedField {
|
||||
col("Fun",
|
||||
"`/ping` `/joke` `/coinflip`", "`/dice` `/rps` `/rpsstats`", "`/rpsleaderboard`"),
|
||||
col("Music (DJ role)",
|
||||
"`/play` `/queue` `/volume`", "`/music skip` `pause` `resume`", "`/music stop` `repeat`", "`/music remove` `move`", "`/music toggle` (Manage Server)"),
|
||||
"`/play` `/queue` `/volume`", "`/music remove` `move`", "`/music toggle` (Manage Server)"),
|
||||
col("Sessions and time",
|
||||
"`/schedule create`", "`/schedule list`", "`/schedule reschedule`", "`/timezone set` `show`"),
|
||||
col("Tickets",
|
||||
|
||||
@@ -10,10 +10,10 @@ import (
|
||||
"github.com/bwmarrin/discordgo"
|
||||
)
|
||||
|
||||
// The player controls. Everything a dashboard can do to the queue (skip, pause,
|
||||
// resume, stop, repeat, remove and move a track) is also a command, so a
|
||||
// server never needs one. They need the DJ role, like /play, /queue and
|
||||
// /volume. Turning music on or off needs Manage Server.
|
||||
// Queue editing. Pausing, skipping, repeating and stopping are buttons on the
|
||||
// now-playing message, so the only queue controls that need commands are
|
||||
// removing a song and moving one. They need the DJ role, like /play, /queue
|
||||
// and /volume. Turning music on or off needs Manage Server.
|
||||
|
||||
func positionOption(name, desc string) *discordgo.ApplicationCommandOption {
|
||||
return &discordgo.ApplicationCommandOption{
|
||||
@@ -27,15 +27,6 @@ func playerOptions() []*discordgo.ApplicationCommandOption {
|
||||
return &discordgo.ApplicationCommandOption{Type: discordgo.ApplicationCommandOptionSubCommand, Name: name, Description: desc, Options: o}
|
||||
}
|
||||
return []*discordgo.ApplicationCommandOption{
|
||||
sub("skip", "Skip the current song (DJ)"),
|
||||
sub("pause", "Pause playback (DJ)"),
|
||||
sub("resume", "Resume playback (DJ)"),
|
||||
sub("stop", "Stop playback and clear the queue (DJ)"),
|
||||
sub("repeat", "Repeat the current song, the whole queue, or nothing (DJ)",
|
||||
&discordgo.ApplicationCommandOption{
|
||||
Type: discordgo.ApplicationCommandOptionString, Name: "mode", Description: "What repeats", Required: true,
|
||||
Choices: []*discordgo.ApplicationCommandOptionChoice{{Name: "off", Value: "off"}, {Name: "song", Value: "song"}, {Name: "queue", Value: "queue"}},
|
||||
}),
|
||||
sub("remove", "Remove a song from the queue (DJ)", positionOption("position", "Its number in /queue")),
|
||||
sub("move", "Move a song to another place in the queue (DJ)",
|
||||
positionOption("from", "Its number in /queue"), positionOption("to", "The number it should have")),
|
||||
@@ -57,44 +48,19 @@ func title(e *music.TrackEntry) string {
|
||||
return strings.TrimSpace(e.Track.Info.Title)
|
||||
}
|
||||
|
||||
// handlePlayer runs a player subcommand. The caller has checked that music is
|
||||
// on and that the member has the DJ role.
|
||||
// handlePlayer runs a queue subcommand. The caller has checked that music is
|
||||
// on and that the member has the DJ role. Pause, skip, repeat and stop are
|
||||
// buttons on the now-playing message, so only what has no button is a command.
|
||||
func handlePlayer(s *discordgo.Session, i *discordgo.InteractionCreate, sub *discordgo.ApplicationCommandInteractionDataOption) {
|
||||
g := i.GuildID
|
||||
args := map[string]*discordgo.ApplicationCommandInteractionDataOption{}
|
||||
for _, o := range sub.Options {
|
||||
args[o.Name] = o
|
||||
}
|
||||
current, _ := music.GetQueue(g)
|
||||
needsPlayer := sub.Name != "repeat" && sub.Name != "remove" && sub.Name != "move"
|
||||
if needsPlayer && current == nil {
|
||||
shared.RespondEphemeral(s, i, "Nothing is playing.")
|
||||
return
|
||||
}
|
||||
|
||||
var err error
|
||||
var msg string
|
||||
switch sub.Name {
|
||||
case "skip":
|
||||
err, msg = music.Skip(g), "Skipped."
|
||||
case "pause":
|
||||
err, msg = music.Pause(g, true), "Paused. `/music resume` continues."
|
||||
case "resume":
|
||||
err, msg = music.Pause(g, false), "Resumed."
|
||||
case "stop":
|
||||
err, msg = music.Stop(g), "Stopped, and the queue is cleared."
|
||||
case "repeat":
|
||||
switch args["mode"].StringValue() {
|
||||
case "song":
|
||||
music.SetRepeat(g, true, false)
|
||||
msg = "The current song repeats."
|
||||
case "queue":
|
||||
music.SetRepeat(g, false, true)
|
||||
msg = "The whole queue repeats."
|
||||
default:
|
||||
music.SetRepeat(g, false, false)
|
||||
msg = "Nothing repeats."
|
||||
}
|
||||
case "remove":
|
||||
n := int(args["position"].IntValue())
|
||||
e, size := queueEntry(g, n)
|
||||
|
||||
Reference in new issue
Block a user