擅长:python、mysql、java
<p>您可以使用类型注释来向您的协同例程提供<a href="https://discordpy.readthedocs.io/en/rewrite/ext/commands/commands.html#converters" rel="nofollow noreferrer">converter</a>(注意,这是<a href="/questions/tagged/discord.py-rewrite" class="post-tag" title="show questions tagged 'discord.py-rewrite'" rel="tag">discord.py-rewrite</a>文档,但这也适用于异步分支)。然后,您可以指定另一个错误处理程序来实现处理错误输入的逻辑。你知道吗</p>
<pre><code>@client.command(pass_context=True)
async def purge(ctx, amount: int=300):
...
@purge.error
async def purge_error(error, ctx):
if isinstance(error, commands.BadArgument):
await client.send_message(ctx.message.channel, "Cannot convert input to integer")
</code></pre>
<p>您还可以查看<a href="https://discordpy.readthedocs.io/en/latest//api.html#discord.Client.purge_from" rel="nofollow noreferrer">^{<cd1>}</a>。我没看过你所有的合作计划,但看起来你在重新设计方向盘。你知道吗</p>