Add Discord client, command router and voice channel handling

This commit is contained in:
2026-09-21 18:48:11 +02:00
parent c4757933e1
commit 347faf6b94
4 changed files with 155 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
package discord
import (
"context"
"log/slog"
"github.com/disgoorg/disgo/events"
"discord-music-bot/internal/commands"
)
type Router struct {
registry *commands.Registry
logger *slog.Logger
}
func NewRouter(registry *commands.Registry, logger *slog.Logger) *Router {
return &Router{
registry: registry,
logger: logger,
}
}
func (r *Router) OnApplicationCommand(event *events.ApplicationCommandInteractionCreate) {
name := event.SlashCommandInteractionData().CommandName()
cmd, ok := r.registry.Get(name)
if !ok {
r.logger.Warn("received unknown command", slog.String("command", name))
return
}
if err := cmd.Execute(context.Background(), event); err != nil {
r.logger.Error("command execution failed", slog.String("command", name), slog.Any("err", err))
}
}