-
-
Notifications
You must be signed in to change notification settings - Fork 40
Added Bookmarks #485
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
Added Bookmarks #485
Conversation
Reviewer's Guide by SourceryThis pull request implements a new bookmarking feature for the Discord bot. The changes include updating the README.md file to modify the contributors list and adding a new Python file for the bookmarks functionality. File-Level Changes
Tips
|
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.
Hey @targzballs - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 3 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.
tux/cogs/utility/bookmarks.py
Outdated
| self.bot = bot | ||
|
|
||
| @commands.Cog.listener() | ||
| async def on_raw_reaction_add(self, payload: discord.RawReactionActionEvent) -> None: |
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.
suggestion: Consider refactoring the method to reduce nesting and improve readability
The current structure with nested try-except blocks can be hard to follow. Consider extracting some logic into separate methods, such as fetching the channel and message, and sending the bookmark.
async def on_raw_reaction_add(self, payload: discord.RawReactionActionEvent) -> None:
if str(payload.emoji) != "🔖":
return
try:
await self._handle_bookmark(payload)
except Exception as e:
logging.error(f"Error handling bookmark: {e}")
tux/cogs/utility/bookmarks.py
Outdated
| try: | ||
| channel = self.bot.get_channel(payload.channel_id) | ||
| if channel is None: | ||
| logger.error("Channel not found") |
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.
suggestion: Use appropriate log levels for different types of errors
Consider using logger.warning for less critical issues (like 'Channel not found') and reserve logger.error for more severe problems. This will help in better error categorization and debugging.
| logger.error("Channel not found") | |
| logger.warning("Channel not found") |
tux/cogs/utility/bookmarks.py
Outdated
|
|
||
| embed = EmbedCreator.create_info_embed( | ||
| title="Message Bookmarked", | ||
| description=f"> {message.content}", |
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.
suggestion: Handle cases where message content might be empty
Add a check for empty message content and provide a default value or alternative text when the content is empty.
| description=f"> {message.content}", | |
| description=f"> {message.content if message.content else '[No message content]'}", |
refactor(bookmarks.py): move bookmarks from utility to services for better organization fix(bookmarks.py): improve error handling and logging in bookmarks service chore(bookmarks.py): remove old bookmarks utility after successful refactor
im nto a fan of git.
previous pr: #479
Summary by Sourcery
Add a new Bookmarks feature to the Discord bot, enabling users to bookmark messages by reacting with an emoji. Update the README to reflect changes in the contributors' section.
New Features:
Documentation: