Skip to content

Conversation

@TheGoatInTheBoat
Copy link

@TheGoatInTheBoat TheGoatInTheBoat commented Jun 3, 2025

Summary by Sourcery

Initialize the Discord bot with two interactive onboarding cogs for random number utilities and set up the bot's main entrypoint

New Features:

  • Add 'higherlower' slash command for a number guessing game
  • Add 'randomnum' slash command to generate a random number within given bounds
  • Introduce main.py as the bot's entry point with logger initialization and working directory setup

@sourcery-ai
Copy link

sourcery-ai bot commented Jun 3, 2025

Reviewer's Guide

This PR introduces two new slash-command cogs for random number generation and an interactive number-guessing game, along with a main entrypoint script to initialize and run the bot.

Sequence diagram for the randomnum command

sequenceDiagram
    actor User
    participant RandomCog

    User->>RandomCog: /randomnum (lower_bound, upper_bound)
    activate RandomCog
    alt lower_bound > upper_bound
        RandomCog->>RandomCog: message = "Lower bound must be <= Upper bound"
    else
        RandomCog->>RandomCog: message = f"{random.randint(lower_bound, upper_bound)} is your number"
    end
    RandomCog->>RandomCog: embed = discord.Embed(...)
    RandomCog-->>User: Sends embed with message
    deactivate RandomCog
Loading

Class diagram for new Cogs and Bot

classDiagram
    class higherlowercog{
        +bot: commands.Bot
        +logger: logging.Logger
        +__init__(bot: commands.Bot)
        +higherlower(interaction: discord.Interaction, lower_bound: int, upper_bound: int) async
        +check(msg: discord.Message) bool
    }
    class RandomCog{
        +bot: commands.Bot
        +logger: logging.Logger
        +__init__(bot: commands.Bot)
        +randomnum(interaction: discord.Interaction, lower_bound: int, upper_bound: int) async
    }
    class Bot{
        +run_bot()
    }
    higherlowercog --|> commands.Cog
    RandomCog --|> commands.Cog
Loading

File-Level Changes

Change Details Files
Added interactive higher/lower guessing game cog with stateful user interaction
  • Defined a new Cog subclass for the game
  • Registered a /higherlower slash command with lower/upper bound parameters
  • Validated bounds and provided ephemeral feedback
  • Used bot.wait_for loop to process user guesses with high/low hints
  • Handled timeouts and sent follow-up messages
src/capy_app/frontend/cogs/onboarding/dan2_onboarding_cog.py
Added simple random number generator cog
  • Defined a new Cog subclass for random number
  • Registered a /randomnum slash command with bounds parameters
  • Validated bounds and generated a random number
  • Sent results in an embed with configurable color
  • Logged the chosen number
src/capy_app/frontend/cogs/onboarding/dan_onboarding_cog.py
Created main application bootstrap script
  • Set working directory to script location
  • Initialized global logger
  • Instantiated and started the bot via a main() function
  • Guarded execution with if __name__ == '__main__'
src/main.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

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

test:
hey fix a b c

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 @TheGoatInTheBoat - I've reviewed your changes - here's some feedback:

  • Use consistent PascalCase for your Cog class and file names (e.g. HigherLowerCog in higher_lower_cog.py) to match Python conventions and improve readability.
  • The check function currently only allows purely digit content, so negative numbers or malformed input will be ignored—consider using try/except on int conversion instead of isdigit().
  • Both cogs perform similar bound-checking and random-number logic; consider extracting that into a shared helper or base class to avoid duplication.
Here's what I looked at during the review
  • 🟡 General issues: 3 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 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.

import random


class RandomCog(commands.Cog):
Copy link

Choose a reason for hiding this comment

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

suggestion: File name doesn't reflect its purpose

Rename dan_onboarding_cog.py to random_cog.py for consistency with the class and command.

@TheGoatInTheBoat TheGoatInTheBoat changed the title initial commit for dan [Feature] Dan's Cogs; higherlower and randomnum 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