我从机器人用户那里获取多个输入,并且我希望在接收输入时禁用他们对命令的使用。
def check(m):
return m.channel == channel and ctx.message.author == m.author
@bot.command()
async def hello(ctx):
await ctx.send("How are you today?")
try:
response = await bot.wait_for('message', timeout=30, check=check) # I want to ensure users cannot execute a command during this stage of the command.
await ctx.send(f"Glad to see you're feeling {response.content}!")
except:
await ctx.send("You must be depressed! I didn't hear a word... :(")我注意到max_concurrency的存在,我觉得它可以适用于这种情况。
发布于 2022-03-24 06:41:04
您可以将该命令装饰如下:
@bot.command()
@commands.max_concurrency(1, commands.BucketType.member, wait=False)
async def hello(ctx):这将导致命令只允许每个公会成员在任何给定时间调用一次。有关其实现的详细说明,请参考文档中的BucketType和MaxConcurrency。
https://stackoverflow.com/questions/71597741
复制相似问题