Skip to content
This repository was archived by the owner on Jan 13, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 1 commit
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.
39 changes: 39 additions & 0 deletions src/capy_app/frontend/cogs/onboarding/elias_onboarding_cog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
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


class EliasCog(commands.Cog):
Copy link

Choose a reason for hiding this comment

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

issue (complexity): Consider refactoring the command into a standalone function without a Cog, custom logger, or unused mappings to simplify the implementation.

You can simplify this to a single `@app_commands.command` (no Cog, no custom logger, no unused mapping) while preserving all behavior:

```python
# commands/rps.py

import discord
from discord import app_commands
from discord.ext import commands
from config import settings
from frontend.config_colors import PING as PING_COLOR

@app_commands.guilds(discord.Object(settings.DEBUG_GUILD_ID))
@app_commands.command(name="rps", description="Plays Rock Paper Scissors with the bot")
async def rps(interaction: discord.Interaction):
    embed = discord.Embed(
        title="Rock Paper Scissors",
        description="Choose your reaction",
        color=PING_COLOR,
    )
    await interaction.response.send_message(embed=embed)
    # Grab the sent message and add reactions
    message = await interaction.original_response()
    for emoji in ("🪨", "📄", "✂️", "", ""):
        await message.add_reaction(emoji)

Steps to apply:

  1. Drop the EliasCog class and setup function entirely.
  2. Create a new module (commands/rps.py) with the above code.
  3. Ensure your bot’s startup loads commands/rps.py (e.g. via bot.tree.copy_global_to(guild=...) or your existing command loader).
  4. Remove the unused status_emojis dict and custom logger import.

This keeps the slash-command, the embed, and the reactions, with far less indirection.

def __init__(self, bot: commands.Bot):
self.bot = bot
self.logger = logging.getLogger(
f"discord.cog.{self.__class__.__name__.lower()}"
)
self.status_emojis = {
"🪨": "Rock",
"": "Paper",
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): Empty string emoji key for Paper

Replace the empty string key with an appropriate emoji (e.g., 📄) or add logic to handle missing keys.

"✂️": "Scissors",
"⭐": "Won",
"❌": "Lost",
}
@app_commands.guilds(discord.Object(id=settings.DEBUG_GUILD_ID))
@app_commands.command(name="RPS", description="Plays Rock Paper Scissors with the bot!", )
async def ping(self, interaction: discord.Interaction, arg1):
Copy link

Choose a reason for hiding this comment

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

suggestion: Command name and handler name mismatched

Please rename the handler and embed title to consistently reference Rock Paper Scissors.

Copy link

Choose a reason for hiding this comment

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

suggestion: Unused argument arg1

Remove arg1 if it's unnecessary, or rename it if it will be used later.

for emoji in self.status_emojis.keys():
await message.add_reaction(emoji)
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): Reacting before message is defined

message must be defined (sent or fetched) before you can add reactions to it. Move the reaction loop after the message is created.

message = f"Choose your reaction"
Copy link

Choose a reason for hiding this comment

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

suggestion (code-quality): Replace f-string with no interpolated values with string (remove-redundant-fstring)

Suggested change
message = f"Choose your reaction"
message = "Choose your reaction"

embed = discord.Embed(
title="Ping",
description=message,
color=colors.PING,
Copy link

Choose a reason for hiding this comment

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

suggestion: Using PING color for RPS embed

Consider adding a specific RPS color to config_colors for clarity instead of reusing colors.PING.

Suggested implementation:

        embed = discord.Embed(
            title="Ping",
            description=message,
            color=colors.RPS,
        )

You must also add a new color constant for RPS in your colors or config_colors module, for example:

RPS = 0x3498db  # Choose an appropriate hex color code

and ensure it is imported where this file uses colors.

)
self.logger.info(message)
await interaction.response.send_message(embed=embed)


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