Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit 70beb43

Browse files
committed
fix: add 15s loop to clean players
1 parent 8e1530f commit 70beb43

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

vibr/cogs/events.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from botbase import CogBase
88
from nextcord.abc import Snowflake
9-
9+
from nextcord.ext.tasks import loop
1010
from vibr.__main__ import Vibr
1111

1212
from .extras.types import Player
@@ -19,6 +19,20 @@
1919

2020

2121
class AutoDisconnect(CogBase[Vibr]):
22+
def __init__(self, bot: Vibr):
23+
super().__init__(bot)
24+
25+
self.fix_clients.start()
26+
27+
@loop(seconds=15)
28+
async def fix_clients(self):
29+
for player in self.bot.voice_clients:
30+
if not player.is_connected:
31+
try:
32+
await player.destroy()
33+
except Exception:
34+
log.error("failed to clean player", exc_info=True)
35+
2236
async def handle_own_voice_state(
2337
self, member: Member, before: VoiceState, after: VoiceState
2438
) -> None:

0 commit comments

Comments
 (0)