- /music skip, pause, resume, stop, repeat, remove, move (DJ role) - /config view, clear, toggletwitch, streamers, beta-features (server owner) - /slvl status, remove-reward; /moderation bans, timeouts; /security history - /beta is now the bot owner's DM-only command: set, off, servers, remove-server, status - betasettings service and repo methods, with integration tests Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
76 lines
1.8 KiB
Go
76 lines
1.8 KiB
Go
package public
|
|
|
|
import (
|
|
"context"
|
|
"velox-bot/internal/commands/music/shared"
|
|
"velox-bot/internal/db/services"
|
|
|
|
"github.com/bwmarrin/discordgo"
|
|
)
|
|
|
|
var Music = &discordgo.ApplicationCommand{
|
|
Name: "music",
|
|
Description: "Music settings and player controls",
|
|
Options: append([]*discordgo.ApplicationCommandOption{
|
|
{
|
|
Type: discordgo.ApplicationCommandOptionSubCommand,
|
|
Name: "toggle",
|
|
Description: "Turn the music player on or off for this server (Manage Server)",
|
|
},
|
|
}, playerOptions()...),
|
|
}
|
|
|
|
func MusicHandler(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
|
if i.GuildID == "" {
|
|
shared.RespondEphemeral(s, i, "This command can only be used in a server.")
|
|
return
|
|
}
|
|
if !shared.RequireMusicService(s, i) {
|
|
return
|
|
}
|
|
|
|
data := i.ApplicationCommandData()
|
|
if len(data.Options) == 0 {
|
|
shared.RespondEphemeral(s, i, "Missing subcommand.")
|
|
return
|
|
}
|
|
sub := data.Options[0]
|
|
|
|
if sub.Name == "toggle" {
|
|
if !shared.RequireManageGuild(s, i) {
|
|
return
|
|
}
|
|
handleToggle(s, i)
|
|
return
|
|
}
|
|
|
|
// Every other subcommand controls the player: music has to be on and the
|
|
// member needs the DJ role, like /play, /queue and /volume.
|
|
if !shared.RequireMusicEnabled(s, i) {
|
|
return
|
|
}
|
|
if !memberHasDJRole(s, i.GuildID, i.Member) {
|
|
shared.RespondEphemeral(s, i, "You need the **DJ** role to use music commands.")
|
|
return
|
|
}
|
|
handlePlayer(s, i, sub)
|
|
}
|
|
|
|
func handleToggle(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
|
guildID, ok := shared.ParseGuildID(s, i)
|
|
if !ok {
|
|
return
|
|
}
|
|
|
|
enabled, err := services.Global.MusicSettings.ToggleMusic(context.Background(), guildID)
|
|
if err != nil {
|
|
shared.RespondEphemeral(s, i, "Failed to toggle music playback.")
|
|
return
|
|
}
|
|
status := "disabled"
|
|
if enabled {
|
|
status = "enabled"
|
|
}
|
|
shared.RespondEphemeral(s, i, "Music playback "+status+" for this server.")
|
|
}
|