mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -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:
|
for p in lavalink.players:
|
||||||
server = p.channel.guild
|
server = p.channel.guild
|
||||||
|
|
||||||
if server.id not in stop_times:
|
|
||||||
stop_times[server.id] = None
|
|
||||||
|
|
||||||
if [self.bot.user] == p.channel.members:
|
if [self.bot.user] == p.channel.members:
|
||||||
if stop_times[server.id] is None:
|
stop_times.setdefault(server.id, int(time.time()))
|
||||||
stop_times[server.id] = int(time.time())
|
else:
|
||||||
|
stop_times.pop(server.id, None)
|
||||||
|
|
||||||
for sid in stop_times:
|
for sid in stop_times.copy():
|
||||||
if stop_times[sid] is None:
|
|
||||||
continue
|
|
||||||
server_obj = self.bot.get_guild(sid)
|
server_obj = self.bot.get_guild(sid)
|
||||||
if await self.config.guild(server_obj).emptydc_enabled():
|
if await self.config.guild(server_obj).emptydc_enabled():
|
||||||
emptydc_timer = await self.config.guild(server_obj).emptydc_timer()
|
emptydc_timer = await self.config.guild(server_obj).emptydc_timer()
|
||||||
if (int(time.time()) - stop_times[sid]) >= emptydc_timer:
|
if (int(time.time()) - stop_times[sid]) >= emptydc_timer:
|
||||||
stop_times[sid] = None
|
stop_times.pop(sid)
|
||||||
try:
|
try:
|
||||||
await lavalink.get_player(sid).disconnect()
|
await lavalink.get_player(sid).disconnect()
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user