🐛 JDA: Fix webhook messages throwing NPE (#214)
* Fix NPE with webhook messages. Webhook messages would be constructed as `JDAGuildSender`, which calls `Objects.requireNonNull(event.getMember())` however the JDA documentation states that the `getMember()` method will `be null in case of Message being received in a PrivateChannel or isWebhookMessage() returning true.` If the message is a webhook message, a generic `JDACommandSender` instance will be constructed instead of a `JDAGuildSender` * Add webhook fix to changelog
This commit is contained in:
parent
5dd925a8d1
commit
09f8dbd956
2 changed files with 4 additions and 2 deletions
|
|
@ -66,7 +66,9 @@ public class JDACommandSender {
|
|||
* @return Constructed JDA Command Sender
|
||||
*/
|
||||
public static @NonNull JDACommandSender of(final @NonNull MessageReceivedEvent event) {
|
||||
if (event.isFromType(ChannelType.PRIVATE)) {
|
||||
if (event.isWebhookMessage()) {
|
||||
return new JDACommandSender(event, event.getAuthor(), event.getChannel());
|
||||
} else if (event.isFromType(ChannelType.PRIVATE)) {
|
||||
return new JDAPrivateSender(event, event.getAuthor(), event.getPrivateChannel());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue