forked from Fascinated/Bat
add premium to guilds and re-enable the global commands that are supposed to be global
This commit is contained in:
@ -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
|
||||
*
|
||||
|
Reference in New Issue
Block a user