Skip to content
New issue

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

feat(answers): ignore incorrect_answers if there isn't #249

Closed
wants to merge 5 commits into from
Closed

feat(answers): ignore incorrect_answers if there isn't #249

wants to merge 5 commits into from

Conversation

Mte90
Copy link

@Mte90 Mte90 commented Dec 16, 2021

Fix #247

@LakeYS
Copy link
Owner

LakeYS commented Dec 17, 2021

Can you send a working config? I receive this error when running under a default configuration, with the incorrect_answers field removed from a category.

TypeError: Cannot read property '0' of null
    at FileDB.validateQuestion (C:\Content\Dev\_Discord\Discord-Trivia-Bot\lib\database\filedb.js:74:80)
    at FileDB.updateGlobals (C:\Content\Dev\_Discord\Discord-Trivia-Bot\lib\database\filedb.js:121:16)
    at new TriviaDiscord (C:\Content\Dev\_Discord\Discord-Trivia-Bot\lib\platform\discord_main.js:82:19)
    at Object.<anonymous> (C:\Content\Dev\_Discord\Discord-Trivia-Bot\lib\platform\discord_shard.js:20:30)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
    at node:internal/main/run_main_module:17:47

And this error after enabling database-allow-long-answers

TypeError: Cannot read property 'length' of null
    at C:\Content\Dev\_Discord\Discord-Trivia-Bot\lib\database\filedb.js:310:59
    at Array.forEach (<anonymous>)
    at FileDB.fetchQuestions (C:\Content\Dev\_Discord\Discord-Trivia-Bot\lib\database\filedb.js:307:27)
    at async TriviaDiscord.getTriviaQuestion (C:\Content\Dev\_Discord\Discord-Trivia-Bot\lib\platform\discord_main.js:429:16)   
    at async HangmanGame.initializeRound (C:\Content\Dev\_Discord\Discord-Trivia-Bot\lib\game.js:231:18)
{}

@Mte90
Copy link
Author

Mte90 commented Dec 17, 2021

I shared the questions on the support channel on discord in a zip few days ago.

{

  "use-reactions": false,
  "hangman-mode": true,
  "hangman-hints": true,
  "hide-difficulty": true,
  "auto-delete-msgs": false,
  "auto-delete-msgs-timer": 25000,
  "auto-delete-answers": false,
  "auto-delete-answers-timer": 0,
  "round-length": 15000,
  "round-timeout": 4000,
  "round-end-warnings-disabled": false,
  "rounds-end-after": 2,
  "use-fixed-rounds": false,
  "rounds-fixed-number": 15,
  "disable-score-display": false,
  "score-value": { "medium": 1 },
  "score-multiplier-max": 2,
  "command-whitelist": [],
  "accept-first-answer-only": true,
  "reveal-answers": true,
  "participant-role-name": "Giocatore Trivia",
  "prefix": "trivia ",
  "allow-eval": false,
  "shard-count": "auto",
  "disable-admin-commands": false,
  "disable-version-check": false,
  "allow-bots": false,
  "databaseURL": "file://./Domande",
  "database-merge": false,
  "database-cache-size": 50,
  "database-allow-long-answers": false,
  "stat-file": "./stats.json",
  "stat-guild-recording": false,
  "embed-color": "006CFF",
  "channel-whitelist": ["trivia"],
  "config-commands-enabled": false,

  "additional-packages": [],
  "additional-packages-root": [],
  "debug-mode": false,
  "debug-log": false,
  "debug-database-flush": false,
  "display-ascii-logo": false,
  "fallback-mode": false,
  "fallback-silent": false,
  "fallback-exceptions": [],
  "fallback-intents": false,

  "enable-listings": false,
  "listing-tokens": {
    "discord.bots.gg": "optionaltokenhere",
    "discords.com": "optionaltokenhere",
    "discordlist.space": "optionaltokenhere",
    "top.gg": "optionaltokenhere"
  }
}

@Mte90
Copy link
Author

Mte90 commented Dec 20, 2021

A question example:

questions:
- question: Assassinio allo...
  correct_answer: specchio
  difficulty: medium
- question: Assassinio sull'Orient...
  correct_answer: Express
  difficulty: medium
- question: Avversario...
  correct_answer: segreto
  difficulty: medium
- question: Carte in...
  correct_answer: tavola
  difficulty: medium

@LakeYS
Copy link
Owner

LakeYS commented Jan 9, 2022

This appears to conflict with other configurations. We will need some sort of handling for the following:

  • Making admins aware that once they set up questions without incorrect answers, they're stuck using hangman mode unless they go back and add incorrect answers. This will likely be a given for many, but it's best to make it as clear as possible. Similar handling to database-allow-long-answers being opt-in with ample warning in the documentation.
  • Handling for configurations (incl. standard multiple-choice games) where the bot can't use the questions missing incorrect answers. We can either error out entirely, or try to filter these questions out, which would display the "No questions available under the current configuration" error if all of the questions are missing incorrect answers.

Some examples of results of the conflict:
Using the attached config, type "trivia play advanced 1 r 1 1 h'. Results in the following error:

C:\Content\Dev\_Discord\Discord-Trivia-Bot\lib\game.js:135
      answers[i] = answers[i].toString();
                              ^

TypeError: Cannot read property 'toString' of undefined
    at Game.buildAnswers (C:\Content\Dev\_Discord\Discord-Trivia-Bot\lib\game.js:135:31)
    at Game.initializeRound (C:\Content\Dev\_Discord\Discord-Trivia-Bot\lib\game.js:291:29)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Using the attached config, but with hangman-mode set to false:

Failed to initialize the database. Errors may occur when attempting to start a game. The following error has occurred:
TypeError: Cannot read property '0' of undefined
    at FileDB.validateQuestion (C:\Content\Dev\_Discord\Discord-Trivia-Bot\lib\database\filedb.js:74:80)
    at FileDB.updateGlobals (C:\Content\Dev\_Discord\Discord-Trivia-Bot\lib\database\filedb.js:121:16)
    at new TriviaDiscord (C:\Content\Dev\_Discord\Discord-Trivia-Bot\lib\platform\discord_main.js:82:19)
    at Object.<anonymous> (C:\Content\Dev\_Discord\Discord-Trivia-Bot\lib\platform\discord_shard.js:20:30)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
    at node:internal/main/run_main_module:17:47

@Mte90
Copy link
Author

Mte90 commented Jan 9, 2022

So what changes i can do to get approved this PR?

@LakeYS
Copy link
Owner

LakeYS commented Jan 9, 2022

For approval, these errors need to be fixed so that your changes will not interfere with anyone else's configurations of the bot.

I am willing to work on this for you when I can, but it may take some time, as some other critical fixes and changes for 2.0 will take precedence.

@Mte90
Copy link
Author

Mte90 commented Jan 10, 2022

I should be able to fix those crash.

@LakeYS LakeYS self-assigned this Feb 1, 2022
@LakeYS
Copy link
Owner

LakeYS commented Feb 1, 2022

Fixes look good so far. I will do a final round of testing and approve this after 2.0 hits stable.

@LakeYS
Copy link
Owner

LakeYS commented Mar 11, 2022

Update: Still awaiting the final changes and release of 2.0. Afterwards, this PR will be my first priority here. Thanks for your patience.

@Mte90
Copy link
Author

Mte90 commented Mar 12, 2022

No problem, I will fix the merge conflicts on monday.

@Mte90
Copy link
Author

Mte90 commented Mar 14, 2022

Fixed the rebase issues.

@Mte90
Copy link
Author

Mte90 commented Jul 20, 2022

Ping

@LakeYS
Copy link
Owner

LakeYS commented Jul 23, 2022

Still here. I will be looking at this shortly. I'm hoping to submit any reviews (if needed) for this soon--couple weeks at the latest. Thanks again for waiting.

@LakeYS
Copy link
Owner

LakeYS commented Aug 10, 2022

  1. Errors out if you attempt to start a normal trivia game with questions that do not have all incorrect answers:
C:\Content\Dev\_Discord\Discord-Trivia-Bot\lib\game\game.js:167
        answers[i] = answers[i].toString();
                                ^

TypeError: Cannot read properties of undefined (reading 'toString')
    at Game.buildAnswers (C:\Content\Dev\_Discord\Discord-Trivia-Bot\lib\game\game.js:167:33)
    at Game.initializeRound (C:\Content\Dev\_Discord\Discord-Trivia-Bot\lib\game\game.js:309:29)

You could fix this by using the exclusion array to filter out these questions if the game isn't in hangman mode. I recommend looking into creating a new type for this alongside 'boolean' and 'multiple'. These types correspond to the number of incorrect answers, which in your case is 0.

If the exclusion array filters out everything, you'll see the following, which is the desired result if your whole database consists of questions that don't apply to your config (in this case, hangman-specific questions with no incorrect answers):

An error occurred while querying the trivia database: Error: There are no questions available under the current configuration.
  1. True/false questions are visible in hangman mode. In normal operation, the file database will look for whether the question has a single incorrect answer. If it does, it is marked as a true/false question and excluded from hangman games.

For both of these, see filedb,js: Assignment of type, and check of type and exclusion

@Mte90
Copy link
Author

Mte90 commented Aug 10, 2022

I have no time to work on this after all this months...
I am still running my patched bot

@LakeYS
Copy link
Owner

LakeYS commented Aug 11, 2022

I understand. Feel free to close this out, or you can keep it open if you think your situation will change eventually.

@Mte90
Copy link
Author

Mte90 commented Aug 11, 2022

If you can fix those issues I can share the italian question database I am using with 38000 questions.

@LakeYS
Copy link
Owner

LakeYS commented Aug 11, 2022

If this change can't be completed here, it will most likely end up on my roadmap, meaning it will likely be fixed eventually. However, I unfortunately can't guarantee a timeframe.

What you do with your database is up to you--it sounds great, but I wouldn't be able to do much with it myself.

@Mte90
Copy link
Author

Mte90 commented Aug 12, 2022

For the database is just useless to share it if this change is not merged but i can upload it somewhere is not a problem.

@Mte90 Mte90 closed this by deleting the head repository Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Questions without incorrect answers
2 participants