-
-
Notifications
You must be signed in to change notification settings - Fork 737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MessageUpdated sometimes returns a null SocketMessage if MessageCacheSize == 0 #1208
Comments
The |
Good point, I'll have to implement a check for that - but I still think it should be made clearer, as the docs and event args imply the |
That has never been the behavior of
|
The Perhaps the solution, then, is to make the second argument a type similar to |
I was seeing an issue where
MessageUpdated
was occasionally giving me a null arg2 (theSocketMessage
), and was able to reproduce it (on the latest version) by sending a message with a URL for which Discord generates an embed automatically - such as https://github.com/RogueException/Discord.Net - but, notably, only whenMessageCacheSize
is0
; MessageUpdated's arg2 will never be null if the cache is enabled.This seems to due to the fact that the
MESSAGE_UPDATE
gateway event, if updating a message to add an embed, doesn't contain author data - and the check onDiscordSocketClient.cs#1221
will only create a "detached"SocketMessage
if the author is present. TheSocketMessage
passed to the event onDiscordSocketClient.cs#1212
,after
, remains null - as withoutMessageCacheSize
being set, the call tochannel.GetCachedMessage
will always return null.According to the documentation (and messages on DAPI), the presence of
MessageCacheSize
should only affect arg1 ofMessageUpdated
, but it seems that it indirectly affects both. I'm not sure what the best solution is in this case, but perhaps the"MESSAGE_UPDATE"
case could be modified to return a SocketMessage with missing properties (or a less derived type that matches better). This would at least match the functionality described in Discord's API docs:Of course, the solution for now is just "Set
MessageCacheSize
", but I still think the event should return, at minimum, what the Discord API does (message and channel IDs).The text was updated successfully, but these errors were encountered: