Hyello I'm new to coding and I'm trying to make this discord bot say "Azu-bot offline" when it goes from being online to offline in discord.
Here is the code that I have for this event
@client.event
async def on_disconnect():
code_channel = client.get_channel(channel id)
await code_channel.send("Azu-bot offline")
and where it says channel id is the actual id of the channel.
The problem is that when I kill the terminal to make the bot go offline it never sends the message so I need help.
I also have one event that makes it say "Azu-bot online" when it gets online which works whenever I run it.
Maybe the problem is that the terminal that I kill to make the bot go offline is the same one that is running the code that makes it send the "Azu-bot offline" message which means since the terminal is dead the code that detects the offline event is no longer running so it won't send. If so then I don't know how to fix that.