예제 #1
0
  @Override
  public List<Message> getPinnedMessages() {
    if (!checkPermission(getJDA().getSelfInfo(), Permission.MESSAGE_READ))
      throw new PermissionException(
          Permission.MESSAGE_READ,
          "Cannot get the pinned message of a channel without MESSAGE_READ access.");

    List<Message> pinnedMessages = new LinkedList<>();
    Requester.Response response =
        ((JDAImpl) getJDA())
            .getRequester()
            .get(Requester.DISCORD_API_PREFIX + "/channels/" + id + "/pins");
    if (response.isOk()) {
      JSONArray pins = response.getArray();
      for (int i = 0; i < pins.length(); i++) {
        pinnedMessages.add(
            new EntityBuilder((JDAImpl) getJDA()).createMessage(pins.getJSONObject(i)));
      }
      return Collections.unmodifiableList(pinnedMessages);
    } else if (response.isRateLimit())
      throw new RateLimitedException(response.getObject().getInt("retry_after"));
    else
      throw new RuntimeException(
          "An unknown error occured attempting to get pinned messages. Ask devs for help.\n"
              + response);
  }
예제 #2
0
 @Override
 public List<PermissionOverride> getPermissionOverrides() {
   List<PermissionOverride> overrides = new LinkedList<>();
   overrides.addAll(userPermissionOverrides.values());
   overrides.addAll(rolePermissionOverrides.values());
   return Collections.unmodifiableList(overrides);
 }
예제 #3
0
 @Override
 public List<User> getUsers() {
   List<User> users =
       getGuild()
           .getUsers()
           .stream()
           .filter(user -> checkPermission(user, Permission.MESSAGE_READ))
           .collect(Collectors.toList());
   return Collections.unmodifiableList(users);
 }
예제 #4
0
 @Override
 public List<PermissionOverride> getRolePermissionOverrides() {
   return Collections.unmodifiableList(
       new LinkedList<PermissionOverride>(rolePermissionOverrides.values()));
 }