Search code examples
javadiscord-jda

Why i don't have GuildMessageReceivedEvent?


I'm making discord bot and i need make a commands like "kick" but JDA has only MessageReceiveEvent. I checked in docs and its says in jda has GuildMessageReceiveEvent but code only says about MessageReceivedEvent.


Solution

  • GuildMessageReceiveEvent has been removed and replaced by MessageReceivedEvent in JDA 5+. To only handle guild messages you just check event.isFromGuild() in your event:

    public void onMessageReceived(MessageReceivedEvent event) {
      if (!event.isFromGuild()) return;
      ...
    }