diff --git a/index.js b/index.js index 380548e..1fc5b44 100644 --- a/index.js +++ b/index.js @@ -49,16 +49,14 @@ function loadQuotes() { await client.startClient(); console.log('✅ MatrixClient connected and authenticated\n'); - // The M_INVALID_PARAM error often happens if we try to access properties - // before the user profile is fully loaded. - // Let's wait for the user identity to be available. + console.log('⏳ Waiting for User Identity to resolve...'); let attempts = 0; while (!client.user || !client.user.userId) { - if (attempts > 15) { - throw new Error('Timeout waiting for Matrix UserID resolution.'); + if (attempts > 30) { + throw new Error('Timeout waiting for Matrix User ID resolution (30s).'); } - console.log(`⏳ Waiting for User ID (Attempt ${attempts + 1})...`); - await new Promise(resolve => setTimeout(resolve, 2000)); + console.log(` ... Waiting for UserID (Attempt ${attempts + 1})`); + await new Promise(resolve => setTimeout(resolve, 1000)); attempts++; }