We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When sending quiz questions to QuizBot, sometimes the function throws an error: "The message cannot be empty unless a file is provided"
Error sending quiz: Error: The message cannot be empty unless a file is provided Question index: 1 Question: { index: 2, question: "Tashkilot tarmoq resurslaridan...", answers: [...], correct_index: 0, type: 'short' }
code
async function sendQuiz(client, index) { const question = questions[index]; try { if (!question || !question.question || !question.answers) { console.error("Invalid question format at index:", index); return; } if (question.type === "long") { const questionText = html.escape(question.question); let answers = [...question.answers]; answers = shuffleArray(answers); const correctAnswer = question.answers[question.correct_index]; const correctIndex = answers.indexOf(correctAnswer); answers = answers.map((answer) => html.escape(answer)); await client.sendMessage("QuizBot", { message: <b>${questionText}</b>\n\n + A) ${answers[0]}\n + B) ${answers[1]}\n + C) ${answers[2]}\n + D) ${answers[3]}\n\n + ${COPYRIGHT}, parse_mode: "HTML", }); await sleep(400); await client.sendMessage("QuizBot", { poll: { question: "Javob:", answers: ["A", "B", "C", "D"], correct_option_id: correctIndex, type: "quiz", is_anonymous: false, explanation: COPYRIGHT, explanation_parse_mode: "HTML", }, }); } else { if ( !Array.isArray(question.answers) || question.correct_index === undefined ) { console.error("Missing required question data at index:", index); return; } await client.sendMessage("QuizBot", { poll: { question: question.question, answers: question.answers, correct_option_id: question.correct_index, type: "quiz", is_anonymous: false, explanation: COPYRIGHT, explanation_parse_mode: "HTML", }, }); } await sleep(500); } catch (err) { if (err.name === "FloodWaitError") { console.log(FloodWait error: waiting ${err.seconds} seconds); await sleep(err.seconds * 1000); await sendQuiz(client, index); } else { console.error("Error sending quiz:", err); console.log("Question index:", index); console.log("Question:", question); } } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Bug Description
When sending quiz questions to QuizBot, sometimes the function throws an error: "The message cannot be empty unless a file is provided"
Current Behavior
Steps to Reproduce
Error Log
code
The text was updated successfully, but these errors were encountered: