Skip to content

feat(discord): add native send_animation for inline GIF playback#10272

Closed
sprmn24 wants to merge 1 commit into
NousResearch:mainfrom
sprmn24:feat/discord-send-animation
Closed

feat(discord): add native send_animation for inline GIF playback#10272
sprmn24 wants to merge 1 commit into
NousResearch:mainfrom
sprmn24:feat/discord-send-animation

Conversation

@sprmn24

@sprmn24 sprmn24 commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds a send_animation override to the Discord platform adapter so that animated GIFs are sent as native Discord file attachments and auto-play inline, instead of falling back to send_image.

Telegram already has this override. Discord's base class fallback sends GIFs through send_image, which works but loses the animation context. Discord's CDN serves GIF attachments with the correct MIME type when the filename ends in .gif, triggering the client's native animation renderer. Without this override, GIFs sent via send_image are uploaded as image.gif but without the animation context path — this override ensures the file is explicitly named animation.gif and routed through the animation code path.

Type of Change

  • New feature (non-breaking addition)

Changes Made

  • Added send_animation method to DiscordPlatform in gateway/platforms/discord.py
  • Downloads GIF from animation_url via aiohttp using the same proxy pattern as send_image
  • Sends as discord.File with filename="animation.gif" so Discord renders it as an auto-playing animation
  • Safety check via is_safe_url before any network call
  • Graceful fallback to super().send_animation() on ImportError or any exception

How to Test

  1. Configure a Discord gateway bot
  2. Ask Hermes to send a GIF URL (e.g. https://media.giphy.com/media/3o7abKhOpu0NwenH3O/giphy.gif)
  3. Confirm the GIF appears inline and auto-plays in Discord (not as a static image or plain URL)

Checklist

  • Code follows project style (matches send_image pattern exactly)
  • No new dependencies (aiohttp already used in send_image)
  • Fallbacks handled gracefully

@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #10283. Your commit was cherry-picked onto current main with your authorship preserved in git log. Thanks for the clean contribution @sprmn24!

@sprmn24

sprmn24 commented Apr 15, 2026

Copy link
Copy Markdown
Contributor Author

thanks, glad it was clean enough to cherry-pick directly 🙏

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