initial
This commit is contained in:
commit
1a4986f294
18 changed files with 3181 additions and 0 deletions
54
pkg/commands/setup.go
Normal file
54
pkg/commands/setup.go
Normal file
|
@ -0,0 +1,54 @@
|
|||
package commands
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"discord-jukebox-bot/pkg/config"
|
||||
"discord-jukebox-bot/pkg/discord"
|
||||
"discord-jukebox-bot/pkg/subsonic"
|
||||
|
||||
"github.com/bwmarrin/discordgo"
|
||||
)
|
||||
|
||||
// Setup sets up all commands for the Discord bot
|
||||
func Setup(cfg *config.Config) (*discord.Bot, error) {
|
||||
// Create the Subsonic client
|
||||
subsonicClient := subsonic.New(
|
||||
cfg.SubsonicServer,
|
||||
cfg.SubsonicUsername,
|
||||
cfg.SubsonicPassword,
|
||||
cfg.SubsonicVersion,
|
||||
cfg.GetTimeout(),
|
||||
)
|
||||
|
||||
// Create the Discord bot
|
||||
bot, err := discord.New(cfg, subsonicClient)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error creating bot: %w", err)
|
||||
}
|
||||
|
||||
// Initialize the jukebox player
|
||||
jukebox := discord.NewJukeboxPlayer(bot)
|
||||
if jukebox == nil {
|
||||
return nil, fmt.Errorf("error creating jukebox player")
|
||||
}
|
||||
|
||||
// Add any additional command initialization here
|
||||
// This is where you can easily add new commands in the future
|
||||
|
||||
return bot, nil
|
||||
}
|
||||
|
||||
// RegisterCustomCommand is a helper function to register a new command
|
||||
// This makes it easy to add new commands in the future
|
||||
func RegisterCustomCommand(
|
||||
bot *discord.Bot,
|
||||
name string,
|
||||
description string,
|
||||
options []*discordgo.ApplicationCommandOption,
|
||||
handler func(s *discordgo.Session, i *discordgo.InteractionCreate),
|
||||
) error {
|
||||
// Register the command handler
|
||||
bot.RegisterCommand(name, handler)
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue