Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,21 @@ public class BirthdayAlert {

public BirthdayAlert(@NotNull SlimeBot bot) {
this.bot = bot;
bot.getScheduler().scheduleDaily(0, true, this::check);
bot.getScheduler().scheduleDaily(1, true, this::check);
}

private void check() {
bot.getJda().getGuilds().forEach(guild -> bot.loadGuild(guild).getBirthday().ifPresent(config -> {
List<Long> members = config.getBirthdayRole().map(guild::getMembersWithRoles).map(m -> m.stream().map(Member::getIdLong).toList()).orElse(Collections.emptyList());

bot.getBirthdays().getAll(guild, members).stream()
List<Birthday> birthdays = bot.getBirthdays().getAll(guild, members);

birthdays.stream()
.filter(b -> !b.isBirthday())
.forEach(b -> new BirthdayEndEvent(b).callEvent());

bot.getBirthdays().getToday(guild).stream()
birthdays.stream()
.filter(Birthday::isBirthday)
.filter(b -> !members.contains(b.getUser().getIdLong()))
.forEach(b -> new BirthdayStartEvent(b).callEvent());
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,6 @@ default List<Birthday> getAll(@NotNull Guild guild, @NotNull List<Long> members)
));
}

@NotNull
@SuppressWarnings("deprecation")
default List<Birthday> getToday(@NotNull Guild guild) {
ZonedDateTime now = ZonedDateTime.now(Main.timezone);
Date today = new Date((now.toEpochSecond() + now.getOffset().getTotalSeconds()) * 1000);

return selectMany(Where.allOf(
Where.equals("guild", guild),
Where.equals("date", new Date(2000 - 1900, today.getMonth(), today.getDate()))
));
}

/*
Listable implementation
*/
Expand Down
Loading