discord.py上的*.shutdown*命令有问题

discord.py上的*.shutdown*命令有问题,discord.py,bots,Discord.py,Bots,我目前正在寻找修复此代码。我正在尝试生成一个.shutdown命令,它基本上会注销bot并关闭bot。我已经编写了一个代码,但它似乎不起作用。这是我的密码。非常感谢你的帮助;p @client.command() 异步def关闭(ctx,*,原因): 如果ctx.message.author.id(581457749724889102): 发送('Bot正在关闭…;(')) logs \-u channel=client.get \-u通道(825005282535014420) logs_c

我目前正在寻找修复此代码。我正在尝试生成一个.shutdown命令,它基本上会注销bot并关闭bot。我已经编写了一个代码,但它似乎不起作用。这是我的密码。非常感谢你的帮助;p


@client.command()
异步def关闭(ctx,*,原因):
如果ctx.message.author.id(581457749724889102):
发送('Bot正在关闭…;('))
logs \-u channel=client.get \-u通道(825005282535014420)
logs_channel.send(f“正在关闭Bot,原因:{reason}”)
退出()
其他:
ctx.send(“对不起,只有grr#6609警官才能这么做。”
谢谢你的帮助

编辑:

这是我的错误

Ignoring exception in on_command_error
Traceback (most recent call last):
  File "C:\Users\USER\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "c:\Users\USER\Desktop\discord bot folder\Nuova cartella\connor.py", line 173, in shutdown
    if ctx.message.author.id(581457749724889102):
TypeError: 'int' object is not callable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\USER\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\USER\Desktop\discord bot folder\Nuova cartella\connor.py", line 82, in on_command_error
    raise error
  File "C:\Users\USER\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\ext\commands\bot.py", line 902, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\USER\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\ext\commands\core.py", line 864, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\USER\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'int' object is not callable



请始终考虑<代码>等待您的函数。您在代码中也有一些形成和理解错误,也许再看一下

您可以检查执行命令的用户是否是bot的所有者。如果不是,当然会出现错误消息

查看以下代码:

@client.command()
@is_owner()#检查bot所有者是否执行了该命令
异步def关闭(ctx):
等待ctx.send(“注销”)
等待客户端。注销()#注销
@关机。错误
异步def关机错误(ctx,错误):
如果isinstance(错误,commands.NotOwner):
等待ctx.send(“您不是bot的所有者。”)#错误消息
我们做了什么?

  • 等待
    取消了大部分功能
  • 内置一个检查,用于检查所有者是否执行了命令
  • 内置一个错误处理程序,如果非所有者试图关闭bot,它将发出一条消息

到底什么不起作用?有错误吗?有效!谢谢!