简体   繁体   English

Discord.py - 尝试获取用户输入时出现超时错误

[英]Discord.py - TimeoutError when trying to take a user_input

I want to have two user input in discord.py from two different users so i made another check function我想从两个不同的用户在 discord.py 中有两个用户输入,所以我又检查了 function

def s_check(b):
    def inner(m):
      return  m.author == b
    return inner

user_1 = await bot.wait_for('message', check=check(ctx.author), timeout=30)

mentioned_user = user_1.mentions[0]

user_2 = await bot.wait_for('message', check = s_check(mentioned_user), timeout = 30) # here it dosen't detects the user input and gives a timeout error

why is my code not detecting the second user input and what is the correct way to do that为什么我的代码没有检测到第二个用户输入,正确的方法是什么

You don't define the check(ctx.author) so we don't know what it is referring too, please add more code to your question so we can help better.您没有定义check(ctx.author) ,所以我们也不知道它指的是什么,请在您的问题中添加更多代码,以便我们提供更好的帮助。

For your problem, you are giving a function that returns another function as the check, whereas documentation indicates you must give a function that returns a boolean for the check. For your problem, you are giving a function that returns another function as the check, whereas documentation indicates you must give a function that returns a boolean for the check.

Here is how I would do it with lamba functions这是我将如何使用Lamba 函数

user_1 = await bot.wait_for('message', check=lambda m: m.author == ctx.author, timeout=30)

mentioned_user = user_1.mentions[0]

user_2 = await bot.wait_for('message', check=lambda m: m.author == mentioned_user , timeout = 30)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM