Code Monkey home page Code Monkey logo

trivia-bot's Introduction

UPDATE

I've been super busy with my full time job and have been unable to complete the full rewrite that I've started working on a little while back. So, I've taken Trivia Bot offline for now. Does that mean it'll never come back online? No! I'd like to take a different development approach with Trivia Bot in the future. Here's what I mean by that:

When I originally designed and wrote the code for the bot, I was a college senior and this was originally a class project. The code was written very poorly as it was rushed. I was also an inexperienced developer at the time and it has been very difficult to scale the project given how crappy it was originally designed. So, I'd like to rewrite it in the future, but using an entirely different programming language. This means I need to completely rip it apart so I can put it back together, and this takes a lot of time.

Please forgive me as life has been super busy these past few years. I love building discord bots and really want to revive Trivia Bot once and for all. For now, all I ask is that you forgive my silence. Thanks for the support these past few years, it meant the world to me as an aspiring software engineer!

What is Trivia Bot?

Trivia Bot is a fun, fully functional, and verified Discord bot that serves the purpose of satisfying your Trivia craving! There are many different modes of Trivia that you can play, either by yourself or with others in your Discord Server. The bot uses the Open Trivia Database API for the trivia questions that are used in the game, so shout out to them for the really cool API! You can find out more about that here.

Please Note: Slash Commands are actively in the works and on the way!! For now, the bot is indeed broken for use in servers, but you can use normal commands in DMs.

Add to your server

Click here to add Trivia Bot to your Discord server! Tell all your friends, too!

Commands

There are many different commands you can use to interact with Trivia Bot. This section will be evolving as more features are continually added! Here is a list of the current commands:

  • !tfchill Starts a round of chill T/F Trivia.
  • !tfcompetitive Starts a round of competitive T/F Trivia.
  • !mcchill Starts a round of chill Multiple Choice Trivia.
  • !mccompetitive Starts a round of competitive Multiple Choice Trivia.
  • !help Lists out all the commands that Trivia Bot responds to, and what they do.
  • !info Responds with a Discord embed that contains links to GitHub, Top.gg, and the Discord Support Server
  • ๐Ÿ›‘ Stops the current Trivia game

The difference between chill and competitive:

chill allows all users to select an answer within the time limit competitive only accepts the first correct answer; everyone else loses by default

You can also append any of the commands to help to learn more about the different game modes, like so:

  • !help tfchill Will give more detail about this specific game mode, for example.

Sub Commands

Trivia Bot now supports optional sub commands!

So...what does this mean for you? Trivia Bot can now take time [seconds] as an optional sub command so that you can extend the time limit per question in a Trivia round! This was done to make the game more accessible for those that can't read as quickly as others, or simply, for those that just want to take their time playing!

Please note: This option is only available for chill modes of gameplay. This is due to the nature of chill modes; competitive modes are meant to be quick, rapid-fire rounds which is why this option was not applied to competitive modes.

Please note part 2: There will be more optional sub commands added in the future such as selecting more than 10 questions, specific category selection, and difficulty selection, to name a few. Please stay tuned for these!

How to use the Sub Commands

time [seconds]

Let's say you want to play a round of tfchill but want to make each question have a time limit of 20 seconds:

All you need to do is type the following: !tfchill time 20

By default, Trivia Bot will give you 10 seconds per question. So, if you don't provide time [seconds], then the bot will default to 10.

Limits:

  • Minimum: 10 seconds
  • Maximum: 180 seconds
  • Can only be applied to tfchill or mcchill game modes

Command Aliases

Sometimes you'll mispell something and sometimes you'll want a quicker way to interact with the bot. Below are a list of aliases that exist so that your original intention will be recognized:

  • !halp, !hwlp, !hrlp works for !help
  • !mchill works for !mcchill
  • !mcompetitive, !mccomp, !mcomp works for !mccompetitive
  • !pong works for !ping
  • !tfcomp works for !tfcompetitive

Contributing

Please see CONTRIBUTING.md for instructions on how you can contribute to the development of this bot. Trivia Bot always welcomes PRs!

Help

