#python #python-3.x #discord #discord.py
#python #python-3.x #Discord #discord.py
Вопрос:
Голосовой канал появляется только тогда, когда я отключил, оглушил или запустил / остановил потоковую передачу как я могу это исправить, когда я присоединяюсь к каналу «➕Kanal Erstellen➕» как мне мгновенно перейти на временный канал?
async def on_voice_state_update(self, member, before, after):
if member.bot:
return
if not before.channel:
print(f'{member.name} joined {after.channel.name}')
if before.channel and not after.channel:
print(f'{member.name} left {before.channel.name}')
if before.channel and after.channel:
if before.channel.id != after.channel.id:
print(f'{member.name} switched from {before.channel.name} to {after.channel.name}')
else:
if member.voice.self_stream:
print(f'{member.name} started streaming')
self.current_streamers.append(member.id)
elif member.voice.self_mute:
print(f'{member.name} muted')
else:
for streamer in self.current_streamers:
if member.id == streamer:
if not member.voice.self_stream:
print(f'{member.name} stopped streaming')
self.current_streamers.remove(member.id)
break
if after.channel is not None:
if after.channel.name == "➕Kanal Erstellen➕":
channel = await creat_voice_channel(after.channel.guild, f'{member.name}´s Callcenter'.lower(),
category_name="Temp")
if channel is not None:
await member.move_to(channel)
if before.channel is not None:
if before.channel.category.id == get_category_by_name(before.channel.guild, "Temp").id:
print("User left Temp channel")
if len(before.channel.members) == 0:
print("channel empty")
await before.channel.delete()```
Ответ №1:
Я полагаю, что ваша проблема в том, if before.channel and after.channel:
что при первоначальном присоединении к каналу не будет before.channel
, поскольку вы раньше не были в канале, и ваш код не будет выполняться.