-
Notifications
You must be signed in to change notification settings - Fork 167
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
[admin] Add button showing info about the last catches of a user #517
base: master
Are you sure you want to change the base?
Conversation
class recentlyCaughtButton(discord.ui.View): | ||
@discord.ui.button(label='Recent Catches', style = discord.ButtonStyle.primary) | ||
async def on_button_click(self, interaction: discord.Interaction, button: discord.ui.Button) -> None: | ||
await interaction.response.defer(ephemeral=True, thinking=True) | ||
embed = discord.Embed( | ||
title=f"Catch times for {user.id} - last 30 catches", | ||
) | ||
recently_caught_balls = await BallInstance.filter( | ||
player=player, | ||
).order_by("-catch_date").limit(30) | ||
ballInfo = "" | ||
for ball in recently_caught_balls: | ||
catch_time = ball.catch_date - ball.spawned_time | ||
ballInfo = f"{ballInfo}{ball.description(short=True)} - {catch_time} - {ball.server_id}\n" | ||
embed.add_field( | ||
name="", | ||
value=ballInfo, | ||
inline=False | ||
) | ||
await interaction.followup.send(embed=embed, ephemeral=True) |
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.
Class should be defined outside of the function and outside of the other class
@@ -129,6 +129,26 @@ async def user( | |||
catch_date__gte=datetime.datetime.now() - datetime.timedelta(days=days), | |||
player=player, | |||
) | |||
class recentlyCaughtButton(discord.ui.View): |
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.
class recentlyCaughtButton(discord.ui.View): | |
class recentlyCaughtButton(discord.ui.View): | |
class RecentlyCaughtButton(discord.ui.View): |
classes should be named using camelcase, just the standard used across python
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.
recentlyCaughtButton is already correct camelcase, which allows the first letter of the name to be either case. I believe you are describing PascalCase, which requires the first letter of each word to be only capital. I will change it accordingly.
) | ||
recently_caught_balls = await BallInstance.filter( | ||
player=player, | ||
).order_by("-catch_date").limit(30) |
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.
just for the edge case, should handle if recently_caught_balls is NOne and just say the user has no caught balls
ballInfo = "" | ||
for ball in recently_caught_balls: | ||
catch_time = ball.catch_date - ball.spawned_time | ||
ballInfo = f"{ballInfo}{ball.description(short=True)} - {catch_time} - {ball.server_id}\n" |
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.
ballInfo = f"{ballInfo}{ball.description(short=True)} - {catch_time} - {ball.server_id}\n" | |
ballInfo += f"{ball.description(short=True)} - {catch_time} - {ball.server_id}\n" |
Instead of overwriting ballInfo each time, you can append to it
Added a button to the embed created by the command 'admin info user', which shows information on the last (up to 30) catches by the user viewed. This includes the ball ID, name, catch time and ID of the server caught in.
Resolves #509