-
-
Notifications
You must be signed in to change notification settings - Fork 254
Madlibs #901
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
Madlibs #901
Conversation
…tion to loop until there are no more inputs left for the user to enter
Tysm for your review @TizzySaurus ! Your reviews are very thorough and it helps me a lot especially since this is my first time contributing to open-source!! I will implement your changes later today if I get the chance. |
Also restructured the Python program so it's under bot/exts/fun instead of bot/exts/fun/madlibs and also moved the JSON file to bot/resources/fun
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
works as intended
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should only allow a user to invoke the command once at a time.
Easy fix, decorate the command with this: https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.max_concurrency
@commands.max_concurrency(1, per=commands.BucketType.user)
It turns out that the bots error handler doesn't actually catch the error raised by a concurrency blocker. To solve this, we can use local error handlers (method) (guide) I've put an implementation together below, since some of this involves digging into our error handler implementation. @madlibs.error
async def handle_madlibs_error(self, ctx: commands.Context, error: commands.CommandError) -> None:
if isinstance(error, commands.MaxConcurrencyReached):
await ctx.send("You are already playing madlibs!")
error.handled = True The reason we set error.handled to True is because in our error handler we use getattr(error, "handler", False) to see if we have already handled the error. |
So this would go in the error handler file in the repo, correct? |
|
No, this would go in the madlibs file, since its local to the command. |
Yeah. |
Ah, gotcha. So where exactly does this go? Right after the |
Yeah, it can go anywhere in the cog, it's just a special decorator like the |
Gotcha, thanks. |
- Added a small piece of code so that users can invoke the command only once at a time - Added an error handler for that piece of code Both of the above were requested by arl (onerandomusername) Co-Authored-By: aru <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm :D
As you mentioned on Discord, it does say "Please try again later" and yes I agree that that the user could try again right away. To be honest, I could probably change what the embed says as a whole. I'm going to think about this more. Also I think mentioning the user would be good, will add that. About the random titles, that was something that Shom770 pointed out in a review so I added that. It sounds like this is a standard convention for similar projects so I decided to commit that suggestion. If you think I should not have it, I think it's fine either way. |
Well, we should keep them then, but I think that message should mention the user at minimum, and remove the please try again later :D |
Yep, I already added that locally, will commit sometime soon :) |
Yep! |
Add an author mention to the timeout embed and removed part of the embed message as requested by arl (onerandomusername)
To whoever eventually hits the merge button: squash. |
- Add a message about not spamming as requested by ChrisLovering - Made a small grammar change in the docstring of the edit listener function
Relevant Issues
Closes #847
Description
This PR is designed to add a fun Madlibs game to Sir Lancebot.
When the command,
.madlibs
, is run, the bot will ask the user to enter a word that fits a random part of speech (e.g. noun, adjective, verb, plural noun, etc.). The user will simply send a message with any word that fits the given part of speech.The bot chooses a random number of user inputs to use for the game and a random story.
Once the user has finished entering all the input prompts, the bot should send a message with the completed story using the words that the user entered.
Did you: