add premium to guilds and re-enable the global commands that are supposed to be global

This commit is contained in:
Lee
2024-06-27 21:05:54 +01:00
parent 2c6dcc08cd
commit 73e4b58695
22 changed files with 385 additions and 44 deletions

View File

@ -10,6 +10,7 @@ import net.dv8tion.jda.api.events.guild.GuildJoinEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.DependsOn;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import java.util.*;
@ -36,6 +37,18 @@ public class GuildService extends ListenerAdapter {
DiscordService.JDA.addEventListener(this);
}
@Scheduled(cron = "0 0 0 * * *")
private void validatePremiumStatus() {
for (BatGuild guild : guilds.values()) {
BatGuild.Premium premium = guild.getPremium();
if (premium.getExpiresAt() != null && premium.getExpiresAt().before(new Date())) {
premium.removePremium();
guildRepository.save(guild);
log.info("Removed premium status from guild \"{}\"", guild.getId());
}
}
}
/**
* Gets a guild by its ID
*