Skip to content

Latest commit

 

History

History
71 lines (59 loc) · 4.85 KB

library_modifications.md

File metadata and controls

71 lines (59 loc) · 4.85 KB

We use a custom fork of Disnake with some added features + fixes as detailed here.

This mainly exists such that if we wish to upgrade from say, 2.5.x -> 2.6.x we know exactly what things require porting.


Features

  • Interaction.deferred_without_send -> bool
    • Hooks into the Interaction object to see if a given interaction has been differed without a follow-up send occurring. We do this as we need to clean up after the bot in the case an error occurs otherwise our users will simply get "Interaction failed to respond" which is not ideal
    • Implementation details:
      • New variable on Interaction -> self.has_been_followed_up: bool = False
        • Set to True in Interaction.send after message is sent
      • New variable on InteractionResponse -> self.has_been_deferred: bool = False
        • Set to True in InteractionResponse.defer
      • New property
  • Show gateway session on initial startup
    • Logs session related information to console with log level WARNING to avoid being suppressed or needing special handling to show. (Anything lower is suppressed bot side.)
    • Implementation details:
  • disnake.Guild.icon.url erroring when icon is None
    • Due to the lack of guild intents, using disnake.Guild.icon.url requires guarding to ensure we can actually use the icon. A similar port will also likely be applied to disnake.User sooner or later.
    • Fixed by adding a new method disnake.Guild.try_fetch_icon_url
    • I consider this one a feature due to the nature of the fix.
    • Related issues: suggestionsbot#3
    • https://workbin.dev/?id=1676113402913198
  • Added __eq__ to disnake.Embed
    • This is used primarily within tests
    • This includes __eq__ on EmbedProxy otherwise they compare as False
    • Note: This now returns None on disnake 2.8.0 and older
  • Heavily modified guild caching in relation to suggestionsbot#24

Fixes

  • Process crashes due to Intents.none() with relation to interactions
    • discord.py, and by extension disnake are built around the idea of at-least having the guilds intent. In this case, a lack of guild objects results in a reproducible process crash for the bot handling the interaction.
    • Implementation details:
    • Note, the fix detailed here and the fix applied to disnake itself are different. We don't care for overwrites at this time, and we have not rebased against upstream since the relevant patches were applied.
  • AttributeError's on discord.Object objects due to Intents.none()
    • On suggestions with un-cached guilds, if they have a thread it can result in an error as the existence check for self.guild will be truthy even with a disnake.Object instance, despite requiring disnake.Guild as subsequent usage after existence checks call disnake.Guild.get_thread
    • Implementation details:
    • Related issues: DisnakeDev/disnake#699
  • Removed the MessageContentPrefixWarning as it would trip due to inheritance of the bot base
  • AttributeError's on discord.Object where discord.Guild was expected.
  • Move thread caching onto Message
    • Due to our intents, threads on messages were not being cached correctly which meant features didnt work
    • Fix: Move caching of message.thread onto the message itself

Notes

On startup even with Intents.none() we still receive partial guilds, noted as unavailable (or something like that). This allows for partial cache hits and explains the inconsistencies of bug reproduction as we require a guild who invited the bot during runtime as the first reproduction step.

Versions are bumped to overcome some CI caching issues.

We don't follow or publish to upstream, a shame I know. Security issues however (such as process crashing) are noted exceptions and dealt with on a case by case basis.