Skip to content

Conversation

@kaylee-xie
Copy link

@kaylee-xie kaylee-xie commented Jun 6, 2025

For the 'poll' cog

Summary by Sourcery

Add Kaylee onboarding cog providing a slash command to create custom 3-choice polls with embed messages and reaction-based voting

New Features:

  • Implement /poll guild-scoped slash command that builds an embed with a question and three choices
  • Automatically add corresponding number emoji reactions to the poll message for voting

@kaylee-xie kaylee-xie requested a review from YaoxuanZhang June 6, 2025 18:09
@kaylee-xie kaylee-xie self-assigned this Jun 6, 2025
@sourcery-ai
Copy link

sourcery-ai bot commented Jun 6, 2025

Reviewer's Guide

Adds a new onboarding cog “KayleeCog” that implements a /poll slash command with three choices, builds an emoji-prefixed embed, logs the poll, sends the embed, and adds emoji reactions for voting.

File-Level Changes

Change Details Files
Introduce KayleeCog with a /poll slash command for three-choice polls
  • Register slash command with app_commands and guild scope
  • Construct emoji-prefixed descriptions list and join into a single string
  • Create and send an embed with poll title and options
  • Log the poll description via logger
  • Fetch the original response and add corresponding emoji reactions
src/capy_app/frontend/cogs/onboarding/kaylee_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

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 @kaylee-xie - I've reviewed your changes and they look great!

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 +9 to +10
#change everything with "Ping"
class KayleeCog(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: Remove or clarify the leftover comment

The #change everything with "Ping" comment appears to be an outdated TODO. Please remove it or update it to reflect the current intent.

Suggested change
#change everything with "Ping"
class KayleeCog(commands.Cog):
class KayleeCog(commands.Cog):

embed = discord.Embed(
title = "Poll: " + question,
description = message,
#color = colors.POLL, #couldn't get it to work :( gave me errors
Copy link

Choose a reason for hiding this comment

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

suggestion: Remove or properly re-enable the commented-out color

Uncomment and fix if colors.POLL is correct; otherwise, remove the commented line to avoid dead code.

Suggested implementation:

        embed = discord.Embed(
            title = "Poll: " + question,
            description = message,
            color = colors.POLL,
        )

If colors.POLL is not defined or imported, you will need to:

  • Ensure colors is imported and POLL is defined as a valid Discord color (e.g., discord.Color.blue() or an integer).
  • If you do not want to use a color, simply remove the commented line entirely.

description = message,
#color = colors.POLL, #couldn't get it to work :( gave me errors
)
self.logger.info(message) #logs message
Copy link

Choose a reason for hiding this comment

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

suggestion: Include more context in the log entry

Logging only the options string may not provide enough information for debugging. Log the question and choices for better context.

Suggested implementation:

        self.logger.info(
            "Poll created | Question: %r | Choices: %r | Message: %r",
            question,
            choices if 'choices' in locals() else 'N/A',
            message
        )                               #logs message

If the variable choices is not defined in this scope, replace it with the actual variable or data structure that contains the poll choices/options. Adjust the logging format as needed to match your codebase's conventions.


@app_commands.guilds(discord.Object(id=settings.DEBUG_GUILD_ID))
@app_commands.command(name="poll", description="Custom poll with 3 choices")
async def poll(self, interaction: discord.Interaction, question: str, choice_1: str, choice_2: str, choice_3: str):
Copy link

Choose a reason for hiding this comment

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

question: Consider adding input validation for the poll fields

Currently, empty or duplicate choices can be submitted. Please ensure question and all choices are non-empty, within length limits, and unique before creating the embed.

Comment on lines +26 to +36
descrip = emojis[i] + " " + choices[i]
descriptions.append(descrip)
message = "\n".join(descriptions) #combine all into one string


#description embed
embed = discord.Embed(
title = "Poll: " + question,
description = message,
#color = colors.POLL, #couldn't get it to work :( gave me errors
)
Copy link

Choose a reason for hiding this comment

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

issue (code-quality): Use f-string instead of string concatenation [×3] (use-fstring-for-concatenation)

@kaylee-xie kaylee-xie changed the title Onboarding kaylee [Feature] Code for 'poll' cog Jun 6, 2025
@kaylee-xie kaylee-xie changed the title [Feature] Code for 'poll' cog [Feature] Kaylee's Cog: Poll 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.

2 participants