Search code examples
pythonherokudiscorddiscord.pysys

quitting heroku app from within python script


I have a Heroku app running a discord.py bot and I want to make a remote shutdown command. If I was running from bash i could just do this with exit() or sys.exit() but neither of these work in Heroku as the app will startup again after the exit() because it thinks its a crash. I tried to use os.system but that didn't work either.

Here is my code:

@bot.command()
@commands.is_owner()
async def remoteshutdown(ctx):
    await ctx.send("Shutting down")
    exit()

Thanks in advance


Solution

  • Use bot.close() or bot.logout().