use of net.robinfriedli.aiode.entities.UserPlaybackHistory in project aiode by robinfriedli.
the class AudioManager method createHistoryEntry.
void createHistoryEntry(Playable playable, Guild guild, VoiceChannel voiceChannel) {
HistoryPool.execute(() -> {
try {
hibernateComponent.consumeSession(session -> {
PlaybackHistory playbackHistory = new PlaybackHistory(LocalDateTime.now(), playable, guild, session);
session.persist(playbackHistory);
if (voiceChannel != null) {
Member selfMember = guild.getSelfMember();
for (Member member : voiceChannel.getMembers()) {
if (!member.equals(selfMember)) {
UserPlaybackHistory userPlaybackHistory = new UserPlaybackHistory(member.getUser(), playbackHistory);
session.persist(userPlaybackHistory);
}
}
}
});
} catch (Exception e) {
logger.error("Exception while creating playback history entry", e);
}
});
}
Aggregations