本文介绍了如果达到 Wait_For_Message 超时,则发送消息 Discord Py的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果 client.wait_for_message 达到超时,我正在尝试发送消息.在这种情况下,它是 30 秒.我使用了 TimeoutError 但它不会抛出任何错误或工作.

I'm trying to send a message if the timeout is reached for client.wait_for_message. In this case it's 30 seconds. I used TimeoutError but it doesn't throw any errors or work.

 try:
    msg = await client.wait_for_message(timeout= 30, author=message.author, check=check)
        if msg:
            await client.send_message(message.channel, "Nice job! {} solved the scramble! The word was {}!".format(message.author.mention, word))
    except TimeoutError:
        await client.send_message(message.channel, "Oops! Nobody solved it. The word was {}!".format(word))

推荐答案

抱歉,经过一番研究,我想出了这个解决方案:

Sorry after researching a bit I came up with this solution:

msg = await client.wait_for_message(timeout= 30, author=message.author, check=check)
if msg:
    await client.send_message(message.channel, "Nice job! {} solved the scramble! The word was {}!".format(message.author.mention, word))
elif msg is None:
    await client.send_message(message.channel, "Oops! Nobody solved it. The word was {}!".format(word))

这篇关于如果达到 Wait_For_Message 超时,则发送消息 Discord Py的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 01:44