【发布时间】:2021-02-02 11:39:41
【问题描述】:
当有人使用下面的代码添加对特定消息的反应时,我正在尝试创建一个 EventWaiter,但它似乎不起作用。我已经尝试修复每一个可能是错误的事情, 然而什么也没发生。 控制台上没有显示错误,似乎 eventwaiter 没有监听 MessageReactionAdd 类
private static final String EMOTE = "\uD83D\uDE39";
// send a message to Dm and starts the method
event.replyInDm("message", (message - > {
message.addReaction("\uD83D\uDD27").queue();
initWaiter(message.getIdLong(), channel);
}));
private void initWaiter(long messageId, PrivateChannel channel) {
// waiting for a specific reaction (EMOTE) in a message with the same id as the message above
waiter.waitForEvent(
MessageReactionAddEvent.class,
(e) - > {
MessageReaction.ReactionEmote emote = e.getReactionEmote();
assert user != null;
return e.getMessageIdLong() == messageId && EMOTE.equals(emote.getName()) && !emote.isEmote() && !user.isBot();
},
(e) - > {
// if the code above is true, this should happen, but it doesn't
assert channel != null;
channel.sendMessage("message").queue();
}
);
【问题讨论】:
标签: java discord discord-jda