mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
[V3 Audio] Cancel emptydisconnect when no longer alone (#2519)
* [audio] cancel disconnect when no longer alone * [audio] fix modifying while iterating
This commit is contained in:
parent
0ac93aacd5
commit
ee11d7da63
@ -3194,21 +3194,17 @@ class Audio(commands.Cog):
|
||||
for p in lavalink.players:
|
||||
server = p.channel.guild
|
||||
|
||||
if server.id not in stop_times:
|
||||
stop_times[server.id] = None
|
||||
|
||||
if [self.bot.user] == p.channel.members:
|
||||
if stop_times[server.id] is None:
|
||||
stop_times[server.id] = int(time.time())
|
||||
stop_times.setdefault(server.id, int(time.time()))
|
||||
else:
|
||||
stop_times.pop(server.id, None)
|
||||
|
||||
for sid in stop_times:
|
||||
if stop_times[sid] is None:
|
||||
continue
|
||||
for sid in stop_times.copy():
|
||||
server_obj = self.bot.get_guild(sid)
|
||||
if await self.config.guild(server_obj).emptydc_enabled():
|
||||
emptydc_timer = await self.config.guild(server_obj).emptydc_timer()
|
||||
if (int(time.time()) - stop_times[sid]) >= emptydc_timer:
|
||||
stop_times[sid] = None
|
||||
stop_times.pop(sid)
|
||||
try:
|
||||
await lavalink.get_player(sid).disconnect()
|
||||
except Exception:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user