Skip to content Skip to sidebar Skip to footer

Check If User Is In A Voice Channel Discord.py

I am making a bot that will play sounds in a vc. I have made the code to join the call, play the mp3, then leave the call but when the user is not in a call I get this error: Ignor

Solution 1:

You can simply check if it's not a nonetype with an if statement

@bot.command()
async def foo(ctx):
    voice_state = ctx.member.voice

    if voice_state is None:
        # Exiting if the user is not in a voice channel
        return await ctx.send('You need to be in a voice channel to use this command')

    # Put the rest of the code here

Post a Comment for "Check If User Is In A Voice Channel Discord.py"