Hello, I am trying to code a bot that will read data and then delete it. I have attached my code. The first for loop is not running at all (I've put a lot of print statements in it). Can someone please tell me where I'm going wrong?
async def on_ready():
print('Bot is now online and ready to roll')
lines=[]
outfile = open("file.txt", "w+")
lines = outfile.readlines()
final = ""
print("I work")
for line in outfile:
print("I also work")
date_str = line.strip()
print(date_str)
date_str = line[:18]
print(date_str)
date_format = '%Y-%m-%d %H:%M:%S'
date_obj = datetime.datetime.strptime(date_str, date_format)
print(date_obj)
now = datetime.datetime.now()
print(now)
diff = date_obj-now
print(diff)
seconds = diff.total_seconds()
print(seconds)
if seconds > 0:
print("running")
await asyncio.sleep(seconds)
await bot.wait_until_ready()
remind_channel = bot.get_channel(channel)
await remind_channel.send("<@role> time to post ad!")
print("ran")
for number, vert in enumerate(lines):
if number != 0:
final = final + vert
outfile.write(final)
outfile.close()