为什么我没有 GuildMessageReceivedEvent?

Why i don't have GuildMessageReceivedEvent?

我正在制作 discord 机器人,我需要发出像“踢”这样的命令,但 JDA 只有 MessageReceiveEvent。我检查了文档,它在 jda 中说有 GuildMessageReceiveEvent,但代码只说了 MessageReceivedEvent。

GuildMessageReceiveEvent 已在 JDA 5+ 中被删除并替换为 MessageReceivedEvent。要仅处理公会消息,您只需在活动中检查 event.isFromGuild()

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