Answer the question
In order to leave comments, you need to log in
How to add all users to Mongo?
I have a Python discord bot, I connected it to MongoBD, but the question arose: how to add all servers and all users to the database?
Answer the question
In order to leave comments, you need to log in
from motor.motor_asyncio import AsyncIOMotorClient # https://pypi.org/project/motor/
client = AsyncIOMotorClient(host="localhost", port=27017)
db = client["mydatabasename"]
for user in bot.users:
await db.users.insert_one(
{
"id": user.id,
"name": user.name,
"discrim": user.discriminator,
"bot": user.bot,
"system": user.system,
}
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question