helpers.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:kitsuchan-2 作者: n303p4 项目源码 文件源码
def yes_no(ctx: commands.Context,
                 message: str="Are you sure? Type **yes** within 10 seconds to confirm. o.o"):
    """Yes no helper. Ask a confirmation message with a timeout of 10 seconds.

    ctx - The context in which the question is being asked.
    message - Optional messsage that the question should ask.
    """
    await ctx.send(message)
    try:
        message = await ctx.bot.wait_for("message", timeout=10,
                                         check=lambda message: message.author == ctx.message.author)
    except asyncio.TimeoutError:
        await ctx.send("Timed out waiting. :<")
        return False
    if message.clean_content.lower() not in ["yes", "y"]:
        await ctx.send("Command cancelled. :<")
        return False
    return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号