fix: use discordgo fork, complete lavalink handshake

this works.
This commit is contained in:
Christopher F 2018-08-22 21:07:22 -04:00
parent 89c44fb63c
commit 566c1b0777
2 changed files with 6 additions and 7 deletions

View File

@ -5,12 +5,12 @@ import (
"log" "log"
"os" "os"
"os/signal" "os/signal"
"strconv"
"syscall" "syscall"
"github.com/foxbot/gavalink" "github.com/foxbot/gavalink"
"github.com/bwmarrin/discordgo" // this requires the "feature/manual-voice-connection branch!!"
"github.com/foxbot/discordgo"
) )
var token string var token string
@ -33,6 +33,7 @@ func main() {
if err != nil { if err != nil {
panic(err) panic(err)
} }
dg.SyncEvents = false
dg.AddHandler(ready) dg.AddHandler(ready)
dg.AddHandler(messageCreate) dg.AddHandler(messageCreate)
@ -87,7 +88,7 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
for _, vs := range g.VoiceStates { for _, vs := range g.VoiceStates {
if vs.UserID == m.Author.ID { if vs.UserID == m.Author.ID {
log.Println("trying to connect to channel") log.Println("trying to connect to channel")
_, err := s.ChannelVoiceJoin(c.GuildID, vs.ChannelID, false, false) err = s.ChannelVoiceJoinManual(c.GuildID, vs.ChannelID, false, false)
if err != nil { if err != nil {
log.Println(err) log.Println(err)
} else { } else {
@ -125,10 +126,9 @@ func voiceServerUpdate(s *discordgo.Session, event *discordgo.VoiceServerUpdate)
return return
} }
gid, _ := strconv.Atoi(event.GuildID)
vsu := gavalink.VoiceServerUpdate{ vsu := gavalink.VoiceServerUpdate{
Endpoint: event.Endpoint, Endpoint: event.Endpoint,
GuildID: gid, GuildID: event.GuildID,
Token: event.Token, Token: event.Token,
} }
handler := new(gavalink.DummyEventHandler) handler := new(gavalink.DummyEventHandler)
@ -137,6 +137,4 @@ func voiceServerUpdate(s *discordgo.Session, event *discordgo.VoiceServerUpdate)
log.Println(err) log.Println(err)
return return
} }
panic("discordgo: cancel event")
} }

View File

@ -31,6 +31,7 @@ func (player *Player) PlayAt(track string, startTime int, endTime int) error {
msg := message{ msg := message{
Op: opPlay, Op: opPlay,
GuildID: player.guildID,
Track: track, Track: track,
StartTime: start, StartTime: start,
EndTime: end, EndTime: end,