-1

So, I am developping a bot on repl.it and I don't understand why my code is not working...

I have a looped async function that is called every 24 hours:

@tasks.loop(hours=24)
async def send_plot():
  await bot.wait_until_ready()
  if str(datetime.now(tz).strftime('%Y-%m-%d')) not in db['Date']:
    append_db('Date', str(datetime.now(tz).strftime('%Y-%m-%d')))
---------------------------------------------------------------------------- # starting here
    print('...')
    for key in db.keys():
      append_db(key, db[key][len(db[key]) - 1])
---------------------------------------------------------------------------- # ending here
  plotting()
  message_channel = bot.get_channel(int(channel_id))
  await message_channel.send(file=discord.File('plot.png'))

So, for an unknown reason nothing is working between those two lines. I was trying to figure it out by myself but I am tired of it cuz nothing rly works. It is some kind of a magic shit happening here...

Here is the append_db function:

def append_db(key, value):
    clone = db[key]
    clone.append(value)
    db[key] = clone

Idk why, but it is the only way it lets me save the information to the repl.it database.

canvinus
  • 11
  • 1
  • I’m not sure Repl.it is really supposed to be used for long-running/scheduled tasks like this. I would be very surprised if this worked the way you intended. – esqew Mar 23 '21 at 02:19
  • @esqew Don't know if it is applicable to OP's code, but I was running several times on repl-it very long running program in C++, and all the times the task was terminated by repl-it exactly after `30 minutes` of running. So seems that repl-it can run any task for half an hour, at least in C++. – Arty Mar 23 '21 at 02:23
  • @esqew I've created a flask app that is being pinged by uptimerobot.com. It keeps my bot alive on repl.it. – canvinus Mar 23 '21 at 02:28

1 Answers1

-1

I was also trying to create a Discord bot on repl.it and a basic bot will work on Repl.it, but when you get more advanced (like a music bot), repl.it has some problems running the code. I recommend running it locally my opening terminal/command prompt, and typing python "file location" or if you have python 3 installed, you can try python3 "file location" and you would replace file location with the location of the file on your computer.

esqew
  • 42,425
  • 27
  • 92
  • 132
Spotech
  • 11
  • 4