Skip to content

Add guild message support and configuration to video_dl cog#138

Merged
psykzz merged 2 commits intomainfrom
claude/add-video-dl-command-guild-messages
Apr 16, 2026
Merged

Add guild message support and configuration to video_dl cog#138
psykzz merged 2 commits intomainfrom
claude/add-video-dl-command-guild-messages

Conversation

@Claude
Copy link
Copy Markdown
Contributor

@Claude Claude AI commented Apr 16, 2026

Summary

This PR extends the video_dl cog to support automatic video downloads in guild channels with configurable permissions, in addition to the existing DM functionality for bot owners.

Changes

Core Features

  • Config System: Added Red-bot Config system to store per-guild settings:

    • Guild enabled/disabled status (default: disabled)
    • Per-channel disabled list (default: all channels enabled)
    • Per-user disabled list (default: all users enabled)
  • Permission Hierarchy:

    • Guilds are disabled by default (must be manually enabled per server)
    • Once enabled, all channels and users are allowed by default
    • Admins can disable specific channels or users as needed

Commands Added

Manual Download Command

  • [p]download <url> - Manually download a video from a URL
    • Shows error messages when download fails
    • Works for any user in any context
    • Ephemeral responses to reduce clutter

Configuration Commands (Admin only)

All commands require manage_guild permission:

  • [p]videodl enable - Enable automatic downloads for the server
  • [p]videodl disable - Disable automatic downloads for the server
  • [p]videodl channelenable [channel] - Enable automatic downloads in a channel
  • [p]videodl channeldisable [channel] - Disable automatic downloads in a channel
  • [p]videodl userenable <user> - Enable automatic downloads for a user
  • [p]videodl userdisable <user> - Disable automatic downloads for a user
  • [p]videodl status - Show current configuration

Behavior Changes

  • Automatic Downloads: Now work in guild channels (when enabled) in addition to DMs
  • Error Handling: Automatic downloads suppress error messages (fail silently) to avoid spam
  • DM Behavior: Unchanged - still works for bot owner only in DMs

Technical Details

  • Updated imports to include Config and checks from redbot.core
  • Added _can_download_in_guild() method for permission checking
  • Updated on_message listener to handle both DMs and guild messages
  • All new commands use hybrid commands (work as both text and slash commands)
  • All commands use ephemeral responses for privacy

Documentation Updates

  • Updated cog docstring to reflect new functionality
  • Updated info.json description
  • Updated __init__.py data statement to reflect stored configuration data

Testing

  • ✅ Python syntax validation passed
  • ✅ Flake8 linting passed with zero errors
  • ✅ All code follows repository conventions (hybrid commands, ephemeral responses, NumPy-style docstrings)

@psykzz psykzz marked this pull request as ready for review April 16, 2026 11:15
@psykzz
Copy link
Copy Markdown
Owner

psykzz commented Apr 16, 2026

@copilot fix tests, and make it so only the bot owner can update if the cog can run in a server / guild

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 16, 2026

@copilot fix tests, and make it so only the bot owner can update if the cog can run in a server / guild

Done in c2d6427.

Bot owner restriction: videodl enable and videodl disable now require @checks.is_owner(). The channel/user subcommands keep @checks.admin_or_permissions(manage_guild=True) for server admins.

Tests fixed: The failing test_ignore_guild_messages was caused by MockMessage lacking a guild attribute and the Config mock not supporting await. Added a _make_guild_config_mock() helper with proper AsyncMock support, updated the cog fixture to inject it, and renamed the test to test_ignore_guild_messages_when_disabled. Also added 3 new tests covering guild-enabled, disabled-channel, and disabled-user cases. All 23 tests pass.

Copilot AI requested a review from psykzz April 16, 2026 11:24
@psykzz psykzz merged commit d40a066 into main Apr 16, 2026
3 checks passed
@psykzz psykzz deleted the claude/add-video-dl-command-guild-messages branch April 16, 2026 15:01
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