【问题标题】:How To Make Discord.py dev only Commands如何制作 Discord.py 仅用于开发的命令
【发布时间】:2021-08-30 16:38:33
【问题描述】:

如何制作 Discord.py 仅用于开发的命令

def restart_bot():


os.execv(sys.executable, ['python'] + sys.argv)

@Bot.command(name= 'restart')
  async def restart(ctx):
  await ctx.send("Restarting bot...")
  restart_bot()

【问题讨论】:

  • 这样重启机器人是个坏主意
  • 它的例子兄弟
  • 有个东西叫:@commands.is_owner()
  • @Dominik 将其作为答案发布!
  • @Makonede 没有必要这样做。它可以作为重复关闭而不是在此站点上给出already exists 的答案。如果评论解决了问题,那很好。

标签: discord.py


【解决方案1】:

您可以使用@commands.is_owner()

基本上是这样的:

@Bot.command(name = 'restart')
@commands.is_owner()
  async def restart(ctx):
  await ctx.send("Restarting bot...")
  restart_bot()

稍后谢谢我:D

【讨论】:

    猜你喜欢
    • 2020-12-03
    • 2018-08-27
    • 2021-11-19
    • 2021-09-02
    • 2021-07-12
    • 2020-12-08
    • 1970-01-01
    • 2020-08-27
    • 2021-07-20
    相关资源
    最近更新 更多