Skip to content

Fix bot instantiation scope and simplify non-help embeds#18

Open
Copilot wants to merge 2 commits intomainfrom
copilot/fix-bot-instance-simplify-embeds
Open

Fix bot instantiation scope and simplify non-help embeds#18
Copilot wants to merge 2 commits intomainfrom
copilot/fix-bot-instance-simplify-embeds

Conversation

Copy link
Contributor

Copilot AI commented Jan 8, 2026

Bot instance was created inside setup_hook() method causing NameError when module-level decorators attempted to reference it. All embeds used complex ANSI cyberpunk styling making error messages and verdicts hard to read.

Changes

Bot instantiation

  • Moved bot = MyBot(...) from inside setup_hook() to module level after class definition
  • Resolves NameError from decorators executing before bot existed

Embed simplification

  • Replaced 6 embed functions with clean Discord embeds (verdict, multi-link, progress, result, error, ratelimit)
  • Removed 3 unused helper functions (make_cyberpunk_header, make_status_indicator, make_progress_bar)
  • Preserved cyberpunk styling in make_cyberpunk_help_embed() and make_compact_help_embed()

Before:

def error_embed(msg: str) -> discord.Embed:
    header = """```ansi
[1;31m╔═══════════════════════════════════════╗[0m
[1;31m║[0m  [1;37m⚠️  SYSTEM ERROR DETECTED[0m          [1;31m║[0m
[1;31m╚═══════════════════════════════════════╝[0m
```"""
    error_content = f"""```ansi
[2;31m>_[0m [1;31m[ERROR][0m [2;37m{msg[:200]}[0m

🔧 Action Required: Check your input and try again."""
return make_embed(title="", description=header + error_content, ...)


**After:**
```python
def error_embed(msg: str) -> discord.Embed:
    return make_embed(
        title="⚠️ Error",
        description=msg[:200],
        color=discord.Color.red(),
        footer="If this persists, contact an administrator"
    )

Impact

  • Bot starts without NameError
  • Error messages, link verdicts, and rate limits are readable
  • Help command retains ASCII art and terminal aesthetic
  • 120 lines removed (1940 → 1820)
Original prompt

🔧 Fix Bot Instance + Simplify Embeds (Keep Cyberpunk Only For Help)

Critical Issues

  1. Bot instance missing - Line 761 missing bot = MyBot(...) causing NameError: name 'bot' is not defined
  2. Over-styled embeds - All functions use complex cyberpunk ANSI styling, making them hard to read

Required Changes

1. Add Missing Bot Instance (CRITICAL)

After line 761 (logger.info(f"✅ Total commands synced: {len(synced_commands)}")), add:

bot = MyBot(command_prefix=get_prefix, intents=intents, help_command=None)

2. Keep Cyberpunk Theme ONLY For Help Command

KEEP these functions as-is:

  • make_cyberpunk_help_embed() (line 310)
  • make_compact_help_embed() (line 425)
  • show_help() command (line 1527)
  • command_info() command (line 1536)

3. Simplify All Other Embed Functions

Replace the complex ANSI-styled functions with simple Discord embeds:

Replace verdict_embed() (line 150):

def verdict_embed(link: str, verdict_text: str, reason: str, author_mention: str = "") -> discord.Embed:
    """Simple AI verdict embed"""
    if "Keep" in verdict_text or "Safe" in verdict_text:
        color = discord.Color.green()
    elif "Skip" in verdict_text or "Caution" in verdict_text:
        color = discord.Color.orange()
    elif "Unsafe" in verdict_text:
        color = discord.Color.red()
    else:
        color = discord.Color.blue()
    
    embed = discord.Embed(
        title="📎 Link Analysis",
        description=f"**{verdict_text}**\n{reason}\n\n`{link[:100]}{'...' if len(link) > 100 else ''}`",
        color=color
    )
    if author_mention:
        embed.set_footer(text=f"Analyzed for {author_mention}")
    embed.timestamp = datetime.datetime.utcnow()
    return embed

Replace multi_link_embed() (line 195):

def multi_link_embed(count: int) -> discord.Embed:
    """Simple multi-link selection prompt"""
    return make_embed(
        title=f"📎 {count} Links Found",
        description="Select the links you want to save using the dropdown menu below.\nYou can select multiple links.",
        color=discord.Color.gold(),
        footer="Tip: Choose only what you need for better organization"
    )

Replace summarize_progress_embed() (line 216):

def summarize_progress_embed(filename: str) -> discord.Embed:
    """Simple progress indicator"""
    return make_embed(
        title="📝 Summarizing Document",
        description=f"Working on **{filename}**… this may take a few seconds.",
        color=discord.Color.blue(),
        footer="AI summarization in progress"
    )

Replace summarize_result_embed() (line 242):

def summarize_result_embed(filename: str, body: str, requester: str) -> discord.Embed:
    """Simple summary output"""
    return make_embed(
        title=f"📝 Summary: {filename}",
        description=body[:3500] if len(body) > 3500 else body,
        color=discord.Color.green(),
        footer=f"Summarized for {requester} • AI-powered"
    )

Replace error_embed() (line 262):

def error_embed(msg: str) -> discord.Embed:
    """Simple error message"""
    return make_embed(
        title="⚠️ Error",
        description=msg[:200],
        color=discord.Color.red(),
        footer="If this persists, contact an administrator"
    )

Replace ratelimit_embed() (line 284):

def ratelimit_embed(wait_s: float) -> discord.Embed:
    """Simple cooldown message"""
    return make_embed(
        title="⏳ Cooldown Active",
        description=f"Please wait **{wait_s:.1f}s** before using this again.\n\nThis prevents spam and keeps the bot responsive.",
        color=discord.Color.orange(),
        footer="Rate limit protection"
    )

4. Remove Unused Helper Functions

Delete these functions (no longer needed):

  • make_cyberpunk_header() (line 90)
  • make_status_indicator() (line 102)
  • make_progress_bar() (line 117)

5. Update make_embed()

Keep it simple (line 128):

def make_embed(
    title: str,
    description: str = "",
    color: discord.Color = discord.Color.blurple(),
    footer: str = "",
    fields: Optional[List[Dict[str, str]]] = None,
) -> discord.Embed:
    """Simple embed builder"""
    embed = discord.Embed(title=title[:256], description=description[:4000], color=color)
    if fields:
        for f in fields:
            embed.add_field(
                name=f.get("name", "")[:256],
                value=f.get("value", "")[:1024],
                inline=f.get("inline", False),
            )
    if footer:
        embed.set_footer(text=footer[:2048])
    embed.timestamp = datetime.datetime.utcnow()
    return embed

Expected Result

After these changes:

  1. ✅ Bot starts without NameError
  2. /help command shows beautiful cyberpunk theme
  3. ✅ All other embeds are clean, simple Discord embeds
  4. ✅ Error messages, link verdicts, rate limits are readable
  5. ✅ File size reduced by ~200 lines

Testing

1...

This pull request was created from Copilot chat.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI self-assigned this Jan 8, 2026
@Rajrooter Rajrooter marked this pull request as ready for review January 8, 2026 23:30
@qodo-code-review
Copy link

PR Code Suggestions ✨

No code suggestions found for the PR.

Co-authored-by: Rajrooter <128113526+Rajrooter@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix bot instance and simplify embed functions Fix bot instantiation scope and simplify non-help embeds Jan 8, 2026
Copilot AI requested a review from Rajrooter January 8, 2026 23:42
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