首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Discord.py \更改max_concurrency中间命令执行

Discord.py \更改max_concurrency中间命令执行
EN

Stack Overflow用户
提问于 2022-03-24 06:05:53
回答 1查看 43关注 0票数 0

我从机器人用户那里获取多个输入,并且我希望在接收输入时禁用他们对命令的使用。

代码语言:javascript
运行
复制
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的存在,我觉得它可以适用于这种情况。

EN

Stack Overflow用户

发布于 2022-03-24 06:41:04

您可以将该命令装饰如下:

代码语言:javascript
运行
复制
@bot.command()
@commands.max_concurrency(1, commands.BucketType.member, wait=False)
async def hello(ctx):

这将导致命令只允许每个公会成员在任何给定时间调用一次。有关其实现的详细说明,请参考文档中的BucketTypeMaxConcurrency

票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71597741

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档