-
-
Notifications
You must be signed in to change notification settings - Fork 738
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
Restructure message creation to handle a lack of guild_id #2039
Conversation
…ack of guild_id on messages.
src/main/java/net/dv8tion/jda/internal/entities/EntityBuilder.java
Outdated
Show resolved
Hide resolved
message = isGuild | ||
? jda.getEntityBuilder().createMessageGuildChannel(content, true) | ||
: jda.getEntityBuilder().createMessagePrivateChannel(content, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add createMessage(content, isGuild, true)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah, I think the little bit of dupe we have that does this ternary is fine for now.
This PR should also add an implementation for |
Pull Request Etiquette
Changes
Closes Issue: NaN
Description
Discord does not provide
guild_id
on message objects. We only ever get this property on messages when they come over the Websocket Gateway. However, historically, JDA has been written to expect it and we've gotten lucky that nothing broke.Recently we made a change to enforce nullability of
getUser
onPrivateChannel
and restructured some code to enable this along with filling in the data whenever we receive it, which happens to happen onMESSAGE_CREATE
. This has revealed our erroneous reliance onguild_id
in non-gateway situations.This PR restructured the EntityBuilder to enforce upon developers of JDA's internal code that they must either have a channel instance or define if the channel is guild or private when building a message. This makes explicit the methodologies used to determine
isGuild
instead of relying on a typically-missingguild_id
json property.