Lem*_*dev 4 python discord.py discord.py-rewrite
我尝试使用以下代码在我的 discord python bot 中创建错误消息:
@purge.error
async def clear_error(ctx, error):
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send('Please specify the amount of messages you want to clear. Usage: //clear <number>')
if isinstance(error, commands.MissingPermissions):
await ctx.send('You do not have manage_messages permssion')
Run Code Online (Sandbox Code Playgroud)
但我在控制台中收到此错误:
Traceback (most recent call last):
File "c:/projects/bad bot/bot.py", line 132, in <module>
@purge.error
AttributeError: 'function' object has no attribute 'error'
Run Code Online (Sandbox Code Playgroud)
我不明白为什么会这样。
如果需要清除命令:
@client.command
@commands.has_permissions(manage_messages=True)
async def purge(ctx, amount : int):
await ctx.channel.purge(limit=amount)
await ctx.send('Done!')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7840 次 |
| 最近记录: |