Skip to content
Open
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
Empty file added a.py
Empty file.
47 changes: 47 additions & 0 deletions src/capy_app/frontend/cogs/onboarding/kaylee_onboarding_cog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import discord
import logging
from discord.ext import commands
from discord import app_commands

from frontend import config_colors as colors
from config import settings

#change everything with "Ping"
class KayleeCog(commands.Cog):
Comment on lines +9 to +10
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):

def __init__(self, bot: commands.Bot):
self.bot = bot
self.logger = logging.getLogger(
f"discord.cog.{self.__class__.__name__.lower()}"
)

@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.

choices = [choice_1, choice_2, choice_3]
emojis = ["1️⃣", "2️⃣", "3️⃣"]

#description string creation
descriptions = []
for i in range(3):
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.

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.

)
Comment on lines +26 to +36
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)

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.

await interaction.response.send_message(embed=embed) #replies to command with the embed

#adding emoji reactions for voting
msg = await interaction.original_response() #get the reply message
for i in range(3):
await msg.add_reaction(emojis[i]) #reacts to that msg with each emoji


async def setup(bot: commands.Bot):
await bot.add_cog(KayleeCog(bot))