discord.py send a message if author isnt in a voice channel

Member.voice will be None, you need to check that

Below is the revised code:

async def play(ctx):
    channel = ctx.author.voice
    if channel:
        await channel.channel.connect() 
        await ctx.send('Joining voicechat.')
        await ctx.send('You have to be in a voice channel first.')

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top