Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions commands/experimental_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,28 +240,28 @@ 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,
)
embed.add_field(name="\u200b", value="\u200b", inline=True)
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,
)
Expand Down
22 changes: 12 additions & 10 deletions commands/search_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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
Expand All @@ -148,7 +150,7 @@ async def recommend(
for proj in recommendations[:5]:
description += (
f"\n**[{proj.title}](<https://scratch.mit.edu/projects/{proj.id}>)**\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
Expand All @@ -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}"
Expand Down Expand Up @@ -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}"
Expand All @@ -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)
Expand All @@ -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}](<https://scratch.mit.edu/studios/{studio.id}>)**\n"
f"-# {studio.project_count} projects • {studio.follower_count} followers\n"
Expand Down
2 changes: 1 addition & 1 deletion events/bot_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
6 changes: 3 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
4 changes: 2 additions & 2 deletions services/scratchblocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading