Members open a ticket from a panel in the ticket channel: one button per category (a dropdown past five), then a short form. Each ticket is a private thread named after the category, number and opener, with a first message that mentions the category's staff role so its members join, and Claim and Close buttons. - Claim: staff (the category's role, or Manage Threads / Manage Server) take a ticket; the first message shows who has it. - Close: the opener or staff close it, with an optional reason. The thread is locked and archived, and the log channel gets a summary and a .txt transcript of the whole thread. - /ticket add|remove|claim|close inside a ticket; /tickets setup, /tickets category add|remove|list and /tickets panel for admins. - Per-member limit on open tickets (default 1), per-server ticket numbers handed out atomically, a deleted thread closes its ticket. - The dashboard asks the bot to post or refresh the panel through ticket_commands (LISTEN/NOTIFY, like music); the listener reconnects if the database connection drops. - Setup warns about missing bot permissions in the ticket and log channels. The flows live in internal/tickets behind small Discord and store interfaces, with unit tests on fakes; the repo and the listener have integration tests (-tags integration, TICKETS_TEST_DB). Needs the ticket tables (velox-dashboard-api migration 000016_tickets). .gitignore gains the /tldr benchmark rules so private chat exports and benchmark results on disk can't be committed from this branch. Co-Authored-By: Claude Opus 5.5 <[email protected]>
106 lines
3.1 KiB
Go
106 lines
3.1 KiB
Go
package commands
|
|
|
|
import (
|
|
"strings"
|
|
"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"
|
|
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,
|
|
}
|
|
|
|
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,
|
|
}
|
|
|
|
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 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)
|
|
}
|
|
}
|
|
|
|
}
|