holy new events that are getting logged
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 1m3s
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 1m3s
This commit is contained in:
parent
f637faf0b6
commit
35223c376a
@ -7,9 +7,13 @@ import cc.fascinated.bat.model.token.beatsaber.scoresaber.ScoreSaberLeaderboardT
|
||||
import cc.fascinated.bat.model.token.beatsaber.scoresaber.ScoreSaberPlayerScoreToken;
|
||||
import cc.fascinated.bat.model.token.beatsaber.scoresaber.ScoreSaberScoreToken;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Invite;
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel;
|
||||
import net.dv8tion.jda.api.entities.emoji.Emoji;
|
||||
import net.dv8tion.jda.api.entities.sticker.GuildSticker;
|
||||
import net.dv8tion.jda.api.events.channel.ChannelCreateEvent;
|
||||
import net.dv8tion.jda.api.events.channel.ChannelDeleteEvent;
|
||||
import net.dv8tion.jda.api.events.channel.update.*;
|
||||
@ -27,6 +31,7 @@ import net.dv8tion.jda.api.events.guild.member.update.GuildMemberUpdateBoostTime
|
||||
import net.dv8tion.jda.api.events.guild.member.update.GuildMemberUpdateNicknameEvent;
|
||||
import net.dv8tion.jda.api.events.guild.member.update.GuildMemberUpdateTimeOutEvent;
|
||||
import net.dv8tion.jda.api.events.guild.override.GenericPermissionOverrideEvent;
|
||||
import net.dv8tion.jda.api.events.guild.update.*;
|
||||
import net.dv8tion.jda.api.events.guild.voice.GenericGuildVoiceEvent;
|
||||
import net.dv8tion.jda.api.events.interaction.ModalInteractionEvent;
|
||||
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
|
||||
@ -40,9 +45,13 @@ import net.dv8tion.jda.api.events.role.update.RoleUpdateColorEvent;
|
||||
import net.dv8tion.jda.api.events.role.update.RoleUpdateIconEvent;
|
||||
import net.dv8tion.jda.api.events.role.update.RoleUpdateNameEvent;
|
||||
import net.dv8tion.jda.api.events.role.update.RoleUpdatePermissionsEvent;
|
||||
import net.dv8tion.jda.api.events.sticker.GuildStickerAddedEvent;
|
||||
import net.dv8tion.jda.api.events.sticker.GuildStickerRemovedEvent;
|
||||
import net.dv8tion.jda.api.events.sticker.update.GuildStickerUpdateNameEvent;
|
||||
import net.dv8tion.jda.api.events.user.update.UserUpdateAvatarEvent;
|
||||
import net.dv8tion.jda.api.events.user.update.UserUpdateGlobalNameEvent;
|
||||
import net.dv8tion.jda.api.events.user.update.UserUpdateNameEvent;
|
||||
import net.dv8tion.jda.api.interactions.DiscordLocale;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
@ -181,6 +190,80 @@ public interface EventListener {
|
||||
default void onChannelUpdateSlowmode(@NonNull BatGuild guild, @NonNull ChannelUpdateSlowmodeEvent event) {
|
||||
}
|
||||
|
||||
default void onGuildUpdateName(@NonNull BatGuild guild, String oldName, String newName, @NonNull GuildUpdateNameEvent event) {
|
||||
}
|
||||
|
||||
default void onGuildStickerAdd(@NonNull BatGuild guild, @NonNull GuildSticker sticker, @NonNull GuildStickerAddedEvent event) {
|
||||
}
|
||||
|
||||
default void onGuildStickerRemove(@NonNull BatGuild guild, @NonNull GuildSticker sticker, @NonNull GuildStickerRemovedEvent event) {
|
||||
}
|
||||
|
||||
default void onGuildStickerRename(@NonNull BatGuild guild, @NonNull GuildSticker sticker, @NonNull String oldName,
|
||||
@NonNull String newName, @NonNull GuildStickerUpdateNameEvent event) {
|
||||
}
|
||||
|
||||
default void onGuildUpdateAfkChannel(@NonNull BatGuild guild, VoiceChannel oldChannel, VoiceChannel newChannel, @NonNull GuildUpdateAfkChannelEvent event) {
|
||||
}
|
||||
|
||||
default void onGuildUpdateAfkTimeout(@NonNull BatGuild guild, Guild.Timeout oldTimeout, Guild.Timeout newTimeout, @NonNull GuildUpdateAfkTimeoutEvent event) {
|
||||
}
|
||||
|
||||
default void onGuildUpdateBanner(@NonNull BatGuild guild, String oldBannerUrl, String newBannerUrl, @NonNull GuildUpdateBannerEvent event) {
|
||||
}
|
||||
|
||||
default void onGuildUpdateDescription(@NonNull BatGuild guild, String oldDescription, String newDescription, @NonNull GuildUpdateDescriptionEvent event) {
|
||||
}
|
||||
|
||||
default void onGuildUpdateIcon(@NonNull BatGuild guild, String oldIconUrl, String newIconUrl, @NonNull GuildUpdateIconEvent event) {
|
||||
}
|
||||
|
||||
default void onGuildUpdateLocale(@NonNull BatGuild guild, DiscordLocale oldLocale, DiscordLocale newLocale, @NonNull GuildUpdateLocaleEvent event) {
|
||||
}
|
||||
|
||||
default void onGuildUpdateCommunityUpdatesChannel(@NonNull BatGuild guild, TextChannel oldChannel, TextChannel newChannel,
|
||||
@NonNull GuildUpdateCommunityUpdatesChannelEvent event) {
|
||||
}
|
||||
|
||||
default void onGuildUpdateBoostTier(@NonNull BatGuild guild, Guild.BoostTier oldTier, Guild.BoostTier newTier, @NonNull GuildUpdateBoostTierEvent event) {
|
||||
}
|
||||
|
||||
default void onGuildUpdateMaxMembers(@NonNull BatGuild guild, int oldCount, int newCount, @NonNull GuildUpdateMaxMembersEvent event) {
|
||||
}
|
||||
|
||||
default void onGuildUpdateExplicitContentLevel(@NonNull BatGuild guild, Guild.ExplicitContentLevel oldLevel, Guild.ExplicitContentLevel newLevel,
|
||||
@NonNull GuildUpdateExplicitContentLevelEvent event) {
|
||||
}
|
||||
|
||||
default void onGuildUpdateMFALevel(@NonNull BatGuild guild, Guild.MFALevel oldLevel, Guild.MFALevel newLevel, @NonNull GuildUpdateMFALevelEvent event) {
|
||||
}
|
||||
|
||||
default void onGuildUpdateNotificationLevel(@NonNull BatGuild guild, Guild.NotificationLevel oldLevel, Guild.NotificationLevel newLevel,
|
||||
@NonNull GuildUpdateNotificationLevelEvent event) {
|
||||
}
|
||||
|
||||
default void onGuildUpdateNSFWLevel(@NonNull BatGuild guild, Guild.NSFWLevel oldLevel, Guild.NSFWLevel newLevel, @NonNull GuildUpdateNSFWLevelEvent event) {
|
||||
}
|
||||
|
||||
default void onGuildUpdateOwner(@NonNull BatGuild guild, @NonNull BatUser oldOwner, @NonNull BatUser newOwner, @NonNull GuildUpdateOwnerEvent event) {
|
||||
}
|
||||
|
||||
default void onGuildUpdateRulesChannel(@NonNull BatGuild guild, TextChannel oldChannel, TextChannel newChannel, @NonNull GuildUpdateRulesChannelEvent event) {
|
||||
}
|
||||
|
||||
default void onGuildUpdateSystemChannel(@NonNull BatGuild guild, TextChannel oldChannel, TextChannel newChannel, @NonNull GuildUpdateSystemChannelEvent event) {
|
||||
}
|
||||
|
||||
default void onGuildUpdateVanityCode(@NonNull BatGuild guild, String oldCode, String newCode, @NonNull GuildUpdateVanityCodeEvent event) {
|
||||
}
|
||||
|
||||
default void onGuildUpdateVerificationLevel(@NonNull BatGuild guild, Guild.VerificationLevel oldLevel, Guild.VerificationLevel newLevel,
|
||||
@NonNull GuildUpdateVerificationLevelEvent event) {
|
||||
}
|
||||
|
||||
default void onGuildUpdateSplash(@NonNull BatGuild guild, String oldSplashUrl, String newSplashUrl, @NonNull GuildUpdateSplashEvent event) {
|
||||
}
|
||||
|
||||
default void onShutdown() {
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,6 @@ public enum LogType {
|
||||
CHANNEL_DELETE(LogCategory.CHANNEL),
|
||||
VOICE_CHANNEL_JOIN(LogCategory.CHANNEL),
|
||||
VOICE_CHANNEL_LEAVE(LogCategory.CHANNEL),
|
||||
CHANNEL_PERMISSIONS_UPDATED(LogCategory.CHANNEL),
|
||||
CHANNEL_CONFIGURATION(LogCategory.CHANNEL),
|
||||
|
||||
/**
|
||||
@ -52,10 +51,14 @@ public enum LogType {
|
||||
EMOJI_ADD(LogCategory.GUILD),
|
||||
EMOJI_REMOVE(LogCategory.GUILD),
|
||||
EMOJI_NAME_UPDATED(LogCategory.GUILD),
|
||||
ROLE_PERMISSIONS_UPDATED(LogCategory.GUILD),
|
||||
ROLE_CREATE(LogCategory.GUILD),
|
||||
ROLE_DELETE(LogCategory.GUILD),
|
||||
ROLE_CONFIGURATION(LogCategory.GUILD);
|
||||
ROLE_CONFIGURATION(LogCategory.GUILD),
|
||||
STICKER_ADD(LogCategory.GUILD),
|
||||
STICKER_REMOVE(LogCategory.GUILD),
|
||||
STICKER_NAME_UPDATED(LogCategory.GUILD),
|
||||
BOOST_TIER_UPDATED(LogCategory.GUILD),
|
||||
GUILD_CONFIGURATION(LogCategory.GUILD);
|
||||
|
||||
/**
|
||||
* The category of the log type
|
||||
|
@ -163,7 +163,7 @@ public class ChannelListener implements EventListener {
|
||||
: deniedPermissions.substring(0, deniedPermissions.length() - 2)), true);
|
||||
}
|
||||
|
||||
logFeature.sendLog(guild, LogType.CHANNEL_PERMISSIONS_UPDATED, EmbedUtils.successEmbed()
|
||||
logFeature.sendLog(guild, LogType.CHANNEL_CONFIGURATION, EmbedUtils.successEmbed()
|
||||
.setDescription(description.build()).build());
|
||||
}
|
||||
|
||||
|
@ -2,15 +2,23 @@ package cc.fascinated.bat.features.logging.listeners;
|
||||
|
||||
import cc.fascinated.bat.common.EmbedDescriptionBuilder;
|
||||
import cc.fascinated.bat.common.EmbedUtils;
|
||||
import cc.fascinated.bat.common.EnumUtils;
|
||||
import cc.fascinated.bat.common.TimeUtils;
|
||||
import cc.fascinated.bat.event.EventListener;
|
||||
import cc.fascinated.bat.features.logging.LogFeature;
|
||||
import cc.fascinated.bat.features.logging.LogType;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import lombok.NonNull;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Invite;
|
||||
import net.dv8tion.jda.api.entities.channel.ChannelType;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel;
|
||||
import net.dv8tion.jda.api.events.guild.invite.GuildInviteCreateEvent;
|
||||
import net.dv8tion.jda.api.events.guild.update.*;
|
||||
import net.dv8tion.jda.api.interactions.DiscordLocale;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -42,11 +50,227 @@ public class GuildListener implements EventListener {
|
||||
), true);
|
||||
}
|
||||
description.appendLine("Max Uses: `%s`".formatted(expandedInvite.getMaxUses() == 0 ? "Infinite" : expandedInvite.getMaxUses()), true);
|
||||
description.appendLine("Creator: %s".formatted(expandedInvite.getInviter() == null ? "Unknown" : expandedInvite.getInviter().getAsMention()), true);;
|
||||
logFeature.sendLog(guild, LogType.INVITE_CREATE, EmbedUtils.successEmbed()
|
||||
.setDescription(description
|
||||
.build())
|
||||
.build());
|
||||
description.appendLine("Creator: %s".formatted(expandedInvite.getInviter() == null ? "Unknown" : expandedInvite.getInviter().getAsMention()), true);
|
||||
;
|
||||
logFeature.sendLog(guild, LogType.INVITE_CREATE, EmbedUtils.successEmbed().setDescription(description.build()).build());
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateName(@NonNull BatGuild guild, String oldName, String newName, @NonNull GuildUpdateNameEvent event) {
|
||||
log.info("Guild name was updated in guild \"{}\" from \"{}\" to \"{}\"", guild.getGuild().getName(), oldName, newName);
|
||||
|
||||
EmbedDescriptionBuilder description = new EmbedDescriptionBuilder("Guild Name Updated")
|
||||
.appendLine("Name: `%s` -> `%s`".formatted(oldName, newName), true);
|
||||
logFeature.sendLog(guild, LogType.GUILD_CONFIGURATION, EmbedUtils.successEmbed().setDescription(description.build()).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateAfkChannel(@NonNull BatGuild guild, VoiceChannel oldChannel, VoiceChannel newChannel, @NonNull GuildUpdateAfkChannelEvent event) {
|
||||
log.info("Guild AFK channel was updated in guild \"{}\" from \"{}\" to \"{}\"", guild.getGuild().getName(), oldChannel == null ? "None" : oldChannel.getName(), newChannel == null ? "None" : newChannel.getName());
|
||||
|
||||
EmbedDescriptionBuilder description = new EmbedDescriptionBuilder("Guild AFK Channel Updated")
|
||||
.appendLine("Channel: `%s` -> `%s`".formatted(
|
||||
oldChannel == null ? "None" : oldChannel.getName(),
|
||||
newChannel == null ? "None" : newChannel.getName()
|
||||
), true);
|
||||
logFeature.sendLog(guild, LogType.GUILD_CONFIGURATION, EmbedUtils.successEmbed().setDescription(description.build()).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateAfkTimeout(@NonNull BatGuild guild, Guild.Timeout oldTimeout, Guild.Timeout newTimeout, @NonNull GuildUpdateAfkTimeoutEvent event) {
|
||||
log.info("Guild AFK timeout was updated in guild \"{}\" from \"{}\" to \"{}\"",
|
||||
guild.getGuild().getName(), oldTimeout.getSeconds(), newTimeout.getSeconds());
|
||||
|
||||
EmbedDescriptionBuilder description = new EmbedDescriptionBuilder("Guild AFK Timeout Updated")
|
||||
.appendLine("Timeout: `%s` -> `%s`".formatted(
|
||||
TimeUtils.format(oldTimeout.getSeconds() * 1000L),
|
||||
TimeUtils.format(newTimeout.getSeconds() * 1000L)
|
||||
), true);
|
||||
logFeature.sendLog(guild, LogType.GUILD_CONFIGURATION, EmbedUtils.successEmbed().setDescription(description.build()).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateBanner(@NonNull BatGuild guild, String oldBannerUrl, String newBannerUrl, @NonNull GuildUpdateBannerEvent event) {
|
||||
log.info("Guild banner was updated in guild \"{}\" from \"{}\" to \"{}\"", guild.getGuild().getName(), oldBannerUrl, newBannerUrl);
|
||||
|
||||
EmbedDescriptionBuilder description = new EmbedDescriptionBuilder("Guild Banner Updated")
|
||||
.appendLine("Banner: [click here](%s)".formatted(newBannerUrl), true);
|
||||
logFeature.sendLog(guild, LogType.GUILD_CONFIGURATION, EmbedUtils.successEmbed().setDescription(description.build()).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateDescription(@NonNull BatGuild guild, String oldDescription, String newDescription, @NonNull GuildUpdateDescriptionEvent event) {
|
||||
log.info("Guild description was updated in guild \"{}\" from \"{}\" to \"{}\"", guild.getGuild().getName(), oldDescription, newDescription);
|
||||
|
||||
EmbedDescriptionBuilder description = new EmbedDescriptionBuilder("Guild Description Updated")
|
||||
.appendLine("Description: `%s` -> `%s`".formatted(oldDescription, newDescription), true);
|
||||
logFeature.sendLog(guild, LogType.GUILD_CONFIGURATION, EmbedUtils.successEmbed().setDescription(description.build()).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateIcon(@NonNull BatGuild guild, String oldIconUrl, String newIconUrl, @NonNull GuildUpdateIconEvent event) {
|
||||
log.info("Guild icon was updated in guild \"{}\" from \"{}\" to \"{}\"", guild.getGuild().getName(), oldIconUrl, newIconUrl);
|
||||
|
||||
EmbedDescriptionBuilder description = new EmbedDescriptionBuilder("Guild Icon Updated")
|
||||
.appendLine("Icon: [click here](%s)".formatted(newIconUrl), true);
|
||||
logFeature.sendLog(guild, LogType.GUILD_CONFIGURATION, EmbedUtils.successEmbed().setDescription(description.build()).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateLocale(@NonNull BatGuild guild, DiscordLocale oldLocale, DiscordLocale newLocale, @NonNull GuildUpdateLocaleEvent event) {
|
||||
log.info("Guild primary language was updated in guild \"{}\" from \"{}\" to \"{}\"", guild.getGuild().getName(), oldLocale, newLocale);
|
||||
|
||||
EmbedDescriptionBuilder description = new EmbedDescriptionBuilder("Guild Primary Language Updated")
|
||||
.appendLine("Language: `%s` -> `%s`".formatted(
|
||||
oldLocale.getLanguageName(),
|
||||
newLocale.getLanguageName()
|
||||
), true);
|
||||
logFeature.sendLog(guild, LogType.GUILD_CONFIGURATION, EmbedUtils.successEmbed().setDescription(description.build()).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateCommunityUpdatesChannel(@NonNull BatGuild guild, TextChannel oldChannel, TextChannel newChannel, @NonNull GuildUpdateCommunityUpdatesChannelEvent event) {
|
||||
log.info("Guild community updates channel was updated in guild \"{}\" from \"{}\" to \"{}\"", guild.getGuild().getName(), oldChannel == null ? "None" : oldChannel.getName(), newChannel == null ? "None" : newChannel.getName());
|
||||
|
||||
EmbedDescriptionBuilder description = new EmbedDescriptionBuilder("Community Updates Channel Updated")
|
||||
.appendLine("Channel: `%s` -> `%s`".formatted(
|
||||
oldChannel == null ? "None" : oldChannel.getName(),
|
||||
newChannel == null ? "None" : newChannel.getName()
|
||||
), true);
|
||||
logFeature.sendLog(guild, LogType.GUILD_CONFIGURATION, EmbedUtils.successEmbed().setDescription(description.build()).build());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateBoostTier(@NonNull BatGuild guild, Guild.BoostTier oldTier, Guild.BoostTier newTier, @NonNull GuildUpdateBoostTierEvent event) {
|
||||
log.info("Guild boost tier was updated in guild \"{}\" from \"{}\" to \"{}\"", guild.getGuild().getName(), oldTier.getKey(), newTier.getKey());
|
||||
|
||||
EmbedDescriptionBuilder description = new EmbedDescriptionBuilder("Guild Boost Tier Updated")
|
||||
.appendLine("Tier: `%s` -> `%s`".formatted(oldTier.getKey(), newTier.getKey()), true);
|
||||
logFeature.sendLog(guild, LogType.BOOST_TIER_UPDATED, EmbedUtils.successEmbed().setDescription(description.build()).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateMaxMembers(@NonNull BatGuild guild, int oldCount, int newCount, @NonNull GuildUpdateMaxMembersEvent event) {
|
||||
log.info("Guild max members was updated in guild \"{}\" from \"{}\" to \"{}\"", guild.getGuild().getName(), oldCount, newCount);
|
||||
|
||||
EmbedDescriptionBuilder description = new EmbedDescriptionBuilder("Guild Max Members Updated")
|
||||
.appendLine("Members: `%s` -> `%s`".formatted(oldCount, newCount), true);
|
||||
logFeature.sendLog(guild, LogType.GUILD_CONFIGURATION, EmbedUtils.successEmbed().setDescription(description.build()).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateExplicitContentLevel(@NonNull BatGuild guild, Guild.ExplicitContentLevel oldLevel, Guild.ExplicitContentLevel newLevel, @NonNull GuildUpdateExplicitContentLevelEvent event) {
|
||||
log.info("Guild explicit content level was updated in guild \"{}\" from \"{}\" to \"{}\"", guild.getGuild().getName(), oldLevel.getKey(), newLevel.getKey());
|
||||
|
||||
EmbedDescriptionBuilder description = new EmbedDescriptionBuilder("Guild Explicit Content Level Updated")
|
||||
.appendLine("Level: `%s` -> `%s`".formatted(
|
||||
EnumUtils.getEnumName(oldLevel),
|
||||
EnumUtils.getEnumName(newLevel)
|
||||
), true);
|
||||
logFeature.sendLog(guild, LogType.GUILD_CONFIGURATION, EmbedUtils.successEmbed().setDescription(description.build()).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateMFALevel(@NonNull BatGuild guild, Guild.MFALevel oldLevel, Guild.MFALevel newLevel, @NonNull GuildUpdateMFALevelEvent event) {
|
||||
log.info("Guild MFA level was updated in guild \"{}\" from \"{}\" to \"{}\"", guild.getGuild().getName(), oldLevel.getKey(), newLevel.getKey());
|
||||
|
||||
EmbedDescriptionBuilder description = new EmbedDescriptionBuilder("Guild MFA Level Updated")
|
||||
.appendLine("Level: `%s` -> `%s`".formatted(
|
||||
EnumUtils.getEnumName(oldLevel),
|
||||
EnumUtils.getEnumName(newLevel)
|
||||
), true);
|
||||
logFeature.sendLog(guild, LogType.GUILD_CONFIGURATION, EmbedUtils.successEmbed().setDescription(description.build()).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateNotificationLevel(@NonNull BatGuild guild, Guild.NotificationLevel oldLevel, Guild.NotificationLevel newLevel, @NonNull GuildUpdateNotificationLevelEvent event) {
|
||||
log.info("Guild notification level was updated in guild \"{}\" from \"{}\" to \"{}\"", guild.getGuild().getName(), oldLevel.getKey(), newLevel.getKey());
|
||||
|
||||
EmbedDescriptionBuilder description = new EmbedDescriptionBuilder("Guild Notification Level Updated")
|
||||
.appendLine("Level: `%s` -> `%s`".formatted(
|
||||
EnumUtils.getEnumName(oldLevel),
|
||||
EnumUtils.getEnumName(newLevel)
|
||||
), true);
|
||||
logFeature.sendLog(guild, LogType.GUILD_CONFIGURATION, EmbedUtils.successEmbed().setDescription(description.build()).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateNSFWLevel(@NonNull BatGuild guild, Guild.NSFWLevel oldLevel, Guild.NSFWLevel newLevel, @NonNull GuildUpdateNSFWLevelEvent event) {
|
||||
log.info("Guild NSFW level was updated in guild \"{}\" from \"{}\" to \"{}\"", guild.getGuild().getName(), oldLevel.getKey(), newLevel.getKey());
|
||||
|
||||
EmbedDescriptionBuilder description = new EmbedDescriptionBuilder("Guild NSFW Level Updated")
|
||||
.appendLine("Level: `%s` -> `%s`".formatted(
|
||||
EnumUtils.getEnumName(oldLevel),
|
||||
EnumUtils.getEnumName(newLevel)
|
||||
), true);
|
||||
logFeature.sendLog(guild, LogType.GUILD_CONFIGURATION, EmbedUtils.successEmbed().setDescription(description.build()).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateOwner(@NonNull BatGuild guild, @NonNull BatUser oldOwner, @NonNull BatUser newOwner, @NonNull GuildUpdateOwnerEvent event) {
|
||||
log.info("Guild owner was updated in guild \"{}\" from \"{}\" to \"{}\"", guild.getGuild().getName(), oldOwner.getUser().getAsTag(), newOwner.getUser().getAsTag());
|
||||
|
||||
EmbedDescriptionBuilder description = new EmbedDescriptionBuilder("Guild Owner Updated")
|
||||
.appendLine("Owner: %s -> %s".formatted(oldOwner.getUser().getAsMention(), newOwner.getUser().getAsMention()), true);
|
||||
logFeature.sendLog(guild, LogType.GUILD_CONFIGURATION, EmbedUtils.successEmbed().setDescription(description.build()).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateRulesChannel(@NonNull BatGuild guild, TextChannel oldChannel, TextChannel newChannel, @NonNull GuildUpdateRulesChannelEvent event) {
|
||||
log.info("Guild rules channel was updated in guild \"{}\" from \"{}\" to \"{}\"", guild.getGuild().getName(), oldChannel == null ? "None" : oldChannel.getName(), newChannel == null ? "None" : newChannel.getName());
|
||||
|
||||
EmbedDescriptionBuilder description = new EmbedDescriptionBuilder("Rules Channel Updated")
|
||||
.appendLine("Channel: %s -> %s".formatted(
|
||||
oldChannel == null ? "`None`" : oldChannel.getAsMention(),
|
||||
newChannel == null ? "`None`" : newChannel.getAsMention()
|
||||
), true);
|
||||
logFeature.sendLog(guild, LogType.GUILD_CONFIGURATION, EmbedUtils.successEmbed().setDescription(description.build()).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateSystemChannel(@NonNull BatGuild guild, TextChannel oldChannel, TextChannel newChannel, @NonNull GuildUpdateSystemChannelEvent event) {
|
||||
log.info("Guild system channel was updated in guild \"{}\" from \"{}\" to \"{}\"", guild.getGuild().getName(), oldChannel == null ? "None" : oldChannel.getName(), newChannel == null ? "None" : newChannel.getName());
|
||||
|
||||
EmbedDescriptionBuilder description = new EmbedDescriptionBuilder("System Channel Updated")
|
||||
.appendLine("Channel: %s -> %s".formatted(
|
||||
oldChannel == null ? "`None`" : oldChannel.getAsMention(),
|
||||
newChannel == null ? "`None`" : newChannel.getAsMention()
|
||||
), true);
|
||||
logFeature.sendLog(guild, LogType.GUILD_CONFIGURATION, EmbedUtils.successEmbed().setDescription(description.build()).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateVanityCode(@NonNull BatGuild guild, String oldCode, String newCode, @NonNull GuildUpdateVanityCodeEvent event) {
|
||||
log.info("Guild vanity code was updated in guild \"{}\" from \"{}\" to \"{}\"", guild.getGuild().getName(), oldCode, newCode);
|
||||
|
||||
EmbedDescriptionBuilder description = new EmbedDescriptionBuilder("Vanity Code Updated")
|
||||
.appendLine("Code: `%s` -> `%s`".formatted(
|
||||
oldCode == null ? "None" : oldCode,
|
||||
newCode == null ? "None" : newCode
|
||||
), true);
|
||||
logFeature.sendLog(guild, LogType.GUILD_CONFIGURATION, EmbedUtils.successEmbed().setDescription(description.build()).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateVerificationLevel(@NonNull BatGuild guild, Guild.VerificationLevel oldLevel, Guild.VerificationLevel newLevel, @NonNull GuildUpdateVerificationLevelEvent event) {
|
||||
log.info("Guild verification level was updated in guild \"{}\" from \"{}\" to \"{}\"", guild.getGuild().getName(), oldLevel.getKey(), newLevel.getKey());
|
||||
|
||||
EmbedDescriptionBuilder description = new EmbedDescriptionBuilder("Verification Level Updated")
|
||||
.appendLine("Level: `%s` -> `%s`".formatted(
|
||||
EnumUtils.getEnumName(oldLevel),
|
||||
EnumUtils.getEnumName(newLevel)
|
||||
), true);
|
||||
logFeature.sendLog(guild, LogType.GUILD_CONFIGURATION, EmbedUtils.successEmbed().setDescription(description.build()).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateSplash(@NonNull BatGuild guild, String oldSplashUrl, String newSplashUrl, @NonNull GuildUpdateSplashEvent event) {
|
||||
log.info("Guild splash was updated in guild \"{}\" from \"{}\" to \"{}\"", guild.getGuild().getName(), oldSplashUrl, newSplashUrl);
|
||||
|
||||
EmbedDescriptionBuilder description = new EmbedDescriptionBuilder("Guild Splash Updated")
|
||||
.appendLine("Splash: [click here](%s)".formatted(newSplashUrl), true);
|
||||
logFeature.sendLog(guild, LogType.GUILD_CONFIGURATION, EmbedUtils.successEmbed().setDescription(description.build()).build());
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ public class RoleListener implements EventListener {
|
||||
description.appendLine("Denied Permissions: %s".formatted(deniedPermissions.substring(0, deniedPermissions.length() - 2)), true);
|
||||
}
|
||||
|
||||
logFeature.sendLog(guild, LogType.ROLE_PERMISSIONS_UPDATED, EmbedUtils.successEmbed()
|
||||
logFeature.sendLog(guild, LogType.ROLE_CONFIGURATION, EmbedUtils.successEmbed()
|
||||
.setDescription(description.build())
|
||||
.build());
|
||||
}
|
||||
|
@ -0,0 +1,64 @@
|
||||
package cc.fascinated.bat.features.logging.listeners;
|
||||
|
||||
import cc.fascinated.bat.common.EmbedDescriptionBuilder;
|
||||
import cc.fascinated.bat.common.EmbedUtils;
|
||||
import cc.fascinated.bat.event.EventListener;
|
||||
import cc.fascinated.bat.features.logging.LogFeature;
|
||||
import cc.fascinated.bat.features.logging.LogType;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import lombok.NonNull;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import net.dv8tion.jda.api.entities.sticker.GuildSticker;
|
||||
import net.dv8tion.jda.api.events.sticker.GuildStickerAddedEvent;
|
||||
import net.dv8tion.jda.api.events.sticker.GuildStickerRemovedEvent;
|
||||
import net.dv8tion.jda.api.events.sticker.update.GuildStickerUpdateNameEvent;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author Fascinated (fascinated7)
|
||||
*/
|
||||
@Component
|
||||
@Log4j2(topic = "Logging - Sticker Listener")
|
||||
public class StickerListener implements EventListener {
|
||||
private final LogFeature logFeature;
|
||||
|
||||
@Autowired
|
||||
public StickerListener(@NonNull LogFeature logFeature) {
|
||||
this.logFeature = logFeature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildStickerAdd(@NonNull BatGuild guild, @NonNull GuildSticker sticker, @NonNull GuildStickerAddedEvent event) {
|
||||
log.info("Sticker \"{}\" was added in guild \"{}\"", sticker.getName(), guild.getName());
|
||||
logFeature.sendLog(guild, LogType.STICKER_ADD, EmbedUtils.successEmbed()
|
||||
.setDescription(new EmbedDescriptionBuilder("Sticker Added")
|
||||
.appendLine("Sticker: %s".formatted(sticker.getName()), true)
|
||||
.appendLine("URL: %s".formatted(sticker.getIconUrl()), true)
|
||||
.build())
|
||||
.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildStickerRemove(@NonNull BatGuild guild, @NonNull GuildSticker sticker, @NonNull GuildStickerRemovedEvent event) {
|
||||
log.info("Sticker \"{}\" was removed in guild \"{}\"", sticker.getName(), guild.getName());
|
||||
logFeature.sendLog(guild, LogType.STICKER_REMOVE, EmbedUtils.successEmbed()
|
||||
.setDescription(new EmbedDescriptionBuilder("Sticker Removed")
|
||||
.appendLine("Sticker: %s".formatted(sticker.getName()), true)
|
||||
.appendLine("URL: %s".formatted(sticker.getIconUrl()), true)
|
||||
.build())
|
||||
.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildStickerRename(@NonNull BatGuild guild, @NonNull GuildSticker sticker, @NonNull String oldName,
|
||||
@NonNull String newName, @NonNull GuildStickerUpdateNameEvent event) {
|
||||
log.info("Sticker \"{}\" was renamed in guild \"{}\" from \"{}\" to \"{}\"", sticker.getName(), guild.getName(), oldName, newName);
|
||||
logFeature.sendLog(guild, LogType.STICKER_NAME_UPDATED, EmbedUtils.successEmbed()
|
||||
.setDescription(new EmbedDescriptionBuilder("Sticker Renamed")
|
||||
.appendLine("Sticker: %s".formatted(sticker.getName()), true)
|
||||
.appendLine("Name: `%s` -> `%s`".formatted(oldName, newName), true)
|
||||
.build())
|
||||
.build());
|
||||
}
|
||||
}
|
@ -25,6 +25,7 @@ import net.dv8tion.jda.api.events.guild.member.update.GuildMemberUpdateBoostTime
|
||||
import net.dv8tion.jda.api.events.guild.member.update.GuildMemberUpdateNicknameEvent;
|
||||
import net.dv8tion.jda.api.events.guild.member.update.GuildMemberUpdateTimeOutEvent;
|
||||
import net.dv8tion.jda.api.events.guild.override.GenericPermissionOverrideEvent;
|
||||
import net.dv8tion.jda.api.events.guild.update.*;
|
||||
import net.dv8tion.jda.api.events.guild.voice.GuildVoiceUpdateEvent;
|
||||
import net.dv8tion.jda.api.events.interaction.ModalInteractionEvent;
|
||||
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
|
||||
@ -37,6 +38,9 @@ import net.dv8tion.jda.api.events.role.update.RoleUpdateColorEvent;
|
||||
import net.dv8tion.jda.api.events.role.update.RoleUpdateIconEvent;
|
||||
import net.dv8tion.jda.api.events.role.update.RoleUpdateNameEvent;
|
||||
import net.dv8tion.jda.api.events.role.update.RoleUpdatePermissionsEvent;
|
||||
import net.dv8tion.jda.api.events.sticker.GuildStickerAddedEvent;
|
||||
import net.dv8tion.jda.api.events.sticker.GuildStickerRemovedEvent;
|
||||
import net.dv8tion.jda.api.events.sticker.update.GuildStickerUpdateNameEvent;
|
||||
import net.dv8tion.jda.api.events.user.update.UserUpdateAvatarEvent;
|
||||
import net.dv8tion.jda.api.events.user.update.UserUpdateGlobalNameEvent;
|
||||
import net.dv8tion.jda.api.events.user.update.UserUpdateNameEvent;
|
||||
@ -516,4 +520,216 @@ public class EventService extends ListenerAdapter {
|
||||
listener.onChannelUpdateSlowmode(guild, event);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateName(@NotNull GuildUpdateNameEvent event) {
|
||||
BatGuild guild = guildService.getGuild(event.getGuild().getId());
|
||||
|
||||
for (EventListener listener : LISTENERS) {
|
||||
listener.onGuildUpdateName(guild, event.getOldName(), event.getNewName(), event);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildStickerAdded(@NotNull GuildStickerAddedEvent event) {
|
||||
BatGuild guild = guildService.getGuild(event.getGuild().getId());
|
||||
|
||||
for (EventListener listener : LISTENERS) {
|
||||
listener.onGuildStickerAdd(guild, event.getSticker(), event);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildStickerRemoved(@NotNull GuildStickerRemovedEvent event) {
|
||||
BatGuild guild = guildService.getGuild(event.getGuild().getId());
|
||||
|
||||
for (EventListener listener : LISTENERS) {
|
||||
listener.onGuildStickerRemove(guild, event.getSticker(), event);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildStickerUpdateName(@NotNull GuildStickerUpdateNameEvent event) {
|
||||
BatGuild guild = guildService.getGuild(event.getGuild().getId());
|
||||
|
||||
for (EventListener listener : LISTENERS) {
|
||||
listener.onGuildStickerRename(guild, event.getSticker(), event.getOldValue(), event.getNewValue(), event);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateAfkChannel(@NotNull GuildUpdateAfkChannelEvent event) {
|
||||
BatGuild guild = guildService.getGuild(event.getGuild().getId());
|
||||
|
||||
for (EventListener listener : LISTENERS) {
|
||||
listener.onGuildUpdateAfkChannel(guild, event.getOldAfkChannel(), event.getNewAfkChannel(), event);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateAfkTimeout(@NotNull GuildUpdateAfkTimeoutEvent event) {
|
||||
BatGuild guild = guildService.getGuild(event.getGuild().getId());
|
||||
|
||||
for (EventListener listener : LISTENERS) {
|
||||
listener.onGuildUpdateAfkTimeout(guild, event.getOldAfkTimeout(), event.getNewAfkTimeout(), event);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateBanner(@NotNull GuildUpdateBannerEvent event) {
|
||||
BatGuild guild = guildService.getGuild(event.getGuild().getId());
|
||||
|
||||
for (EventListener listener : LISTENERS) {
|
||||
listener.onGuildUpdateBanner(guild, event.getOldBannerUrl(), event.getNewBannerUrl(), event);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateDescription(@NotNull GuildUpdateDescriptionEvent event) {
|
||||
BatGuild guild = guildService.getGuild(event.getGuild().getId());
|
||||
|
||||
for (EventListener listener : LISTENERS) {
|
||||
listener.onGuildUpdateDescription(guild, event.getOldDescription(), event.getNewDescription(), event);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateIcon(@NotNull GuildUpdateIconEvent event) {
|
||||
BatGuild guild = guildService.getGuild(event.getGuild().getId());
|
||||
|
||||
for (EventListener listener : LISTENERS) {
|
||||
listener.onGuildUpdateIcon(guild, event.getOldIconUrl(), event.getNewIconUrl(), event);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateLocale(@NotNull GuildUpdateLocaleEvent event) {
|
||||
BatGuild guild = guildService.getGuild(event.getGuild().getId());
|
||||
|
||||
for (EventListener listener : LISTENERS) {
|
||||
listener.onGuildUpdateLocale(guild, event.getOldValue(), event.getNewValue(), event);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateCommunityUpdatesChannel(@NotNull GuildUpdateCommunityUpdatesChannelEvent event) {
|
||||
BatGuild guild = guildService.getGuild(event.getGuild().getId());
|
||||
|
||||
for (EventListener listener : LISTENERS) {
|
||||
listener.onGuildUpdateCommunityUpdatesChannel(guild, event.getOldCommunityUpdatesChannel(), event.getNewCommunityUpdatesChannel(), event);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateBoostTier(@NotNull GuildUpdateBoostTierEvent event) {
|
||||
BatGuild guild = guildService.getGuild(event.getGuild().getId());
|
||||
|
||||
for (EventListener listener : LISTENERS) {
|
||||
listener.onGuildUpdateBoostTier(guild, event.getOldBoostTier(), event.getNewBoostTier(), event);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateMaxMembers(@NotNull GuildUpdateMaxMembersEvent event) {
|
||||
BatGuild guild = guildService.getGuild(event.getGuild().getId());
|
||||
|
||||
for (EventListener listener : LISTENERS) {
|
||||
listener.onGuildUpdateMaxMembers(guild, event.getOldMaxMembers(), event.getNewMaxMembers(), event);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateExplicitContentLevel(@NotNull GuildUpdateExplicitContentLevelEvent event) {
|
||||
BatGuild guild = guildService.getGuild(event.getGuild().getId());
|
||||
|
||||
for (EventListener listener : LISTENERS) {
|
||||
listener.onGuildUpdateExplicitContentLevel(guild, event.getOldLevel(), event.getNewLevel(), event);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateMFALevel(@NotNull GuildUpdateMFALevelEvent event) {
|
||||
BatGuild guild = guildService.getGuild(event.getGuild().getId());
|
||||
|
||||
for (EventListener listener : LISTENERS) {
|
||||
listener.onGuildUpdateMFALevel(guild, event.getOldMFALevel(), event.getNewMFALevel(), event);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateNotificationLevel(@NotNull GuildUpdateNotificationLevelEvent event) {
|
||||
BatGuild guild = guildService.getGuild(event.getGuild().getId());
|
||||
|
||||
for (EventListener listener : LISTENERS) {
|
||||
listener.onGuildUpdateNotificationLevel(guild, event.getOldNotificationLevel(), event.getNewNotificationLevel(), event);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateNSFWLevel(@NotNull GuildUpdateNSFWLevelEvent event) {
|
||||
BatGuild guild = guildService.getGuild(event.getGuild().getId());
|
||||
|
||||
for (EventListener listener : LISTENERS) {
|
||||
listener.onGuildUpdateNSFWLevel(guild, event.getOldNSFWLevel(), event.getNewNSFWLevel(), event);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateOwner(@NotNull GuildUpdateOwnerEvent event) {
|
||||
BatGuild guild = guildService.getGuild(event.getGuild().getId());
|
||||
if (event.getOldOwner() == null || event.getNewOwner() == null) {
|
||||
return;
|
||||
}
|
||||
BatUser oldOwner = userService.getUser(event.getOldOwner().getId(), event.getOldOwner().getUser());
|
||||
BatUser newOwner = userService.getUser(event.getNewOwner().getId(), event.getNewOwner().getUser());
|
||||
|
||||
for (EventListener listener : LISTENERS) {
|
||||
listener.onGuildUpdateOwner(guild, oldOwner, newOwner, event);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateRulesChannel(@NotNull GuildUpdateRulesChannelEvent event) {
|
||||
BatGuild guild = guildService.getGuild(event.getGuild().getId());
|
||||
|
||||
for (EventListener listener : LISTENERS) {
|
||||
listener.onGuildUpdateRulesChannel(guild, event.getOldRulesChannel(), event.getNewRulesChannel(), event);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateSystemChannel(@NotNull GuildUpdateSystemChannelEvent event) {
|
||||
BatGuild guild = guildService.getGuild(event.getGuild().getId());
|
||||
|
||||
for (EventListener listener : LISTENERS) {
|
||||
listener.onGuildUpdateSystemChannel(guild, event.getOldSystemChannel(), event.getNewSystemChannel(), event);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateVanityCode(@NotNull GuildUpdateVanityCodeEvent event) {
|
||||
BatGuild guild = guildService.getGuild(event.getGuild().getId());
|
||||
|
||||
for (EventListener listener : LISTENERS) {
|
||||
listener.onGuildUpdateVanityCode(guild, event.getOldVanityCode(), event.getNewVanityCode(), event);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateVerificationLevel(@NotNull GuildUpdateVerificationLevelEvent event) {
|
||||
BatGuild guild = guildService.getGuild(event.getGuild().getId());
|
||||
|
||||
for (EventListener listener : LISTENERS) {
|
||||
listener.onGuildUpdateVerificationLevel(guild, event.getOldVerificationLevel(), event.getNewVerificationLevel(), event);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildUpdateSplash(@NotNull GuildUpdateSplashEvent event) {
|
||||
BatGuild guild = guildService.getGuild(event.getGuild().getId());
|
||||
|
||||
for (EventListener listener : LISTENERS) {
|
||||
listener.onGuildUpdateSplash(guild, event.getOldSplashUrl(), event.getNewSplashUrl(), event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,77 +0,0 @@
|
||||
package cc.fascinated.bat.service;
|
||||
|
||||
import info.movito.themoviedbapi.TmdbApi;
|
||||
import info.movito.themoviedbapi.model.core.Movie;
|
||||
import info.movito.themoviedbapi.model.core.MovieResultsPage;
|
||||
import info.movito.themoviedbapi.model.core.TvSeries;
|
||||
import info.movito.themoviedbapi.model.core.TvSeriesResultsPage;
|
||||
import lombok.Getter;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Nick (okNick)
|
||||
*/
|
||||
@Service
|
||||
@Getter
|
||||
@Log4j2(topic = "TMDB Service")
|
||||
public class TMDBService {
|
||||
/**
|
||||
* The API key.
|
||||
*/
|
||||
private final String apiKey;
|
||||
|
||||
/**
|
||||
* The TMDB API instance.
|
||||
*/
|
||||
private final TmdbApi tmdbApi;
|
||||
|
||||
public TMDBService(@Value("${tmdb.api-key}") String apiKey) {
|
||||
this.apiKey = apiKey;
|
||||
|
||||
this.tmdbApi = new TmdbApi(apiKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup movies based on the provided query and options.
|
||||
*
|
||||
* @param query The query to search for
|
||||
* @param includeAdult Whether to include adult content
|
||||
* @param language The language to search in
|
||||
* @param primaryReleaseYear The primary release year to filter by
|
||||
* @param region The region to search in
|
||||
* @param year The year to filter by
|
||||
* @return The list of movies found with the provided query and options
|
||||
*/
|
||||
@SneakyThrows
|
||||
public List<Movie> lookupMovies(String query, boolean includeAdult, String language, String primaryReleaseYear, String region, String year) {
|
||||
MovieResultsPage movies = tmdbApi.getSearch().searchMovie(query, includeAdult, language, primaryReleaseYear, 1, region, year);
|
||||
if (movies.getTotalResults() == 0) {
|
||||
return null;
|
||||
}
|
||||
return movies.getResults();
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup series based on the provided query and options.
|
||||
*
|
||||
* @param query The query to search for
|
||||
* @param includeAdult Whether to include adult content
|
||||
* @param language The language to search in
|
||||
* @param firstAirDateYear The first air date year to filter by
|
||||
* @param year The year to filter by
|
||||
* @return The list of series found with the provided query and options
|
||||
*/
|
||||
@SneakyThrows
|
||||
public List<TvSeries> lookupSeries(String query, boolean includeAdult, String language, int firstAirDateYear, int year) {
|
||||
TvSeriesResultsPage series = tmdbApi.getSearch().searchTv(query, firstAirDateYear, includeAdult, language, 1, year);
|
||||
if (series.getTotalResults() == 0) {
|
||||
return null;
|
||||
}
|
||||
return series.getResults();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user