#Safely stop bot?

1 messages · Page 1 of 1 (latest)

sudden sorrel
#

Attempting to stop the GatewayBot bot instance from within a registered async callback (in this case, with hikari.StartedEvent gives me: hikari.errors.ComponentStateConflictError: Cannot wait for an inactive bot to join. I am shutting the bot down with bot.close() after (asynchronously) waiting for 10s to ensure it's not corrupting startup state. Not sure if this is a bug or if there's another way to shut down the bot that doesn't incur error messages. (Note: I do get log messages that indicate that the bot successfully shuts down; then afterwards, the error is raised.)

#

Relevant code snippet:

@bot.listen()
async def send_message(event: hikari.StartedEvent) -> None:
    await bot.rest.create_message(CHANNEL, 'Message')
    await asyncio.sleep(10)
    await bot.close()

bot.run()
violet ferry
#

You can't close the bot in the started event

#

And why don't you just use a RESTBot for that?