Issue
I run a Discord py script on my Raspberry Pi 4, but after a while (around 45 minutes) it just restarts when I haven't done anything. After some time it just turns off without an error. Why does this happen? My script worked fine when I used it on heroku.com but now my rasp restarts without me wanting it (I know it restarts because it prints my on_ready()
message). How can I solve this? I tried running it in the editor on the Raspberry but that also restarts. After some time it also turns off and then my bot doesn't respond anymore. Below is my piece of code for on_ready
:
@bot.event
async def on_ready():
print(f'Logged in as {bot.user}'.format(bot))
Update: I think it doesn’t restart it but it runs it again because normally I get 1 embed sent but now like 8 or 7 at once of the same thing
Update 2: It probably is a connection error, someone in the discord.py discord told me i should handle it in my code. How can i do that?
Solution
The answer wasn't something in my code, Discord.py reconnects and they continue my loop function that was running before the disconnect but i didn't know that so i called the command again after he reconneted, which resulted in the FUNCTION running multiple times not the whole bot, so that was the reason he spammed the embeds. The solution, just ignore the reconnect because everything continues where it disconneted! :)
Answered By - maurijn.vd
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.