meta: add example project
This commit is contained in:
parent
b1983105f3
commit
28ddb171ff
|
@ -26,8 +26,13 @@ var (
|
|||
)
|
||||
|
||||
// NewLavalink creates a new Lavalink manager
|
||||
func NewLavalink() *Lavalink {
|
||||
return &Lavalink{}
|
||||
func NewLavalink(shards int, userID int) *Lavalink {
|
||||
return &Lavalink{
|
||||
Shards: shards,
|
||||
UserID: userID,
|
||||
nodes: make([]Node, 1),
|
||||
players: make(map[string]*Player),
|
||||
}
|
||||
}
|
||||
|
||||
// AddNodes adds a node to the Lavalink manager
|
||||
|
|
11
node.go
11
node.go
|
@ -116,11 +116,11 @@ func (node *Node) onEvent(msgType int, msg []byte) error {
|
|||
|
||||
switch m.Type {
|
||||
case eventTrackEnd:
|
||||
err = (*player.handler).OnTrackEnd(player, m.Track, m.Reason)
|
||||
err = player.handler.OnTrackEnd(player, m.Track, m.Reason)
|
||||
case eventTrackException:
|
||||
err = (*player.handler).OnTrackException(player, m.Track, m.Reason)
|
||||
err = player.handler.OnTrackException(player, m.Track, m.Reason)
|
||||
case eventTrackStuck:
|
||||
err = (*player.handler).OnTrackStuck(player, m.Track, m.ThresholdMs)
|
||||
err = player.handler.OnTrackStuck(player, m.Track, m.ThresholdMs)
|
||||
}
|
||||
|
||||
return err
|
||||
|
@ -132,10 +132,7 @@ func (node *Node) onEvent(msgType int, msg []byte) error {
|
|||
}
|
||||
|
||||
// CreatePlayer creates an audio player on this node
|
||||
func (node *Node) CreatePlayer(guildID string, sessionID string, event VoiceServerUpdate, handler *EventHandler) (*Player, error) {
|
||||
if handler == nil {
|
||||
return nil, errNilHandler
|
||||
}
|
||||
func (node *Node) CreatePlayer(guildID string, sessionID string, event VoiceServerUpdate, handler EventHandler) (*Player, error) {
|
||||
msg := message{
|
||||
Op: opVoiceUpdate,
|
||||
GuildID: guildID,
|
||||
|
|
Loading…
Reference in New Issue