How to run two Flask discord.py bots in the same repl.it project?

2024/11/8 8:54:30

I am using repl.it to run two bots in the same repl and I'm using imports as a I saw in other stackoverflow questions.

print('This will be the page where all bots will be made.')
import os
import bot1
import keep_alive
import bot2
import keep_alive1
while True:print('ALL BOTS STARTED!')

The problem is, it never gets to the while loop (it's for testing) because it gets stuck in the bot1 file. How should I fix this? The reason I'm doing it in the same repl project is so I can merge the bot database.

Answer

You should not be using an SQLite or local database with repl.it. This is because when the containers do a restart you might lose some data (unless they have changed this over the years).

It is recommended to use a database like MongoDB which offers a free 500MB database for you to use.

Since you did ask a question, I will answer it. You could try this:

import asyncioloop = asyncio.get_event_loop()
loop.create_task(bot1.start("bot_token1"))
loop.create_task(bot2.start("bot_token2"))
loop.run_forever()

You would need to use cogs and have both bots set up in the main.py then use cogs for better file management.

https://en.xdnf.cn/q/120635.html

Related Q&A

build a perfect maze recursively in python

I have this project to build a perfect maze recursively by using python. I have a MyStack class which creates a stack to track the path that I go through. And a Cell class which represent each square w…

How do I select random text on screen [closed]

Closed. This question needs debugging details. It is not currently accepting answers.Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to repro…

Conditional return with no else [duplicate]

This question already has answers here:Python Ternary Operator Without else(9 answers)Closed 10 months ago.Im try to do something like that in Python:return None if a is NoneInstead of having:if a is N…

Finding the position of an item in another list from a number in a different list

Developing on my previous question Im wondering whether there is a way to have an element in a list and find that position in another list and return what is in the position as a variable. for example:…

Why am I getting array instead of vector size? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.Want to improve this question? Add details and clarify the problem by editing this post.Closed 3 years ago.Improve…

Sending Email attachment (.txt file) using Python 2.7 (smtplib) [duplicate]

This question already has answers here:How to send email attachments?(21 answers)Closed 9 years ago.So Im trying to send a .txt file as an attachment and I cant find the right code to work. Here is my…

Python selenium drop down menu click

i want to select option from a drop down menu, for this i use that :br.find_element_by_xpath("//*[@id=adyen-encrypted-form]/fieldset/div[3]/div[2]/div/div/div/div/div[2]/div/ul/li[5]/span").c…

TypeError: Argument must be rect style object - Pygame (Python [duplicate]

This question already has answers here:Closed 11 years ago.Possible Duplicate:Pygame (Python) - TypeError: Argument must be rect style object I am trying to make a brick breaker game in Pygame (with P…

How to compare dates in python and find the greater one

I want to compare 2 date and predict a label true if date 1 greater than date 2 and predict false date 1 less than date 2. I have trained the model but model is predicting wrong for near by dates that …

Python: is isalnum() the same as isalpha with isdigit?

Is there a way to concretely verify this? I tried to solve a coding question but it seems one of the test cases (not revealed to me) takes this as wrong. In what kinds of cases does this fail to be tr…