Open
Conversation
wookie184
requested changes
Sep 15, 2025
Contributor
wookie184
left a comment
There was a problem hiding this comment.
Hi, sorry for the slow review, this looks great, thank you!
I have two minor comments.
bot/exts/fun/fun.py
Outdated
Comment on lines
165
to
170
| async with aiohttp.ClientSession() as session, session.get( | ||
| "https://icanhazdadjoke.com", | ||
| headers={ | ||
| "Accept":"application/json", | ||
| "User-Agent": "Sir-lancebot" | ||
| }) as res: |
Contributor
There was a problem hiding this comment.
- Reusing the bot's internal http_session is more efficient than creating a new one.
- Including a contact method (e.g. the URL to the project) in the user agent is good practice.
Suggested change
| async with aiohttp.ClientSession() as session, session.get( | |
| "https://icanhazdadjoke.com", | |
| headers={ | |
| "Accept":"application/json", | |
| "User-Agent": "Sir-lancebot" | |
| }) as res: | |
| async with self.bot.http_session.get( | |
| "https://icanhazdadjoke.com", | |
| headers={ | |
| "Accept": "application/json", | |
| "User-Agent": "Sir-Lancebot (https://github.com/python-discord/sir-lancebot)", | |
| } | |
| ) as res: |
bot/exts/fun/fun.py
Outdated
| data = await res.json() | ||
| await ctx.send(data["joke"]) | ||
| else: | ||
| await ctx.send("There is no dad joke now") |
Contributor
There was a problem hiding this comment.
This path indicates something is wrong, it's probably a good idea to raise an error so it will be logged and we can look into it. res.raise_for_status() can be used to do this.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relevant Issues
https://github.com//issues/1691?notification_referrer_id=NT_kwDOBivkC7UxODE0MTkwMjE5MjoxMDM1Mzk3MjM#event-19124053085Description
Changes made:
How it's implemented:
Did you: