[英]How to make a custom function on discord.py?
I am developing a discord bot, and I have to use following function:我正在开发一个 discord 机器人,我必须使用以下 function:
async def get_ox(author,my_msg):
ox = ['⭕', '❌']
for i in ox:
await my_msg.add_reaction(i)
def check(reaction, user):
return user == author and str(reaction) in ox
try:
reaction = await client.wait_for('reaction_add', check=check, timeout=10.0)
except asyncio.TimeoutError:
return False
else:
reaction = reaction[0]
if str(reaction)==ox[1]:
return False
else:
return True
But it definitely does not work, and just returns True.但是肯定不行,直接返回True。
How can I make it?我怎样才能做到?
My problem was await
.我的问题是
await
。
I had to call the function like: await get_ox(message.author, my_msg)
我不得不像这样调用 function:
await get_ox(message.author, my_msg)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.