-
-
Notifications
You must be signed in to change notification settings - Fork 43
refactor(treewide): reorder statements to improve speed #953
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,10 +35,11 @@ | |
The ID of the xkcd comic to search for. | ||
""" | ||
|
||
if comic_id: | ||
sourcery-ai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (bug_risk): The logic for handling comic_id has been inverted, which may affect behavior for comic_id=0. The updated logic prevents access to comic 0 if it's valid. Explicitly check for None to allow comic_id=0. |
||
await self.specific(ctx, comic_id) | ||
else: | ||
if not comic_id: | ||
await ctx.send_help("xkcd") | ||
return | ||
|
||
await self.specific(ctx, comic_id) | ||
|
||
@xkcd.command( | ||
name="latest", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,22 +75,16 @@ | |
member : discord.Member | ||
The member to get the avatar of. | ||
""" | ||
if member is not None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (bug_risk): The function now only handles discord.Interaction sources for members, potentially breaking support for other source types. If this change is intentional, please document or enforce the restriction. Otherwise, it may break support for non-Interaction sources. |
||
if isinstance(source, discord.Interaction) and member is not None: | ||
guild_avatar = member.guild_avatar.url if member.guild_avatar else None | ||
global_avatar = member.avatar.url if member.avatar else None | ||
files = [await self.create_avatar_file(avatar) for avatar in [guild_avatar, global_avatar] if avatar] | ||
|
||
if files: | ||
if isinstance(source, discord.Interaction): | ||
await source.response.send_message(files=files) | ||
else: | ||
await source.reply(files=files) | ||
await source.response.send_message(files=files) | ||
else: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (bug_risk): No fallback for non-Interaction sources when sending avatar files. If source can be something other than discord.Interaction, add a fallback or raise a clear error to avoid AttributeError. |
||
message = "Member has no avatar." | ||
if isinstance(source, discord.Interaction): | ||
await source.response.send_message(content=message, ephemeral=True, delete_after=30) | ||
else: | ||
await source.reply(content=message, ephemeral=True, delete_after=30) | ||
await source.response.send_message(content=message, ephemeral=True, delete_after=30) | ||
|
||
elif isinstance(source, commands.Context): | ||
member = await commands.MemberConverter().convert(source, str(source.author.id)) | ||
|
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.
issue (bug_risk): SENTRY_INITIALIZED is set at import time, which may not reflect runtime state.
If sentry_sdk may be initialized after import, caching its state could cause incorrect behavior. Consider calling sentry_sdk.is_initialized() directly unless initialization is guaranteed to be static.