Added ability to delete playlists
Some checks failed
Locusworks Team/eight-track/pipeline/head There was a failure building this commit
Some checks failed
Locusworks Team/eight-track/pipeline/head There was a failure building this commit
This commit is contained in:
@@ -38,10 +38,14 @@ import java.util.List;
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import net.dv8tion.jda.api.entities.ChannelType;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.events.guild.GuildJoinEvent;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
import net.locusworks.discord.eighttrack.database.entities.DiscordGuild;
|
||||
import net.locusworks.discord.eighttrack.services.ConfigurationService;
|
||||
@@ -66,6 +70,9 @@ public class DiscordEventHandler extends ListenerAdapter {
|
||||
@Autowired
|
||||
private GuildSongRepoService guildSongRepoService;
|
||||
|
||||
@Autowired
|
||||
private ReactionHandler reactionHandler;
|
||||
|
||||
@PostConstruct
|
||||
private void init() throws IOException {
|
||||
this.musicDir = confService.getMusicDirectory();
|
||||
@@ -74,6 +81,26 @@ public class DiscordEventHandler extends ListenerAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
@Scheduled(fixedRate = 300000L, initialDelay=300000L)
|
||||
private void clearHandlerCache() {
|
||||
logger.debug("Clearing reaction handler cache of dead reactions");
|
||||
reactionHandler.cleanCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessageReactionAdd(MessageReactionAddEvent e) {
|
||||
if (e.getUser().isBot()) {
|
||||
return;
|
||||
}
|
||||
if (!e.getChannel().getType().equals(ChannelType.TEXT)) {
|
||||
return;
|
||||
}
|
||||
TextChannel channel = (TextChannel) e.getChannel();
|
||||
if (reactionHandler.canHandle(channel.getGuild().getIdLong(), e.getMessageIdLong())) {
|
||||
reactionHandler.handle(channel, e.getMessageIdLong(), e.getUser().getIdLong(), e.getReaction());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildJoin(GuildJoinEvent event) {
|
||||
try {
|
||||
@@ -108,7 +135,7 @@ public class DiscordEventHandler extends ListenerAdapter {
|
||||
|
||||
if (!GuildMusicService.getMap().containsKey(event.getGuild().getIdLong())) {
|
||||
GuildMusicService.getMap().put(event.getGuild().getIdLong(),
|
||||
new GuildMusicHandler(musicDir, event.getGuild().getIdLong(), uploadHandler, guildSongRepoService));
|
||||
new GuildMusicHandler(musicDir, event.getGuild().getIdLong(), uploadHandler, reactionHandler, guildSongRepoService));
|
||||
}
|
||||
|
||||
GuildMusicHandler gmh = GuildMusicService.getMap().get(event.getGuild().getIdLong());
|
||||
|
||||
Reference in New Issue
Block a user