feat(snippets): change snippet command behavior by pawbtism · Pull Request #875 · allthingslinux/tux · GitHub
Skip to content
This repository was archived by the owner on May 14, 2026. It is now read-only.

feat(snippets): change snippet command behavior#875

Merged
anemoijereja-eden merged 4 commits into
allthingslinux:mainfrom
pawbtism:reply-snippet
Jun 1, 2025
Merged

feat(snippets): change snippet command behavior#875
anemoijereja-eden merged 4 commits into
allthingslinux:mainfrom
pawbtism:reply-snippet

Conversation

@pawbtism

@pawbtism pawbtism commented May 30, 2025

Copy link
Copy Markdown
Contributor

Description

resolves #870 and changes snippet behavior to reply to the command

Guidelines

  • My code follows the style guidelines of this project (formatted with Ruff)

  • I have performed a self-review of my own code

  • I have commented my code, particularly in hard-to-understand areas

  • I have made corresponding changes to the documentation if needed

  • My changes generate no new warnings

  • I have tested this change

  • Any dependent changes have been merged and published in downstream modules

  • I have added all appropriate labels to this PR

  • I have followed all of these guidelines.

How Has This Been Tested? (if applicable)

locally hosted and tested in ATL's dev server

Summary by Sourcery

Enhancements:

  • Change snippet command to reply to the invoking or referenced message instead of sending a standalone message.

@sourcery-ai

sourcery-ai Bot commented May 30, 2025

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey @CapnRyna - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 2 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 thread tux/cogs/snippets/get_snippet.py Outdated
Comment thread tux/cogs/snippets/get_snippet.py Outdated

@HikariNee HikariNee left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good.

@jakobdylanc

jakobdylanc commented Jun 1, 2025

Copy link
Copy Markdown
Contributor

# pagination if text > 2000 characters
if len(text) <= 2000:
# Check if there is a message being replied to
if ctx.message.reference and ctx.message.reference.resolved:
reference = ctx.message.reference.resolved
if isinstance(reference, Message):
await reference.reply(text, allowed_mentions=AllowedMentions.none())
else:
await ctx.reply(text, allowed_mentions=AllowedMentions.none())
else:
await ctx.reply(text, allowed_mentions=AllowedMentions.none())
return

This can be simplified to just:

# pagination if text > 2000 characters
if len(text) <= 2000:
    # Check if there is a message being replied to
    reference = getattr(ctx.message.reference, "resolved", None)
    reply_target = reference if isinstance(reference, Message) else ctx

    await reply_target.reply(text, allowed_mentions=AllowedMentions.none())
    return

@anemoijereja-eden

Copy link
Copy Markdown
Contributor

@anemoijereja-eden anemoijereja-eden merged commit 43c1e05 into allthingslinux:main Jun 1, 2025
1 check passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add reply to snippets

4 participants