【发布时间】:2021-03-13 23:59:27
【问题描述】:
我在一个命令中使用了两次 max_concurrency,以限制每个公会最多调用 3 次,每个用户最多调用一次:
@commands.max_concurrency(3,per=commands.BucketType.guild,wait=False)
@commands.max_concurrency(1,per=commands.BucketType.user,wait=False)
async def start(self, ctx):
我的问题是如何使用 BucketType 参数来创建单独的错误消息。
作为我要问的一个例子:
@start.error
async def on_command_error(self,ctx,error):
if isinstance(error, commands.MaxConcurrencyReached):
guild_error = "Too many playing"
user_error = "You're already playing"
await ctx.send("guild_error or user_error depending on BucketType?")
【问题讨论】:
标签: python error-handling discord discord.py discord.py-rewrite