1
votes

I am making a discord bot using the discord.py rewrite and I have recently run into a problem.

I have made a command to join a user's voice channel. The thing is, my command works perfectly fine when I run it on my local PC, but now that I'm trying to run it on a raspberry pi it fails when connecting to the voice channel.

I have tried installing all dependencies but I just can't get it to work. Code for the command:

@bot.command()
async def join(ctx):
    channel = ctx.message.author.voice.channel
    voice = get(bot.voice_clients, guild=ctx.guild)

    if voice and voice.is_connected():
        await voice.move_to(channel)
    else:
        voice = await channel.connect()

    await ctx.send("I joined the channel!")

There are no exceptions raised.

1
Does your pi support voice libraries? As well as things such as pynaclEthan M-H
How would I check that? I didn't receive any errors when installing it.0kelk
were you able to get it to connect?Eight Rice
Nope, I suppose it's something to do with the raspberry pi, but I can't figure it out.0kelk

1 Answers

2
votes

You are using a bad way to connect to the voice channel. Try using this code.

It identify where the user is and connect in that voice channel.

   @bot.command(name='join', invoke_without_subcommand=True)
    async def join(ctx):
       destination = ctx.author.voice.channel
       if ctx.voice_state.voice:
         await ctx.voice_state.voice.move_to(destination)
         return
    
       ctx.voice_state.voice = await destination.connect()
       await ctx.send(f"Joined {ctx.author.voice.channel} Voice Channel")