From 0fe4310e528aa5ed0a0dd16c8b818fb077492629 Mon Sep 17 00:00:00 2001 From: AAA3A <89632044+AAA3A-AAA3A@users.noreply.github.com> Date: Thu, 28 May 2026 18:57:15 +0200 Subject: [PATCH] Allow passing a voice channel to `[p]summon` (#5536) Co-authored-by: Draper <27962761+Drapersniper@users.noreply.github.com> Co-authored-by: Jakub Kuczys Co-authored-by: Kreusada <67752638+Kreusada@users.noreply.github.com> --- docs/cog_guides/audio.rst | 5 ++- redbot/cogs/audio/core/commands/controller.py | 37 +++++++++++++------ 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/docs/cog_guides/audio.rst b/docs/cog_guides/audio.rst index 72827b39b..6004abfbd 100644 --- a/docs/cog_guides/audio.rst +++ b/docs/cog_guides/audio.rst @@ -3199,12 +3199,15 @@ summon .. code-block:: none - [p]summon + [p]summon [voice_channel] **Description** Summon the bot to a voice channel. +If ``[voice_channel]`` is not specified, the bot will join the channel you are currently in. +``[voice_channel]`` can be a channel link ("Copy Link" option in channel's context menu) or ID. + .. _audio-command-volume: ^^^^^^ diff --git a/redbot/cogs/audio/core/commands/controller.py b/redbot/cogs/audio/core/commands/controller.py index 8cc971469..4bf78bcad 100644 --- a/redbot/cogs/audio/core/commands/controller.py +++ b/redbot/cogs/audio/core/commands/controller.py @@ -618,8 +618,14 @@ class PlayerControllerCommands(MixinMeta, metaclass=CompositeMetaClass): @commands.guild_only() @commands.cooldown(1, 15, commands.BucketType.guild) @commands.bot_has_permissions(embed_links=True) - async def command_summon(self, ctx: commands.Context): - """Summon the bot to a voice channel.""" + async def command_summon( + self, ctx: commands.Context, *, voice_channel: discord.VoiceChannel = None + ): + """Summon the bot to a voice channel. + + If `[voice_channel]` is not specified, the bot will join the channel you are currently in. + `[voice_channel]` can be a channel link ("Copy Link" option in channel's context menu) or ID. + """ dj_enabled = self._dj_status_cache.setdefault( ctx.guild.id, await self.config.guild(ctx.guild).dj_enabled() ) @@ -643,10 +649,22 @@ class PlayerControllerCommands(MixinMeta, metaclass=CompositeMetaClass): ) try: + if voice_channel is not None: + current_perms = voice_channel.permissions_for(ctx.author) + if not current_perms.connect: + ctx.command.reset_cooldown(ctx) + return await self.send_embed_msg( + ctx, + title=_("Unable To Join Voice Channel"), + description=_( + "You don't have permission to connect to the specified channel." + ), + ) + channel = voice_channel or ctx.author.voice.channel if ( - not self.can_join_and_speak(ctx.author.voice.channel) - or not ctx.author.voice.channel.permissions_for(ctx.me).move_members - and self.is_vc_full(ctx.author.voice.channel) + not self.can_join_and_speak(channel) + or not channel.permissions_for(ctx.me).move_members + and self.is_vc_full(channel) ): ctx.command.reset_cooldown(ctx) return await self.send_embed_msg( @@ -656,17 +674,14 @@ class PlayerControllerCommands(MixinMeta, metaclass=CompositeMetaClass): ) if not self._player_check(ctx): player = await lavalink.connect( - ctx.author.voice.channel, + channel, self_deaf=await self.config.guild_from_id(ctx.guild.id).auto_deafen(), ) player.store("notify_channel", ctx.channel.id) else: player = lavalink.get_player(ctx.guild.id) player.store("notify_channel", ctx.channel.id) - if ( - ctx.author.voice.channel == player.channel - and ctx.guild.me in ctx.author.voice.channel.members - ): + if channel == player.channel and ctx.guild.me in channel.members: ctx.command.reset_cooldown(ctx) return await self.send_embed_msg( ctx, @@ -674,7 +689,7 @@ class PlayerControllerCommands(MixinMeta, metaclass=CompositeMetaClass): description=_("I am already in your channel."), ) await player.move_to( - ctx.author.voice.channel, + channel, self_deaf=await self.config.guild_from_id(ctx.guild.id).auto_deafen(), ) await ctx.tick()