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.
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
inInteraction.send
after message is sent
- Set to
- New variable on
InteractionResponse
->self.has_been_deferred: bool = False
- Set to
True
inInteractionResponse.defer
- Set to
- New property
- New variable on
- Hooks into the
- 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:
- After
data: gateway.GatewayBot = await self.request(Route("GET", "/gateway/bot"))
inget_bot_gateway
- After
- Logs session related information to console with log level
disnake.Guild.icon.url
erroring whenicon
isNone
- 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 todisnake.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
- Due to the lack of guild intents, using
- Added
__eq__
todisnake.Embed
- This is used primarily within tests
- This includes
__eq__
onEmbedProxy
otherwise they compare as False - Note: This now returns
None
on disnake2.8.0
and older
- Heavily modified guild caching in relation to suggestionsbot#24
- Introduced the variable
guild_ids
- Disabled the guild cache even with enabled guild intents
- Change
state._add_guild_from_data
to not create and cache a guild object - See commit https://github.com/suggestionsbot/disnake/commit/a21e761d72bba13af1f834f7f5b18724ea9ce0f5
- Introduced the variable
- Process crashes due to
Intents.none()
with relation to interactionsdiscord.py
, and by extensiondisnake
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:
- Prematurely return from
disnake.abc._fill_overwrites
before it hitseveryone_id = self.guild.id
- Prematurely return from
- 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 ondiscord.Object
objects due toIntents.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 adisnake.Object
instance, despite requiringdisnake.Guild
as subsequent usage after existence checks calldisnake.Guild.get_thread
- Implementation details:
- Modify
disnake.Message.thread
to the following
- Modify
- Related issues: DisnakeDev/disnake#699
- On suggestions with un-cached guilds, if they have a thread it can result in an error as the existence check for
- Removed the
MessageContentPrefixWarning
as it would trip due to inheritance of the bot base AttributeError
's ondiscord.Object
wherediscord.Guild
was expected.- This is the same as "
AttributeError
's ondiscord.Object
objects due toIntents.none()
" - Implementation details
- Related issue: DisnakeDev/disnake#712
- This is the same as "
- 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
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.