Java Code Examples for net.dv8tion.jda.api.utils.MiscUtil#parseSnowflake()
The following examples show how to use
net.dv8tion.jda.api.utils.MiscUtil#parseSnowflake() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReceivedMessage.java From JDA with Apache License 2.0 | 5 votes |
private User matchUser(Matcher matcher) { long userId = MiscUtil.parseSnowflake(matcher.group(1)); if (!mentionedUsers.contains(userId)) return null; User user = getJDA().getUserById(userId); if (user == null) user = api.getFakeUserMap().get(userId); if (user == null && userMentions != null) user = userMentions.stream().filter(it -> it.getIdLong() == userId).findFirst().orElse(null); return user; }
Example 2
Source File: ReceivedMessage.java From JDA with Apache License 2.0 | 5 votes |
private Role matchRole(Matcher matcher) { long roleId = MiscUtil.parseSnowflake(matcher.group(1)); if (!mentionedRoles.contains(roleId)) return null; if (getChannelType().isGuild()) return getGuild().getRoleById(roleId); else return getJDA().getRoleById(roleId); }
Example 3
Source File: ReceivedMessage.java From JDA with Apache License 2.0 | 5 votes |
private Emote matchEmote(Matcher m) { long emoteId = MiscUtil.parseSnowflake(m.group(2)); String name = m.group(1); boolean animated = m.group(0).startsWith("<a:"); Emote emote = getJDA().getEmoteById(emoteId); if (emote == null) emote = new EmoteImpl(emoteId, api).setName(name).setAnimated(animated); return emote; }
Example 4
Source File: ReceivedMessage.java From JDA with Apache License 2.0 | 4 votes |
private TextChannel matchTextChannel(Matcher matcher) { long channelId = MiscUtil.parseSnowflake(matcher.group(1)); return getJDA().getTextChannelById(channelId); }
Example 5
Source File: MessageChannel.java From JDA with Apache License 2.0 | 3 votes |
/** * Convenience method to delete messages in the most efficient way available. * <br>This combines both {@link TextChannel#deleteMessagesByIds(Collection)} as well as {@link #deleteMessageById(long)} * to delete all messages provided. No checks will be done to prevent failures, use {@link java.util.concurrent.CompletionStage#exceptionally(Function)} * to handle failures. * * <p>For possible ErrorResponses see {@link #purgeMessagesById(long...)}. * * @param messageIds * The message ids to delete * * @return List of futures representing all deletion tasks * * @see CompletableFuture#allOf(java.util.concurrent.CompletableFuture[]) */ @Nonnull default List<CompletableFuture<Void>> purgeMessagesById(@Nonnull List<String> messageIds) { if (messageIds == null || messageIds.isEmpty()) return Collections.emptyList(); long[] ids = new long[messageIds.size()]; for (int i = 0; i < ids.length; i++) ids[i] = MiscUtil.parseSnowflake(messageIds.get(i)); return purgeMessagesById(ids); }