Files
FernandoJVideiraandClaude Sonnet 5.5 132a2cd986 Commands for everything a dashboard can do
- /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]>
2026-10-23 02:10:05 +01:00

139 lines
4.5 KiB
Go

package commands
import (
"strings"
"velox-bot/internal/beta"
"velox-bot/internal/commands/betacmd"
"velox-bot/internal/commands/config"
"velox-bot/internal/commands/fun"
"velox-bot/internal/commands/help"
cmdlevel "velox-bot/internal/commands/level"
"velox-bot/internal/commands/meeting"
"velox-bot/internal/commands/moderation"
cmdmusic "velox-bot/internal/commands/music"
"velox-bot/internal/commands/projects"
"velox-bot/internal/commands/schedule"
cmdsecurity "velox-bot/internal/commands/security"
cmdtickets "velox-bot/internal/commands/tickets"
"velox-bot/internal/commands/timezone"
"velox-bot/internal/music"
"github.com/bwmarrin/discordgo"
)
var AllCommands = []*discordgo.ApplicationCommand{
fun.Ping,
fun.Joke,
fun.Coinflip,
fun.Dice,
fun.Rps,
fun.RpsStats,
fun.RpsLeaderboard,
help.Help,
cmdlevel.Slvl,
cmdlevel.Rank,
cmdlevel.Leaderboard,
cmdlevel.Rewards,
cmdmusic.Play,
cmdmusic.Queue,
cmdmusic.Volume,
cmdmusic.Music,
meeting.Meeting,
moderation.Moderation,
timezone.Timezone,
schedule.Schedule,
projects.Projects,
config.Config,
cmdtickets.Tickets,
cmdtickets.Ticket,
cmdsecurity.Security,
cmdsecurity.Lockdown,
cmdsecurity.Unlock,
}
var handlers = map[string]func(s *discordgo.Session, i *discordgo.InteractionCreate){
"ping": fun.PingHandler,
"joke": fun.JokeHandler,
"coinflip": fun.CoinflipHandler,
"dice": fun.DiceHandler,
"rps": fun.RpsHandler,
"rpsstats": fun.RpsStatsHandler,
"rpsleaderboard": fun.RpsLeaderboardHandler,
"help": help.HelpHandler,
"slvl": cmdlevel.SlvlHandler,
"rank": cmdlevel.RankHandler,
"leaderboard": cmdlevel.LeaderboardHandler,
"rewards": cmdlevel.RewardsHandler,
"meeting": meeting.MeetingHandler,
"moderation": moderation.ModerationHandler,
"timezone": timezone.TimezoneHandler,
"schedule": schedule.ScheduleHandler,
"projects": projects.ProjectsHandler,
"play": cmdmusic.PlayHandler,
"queue": cmdmusic.QueueHandler,
"volume": cmdmusic.VolumeHandler,
"music": cmdmusic.MusicHandler,
"config": config.ConfigHandler,
"tickets": cmdtickets.TicketsHandler,
"ticket": cmdtickets.TicketHandler,
"security": cmdsecurity.SecurityHandler,
"lockdown": cmdsecurity.LockdownHandler,
"unlock": cmdsecurity.UnlockHandler,
}
// BetaCommands are the beta features' slash commands. They're registered in
// the beta server only, so nobody else even sees them, and each handler is
// wrapped so it runs only for members with the Beta Tester role (see the beta
// package). To put a feature in beta, add it with RegisterBeta instead of to
// AllCommands and handlers; to release it, move it there.
var BetaCommands = []*discordgo.ApplicationCommand{}
// OwnerCommands are registered globally but can only be used in a direct
// message with the bot, so they are in no server's menu. /beta is the bot
// owner's control over the beta program (see betacmd).
var OwnerCommands = []*discordgo.ApplicationCommand{betacmd.Beta}
func init() {
handlers[betacmd.Beta.Name] = betacmd.Handler
}
// RegisterBeta adds a slash command that only beta testers can use.
func RegisterBeta(cmd *discordgo.ApplicationCommand, h func(s *discordgo.Session, i *discordgo.InteractionCreate)) {
BetaCommands = append(BetaCommands, cmd)
handlers[cmd.Name] = beta.Gate(h)
}
func HandleInteraction(s *discordgo.Session, i *discordgo.InteractionCreate) {
switch i.Type {
case discordgo.InteractionApplicationCommand:
if h, ok := handlers[i.ApplicationCommandData().Name]; ok {
h(s, i)
}
case discordgo.InteractionMessageComponent:
data := i.MessageComponentData()
switch {
case strings.HasPrefix(data.CustomID, "music:"):
music.HandleComponent(s, i)
case strings.HasPrefix(data.CustomID, "schedule:"):
schedule.HandleComponent(s, i)
case strings.HasPrefix(data.CustomID, "projects:"):
projects.HandleComponent(s, i)
case strings.HasPrefix(data.CustomID, "tickets:"):
cmdtickets.HandleComponent(s, i)
case strings.HasPrefix(data.CustomID, "security:"):
cmdsecurity.HandleComponent(s, i)
}
case discordgo.InteractionModalSubmit:
data := i.ModalSubmitData()
switch {
case strings.HasPrefix(data.CustomID, "schedule:"):
schedule.HandleModalSubmit(s, i)
case strings.HasPrefix(data.CustomID, "projects:"):
projects.HandleModalSubmit(s, i)
case strings.HasPrefix(data.CustomID, "tickets:"):
cmdtickets.HandleModalSubmit(s, i)
}
}
}