@client.command(pass_context=True)
async def solodab(context):
user = context.message.author
channel = user.voice_channel
if user == channel:
author = context.message.author
channel = author.voice_channel
vc = await client.join_voice_channel(channel)
print("3")
time.sleep(1)
print("2")
time.sleep(1)
print("1")
time.sleep(1)
await vc.disconnect()
else:
print("Dab")
await client.say("User is not in channel: ")
我正在制作一个solosnipe机器人,但是我想这样做,所以如果有人在写这篇文章,它应该给该人一个消息,告诉他们加入该频道。但是我不知道该怎么办
答案 0 :(得分:0)
我发现了问题,我需要添加一个try / except块。还有一些如果陈述是
if voice_channel == None:
voice_channel = author.voice_channel
if server == author:
await client.say("This just needs to be here dabdab")
else:
try:
vc = await client.join_voice_channel(voice_channel)
except:
await client.say("You are not in a channel, join one!!" + author.mention)