feat: added web server with currently playing song
This commit is contained in:
parent
1a4986f294
commit
7f16452a99
12 changed files with 847 additions and 9 deletions
|
@ -2,6 +2,7 @@ package commands
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"discord-jukebox-bot/pkg/config"
|
||||
"discord-jukebox-bot/pkg/discord"
|
||||
|
@ -10,6 +11,12 @@ import (
|
|||
"github.com/bwmarrin/discordgo"
|
||||
)
|
||||
|
||||
// Store a reference to the jukebox player for external access
|
||||
var (
|
||||
jukeboxPlayer *discord.JukeboxPlayer
|
||||
jukeboxPlayerLock sync.RWMutex
|
||||
)
|
||||
|
||||
// Setup sets up all commands for the Discord bot
|
||||
func Setup(cfg *config.Config) (*discord.Bot, error) {
|
||||
// Create the Subsonic client
|
||||
|
@ -32,6 +39,11 @@ func Setup(cfg *config.Config) (*discord.Bot, error) {
|
|||
if jukebox == nil {
|
||||
return nil, fmt.Errorf("error creating jukebox player")
|
||||
}
|
||||
|
||||
// Store the jukebox player reference
|
||||
jukeboxPlayerLock.Lock()
|
||||
jukeboxPlayer = jukebox
|
||||
jukeboxPlayerLock.Unlock()
|
||||
|
||||
// Add any additional command initialization here
|
||||
// This is where you can easily add new commands in the future
|
||||
|
@ -51,4 +63,11 @@ func RegisterCustomCommand(
|
|||
// Register the command handler
|
||||
bot.RegisterCommand(name, handler)
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetJukebox returns the current jukebox player instance
|
||||
func GetJukebox() *discord.JukeboxPlayer {
|
||||
jukeboxPlayerLock.RLock()
|
||||
defer jukeboxPlayerLock.RUnlock()
|
||||
return jukeboxPlayer
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue