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,
}
)