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