Allow passing a voice channel to [p]summon (#5536)

Co-authored-by: Draper <27962761+Drapersniper@users.noreply.github.com>
Co-authored-by: Jakub Kuczys <me@jacken.men>
Co-authored-by: Kreusada <67752638+Kreusada@users.noreply.github.com>
This commit is contained in:
AAA3A
2026-05-28 18:57:15 +02:00
committed by GitHub
parent 28ff1f6d03
commit 0fe4310e52
2 changed files with 30 additions and 12 deletions
+4 -1
View File
@@ -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:
^^^^^^
+26 -11
View File
@@ -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()