首页 > 解决方案 > 如何制作 Discord.py 仅用于开发的命令

问题描述

如何制作 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()

标签: discord.py

解决方案


你可以做@commands.is_owner()

基本上是这样的:

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

稍后谢谢我 :D


推荐阅读