/** * The {@link net.dv8tion.jda.core.entities.SelfUser SelfUser} * * @return The {@link net.dv8tion.jda.core.entities.SelfUser SelfUser} */ public SelfUser getSelfUser() { return api.getSelfUser(); }
public SelfUpdateAvatarEvent(JDA api, long responseNumber, String oldAvatarId) { super(api, responseNumber, oldAvatarId, api.getSelfUser().getAvatarId(), IDENTIFIER); }
@Override public String toString() { return "UserSettings(" + getJDA().getSelfUser() + ")"; } }
public SelfUpdateEmailEvent(JDA api, long responseNumber, String oldEmail) { super(api, responseNumber, oldEmail, api.getSelfUser().getEmail(), IDENTIFIER); }
public SelfUpdateNameEvent(JDA api, long responseNumber, String oldName) { super(api, responseNumber, oldName, api.getSelfUser().getName(), IDENTIFIER); }
public SelfUpdateDiscriminatorEvent(JDA api, long responseNumber, String oldDiscriminator) { super(api, responseNumber, oldDiscriminator, api.getSelfUser().getDiscriminator(), IDENTIFIER); }
public SelfUpdatePhoneNumberEvent(JDA api, long responseNumber, String oldPhoneNumber) { super(api, responseNumber, oldPhoneNumber, api.getSelfUser().getPhoneNumber(), IDENTIFIER); }
@Override public int hashCode() { return Long.hashCode(getJDA().getSelfUser().getIdLong()); }
@Override public List<RequestFuture<Void>> purgeMessages(List<? extends Message> messages) { if (messages == null || messages.isEmpty()) return Collections.emptyList(); for (Message m : messages) { if (m.getAuthor().equals(getJDA().getSelfUser())) continue; throw new IllegalArgumentException("Cannot delete messages of other users in a group channel"); } return Group.super.purgeMessages(messages); }
@Override public List<RequestFuture<Void>> purgeMessages(List<? extends Message> messages) { if (messages == null || messages.isEmpty()) return Collections.emptyList(); for (Message m : messages) { if (m.getAuthor().equals(getJDA().getSelfUser())) continue; throw new IllegalArgumentException("Cannot delete messages of other users in a private channel"); } return PrivateChannel.super.purgeMessages(messages); }
/** * Removes this Reaction from the Message. * <br>This will remove our own reaction as an overload * of {@link #removeReaction(User)}. * * <p>Possible ErrorResponses include: * <ul> * <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE} * <br>If the message this reaction was attached to got deleted.</li> * * <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#UNKNOWN_CHANNEL UNKNOWN_CHANNEL} * <br>If the channel this reaction was used in got deleted.</li> * * <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS} * <br>If we were removed from the channel/guild</li> * </ul> * * @return {@link net.dv8tion.jda.core.requests.RestAction RestAction} - Type: Void * Nothing is returned on success */ @CheckReturnValue public RestAction<Void> removeReaction() { return removeReaction(getJDA().getSelfUser()); }
@Override public MessageAction editMessage(Message newContent) { if (!getJDA().getSelfUser().equals(getAuthor())) throw new IllegalStateException("Attempted to update message that was not sent by this account. You cannot modify other User's messages!"); return getChannel().editMessageById(getIdLong(), newContent); }
final long maxSize = getJDA().getSelfUser().getAllowedFileSize(); Checks.check(file.length() <= maxSize, "File may not exceed the maximum file length of %d bytes!", maxSize); try
@Override public List<RequestFuture<Void>> purgeMessages(List<? extends Message> messages) { if (messages == null || messages.isEmpty()) return Collections.emptyList(); boolean hasPerms = getGuild().getSelfMember().hasPermission(this, Permission.MESSAGE_MANAGE); if (!hasPerms) { for (Message m : messages) { if (m.getAuthor().equals(getJDA().getSelfUser())) continue; throw new InsufficientPermissionException(Permission.MESSAGE_MANAGE, "Cannot delete messages of other users"); } } return TextChannel.super.purgeMessages(messages); }
final long maxSize = getJDA().getSelfUser().getAllowedFileSize(); Checks.check(data.length <= maxSize, "File may not exceed the maximum file length of %d bytes!", maxSize); return addFile(new ByteArrayInputStream(data), name);
@Override public RestAction<Void> addReaction(Emote emote) { Checks.notNull(emote, "Emote"); MessageReaction reaction = reactions.parallelStream() .filter(r -> Objects.equals(r.getReactionEmote().getId(), emote.getId())) .findFirst().orElse(null); if (reaction == null) { Checks.check(emote.canInteract(getJDA().getSelfUser(), channel), "Cannot react with the provided emote because it is not available in the current channel."); } else if (reaction.isSelf()) { return new RestAction.EmptyRestAction<>(getJDA(), null); } return channel.addReactionById(getIdLong(), emote); }
@Override public AuditableRestAction<Void> delete() { if (!getJDA().getSelfUser().equals(getAuthor())) { if (isFromType(ChannelType.PRIVATE) || isFromType(ChannelType.GROUP)) throw new IllegalStateException("Cannot delete another User's messages in a Group or PrivateChannel."); else if (!getGuild().getSelfMember() .hasPermission((TextChannel) getChannel(), Permission.MESSAGE_MANAGE)) throw new InsufficientPermissionException(Permission.MESSAGE_MANAGE); } return channel.deleteMessageById(getIdLong()); }
@Override public RestAction<Void> removeReactionById(String messageId, String unicode, User user) { Checks.isSnowflake(messageId, "Message ID"); Checks.noWhitespace(unicode, "Unicode emoji"); Checks.notNull(user, "User"); if (!getJDA().getSelfUser().equals(user)) checkPermission(Permission.MESSAGE_MANAGE); final String code = MiscUtil.encodeUTF8(unicode); Route.CompiledRoute route; if (user.equals(getJDA().getSelfUser())) route = Route.Messages.REMOVE_OWN_REACTION.compile(getId(), messageId, code); else route = Route.Messages.REMOVE_REACTION.compile(getId(), messageId, code, user.getId()); return new RestAction<Void>(getJDA(), route) { @Override protected void handleResponse(Response response, Request<Void> request) { if (!response.isOk()) request.onFailure(response); else request.onSuccess(null); } }; }
final long maxSize = getJDA().getSelfUser().getAllowedFileSize(); Checks.check(data.length <= maxSize, "File is too big! Max file-size is %d bytes", maxSize); return sendFile(new ByteArrayInputStream(data), fileName, message);
if (!user.equals(getJDA().getSelfUser())) : MiscUtil.encodeUTF8(emote.getName()); Route.CompiledRoute route; if (user.equals(getJDA().getSelfUser())) route = Route.Messages.REMOVE_OWN_REACTION.compile(channel.getId(), getMessageId(), code); else