Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Guild#retrieveScheduledEvents #2707

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/main/java/net/dv8tion/jda/api/entities/Guild.java
Original file line number Diff line number Diff line change
Expand Up @@ -1440,6 +1440,15 @@ default List<Member> getMembersWithRoles(@Nonnull Collection<Role> roles)
*/
@Nonnull
SortedSnowflakeCacheView<ScheduledEvent> getScheduledEventCache();

/**
* Retrieves all {@link ScheduledEvent ScheduledEvents} for this guild.
*
* @return {@link RestAction} - Type: {@link List} of {@link ScheduledEvent}
*/
@Nonnull
@CheckReturnValue
RestAction<List<ScheduledEvent>> retrieveScheduledEvents();

/**
* Gets a list of all {@link ScheduledEvent ScheduledEvents} in this Guild that have the same
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/net/dv8tion/jda/internal/entities/GuildImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,20 @@ public TextChannel getRulesChannel()
return rulesChannel;
}

@Nonnull
@Override
public RestAction<List<ScheduledEvent>> retrieveScheduledEvents()
{
Route.CompiledRoute route = Route.Guilds.GET_SCHEDULED_EVENTS.compile(getId());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about the with_user_count query parameter?


return new RestActionImpl<>(getJDA(), route,
(response, request) ->
response.getArray()
.stream(DataArray::getObject)
.map(json -> api.getEntityBuilder().createScheduledEvent(this, json))
.collect(Collectors.toList()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.collect(Collectors.toList()));
.collect(Helpers.toUnmodifiableList()));

}

@Nonnull
@Override
public CacheRestAction<ScheduledEvent> retrieveScheduledEventById(@Nonnull String id)
Expand Down
Loading