Skip to content

Conversation

@Jest-a
Copy link

@Jest-a Jest-a commented Jun 3, 2025

Summary by Sourcery

New Features:

  • Introduce Thomas onboarding Cog with a /thomas slash command

@sourcery-ai
Copy link

sourcery-ai bot commented Jun 3, 2025

Reviewer's Guide

Introduces a new ThomasCog for onboarding in the Discord bot, defining random text and image responses and exposing a slash command to send a styled embed.

Sequence Diagram for the /thomas Command

sequenceDiagram
    actor User
    participant DiscordClient as Discord Client
    participant DiscordBot as Discord Bot
    participant ThomasCog

    User->>DiscordClient: Executes /thomas command
    DiscordClient->>DiscordBot: Forwards command /thomas
    DiscordBot->>ThomasCog: Thomas(interaction)
    activate ThomasCog
    ThomasCog->>ThomasCog: line = random.choice(random_lines)
    ThomasCog->>ThomasCog: image = random.choice(random_images)
    ThomasCog->>ThomasCog: Create discord.Embed(title, description, color)
    ThomasCog->>ThomasCog: embed.set_image(url=image)
    ThomasCog->>DiscordBot: interaction.response.send_message(embed)
    deactivate ThomasCog
    DiscordBot->>DiscordClient: Sends message with embed
    DiscordClient->>User: Displays message
Loading

Class Diagram for the new ThomasCog

classDiagram
    class ThomasCog {
        +bot: commands.Bot
        +logger: logging.Logger
        +random_lines: list~str~
        +random_images: list~str~
        +__init__(bot: commands.Bot)
        +Thomas(interaction: discord.Interaction) async
    }
    ThomasCog --|> commands.Cog
    ThomasCog ..> discord.Bot : uses
    ThomasCog ..> logging.Logger : uses
    ThomasCog ..> discord.Interaction : uses
    ThomasCog ..> discord.Embed : creates

    class commands.Cog {<<Interface/Base>>}
    class discord.Bot {<<Framework>>}
    class discord.Interaction {<<Framework>>}
    class discord.Embed {<<Data>>}
    class logging.Logger {<<Utility>>}

    class Global {
        <<Module>>
        +setup(bot: commands.Bot) async
    }
    Global ..> ThomasCog : instantiates
    Global ..> discord.Bot : registers cog
Loading

File-Level Changes

Change Details Files
Create ThomasCog with random response data
  • Added imports for discord, logging, random, and config
  • Defined ThomasCog class with bot reference and logger
  • Initialized lists of random_lines and random_images
src/capy_app/frontend/cogs/onboarding/thomas_onboarding_cog.py
Implement slash command to send embeds
  • Decorated method with @app_commands.command and guild restriction
  • Selected random line and image on invocation
  • Built and sent a discord.Embed with title, description, color, and image
src/capy_app/frontend/cogs/onboarding/thomas_onboarding_cog.py
Add logging of chosen content
  • Configured a logger in the cog init
  • Logged the selected line and image URL before sending response
src/capy_app/frontend/cogs/onboarding/thomas_onboarding_cog.py
Register cog on bot setup
  • Defined async setup function
  • Added cog to bot using bot.add_cog
src/capy_app/frontend/cogs/onboarding/thomas_onboarding_cog.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@Jest-a Jest-a self-assigned this Jun 3, 2025
@Jest-a Jest-a requested a review from YaoxuanZhang June 3, 2025 19:36
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Jest-a - I've reviewed your changes - here's some feedback:

  • Add missing commas between strings in the random_lines and random_images lists so each entry is a separate list item instead of getting concatenated.
  • Rename the command method from Thomas to lowercase (e.g. thomas) to follow PEP8 naming conventions for function/method names.
  • Update the embed title (currently "Tom") to match the command/cog name for consistency (e.g. use "Thomas").
Here's what I looked at during the review
  • 🟡 General issues: 4 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines 18 to 27
self.random_lines = [
"Every good thing that happens to you in this game is preplanned like a show. There's an audience waiting for your downfall."
"...I should buy a boat."
"So... come here often?"
"Wanna hear a joke?"
"Im out of funny ideas, come back later"
"Check out this cool gif"
"I'm hungry. Like, I really could go for some rigatoni right now."
"I've been thinking of starting a band recently. Might call it [adjective] [noun]. What do you think?"
]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Missing commas between string literals in random_lines list

Without commas, these strings are combined into a single list element. Please add commas to separate each string as an individual item.

"Check out this cool gif"
"I'm hungry. Like, I really could go for some rigatoni right now."
"I've been thinking of starting a band recently. Might call it [adjective] [noun]. What do you think?"
]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Missing commas between string literals in random_images list

Without commas, all URLs are combined into one string. Add commas so each URL is a separate list element for random.choice().


@app_commands.guilds(discord.Object(id=settings.DEBUG_GUILD_ID))
@app_commands.command(name="thomas", description="Does Something")
async def Thomas(self, interaction: discord.Interaction):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Method name should follow snake_case naming

Rename Thomas to thomas to comply with PEP8 naming conventions.

)
embed.set_image(url=image)

self.logger.info(f"Selected line: {line}, image: {image}")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Use debug level for verbose selection logs

Switch to self.logger.debug for these detailed randomization messages to reduce noise in production logs.

Suggested change
self.logger.info(f"Selected line: {line}, image: {image}")
self.logger.debug(f"Selected line: {line}, image: {image}")

@YaoxuanZhang
Copy link
Member

new name, who dis?

@Jest-a Jest-a changed the title initial commit for thoams initial commit for thomas Jun 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants