diff --git a/commands/experimental_commands.py b/commands/experimental_commands.py index 34afc0a..0349397 100644 --- a/commands/experimental_commands.py +++ b/commands/experimental_commands.py @@ -240,16 +240,16 @@ async def compare(self, ctx: interactions.SlashContext, user1: str, user2: str): sc_user2 = scratch.get_user(user2) embed = interactions.Embed( - title=f"Comparing {user1} and {user2}", color=scratch_orange + title=f"{user1} and {user2}", color=scratch_orange ) embed.add_field( name=user1, value=( - f"Projects: {sc_user1.project_count()}\n" - f"Followers: {sc_user1.follower_count()}\n" - f"Following: {sc_user1.following_count()}\n" - f"Loves: {sc_user1.loves_count()}\n" - f"Favorites: {sc_user1.favorites_count()}" + f"{sc_user1.project_count()} projects\n" + f"{sc_user1.follower_count()} <:Followers:1524005976485924874>\n" + f"{sc_user1.following_count()} <:Followings:1524093134060130405>\n" + f"{sc_user1.loves_count()} <:Heart:1524004399104655440>\n" + f"{sc_user1.favorites_count()} <:Star:1524004383778406562>" ), inline=True, ) @@ -257,11 +257,11 @@ async def compare(self, ctx: interactions.SlashContext, user1: str, user2: str): embed.add_field( name=user2, value=( - f"Projects: {sc_user2.project_count()}\n" - f"Followers: {sc_user2.follower_count()}\n" - f"Following: {sc_user2.following_count()}\n" - f"Loves: {sc_user2.loves_count()}\n" - f"Favorites: {sc_user2.favorites_count()}" + f"{sc_user2.project_count()} projects\n" + f"{sc_user2.follower_count()} <:Followers:1524005976485924874>\n" + f"{sc_user2.following_count()} <:Followings:1524093134060130405>\n" + f"{sc_user2.loves_count()} <:Heart:1524004399104655440>\n" + f"{sc_user2.favorites_count()} <:Star:1524004383778406562>" ), inline=True, ) diff --git a/commands/search_commands.py b/commands/search_commands.py index a5cc593..3b4ad36 100644 --- a/commands/search_commands.py +++ b/commands/search_commands.py @@ -117,7 +117,7 @@ async def recommend( msg = interactions.Embed(color=scratch_orange) if recommendation_type == "projects": - loved_projects = list(islice(user.loved_projects(limit=10), 10)) + loved_projects = list(islice(user.favorites(limit=40), 40)) if not loved_projects: msg.title = f"No recommendations found for {username}" @@ -128,16 +128,18 @@ async def recommend( recommendations = [] seen_ids = set() - for project in loved_projects[:3]: + for project in loved_projects[:5]: try: + project.update() # .favorites() doesn't return the author, so we update the project to get it author = project.author() - for proj in list(author.projects(limit=5)): + for proj in list(author.projects(limit=10)): if proj.id not in seen_ids and proj.id != project.id: recommendations.append(proj) seen_ids.add(proj.id) if len(recommendations) >= 5: break - except Exception: + except Exception as e: + print(e) continue if len(recommendations) >= 5: break @@ -148,7 +150,7 @@ async def recommend( for proj in recommendations[:5]: description += ( f"\n**[{proj.title}]()**\n" - f"-# by [{proj.author_name}](https://scratch.mit.edu/users/{proj.author_name}) " + f"-# by [{proj.author().username}](https://scratch.mit.edu/users/{proj.author().username}) " f"• ❤️ {proj.loves} • ⭐ {proj.favorites}\n" ) msg.description = description @@ -157,7 +159,7 @@ async def recommend( msg.description = "Could not find similar projects at this time." elif recommendation_type == "users": - following = list(islice(user.following_names(limit=20), 20)) + following = list(islice(user.following_names(limit=40), 20)) if not following: msg.title = f"No recommendations found for {username}" @@ -200,7 +202,7 @@ async def recommend( msg.description = "Could not find similar users at this time." elif recommendation_type == "studios": - curating = list(islice(user.studios_curating(limit=20), 20)) + curating = list(islice(user.studios(limit=40), 20)) if not curating: msg.title = f"No recommendations found for {username}" @@ -213,10 +215,9 @@ async def recommend( for studio in curating[:5]: try: - for curator_name in list(studio.curator_names(limit=10))[:3]: + for curator in list(studio.curators(limit=10))[:3]: try: - curator = scratch.get_user(curator_name) - for potential_studio in list(curator.studios_curating(limit=5)): + for potential_studio in list(curator.studios(limit=5)): if potential_studio.id not in seen_ids: recommendations.append(potential_studio) seen_ids.add(potential_studio.id) @@ -235,6 +236,7 @@ async def recommend( msg.title = f"🎨 Studio recommendations for {username}" description = "Based on studios you're in, you might like:\n" for studio in recommendations[:5]: + studio.update() # Ensure we have all available data about the studio description += ( f"\n**[{studio.title}]()**\n" f"-# {studio.project_count} projects • {studio.follower_count} followers\n" diff --git a/events/bot_events.py b/events/bot_events.py index be07578..c96ddde 100644 --- a/events/bot_events.py +++ b/events/bot_events.py @@ -107,7 +107,7 @@ async def on_component(self, event: interactions.events.Component): @interactions.listen() async def on_command_error(event: CommandError): logging.exception( - f"Error in command {event.ctx.command.name}", + f"Error in command", exc_info=event.error ) diff --git a/main.py b/main.py index 15edb39..7184800 100644 --- a/main.py +++ b/main.py @@ -20,14 +20,14 @@ bot.load_extension("commands.studio_forum_commands") bot.load_extension("commands.search_commands") bot.load_extension("commands.utility_commands") -# bot.load_extension("commands.experimental_commands") # uncomment when ready +bot.load_extension("commands.experimental_commands") bot.load_extension("commands.prefix_commands") bot.load_extension("commands.currency_commands") # Attach Top.gg integration (registers its own listeners on `bot`) -import topGG +# import topGG -topGG.attach_to_bot(bot) +# topGG.attach_to_bot(bot) def main(): diff --git a/services/scratchblocks.py b/services/scratchblocks.py index 3c1acab..9c3996b 100644 --- a/services/scratchblocks.py +++ b/services/scratchblocks.py @@ -35,11 +35,11 @@ async def render_blocks_image( # Update scratchblocks path html = html.replace( "scratchblocks/build/scratchblocks.min.js", - "scratchblocks/build/scratchblocks.min.js", + "../scratchblocks/build/scratchblocks.min.js", ) html = html.replace( "scratchblocks/build/translations-all.js", - "scratchblocks/build/translations-all.js", + "../scratchblocks/build/translations-all.js", ) # Save modified HTML to a temporary file