@Override public List<Member> getMembers() { return Collections.unmodifiableList(getGuild().getMembersMap().valueCollection().stream() .filter(m -> m.hasPermission(this, Permission.MESSAGE_READ)) .collect(Collectors.toList())); }
private void checkPermission(Permission permission) { if (!guild.getSelfMember().hasPermission(permission)) throw new InsufficientPermissionException(permission); } }
@Override public boolean canTalk(Member member) { if (!getGuild().equals(member.getGuild())) throw new IllegalArgumentException("Provided Member is not from the Guild that this TextChannel is part of."); return member.hasPermission(this, Permission.MESSAGE_READ, Permission.MESSAGE_WRITE); }
private boolean hasPermission(Permission permission) { switch (channel.getType()) { case TEXT: return getMember().hasPermission(getTextChannel(), permission); default: return true; } }
protected void checkPermission(Permission perm) { if (!getGuild().getSelfMember().hasPermission(perm)) throw new InsufficientPermissionException(perm); }
protected boolean hasPermission(Permission perm) { if (channel.getType() != ChannelType.TEXT) return true; TextChannel text = (TextChannel) channel; Member self = text.getGuild().getSelfMember(); return self.hasPermission(text, perm); }
/** * Creates a new MessageHistory object. * * @param channel * The {@link net.dv8tion.jda.core.entities.MessageChannel MessageChannel} to retrieval history from. */ public MessageHistory(MessageChannel channel) { this.channel = channel; if (channel instanceof TextChannel) { TextChannel tc = (TextChannel) channel; if (!tc.getGuild().getSelfMember().hasPermission(tc, Permission.MESSAGE_HISTORY)) throw new InsufficientPermissionException(Permission.MESSAGE_HISTORY); } }
@Override protected boolean checkPermissions() { if (!getGuild().getSelfMember().hasPermission(Permission.MANAGE_SERVER)) throw new InsufficientPermissionException(Permission.MANAGE_SERVER); return super.checkPermissions(); } }
@Override protected boolean checkPermissions() { if (!getGuild().getSelfMember().hasPermission(Permission.MANAGE_EMOTES)) throw new InsufficientPermissionException(Permission.MANAGE_EMOTES); return super.checkPermissions(); } }
private void checkPermission(Permission permission) { if (channel.getType() == ChannelType.TEXT) { Channel location = (Channel) channel; if (!location.getGuild().getSelfMember().hasPermission(location, permission)) throw new InsufficientPermissionException(permission); } }
protected void checkPermission(Permission permission, String message) { if (!getGuild().getSelfMember().hasPermission(this, permission)) { if (message != null) throw new InsufficientPermissionException(permission, message); else throw new InsufficientPermissionException(permission); } } }
public AuditLogPaginationAction(Guild guild) { super(guild.getJDA(), Route.Guilds.GET_AUDIT_LOGS.compile(guild.getId()), 1, 100, 100); if (!guild.getSelfMember().hasPermission(Permission.VIEW_AUDIT_LOGS)) throw new InsufficientPermissionException(Permission.VIEW_AUDIT_LOGS); this.guild = guild; }
@Override protected boolean checkPermissions() { if (!getGuild().getSelfMember().hasPermission(getChannel(), Permission.MANAGE_WEBHOOKS)) throw new InsufficientPermissionException(Permission.MANAGE_WEBHOOKS); return super.checkPermissions(); } }
@Override protected boolean checkPermissions() { final Member selfMember = getGuild().getSelfMember(); if (!selfMember.hasPermission(getChannel(), Permission.MANAGE_CHANNEL)) throw new InsufficientPermissionException(Permission.MANAGE_CHANNEL); return super.checkPermissions(); }
@Override protected boolean checkPermissions() { if (!getGuild().getSelfMember().hasPermission(getChannel(), Permission.MANAGE_PERMISSIONS)) throw new InsufficientPermissionException(Permission.MANAGE_PERMISSIONS); return super.checkPermissions(); } }
private static void checkArguments(MessageChannel channel, String messageId) { Checks.isSnowflake(messageId, "Message ID"); Checks.notNull(channel, "Channel"); if (channel.getType() == ChannelType.TEXT) { TextChannel t = (TextChannel) channel; if (!t.getGuild().getSelfMember().hasPermission(t, Permission.MESSAGE_HISTORY)) throw new InsufficientPermissionException(Permission.MESSAGE_HISTORY); } }
@Override public InviteAction createInvite() { if (!this.getGuild().getSelfMember().hasPermission(this, Permission.CREATE_INSTANT_INVITE)) throw new InsufficientPermissionException(Permission.CREATE_INSTANT_INVITE); return new InviteAction(this.getJDA(), this.getId()); }
@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()); }
public MessagePaginationAction(MessageChannel channel) { super(channel.getJDA(), Route.Messages.GET_MESSAGE_HISTORY.compile(channel.getId()), 1, 100, 100); if (channel.getType() == ChannelType.TEXT) { TextChannel textChannel = (TextChannel) channel; if (!textChannel.getGuild().getSelfMember().hasPermission(textChannel, Permission.MESSAGE_HISTORY)) throw new InsufficientPermissionException(Permission.MESSAGE_HISTORY); } this.channel = channel; }
@Override public MemberAction addMember(String accessToken, String userId) { Checks.notBlank(accessToken, "Access-Token"); Checks.isSnowflake(userId, "User ID"); Checks.check(getMemberById(userId) == null, "User is already in this guild"); if (!getSelfMember().hasPermission(Permission.CREATE_INSTANT_INVITE)) throw new InsufficientPermissionException(Permission.CREATE_INSTANT_INVITE); return new MemberAction(getJDA(), this, userId, accessToken); }