@_playnow.before_invoke<EOL><INDENT>@_previous.before_invoke<EOL>@_play.before_invoke<EOL>async def ensure_voice(self, ctx):<DEDENT>
player = self.bot.lavalink.players.get(ctx.guild.id)<EOL>if not player.is_connected:<EOL><INDENT>if not ctx.author.voice or not ctx.author.voice.channel:<EOL><INDENT>await ctx.send('<STR_LIT>')<EOL>raise commands.CommandInvokeError(<EOL>'<STR_LIT>')<EOL><DEDENT>permissions = ctx.author.voice.channel.permissions_for(ctx.me)<EOL>if not permissions.connect or not permissions.speak:<EOL><INDENT>await ctx.send('<STR_LIT>')<EOL>raise commands.CommandInvokeError(<EOL>'<STR_LIT>')<EOL><DEDENT>player.store('<STR_LIT>', ctx.channel.id)<EOL>await player.connect(ctx.author.voice.channel.id)<EOL><DEDENT>else:<EOL><INDENT>if player.connected_channel.id != ctx.author.voice.channel.id:<EOL><INDENT>return await ctx.send('<STR_LIT>')<EOL><DEDENT><DEDENT>
A few checks to make sure the bot can join a voice channel.