首页 > 解决方案 > 如何在 discord.py 上创建自定义函数?

问题描述

我正在开发一个不和谐的机器人,我必须使用以下功能:

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

但它绝对不起作用,只是返回 True。
我怎样才能做到?

标签: pythondiscord.py

解决方案


我的问题是await
我不得不像这样调用函数:await get_ox(message.author, my_msg)


推荐阅读