Discussions have been enabled on this repository, so please feel free to ask any questions, make suggestions, etc. over here if you'd like! Please report bugs by opening up an issue for it in the Issues tab.

You can also join the Trivia Bot Support server and ask questions there, too:

Known Limitations/Bugs

Trivia Bot is still an active work in progress and therefore, it has some quirks that still need to be ironed out. (Contributions are welcomed and encouraged, and this is a great place to start if you're wanting to dip your toes in the codebase.) This is a list of the issues that will be fixed eventually, but until then, please know that they're there:

  • This happens in both chill and competitive modes.

    User 1 selects choice B, unselects choice B, then selects choice C. The correct answer was C and the bot accepts User 1's choice even though only the first selection should be considered.

    The Discord API limits what can be done with reactions (which is how Trivia Bot collects answers). The solution would be to disregard any other clicks after the first attempt has been executed. The issue relevant to fixing this can be found by clicking here.

  • The bot will throw an error, can be seen here, about Permissions, but I have no idea what causes it or how to fix it. I am actively investigating this and I hope to find a solution soon!

trivia-bot's People

Contributors

dcarpenter31 avatar dependabot[bot] avatar elenirotsides avatar jhector10 avatar jlora23 avatar marcwebdev avatar mtrunt avatar renovate-bot avatar renovate[bot] avatar sboamah avatar vishal5251 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

trivia-bot's Issues

Proper response for invalid commands

This is only relevant when we start writing code that accepts trivia customization, hand written answers (response with no reactions, just user submitting a discord chat response)

Clicking ๐Ÿ›‘ should trigger the "Time's Up" embed to be sent immediately

Describe the bug
If a user clicks on ๐Ÿ›‘ to stop a game, the "Times's up" embed should be sent immediately, not after the time has run out. This happens in chill modes. In competitive modes, the embed is sent immediately, which is what we want, but the same should happen in chill modes.

To Reproduce
Steps to reproduce the behavior:

  1. Type in !tfchill
  2. Click on the ๐Ÿ›‘ to stop the game
  3. Observe how long it takes for the "Time's Up" embed to be sent
  4. Now, type in !tfcomp
  5. Click on the ๐Ÿ›‘ to stop the game
  6. Observe how long it takes for the "Time's Up" embed to be sent

Expected behavior
Chill games should behave like competitive games; "Time's up" should be sent immediately. This is necessary because in #104 , functionality has been added to make the time limit per question be based on user request. So, if you say you want time to be 180 seconds (the maximum), then it will take 180 seconds until the game concludes. That shouldn't happen.

Basic Trivia game (multiple choice) - `-play mc chill`

Foundational functionality:

  1. To start, only allow trivia to be multiple choice
  2. Respond with reactions on the embed, record users response
  3. Number of questions by default will be 10
  4. Category will be random by default
  5. Difficulty will be random by default

COMMAND: -play mc chill
Should mimic the same game play as the -play tf chill game mode

The point of this is to establish working code and a working trivia game. Once we nail this, we can then make all the other fields dynamic in the code, and customizable by the user

`-play mc competitive`

Foundational functionality:

  1. To start, only allow trivia to be multiple choice
  2. Respond with reactions on the embed, record users response
  3. Number of questions by default will be 10
  4. Category will be random by default
  5. Difficulty will be random by default

COMMAND: -play mc competitive
Should mimic the same game play as the -play tf competitive game mode

Timer

  1. Bot should respond when the time is 15 seconds (just an example) before the time is up (warn the users).
  2. Set limit to how long each question takes to answers (set by us)

Implement architecture for rate limit

Is your feature request related to a problem? Please describe.
We need to make sure that we never exceed the rate limit, so implementing some kind of architecture to monitor this will solve this problem.

Add `-stop` command to help embed

When -help is invoked, we should also display what -stop does here too. Any time a new command is added, the help embed should get an update

Update FlowMap and Wire Frame

We need an updated FlowMap since we're no longer doing Flow Bot and an updated Wire Frame. This can be split up between two people, or one person can do it; doesn't matter. We just need these done so that whenever the lab is graded, it'll reflect our new project.

Research and then implement slash commands

Is your feature request related to a problem? Please describe.
A lot of bots have slash commands now, so Trivia Bot should as well
Slash commands are going to be strictly enforced by Discord in the coming months, so Trivia Bot needs to implement them.

Help embeds don't look the same on mobile

Describe the bug
When using Discord on mobile, the help embeds don't look the same.

To Reproduce
Steps to reproduce the behavior:

  1. Open Discord on your mobile device
  2. Execute !help and notice the formatting
  3. Now open Discord with the desktop application
  4. Repeat step 2

Expected behavior
Formatting should exactly match, or be close enough

Screenshots
On mobile:
IMG_7325
On desktop:
image

Additional context
The solution:
Instead of using \n to add line breaks, we need to be using the addField() method whenever we want a new line to begin. While looking at the code again, I noticed that we used this method for the !play tf help command and the formatting was consistent on both platforms. Here's a screenshot of this command's output on mobile:
IMG_7326
On desktop, the styling looks the same which is the goal.

Game mode suggestion; "Deathmatch Mode"

Is your feature request related to a problem? Please describe.
This feature is just a fun idea.

Describe the solution you'd like
Using a "life" system, you can make a mode where every wrong answer will remove a "life" or attempt. If you lose a specific amount of lives, you are eliminated from the game.

For example, everyone starts with 3 lives. If the answer to a question is "A" but someone (or multiple people) answer "B" (or any other wrong answer), they lose one life. This continues until only one person has any lives left.

Describe alternatives you've considered
Another alternative mode you can use where only one person can answer a question, and they can claim the points of that question; "lives" would help with this by deincentivize answering recklessly; whoever answers and gets a certain amount of points first wins.

If there are multiple people that also lose lives at once, you can either eliminate them at the same time (both / all losers at that round get 1st place, the second / follow up loser has 3rd / 4th / 5th / ...) or use the next question as a tie breaker.

Create help command

Most bots have a help command that shows how the bot can be used. We should do this as well in the form of a Discord Embed.

Example:
User sends to the channel: -help
Bot replies to the channel: With an embed listing out all the commands and what they do

Bot response to the word "trivia"

If users use the word 'trivia' anywhere in a conversation, the bot will be triggered and will respond with:

"Did someone say my name?"

Commands should only be valid when its an exact match

Describe the bug
Commands can be valid if they're not an exact match and this shouldn't happen.

To Reproduce
Steps to reproduce the behavior:

  1. Type in !tfchill woohoo
  2. Notice that a game will start even though 'woohoo' isn't a valid parameter

Expected behavior
Should only respond to exact matches.

Make commands case insensitive

Describe the bug
Not really a bug, but an annoyance. Commands should probably be case insensitive.

Expected behavior
!tfchill should yield the same response as !tfChill, for example.

Additional context
Probably just need to slap a .toLowerCase() on the inputs to solve this problem

Feature Request: Show a timer in chill modes so users know how much time they have left

Is your feature request related to a problem? Please describe.
After talking with a friend that played with Trivia Bot, he asked me to create some kind of visual in game, so users can know how much time is left in chill mode.

Describe the solution you'd like
I'm thinking this can be a new util, so I plan on creating a util that can be used in all chill game modes. It should be a new message embed that dynamically updates every second to show how much time is left.

Describe alternatives you've considered
This can also be a part of the normal message that gets sent when there is a new question, so this might be a better solution since there might be a bit of lag, will have to experiment to see which is better.

Improve logging

Is your feature request related to a problem? Please describe.
We need a means of logging...we currently have nothing. I'd like to be able to track where and when problems occur, should they occur.

Update bot to utilize discord v13

The API was just updated to v13 which includes a lot of new functionality. I'd like to use a lot of these new features and enhance Trivia Bot. TODO: research and decide which features we can use.

Figure out how to decode the api response

I believe some responses are coming back with some sort of PHP encoding (I don't know if that makes sense or if that is even accurate), so we need to figure out how to decode (or encode? idk what the correct word is to explain what I'm trying to say) the strings that the api is returning into plain English so our bot is user friendly.

Here's an example of what I mean:

image

In this case, ' translates to an apostrophe or quotes I guess, but it won't display as such unless we convert it.

Research:

  1. How to make this conversion and what it means
  2. If there's a JavaScript built in function that can make this conversion
  3. If there's an NPM package we can install to make this conversion

And then implement the best solution into the code, or write a comment here with the solution after you've tested and can confirm that your solution does indeed make the proper conversion.

Stop bot without shutting bot down

This is a 'nice to have if we have time' kind of issue. If we have time, we should figure out how to terminate a game without shutting down the bot completely. If not, then its okay because at least we can still stop!

Allow user to increase timer

Pass in the time as an optional argument so it can be customized if a user indicates they want to change the settings for a particular game. The default should always be 10 unless the user specifies otherwise.

Make conversion to ms (x1000)

Update README.md with instructions on how to use the bot

We should document what the bot does and how to use it in the README.md, and continually edit it as we add more features to the bot. Push the other stuff down a bit so the Professor and TA's can still get the information they need to grade us accordingly. This issue is to serve the purpose of making the initial change that way all subsequent additions are easier.

BUG: URGENT - `UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions`

Describe the bug
We are not error handling for missing permissions. The bot craps out when there's a discrepancy in permissions somewhere: UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions

To Reproduce
Steps to reproduce the behavior:

I have no idea how this happens, but its been crashing the bot, needs to be taken care of ASAP

Implement Docker

This is to ensure the project works on all platforms. The dependancies will be relevant to the container the project will be installed in.

Update README to show the different aliases for each command

Describe the solution you'd like
Each command has at least one alias associated with it. Right now, this is only exposed in the code, so an end user wouldn't know that these aliases exist. I'd like there to be a Command Aliases section of the README.md that lists out all of the aliases and what commands they're associated with.

Additional context
The commands and their aliases for Trivia Bot can be found in the src/Commands folder. Each command has an alias attribute which can be viewed in each of the files in this directory.

Create point system for games that have random difficulty levels

For games where the difficulty levels are randomly picked by the api, it would be cool to implement a point system!

  • Easy: 1 point
  • Medium: 2 points
  • Hard: 3 points

Its' as simple as adding in a few conditionals checking what the difficulty level is for the current question, and then updating the leaderboard accordingly.

Dependency Dashboard

This issue provides visibility into Renovate updates and their statuses. Learn more

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

  • Pin dependencies (@babel/core, @babel/node, @babel/preset-env, axios, dotenv, nodemon, parse-entities)

  • Check this box to trigger a request for Renovate to run again on this repository

Can no longer DM the bot

Describe the bug
After my latest OOP refactor, I think I removed the ability to dm the bot because it doesn't respond to dm's anymore. I need to fix this so that this functionality can be restored.

Expected behavior
Interacting with the bot in dm's should be no different than interacting in a server. The only difference is that you can collaborate on games with other users in a server, but otherwise functionality shouldn't change.

Refactor: Rename repo to `Trivia-Bot`

We'll need to:

  1. Rename the repo on GitHub
  2. Update where Heroku is pointing to
  3. Update all our local clones of this repository: change the remote URL in our local git repos with git remote set-url origin URL, view the current url with git remote get-url origin, see git remote --help for more details

Refactor: Use OOP paradigm instead of lumping everything into `bot.js`

Does all the command logic have to go into one bot.on('message.....) event?

Talking to myself because I'm having an epiphany several months later: Probably not. Once more research is done about writing the bot using object oriented programming, things will become more clear. I highly doubt it all needs to go into the same event, but who knows.

Basic Trivia game (true/false) `-play tf chill`

Foundational functionality:

  1. To start, only allow trivia to be true/false
  2. Respond with reactions on the embed, record users response
  3. Number of questions by default will be 10
  4. Category will be random by default
  5. Difficulty will be random by default
  6. Allow all users to answer, display all the users that got it right after each question's time is up.

COMMAND: -play tf chill

The point of this is to establish working code and a working trivia game. Once we nail this, we can then make all the other fields dynamic in the code, and customizable by the user.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.