Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic on session.ChannelVoiceJoin in deafened=false mode #1172

Closed
la4zen opened this issue Apr 28, 2022 · 1 comment · Fixed by #1166
Closed

Panic on session.ChannelVoiceJoin in deafened=false mode #1172

la4zen opened this issue Apr 28, 2022 · 1 comment · Fixed by #1166

Comments

@la4zen
Copy link

la4zen commented Apr 28, 2022

// (ss *discordgo.Session, m *discordgo.MessageCreate)
if strings.HasPrefix(m.Content, "..join") {
	c, err := ss.State.Channel(m.ChannelID)
	if err != nil {
		return
	}
	g, err := ss.State.Guild(c.GuildID)
	if err != nil {
		return
	}
	for _, vs := range g.VoiceStates {
		if vs.UserID == m.Author.ID {
			vc, err := ss.ChannelVoiceJoin(c.GuildID, vs.ChannelID, true, false)
			if err != nil {
				return
			}
			print(vc)
			return
		}
	}
}

This code throws

panic: slice bounds out of range [:4] with capacity 0
github.com/bwmarrin/discordgo.(*VoiceConnection).opusReceiver(0xc00039d4a0, 0xc00009a3d0, 0xc000280900, 0xc0000f6960)
        go/pkg/mod/github.com/bwmarrin/discordgo@v0.25.0/voice.go:837 +0x575
created by github.com/bwmarrin/discordgo.(*VoiceConnection).onEvent
        go/pkg/mod/github.com/bwmarrin/discordgo@v0.25.0/voice.go:441 +0x573
@FedorLap2006 FedorLap2006 linked a pull request Apr 28, 2022 that will close this issue
@FedorLap2006
Copy link
Collaborator

Duplicate of #1161

@FedorLap2006 FedorLap2006 marked this as a duplicate of #1161 Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants