Reputation: 1
async def start():
while True:
await switch()
time.sleep(1)
async def switch():
for i in range(len(aktiv)):
print(list[i])
print(aktiv[i])
if list[i].voice != None:
if aktiv[i] == False:
aktiv[i] = True
print('Erkannt')
await music(list[i], song)
else:
pass
else:
aktiv[i] = False
Bot was written to play Music when a Player joined a voice Channel I check if the Player is new in the channel using the code. But when the loop is running it seems like it can't detect, when a user.voice changes. It only takes the very first input. Does somebody have a solution how i can test if a person is new in a Channel?
Upvotes: 0
Views: 917
Reputation: 15728
You're using time.sleep
which is a blocking function, (for more info read here), use asyncio.sleep
instead
import asyncio
async def start():
while True:
await switch()
await asyncio.sleep(1)
Upvotes: 1