Skip to content

Suppress embeds from original message after successful video download#140

Merged
psykzz merged 3 commits intomainfrom
claude/validate-remove-embed-from-posts
Apr 17, 2026
Merged

Suppress embeds from original message after successful video download#140
psykzz merged 3 commits intomainfrom
claude/validate-remove-embed-from-posts

Conversation

@Claude
Copy link
Copy Markdown
Contributor

@Claude Claude AI commented Apr 17, 2026

When the bot successfully downloads and replies with a video, the original message's auto-generated embed (from Discord's URL preview) remains visible, creating redundant content. This PR adds automatic embed suppression to clean up the channel after successful downloads.

Changes

  • Permission check: Added _can_manage_messages() helper to verify bot has manage_messages permission
  • Embed suppression: Call message.edit(suppress=True) after successful video replies (both direct upload and catbox.moe fallback)
  • Error handling: Gracefully ignore suppression failures (missing permissions, already suppressed, etc.)

Implementation

await message.reply(
    content=f"Downloaded from {platform.title()}:",
    file=discord.File(file_path)
)
# Remove the original URL embed if bot has permission
if self._can_manage_messages(message.channel):
    try:
        await message.edit(suppress=True)
    except discord.HTTPException:
        pass

Requires the bot to have manage_messages permission in the channel. Suppression is only attempted after a successful download reply, and failures are silently ignored to avoid disrupting the primary download functionality.

- Add _can_manage_messages() helper to check for manage_messages permission
- Suppress embeds from original message after successful video reply (both direct upload and catbox.moe)
- Only suppress if bot has manage_messages permission
- Gracefully handle errors if embed suppression fails

Agent-Logs-Url: https://github.com/psykzz/cogs/sessions/c5512bc1-6dd7-4d1b-8cca-5bc4f3e9aa04

Co-authored-by: psykzz <1134201+psykzz@users.noreply.github.com>
Comment thread video_dl/video_dl.py Outdated
Comment on lines +300 to +305
if self._can_manage_messages(message.channel):
try:
await message.edit(suppress=True)
except discord.HTTPException:
# Ignore errors (e.g., message already has no embeds)
pass
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@copilot extract this into a "remove_embed" function to avoid repetition.

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.

Extracted into _remove_embed(message) in 59bbd92. Both the direct upload and catbox fallback paths now call this single helper instead of duplicating the permission check + message.edit(suppress=True) logic.

Copilot AI requested a review from psykzz April 17, 2026 09:20
@psykzz psykzz marked this pull request as ready for review April 17, 2026 09:27
@psykzz
Copy link
Copy Markdown
Owner

psykzz commented Apr 17, 2026

@copilot fix tests - also make it a requirement for every PR going forward, all tests and status checks must pass.

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 17, 2026

@copilot fix tests - also make it a requirement for every PR going forward, all tests and status checks must pass.

Fixed in 0c900ad. The test_process_guild_messages_when_enabled test was failing because MockGuildChannel lacked permissions_for() (needed by _can_manage_messages) and MockMessage lacked edit() (needed by _remove_embed). Added MockPermissions, permissions_for() to MockGuildChannel, and edit() to MockMessage. All 99 tests now pass.

@psykzz psykzz merged commit cd1188c into main Apr 17, 2026
3 checks passed
@psykzz psykzz deleted the claude/validate-remove-embed-from-posts branch April 17, 2026 09:32
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.

3 participants