Я хочу получать данные из API каждые 2 секунды, поэтому я сделал для этого цикл while. Но для запуска бота нам нужно использовать bot.run('token') в конце кода, но поскольку мой цикл практически бесконечен, он никогда не достигнет этой строки.
Ниже схема кода
Код: Выделить всё
# import whatever necessary
# declare constants/variables
# define functions needed
# define time step
time_step = 2
# while loop starts
while True:
# take new API data and store it in a file
# compare the previous data and current data and get what's necessary
# ***Want to print with the bot here***
# replace old file data with the new file data
# close files
# sleep till time for this iteration of while is not equal to time_step (2 seconds)
continue # after 2 seconds have been completed in this while iteration
run.bot('token') # but it will never reach this line as the while loop is infinite
Подробнее здесь: https://stackoverflow.com/questions/760 ... iscord-bot