Compare commits

...

3 Commits

3 changed files with 19 additions and 10 deletions

View File

@@ -1,4 +1,5 @@
from ... import utils from ... import utils
from ...state import players
from .utils import command_allowed from .utils import command_allowed
@@ -19,5 +20,8 @@ async def leave(message):
if not command_allowed(message): if not command_allowed(message):
return return
if message.guild.id in players:
del players[message.guild.id]
await message.guild.voice_client.disconnect() await message.guild.voice_client.disconnect()
await utils.add_check_reaction(message) await utils.add_check_reaction(message)

View File

@@ -251,7 +251,8 @@ async def skip(message):
if not command_allowed(message): if not command_allowed(message):
return return
if not players[message.guild.id] and not players[message.guild.id].queue: if players[message.guild.id] and not players[message.guild.id].queue:
del players[message.guild.id]
message.guild.voice_client.stop() message.guild.voice_client.stop()
await utils.reply( await utils.reply(
message, message,

View File

@@ -15,7 +15,7 @@ import disnake_paginator
from . import commands, utils from . import commands, utils
from .commands import Command as C from .commands import Command as C
from .constants import EMBED_COLOR, OWNERS, PREFIX, RELOADABLE_MODULES from .constants import EMBED_COLOR, OWNERS, PREFIX, RELOADABLE_MODULES
from .state import client, command_cooldowns, command_locks, idle_tracker from .state import client, command_cooldowns, command_locks, idle_tracker, players
async def on_message(message, edited=False): async def on_message(message, edited=False):
@@ -149,17 +149,21 @@ async def on_message(message, edited=False):
async def on_voice_state_update(_, before, after): async def on_voice_state_update(_, before, after):
if not before.channel and after.channel:
return
if before.channel and not after.channel:
if before.channel.guild.id in players:
del players[before.channel.guild.id]
return
def is_empty(channel): def is_empty(channel):
return [m.id for m in (channel.members if channel else [])] == [client.user.id] return [m.id for m in (channel.members if channel else [])] == [client.user.id]
channel = None if is_empty(after.channel):
if is_empty(before.channel): if after.channel.guild.id in players:
channel = before.channel del players[after.channel.guild.id]
elif is_empty(after.channel): await after.channel.guild.voice_client.disconnect()
channel = after.channel
if channel:
await channel.guild.voice_client.disconnect()
def rreload(reloaded_modules, module): def rreload(reloaded_modules, module):