I got a discord Bot in which I want to implement a own logging System. The problem here is that I check if I want to check if the bot was shut down in the last log, it detects it but still does something wrong of which I don't really know what.
This is the relevant code, added some prints for debugging:
for file in get_log_files(path): # get_log_files yields all log files in the path
with open(path+file, "r", encoding="cp1252") as f:
print(not f.read().endswith('Bot wird heruntergefahren'))
if not f.read().endswith('Bot wird heruntergefahren'):
return file
else: print(1)
If I execute my bot, which runs at start through the log in on_ready
this function, it reads the last log correctly and if shut down before, prints out a False, if not a True. Here now comes the problem:
Doesn't matter which of the two were printed, it never prints the 1
afterwards: