mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
[Audio] Match v2 behavior for channel change (#2521)
* [Audio] Match v2 behavior for channel change * Use move_to instead of connect
This commit is contained in:
parent
2a486cad66
commit
de7d08ee75
@ -2833,6 +2833,7 @@ class Audio(commands.Cog):
|
|||||||
)
|
)
|
||||||
is_mod = discord.utils.get(ctx.guild.get_member(member.id).roles, id=mod_role) is not None
|
is_mod = discord.utils.get(ctx.guild.get_member(member.id).roles, id=mod_role) is not None
|
||||||
is_bot = member.bot is True
|
is_bot = member.bot is True
|
||||||
|
is_other_channel = await self._channel_check(ctx)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
is_active_dj
|
is_active_dj
|
||||||
@ -2842,6 +2843,7 @@ class Audio(commands.Cog):
|
|||||||
or is_admin
|
or is_admin
|
||||||
or is_mod
|
or is_mod
|
||||||
or is_bot
|
or is_bot
|
||||||
|
or is_other_channel
|
||||||
)
|
)
|
||||||
|
|
||||||
async def _is_alone(self, ctx, member):
|
async def _is_alone(self, ctx, member):
|
||||||
@ -3092,6 +3094,32 @@ class Audio(commands.Cog):
|
|||||||
|
|
||||||
self._restart_connect()
|
self._restart_connect()
|
||||||
|
|
||||||
|
async def _channel_check(self, ctx):
|
||||||
|
player = lavalink.get_player(ctx.guild.id)
|
||||||
|
try:
|
||||||
|
in_channel = sum(
|
||||||
|
not m.bot for m in ctx.guild.get_member(self.bot.user.id).voice.channel.members
|
||||||
|
)
|
||||||
|
except AttributeError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
if not ctx.author.voice:
|
||||||
|
user_channel = None
|
||||||
|
else:
|
||||||
|
user_channel = ctx.author.voice.channel
|
||||||
|
|
||||||
|
if in_channel == 0 and user_channel:
|
||||||
|
if (
|
||||||
|
(player.channel != user_channel)
|
||||||
|
and not player.current
|
||||||
|
and player.position == 0
|
||||||
|
and len(player.queue) == 0
|
||||||
|
):
|
||||||
|
await player.move_to(user_channel)
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
async def _check_api_tokens(self):
|
async def _check_api_tokens(self):
|
||||||
spotify = await self.bot.db.api_tokens.get_raw(
|
spotify = await self.bot.db.api_tokens.get_raw(
|
||||||
"spotify", default={"client_id": "", "client_secret": ""}
|
"spotify", default={"client_id": "", "client_secret": ""}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user