async def ensure_voice(self, ctx):
    ' This check ensures that the bot and command author are in the same voicechannel. '
    player = self.bot.lavalink.player_manager.create(ctx.guild.id, endpoint=str(ctx.guild.region))
    should_connect = (ctx.command.name in ('play',))
    if ((not ctx.author.voice) or (not ctx.author.voice.channel)):
        raise commands.CommandInvokeError('Join a voice channel first :loud_sound:')
    if (not player.is_connected):
        if (not should_connect):
            raise commands.CommandInvokeError('Not connected :mute:')
        permissions = ctx.author.voice.channel.permissions_for(ctx.me)
        if ((not permissions.connect) or (not permissions.speak)):
            raise commands.CommandInvokeError('I need the `CONNECT` and `SPEAK` permissions. :disappointed_relieved:')
        player.store('channel', ctx.channel.id)
        (await self.connect_to(ctx.guild.id, str(ctx.author.voice.channel.id)))
    elif (int(player.channel_id) != ctx.author.voice.channel.id):
        raise commands.CommandInvokeError('You need to be in my voice channel :loud_sound:')
This check ensures that the bot and command author are in the same voicechannel.
async def ensure_voice(self, ctx):
    '  '
    player = self.bot.lavalink.player_manager.create(ctx.guild.id, endpoint=str(ctx.guild.region))
    should_connect = (ctx.command.name in ('play',))
    if ((not ctx.author.voice) or (not ctx.author.voice.channel)):
        raise commands.CommandInvokeError('Join a voice channel first :loud_sound:')
    if (not player.is_connected):
        if (not should_connect):
            raise commands.CommandInvokeError('Not connected :mute:')
        permissions = ctx.author.voice.channel.permissions_for(ctx.me)
        if ((not permissions.connect) or (not permissions.speak)):
            raise commands.CommandInvokeError('I need the `CONNECT` and `SPEAK` permissions. :disappointed_relieved:')
        player.store('channel', ctx.channel.id)
        (await self.connect_to(ctx.guild.id, str(ctx.author.voice.channel.id)))
    elif (int(player.channel_id) != ctx.author.voice.channel.id):
        raise commands.CommandInvokeError('You need to be in my voice channel :loud_sound:')