diff --git a/redbot/cogs/audio/audio.py b/redbot/cogs/audio/audio.py index a08539241..ae96b0f6b 100644 --- a/redbot/cogs/audio/audio.py +++ b/redbot/cogs/audio/audio.py @@ -3487,6 +3487,41 @@ class Audio(commands.Cog): player.store("playing_song", None) player.store("requester", None) + @commands.command() + @commands.guild_only() + @commands.cooldown(1, 15, discord.ext.commands.BucketType.guild) + @commands.bot_has_permissions(embed_links=True) + async def summon(self, ctx): + """Summon the bot to a voice channel.""" + dj_enabled = await self.config.guild(ctx.guild).dj_enabled() + try: + if ( + not ctx.author.voice.channel.permissions_for(ctx.me).connect + or not ctx.author.voice.channel.permissions_for(ctx.me).move_members + and self._userlimit(ctx.author.voice.channel) + ): + return await self._embed_msg( + ctx, _("I don't have permission to connect to your channel.") + ) + if not self._player_check(ctx): + await lavalink.connect(ctx.author.voice.channel) + player = lavalink.get_player(ctx.guild.id) + player.store("connect", datetime.datetime.utcnow()) + else: + player = lavalink.get_player(ctx.guild.id) + if ctx.author.voice.channel == player.channel: + return + await player.move_to(ctx.author.voice.channel) + except AttributeError: + return await self._embed_msg(ctx, _("Connect to a voice channel first.")) + except IndexError: + return await self._embed_msg( + ctx, _("Connection to Lavalink has not yet been established.") + ) + if dj_enabled: + if not await self._can_instaskip(ctx, ctx.author): + return await self._embed_msg(ctx, _("You need the DJ role to summon the bot.")) + @commands.command() @commands.guild_only() @commands.bot_has_permissions(embed_links=True)