mirror of
https://github.com/DreamExposure/DisCal-Discord-Bot.git
synced 2026-02-09 21:18:28 -06:00
This should fix NPE due to WebCalendar chain being empty
With Mono.zip, it will skip the zip if one of the values is an empty Mono. So this should fix that by adding a default value in the event the guild does not have a calendar while building the WebGUild object
This commit is contained in:
@@ -14,6 +14,10 @@ import reactor.core.publisher.Mono;
|
||||
*/
|
||||
public class WebCalendar {
|
||||
|
||||
public static WebCalendar empty() {
|
||||
return new WebCalendar("primary", "primary", "N/a", "N/a", "N/a", "N/a", false);
|
||||
}
|
||||
|
||||
//TODO: Make a reactive version of this method...
|
||||
public static Mono<WebCalendar> fromCalendar(final CalendarData cd, final GuildSettings gs) {
|
||||
if ("primary".equalsIgnoreCase(cd.getCalendarAddress())) {
|
||||
|
||||
@@ -68,7 +68,8 @@ public class WebGuild {
|
||||
final Mono<WebCalendar> calendar = settings.flatMap(s ->
|
||||
DatabaseManager.getMainCalendar(id)
|
||||
.flatMap(d -> WebCalendar.fromCalendar(d, s))
|
||||
);
|
||||
)
|
||||
.defaultIfEmpty(WebCalendar.empty());
|
||||
|
||||
return Mono.zip(botNick, settings, roles, webChannels, announcements, calendar)
|
||||
.map(TupleUtils.function((bn, s, r, wc, a, c) -> {
|
||||
|
||||
Reference in New Issue
Block a user