本文整理汇总了Java中net.dv8tion.jda.core.events.message.react.MessageReactionAddEvent类的典型用法代码示例。如果您正苦于以下问题:Java MessageReactionAddEvent类的具体用法?Java MessageReactionAddEvent怎么用?Java MessageReactionAddEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MessageReactionAddEvent类属于net.dv8tion.jda.core.events.message.react包,在下文中一共展示了MessageReactionAddEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupStepFour
import net.dv8tion.jda.core.events.message.react.MessageReactionAddEvent; //导入依赖的package包/类
public static void setupStepFour(MessageReactionAddEvent event) {
Message message = event.getTextChannel().getMessageById(event.getMessageId()).complete();
VerificationSettings settings = settingslist.get(event.getGuild());
MessageReaction.ReactionEmote emote = event.getReactionEmote();
//System.out.println(event.getReactionEmote().getEmote().isManaged());
if(!event.getReactionEmote().getEmote().isManaged()){
if(!event.getGuild().getEmotes().contains(emote.getEmote())) {
message.getTextChannel().sendMessage(EmbedUtil.error("Unsupported emote", "You can only use global or custom emotes of your server").build()).queue(msg -> msg.delete().queueAfter(5, TimeUnit.SECONDS));
return;
}
}
settings.emote = emote;
settingslist.replace(event.getGuild(), settings);
message.editMessage(EmbedUtil.info("Step 5 - Verified role", "Please type in the emote that should be reacted by users when acceptings rules").build()).queue();
VerificationSetup setup = setups.get(message.getGuild());
setup.step++;
setups.replace(message.getGuild(), setup);
event.getReaction().removeReaction(event.getUser()).queue();
}
示例2: pagination
import net.dv8tion.jda.core.events.message.react.MessageReactionAddEvent; //导入依赖的package包/类
private void pagination(Message message, int pageNum)
{
waiter.waitForEvent(MessageReactionAddEvent.class, (MessageReactionAddEvent event) -> {
if(!event.getMessageId().equals(message.getId()))
return false;
if(!(LEFT.equals(event.getReactionEmote().getName())
|| STOP.equals(event.getReactionEmote().getName())
|| RIGHT.equals(event.getReactionEmote().getName())))
return false;
return isValidUser(event.getUser(), event.getGuild());
}, event -> {
int newPageNum = pageNum;
switch(event.getReactionEmote().getName())
{
case LEFT: if(newPageNum>1) newPageNum--; break;
case RIGHT: if(newPageNum<urls.size()) newPageNum++; break;
case STOP: finalAction.accept(message); return;
}
try{event.getReaction().removeReaction(event.getUser()).queue();}catch(PermissionException e){}
int n = newPageNum;
message.editMessage(renderPage(newPageNum)).queue(m -> {
pagination(m, n);
});
}, timeout, unit, () -> finalAction.accept(message));
}
示例3: pagination
import net.dv8tion.jda.core.events.message.react.MessageReactionAddEvent; //导入依赖的package包/类
private void pagination(Message message, int pageNum)
{
waiter.waitForEvent(MessageReactionAddEvent.class, (MessageReactionAddEvent event) -> {
if(!event.getMessageId().equals(message.getId()))
return false;
if(!(LEFT.equals(event.getReactionEmote().getName())
|| STOP.equals(event.getReactionEmote().getName())
|| RIGHT.equals(event.getReactionEmote().getName())))
return false;
return isValidUser(event.getUser(), event.getGuild());
}, event -> {
int newPageNum = pageNum;
switch(event.getReactionEmote().getName())
{
case LEFT: if(newPageNum>1) newPageNum--; break;
case RIGHT: if(newPageNum<pages) newPageNum++; break;
case STOP: finalAction.accept(message); return;
}
try{event.getReaction().removeReaction(event.getUser()).queue();}catch(PermissionException e){}
int n = newPageNum;
message.editMessage(renderPage(newPageNum)).queue(m -> {
pagination(m, n);
});
}, timeout, unit, () -> finalAction.accept(message));
}
示例4: onEvent
import net.dv8tion.jda.core.events.message.react.MessageReactionAddEvent; //导入依赖的package包/类
@Override
public void onEvent(Event e) {
super.onEvent(e);
if(e instanceof MessageReactionAddEvent) {
MessageReactionAddEvent event = ((MessageReactionAddEvent) e);
if(event.getMessageId().equals(messageId)
&& !event.getUser().equals(getJda().getSelfUser())) {
try {
sleep(1500);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
event.getReaction().removeReaction(getJda().getUserById("93721838093352960"));
}
}
}
示例5: onMessageReactionAdd
import net.dv8tion.jda.core.events.message.react.MessageReactionAddEvent; //导入依赖的package包/类
@Override
public void onMessageReactionAdd(MessageReactionAddEvent event)
{
super.onMessageReactionAdd(event);
if (event.getUser().isBot())
{
return;
}
event.getChannel().getMessageById(event.getMessageId()).queue((message) -> {
Role role = getRole(message, event.getReaction());
Guild guild = message.getGuild();
if (role == null)
{
return;
}
guild.getController().addRolesToMember(guild.getMember(event.getUser()), role).queue();
});
}
示例6: fired
import net.dv8tion.jda.core.events.message.react.MessageReactionAddEvent; //导入依赖的package包/类
@Override
public default Object fired(Object... data) {
final MessageType messageType = (MessageType) data[1];
switch (messageType) {
case RECEIVED:
return onMessageReceived((MessageEvent) data[0]);
case UPDATED:
return onMessageUpdate((MessageUpdateEvent) data[0]);
case DELETED:
return onMessageDelete((MessageDeleteEvent) data[0]);
case BULK_DELETED:
return onMessageBulkDelete((MessageBulkDeleteEvent) data[0]);
case EMBEDED:
return onMessageEmbed((MessageEmbedEvent) data[0]);
case REACTION_ADDED:
return onMessageReactionAdd((MessageReactionAddEvent) data[0]);
case REACTION_REMOVED:
return onMessageReactionRemove((MessageReactionRemoveEvent) data[0]);
case REACTION_REMOVED_ALL:
return onMessageReactionRemoveAll((MessageReactionRemoveAllEvent) data[0]);
default:
return false;
}
}
示例7: onMessageReactionAdd
import net.dv8tion.jda.core.events.message.react.MessageReactionAddEvent; //导入依赖的package包/类
@Override
public final void onMessageReactionAdd(MessageReactionAddEvent event) {
final Object[] output = ListenerManager.fireListeners(MessageListener.class, CommandHandler.ADMIN_PREDICATE, new Object[]{event, MessageType.REACTION_ADDED});
if (DEBUG && output.length > 0) {
System.out.println(String.format("%d plugin%s used this message event: %s", output.length, (output.length == 1 ? "" : "s"), event));
}
}
示例8: deleteChannel
import net.dv8tion.jda.core.events.message.react.MessageReactionAddEvent; //导入依赖的package包/类
public static void deleteChannel(VoiceChannel channel, Message message, MessageReactionAddEvent event) {
String oldEntry = RubiconBot.getMySQL().getGuildValue(event.getGuild(), "autochannels");
String newEntry = oldEntry.replace(channel.getId() + ",", "");
RubiconBot.getMySQL().updateGuildValue(event.getGuild(), "autochannels", newEntry);
message.editMessage(EmbedUtil.success("Deleted channel", "Autochannel " + channel.getName() + " successfully removed").build()).complete();
new Timer().schedule(new TimerTask() {
@Override
public void run() {
message.delete().queue();
}
}, 5000);
channel.delete().queue();
}
示例9: handleReaction
import net.dv8tion.jda.core.events.message.react.MessageReactionAddEvent; //导入依赖的package包/类
public static void handleReaction(MessageReactionAddEvent e) {
if (awaitingConfirm.containsKey(e.getMessageIdLong())) {
if (e.getReactionEmote().getName().equals("✅") && e.getUser() != e.getJDA().getSelfUser()) {
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setAuthor("Message from developers!", null, e.getJDA().getSelfUser().getEffectiveAvatarUrl());
embedBuilder.setDescription(awaitingConfirm.get(e.getMessageIdLong()));
embedBuilder.setColor(Colors.COLOR_ERROR);
List<Long> sentOwners = new ArrayList<>();
for (Guild guild : e.getJDA().getGuilds()) {
if (!sentOwners.contains(guild.getOwner().getUser().getIdLong())) {
guild.getOwner().getUser().openPrivateChannel().queue(privateChannel -> privateChannel.sendMessage(embedBuilder.build()).queue());
sentOwners.add(guild.getOwner().getUser().getIdLong());
}
}
}
awaitingConfirm.remove(e.getMessageIdLong());
e.getTextChannel().deleteMessageById(e.getMessageId()).queue();
}
}
示例10: onMessageReactionAdd
import net.dv8tion.jda.core.events.message.react.MessageReactionAddEvent; //导入依赖的package包/类
@Override
public void onMessageReactionAdd(MessageReactionAddEvent event) {
if (event.getUser().equals(RubiconBot.getJDA().getSelfUser()))
return;
CommandVote.reactVote(event);
CommandBroadcast.handleReaction(event);
CommandAutochannel.handleReaction(event);
CommandVerification.handleReaction(event);
}
示例11: onMessageReactionAdd
import net.dv8tion.jda.core.events.message.react.MessageReactionAddEvent; //导入依赖的package包/类
@Override
public void onMessageReactionAdd(MessageReactionAddEvent event) {
try {
Vote.reactVote(event.getReaction().getEmote().getName().replace(":", ""),event);
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
}
}
示例12: onEvent
import net.dv8tion.jda.core.events.message.react.MessageReactionAddEvent; //导入依赖的package包/类
@Override
public void onEvent(Event event) {
ArrayList<String> reactions = new ArrayList<>();
reactions.add("⏯");
reactions.add("⏹");
reactions.add("⏭");
if (event instanceof MessageReactionAddEvent) {
if (!((MessageReactionAddEvent) event).getUser().equals(jda.getSelfUser())) {
if (!idMessageNowPlaying.isEmpty() && ((MessageReactionAddEvent) event).getMessageId().equals(idMessageNowPlaying)) {
if (((MessageReactionAddEvent) event).getReaction().getEmote().getName().equals(reactions.get(0))
|| ((MessageReactionAddEvent) event).getReaction().getEmote().getName().equals(reactions.get(1))
|| ((MessageReactionAddEvent) event).getReaction().getEmote().getName().equals(reactions.get(2))) {
if (((MessageReactionAddEvent) event).getReaction().getEmote().getName().equals(reactions.get(0))) {
if (musicManager.player.isPaused()) {
musicManager.player.setPaused(false);
channel.getManager().setTopic("").queue();
channel.deleteMessageById(idMessageNowPlaying).complete();
idMessageNowPlaying = "";
sendNowPlaying();
} else {
sendNowPaused();
musicManager.player.setPaused(true);
}
}
if (((MessageReactionAddEvent) event).getReaction().getEmote().getName().equals(reactions.get(1))) {
musicManager.scheduler.clearQueue();
musicManager.player.stopTrack();
musicManager.player.setPaused(false);
}
if (((MessageReactionAddEvent) event).getReaction().getEmote().getName().equals(reactions.get(2))) {
musicManager.scheduler.nextTrack();
musicManager.player.setPaused(false);
}
} else {
}
}
}
}
}
示例13: onMessageReactionAdd
import net.dv8tion.jda.core.events.message.react.MessageReactionAddEvent; //导入依赖的package包/类
@Override
public void onMessageReactionAdd(MessageReactionAddEvent event) {
Function<MessageReactionAddEvent, Boolean> handler = listeners.get(event.getMessageId());
if (handler != null && Boolean.TRUE.equals(handler.apply(event))) {
listeners.remove(event.getMessageId());
}
}
示例14: onMessageReactionAdd
import net.dv8tion.jda.core.events.message.react.MessageReactionAddEvent; //导入依赖的package包/类
@Override
public void onMessageReactionAdd(MessageReactionAddEvent e) {
if (e.getReaction().getEmote().getName().equalsIgnoreCase("\uD83D\uDD02")) {
if (e.getJDA().getTextChannelById(e.getChannel().getId()).getGuild().getSelfMember().hasPermission(Permission.MESSAGE_MANAGE)) {
e.getChannel().getMessageById(e.getMessageId()).complete().clearReactions().queue();
}
onMessageReceived(new MessageReceivedEvent(e.getJDA(), e.getResponseNumber(), e.getChannel().getMessageById(e.getMessageId()).complete()));
}
}
示例15: onMessageReactionAdd
import net.dv8tion.jda.core.events.message.react.MessageReactionAddEvent; //导入依赖的package包/类
@Override
public void onMessageReactionAdd(MessageReactionAddEvent e) {
if (e.getReaction().getEmote().getName().equalsIgnoreCase("\uD83D\uDD02")) {
if (e.getGuild().getSelfMember().hasPermission(Permission.MESSAGE_MANAGE)) {
e.getChannel().getMessageById(e.getMessageId()).complete().clearReactions().queue();
}
onMessageReceived(new MessageReceivedEvent(e.getJDA(), e.getResponseNumber(), e.getChannel().getMessageById(e.getMessageId()).complete()));
}
}