如何在 discord.py 机器人加入语音频道之间添加暂停?
How to add a pause between a discord.py bot joining a voice-channel?
我正在用 discord.py 制作一个不和谐的机器人。该机器人应该加入 VC 并等待 5 分钟,然后离开。出于测试目的,此数字已设置为 2 秒。现在的问题是,当机器人加入时,等待功能被完全忽略了。不管我怎么设置。
我试过更大的数字,但那也不行。
#The part of the code I'm having trouble with:
try:
vc = await ctx.guild.get_channel(int(chanid)).connect()
time.sleep(2)
await vc.disconnect()
except:
print(f"Action Failed: JoinVC.")
#Keep in mind, this is only part of the code.
我希望机器人尝试加入频道,并在 2 秒后离开。当代码按原样 运行 时,我没有收到任何错误消息。
time.sleep
不适用于 discord.py 所基于的 asyncio。请尝试 await asyncio.sleep(3)
。
我正在用 discord.py 制作一个不和谐的机器人。该机器人应该加入 VC 并等待 5 分钟,然后离开。出于测试目的,此数字已设置为 2 秒。现在的问题是,当机器人加入时,等待功能被完全忽略了。不管我怎么设置。
我试过更大的数字,但那也不行。
#The part of the code I'm having trouble with:
try:
vc = await ctx.guild.get_channel(int(chanid)).connect()
time.sleep(2)
await vc.disconnect()
except:
print(f"Action Failed: JoinVC.")
#Keep in mind, this is only part of the code.
我希望机器人尝试加入频道,并在 2 秒后离开。当代码按原样 运行 时,我没有收到任何错误消息。
time.sleep
不适用于 discord.py 所基于的 asyncio。请尝试 await asyncio.sleep(3)
。