forked from Fascinated/Bat
make log messages more consistent
This commit is contained in:
parent
b6ba778ff2
commit
772787a98e
@ -12,6 +12,7 @@ import net.dv8tion.jda.api.entities.Role;
|
|||||||
import net.dv8tion.jda.api.entities.emoji.Emoji;
|
import net.dv8tion.jda.api.entities.emoji.Emoji;
|
||||||
import net.dv8tion.jda.api.events.channel.ChannelCreateEvent;
|
import net.dv8tion.jda.api.events.channel.ChannelCreateEvent;
|
||||||
import net.dv8tion.jda.api.events.channel.ChannelDeleteEvent;
|
import net.dv8tion.jda.api.events.channel.ChannelDeleteEvent;
|
||||||
|
import net.dv8tion.jda.api.events.channel.update.ChannelUpdateNameEvent;
|
||||||
import net.dv8tion.jda.api.events.channel.update.GenericChannelUpdateEvent;
|
import net.dv8tion.jda.api.events.channel.update.GenericChannelUpdateEvent;
|
||||||
import net.dv8tion.jda.api.events.emoji.EmojiAddedEvent;
|
import net.dv8tion.jda.api.events.emoji.EmojiAddedEvent;
|
||||||
import net.dv8tion.jda.api.events.emoji.EmojiRemovedEvent;
|
import net.dv8tion.jda.api.events.emoji.EmojiRemovedEvent;
|
||||||
@ -132,6 +133,9 @@ public interface EventListener {
|
|||||||
default void onEmojiRename(@NonNull BatGuild guild, @NonNull Emoji emoji, @NonNull String oldName, @NonNull String newName, @NonNull EmojiUpdateNameEvent event) {
|
default void onEmojiRename(@NonNull BatGuild guild, @NonNull Emoji emoji, @NonNull String oldName, @NonNull String newName, @NonNull EmojiUpdateNameEvent event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default void onChannelUpdateName(@NonNull BatGuild guild, @NonNull ChannelUpdateNameEvent event) {
|
||||||
|
}
|
||||||
|
|
||||||
default void onShutdown() {
|
default void onShutdown() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,7 @@ public enum LogType {
|
|||||||
CHANNEL_DELETE(LogCategory.CHANNEL),
|
CHANNEL_DELETE(LogCategory.CHANNEL),
|
||||||
VOICE_CHANNEL_JOIN(LogCategory.CHANNEL),
|
VOICE_CHANNEL_JOIN(LogCategory.CHANNEL),
|
||||||
VOICE_CHANNEL_LEAVE(LogCategory.CHANNEL),
|
VOICE_CHANNEL_LEAVE(LogCategory.CHANNEL),
|
||||||
|
CHANNEL_UPDATE_NAME(LogCategory.CHANNEL),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Guild Events
|
* Guild Events
|
||||||
|
@ -17,6 +17,7 @@ import net.dv8tion.jda.api.entities.channel.unions.AudioChannelUnion;
|
|||||||
import net.dv8tion.jda.api.entities.channel.unions.ChannelUnion;
|
import net.dv8tion.jda.api.entities.channel.unions.ChannelUnion;
|
||||||
import net.dv8tion.jda.api.events.channel.ChannelCreateEvent;
|
import net.dv8tion.jda.api.events.channel.ChannelCreateEvent;
|
||||||
import net.dv8tion.jda.api.events.channel.ChannelDeleteEvent;
|
import net.dv8tion.jda.api.events.channel.ChannelDeleteEvent;
|
||||||
|
import net.dv8tion.jda.api.events.channel.update.ChannelUpdateNameEvent;
|
||||||
import net.dv8tion.jda.api.events.guild.voice.GenericGuildVoiceEvent;
|
import net.dv8tion.jda.api.events.guild.voice.GenericGuildVoiceEvent;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
@ -50,7 +51,7 @@ public class ChannelListener implements EventListener {
|
|||||||
logFeature.sendLog(guild, LogType.CHANNEL_CREATE, EmbedUtils.successEmbed()
|
logFeature.sendLog(guild, LogType.CHANNEL_CREATE, EmbedUtils.successEmbed()
|
||||||
.setDescription(new EmbedDescriptionBuilder("%s Created".formatted(type))
|
.setDescription(new EmbedDescriptionBuilder("%s Created".formatted(type))
|
||||||
.appendLine("%s: %s".formatted(type, event.getChannel().getAsMention()), true)
|
.appendLine("%s: %s".formatted(type, event.getChannel().getAsMention()), true)
|
||||||
.appendLine("Name: %s".formatted(event.getChannel().getName()), true)
|
.appendLine("Name: `%s`".formatted(event.getChannel().getName()), true)
|
||||||
.build())
|
.build())
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
@ -61,14 +62,28 @@ public class ChannelListener implements EventListener {
|
|||||||
String type = formatChannelType(channel);
|
String type = formatChannelType(channel);
|
||||||
log.info("{} \"{}\" was deleted in guild \"{}\"", type, event.getChannel().getName(), guild.getName());
|
log.info("{} \"{}\" was deleted in guild \"{}\"", type, event.getChannel().getName(), guild.getName());
|
||||||
EmbedDescriptionBuilder description = new EmbedDescriptionBuilder("%s Deleted".formatted(type))
|
EmbedDescriptionBuilder description = new EmbedDescriptionBuilder("%s Deleted".formatted(type))
|
||||||
.appendLine("Name: #%s".formatted(channel.getName()), true);
|
.appendLine("Name: `#%s`".formatted(channel.getName()), true);
|
||||||
if (channel instanceof TextChannel) {
|
if (channel instanceof TextChannel) {
|
||||||
TextChannel textChannel = channel.asTextChannel();
|
TextChannel textChannel = channel.asTextChannel();
|
||||||
description.appendLine("Topic: %s".formatted(textChannel.getTopic() == null ? "No Topic" : textChannel.getTopic()), true);
|
description.appendLine("Topic: `%s`".formatted(textChannel.getTopic() == null ? "No Topic" : textChannel.getTopic()), true);
|
||||||
}
|
}
|
||||||
logFeature.sendLog(guild, LogType.CHANNEL_DELETE, EmbedUtils.errorEmbed().setDescription(description.build()).build());
|
logFeature.sendLog(guild, LogType.CHANNEL_DELETE, EmbedUtils.errorEmbed().setDescription(description.build()).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onChannelUpdateName(@NonNull BatGuild guild, @NonNull ChannelUpdateNameEvent event) {
|
||||||
|
ChannelUnion channel = event.getChannel();
|
||||||
|
String type = formatChannelType(channel);
|
||||||
|
log.info("{} \"{}\" name was updated in guild \"{}\"", type, event.getChannel().getName(), guild.getName());
|
||||||
|
logFeature.sendLog(guild, LogType.CHANNEL_UPDATE_NAME, EmbedUtils.successEmbed()
|
||||||
|
.setDescription(new EmbedDescriptionBuilder("%s Name Updated".formatted(type))
|
||||||
|
.appendLine("%s: %s".formatted(type, event.getChannel().getAsMention()), true)
|
||||||
|
.appendLine("Old Name: `%s`".formatted(event.getOldValue()), true)
|
||||||
|
.appendLine("New Name: `%s`".formatted(event.getNewValue()), true)
|
||||||
|
.build())
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGuildVoiceUpdate(@NonNull BatGuild guild, @NonNull BatUser user, @NonNull GenericGuildVoiceEvent event) {
|
public void onGuildVoiceUpdate(@NonNull BatGuild guild, @NonNull BatUser user, @NonNull GenericGuildVoiceEvent event) {
|
||||||
AudioChannelUnion channel = event.getVoiceState().getChannel();
|
AudioChannelUnion channel = event.getVoiceState().getChannel();
|
||||||
|
@ -44,7 +44,7 @@ public class GuildListener implements EventListener {
|
|||||||
.setDescription(new EmbedDescriptionBuilder("Invite Created")
|
.setDescription(new EmbedDescriptionBuilder("Invite Created")
|
||||||
.appendLine("Invite: %s".formatted(expanded.getUrl()), true)
|
.appendLine("Invite: %s".formatted(expanded.getUrl()), true)
|
||||||
.appendLine("Channel: %s".formatted(expanded.getChannel()), true)
|
.appendLine("Channel: %s".formatted(expanded.getChannel()), true)
|
||||||
.appendLine("Max Uses: %s".formatted(expanded.getMaxUses() == 0 ? "Infinite" : expanded.getMaxUses()), true)
|
.appendLine("Max Uses: `%s`".formatted(expanded.getMaxUses() == 0 ? "Infinite" : expanded.getMaxUses()), true)
|
||||||
.appendLine("Creator: %s".formatted(expanded.getInviter() == null ? "Unknown" : expanded.getInviter().getAsMention()), true)
|
.appendLine("Creator: %s".formatted(expanded.getInviter() == null ? "Unknown" : expanded.getInviter().getAsMention()), true)
|
||||||
.build())
|
.build())
|
||||||
.build()));
|
.build()));
|
||||||
@ -57,7 +57,7 @@ public class GuildListener implements EventListener {
|
|||||||
logFeature.sendLog(guild, LogType.EMOJI_ADD, EmbedUtils.successEmbed()
|
logFeature.sendLog(guild, LogType.EMOJI_ADD, EmbedUtils.successEmbed()
|
||||||
.setDescription(new EmbedDescriptionBuilder("Emoji Added")
|
.setDescription(new EmbedDescriptionBuilder("Emoji Added")
|
||||||
.appendLine("Emoji: %s".formatted(emoji.getFormatted()), true)
|
.appendLine("Emoji: %s".formatted(emoji.getFormatted()), true)
|
||||||
.appendLine("Name: %s".formatted(emoji.getName()), true)
|
.appendLine("Name: `%s`".formatted(emoji.getName()), true)
|
||||||
.build())
|
.build())
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
@ -68,7 +68,7 @@ public class GuildListener implements EventListener {
|
|||||||
logFeature.sendLog(guild, LogType.EMOJI_REMOVE, EmbedUtils.successEmbed()
|
logFeature.sendLog(guild, LogType.EMOJI_REMOVE, EmbedUtils.successEmbed()
|
||||||
.setDescription(new EmbedDescriptionBuilder("Emoji Removed")
|
.setDescription(new EmbedDescriptionBuilder("Emoji Removed")
|
||||||
.appendLine("Emoji: %s".formatted(emoji.getFormatted()), true)
|
.appendLine("Emoji: %s".formatted(emoji.getFormatted()), true)
|
||||||
.appendLine("Name: %s".formatted(emoji.getName()), true)
|
.appendLine("Name: `%s`".formatted(emoji.getName()), true)
|
||||||
.build())
|
.build())
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
@ -79,8 +79,8 @@ public class GuildListener implements EventListener {
|
|||||||
logFeature.sendLog(guild, LogType.EMOJI_RENAME, EmbedUtils.successEmbed()
|
logFeature.sendLog(guild, LogType.EMOJI_RENAME, EmbedUtils.successEmbed()
|
||||||
.setDescription(new EmbedDescriptionBuilder("Emoji Renamed")
|
.setDescription(new EmbedDescriptionBuilder("Emoji Renamed")
|
||||||
.appendLine("Emoji: %s".formatted(emoji.getFormatted()), true)
|
.appendLine("Emoji: %s".formatted(emoji.getFormatted()), true)
|
||||||
.appendLine("Old Name: %s".formatted(oldName), true)
|
.appendLine("Old Name: `%s`".formatted(oldName), true)
|
||||||
.appendLine("New Name: %s".formatted(newName), true)
|
.appendLine("New Name: `%s`".formatted(newName), true)
|
||||||
.build())
|
.build())
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ public class MemberListener implements EventListener {
|
|||||||
logFeature.sendLog(guild, LogType.MEMBER_JOIN, EmbedUtils.successEmbed()
|
logFeature.sendLog(guild, LogType.MEMBER_JOIN, EmbedUtils.successEmbed()
|
||||||
.setDescription(new EmbedDescriptionBuilder("Member Joined")
|
.setDescription(new EmbedDescriptionBuilder("Member Joined")
|
||||||
.appendLine("Member: %s".formatted(user.getDiscordUser().getAsMention()), true)
|
.appendLine("Member: %s".formatted(user.getDiscordUser().getAsMention()), true)
|
||||||
.appendLine("Username: %s".formatted(user.getDiscordUser().getName()), true)
|
.appendLine("Username: `%s`".formatted(user.getDiscordUser().getName()), true)
|
||||||
.appendLine("Joined Discord: <t:%s:R>".formatted(user.getDiscordUser().getTimeCreated().toEpochSecond()), true)
|
.appendLine("Joined Discord: <t:%s:R>".formatted(user.getDiscordUser().getTimeCreated().toEpochSecond()), true)
|
||||||
.build())
|
.build())
|
||||||
.setThumbnail(user.getDiscordUser().getEffectiveAvatarUrl())
|
.setThumbnail(user.getDiscordUser().getEffectiveAvatarUrl())
|
||||||
@ -70,7 +70,7 @@ public class MemberListener implements EventListener {
|
|||||||
logFeature.sendLog(guild, LogType.MEMBER_LEAVE, EmbedUtils.errorEmbed()
|
logFeature.sendLog(guild, LogType.MEMBER_LEAVE, EmbedUtils.errorEmbed()
|
||||||
.setDescription(new EmbedDescriptionBuilder("Member Left")
|
.setDescription(new EmbedDescriptionBuilder("Member Left")
|
||||||
.appendLine("Member: <@%s>".formatted(user.getId()), true)
|
.appendLine("Member: <@%s>".formatted(user.getId()), true)
|
||||||
.appendLine("Username: %s".formatted(user.getName()), true)
|
.appendLine("Username: `%s`".formatted(user.getName()), true)
|
||||||
.build())
|
.build())
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
@ -239,7 +239,7 @@ public class MemberListener implements EventListener {
|
|||||||
logFeature.sendLog(guild, LogType.MEMBER_BOOSTED, EmbedUtils.successEmbed()
|
logFeature.sendLog(guild, LogType.MEMBER_BOOSTED, EmbedUtils.successEmbed()
|
||||||
.setDescription(new EmbedDescriptionBuilder("Member Boosted")
|
.setDescription(new EmbedDescriptionBuilder("Member Boosted")
|
||||||
.appendLine("Member: %s".formatted(user.getDiscordUser().getAsMention()), true)
|
.appendLine("Member: %s".formatted(user.getDiscordUser().getAsMention()), true)
|
||||||
.appendLine("Boost Months: %s".formatted(boostAmount), true)
|
.appendLine("Boost Months: `%s`".formatted(boostAmount), true)
|
||||||
.appendLine("Boost End: <t:%s>".formatted(seconds), true)
|
.appendLine("Boost End: <t:%s>".formatted(seconds), true)
|
||||||
.build())
|
.build())
|
||||||
.build());
|
.build());
|
||||||
@ -256,7 +256,7 @@ public class MemberListener implements EventListener {
|
|||||||
logFeature.sendLog(guild, LogType.MEMBER_BOOST_EXPIRE, EmbedUtils.errorEmbed()
|
logFeature.sendLog(guild, LogType.MEMBER_BOOST_EXPIRE, EmbedUtils.errorEmbed()
|
||||||
.setDescription(new EmbedDescriptionBuilder("Member Boost Expired")
|
.setDescription(new EmbedDescriptionBuilder("Member Boost Expired")
|
||||||
.appendLine("Member: %s".formatted(user.getDiscordUser().getAsMention()), true)
|
.appendLine("Member: %s".formatted(user.getDiscordUser().getAsMention()), true)
|
||||||
.appendLine("Boosts Removed: %s".formatted(boostAmount), true)
|
.appendLine("Boosts Removed: `%s`".formatted(boostAmount), true)
|
||||||
.build())
|
.build())
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import lombok.extern.log4j.Log4j2;
|
|||||||
import net.dv8tion.jda.api.entities.Invite;
|
import net.dv8tion.jda.api.entities.Invite;
|
||||||
import net.dv8tion.jda.api.events.channel.ChannelCreateEvent;
|
import net.dv8tion.jda.api.events.channel.ChannelCreateEvent;
|
||||||
import net.dv8tion.jda.api.events.channel.ChannelDeleteEvent;
|
import net.dv8tion.jda.api.events.channel.ChannelDeleteEvent;
|
||||||
|
import net.dv8tion.jda.api.events.channel.update.ChannelUpdateNameEvent;
|
||||||
import net.dv8tion.jda.api.events.emoji.EmojiAddedEvent;
|
import net.dv8tion.jda.api.events.emoji.EmojiAddedEvent;
|
||||||
import net.dv8tion.jda.api.events.emoji.EmojiRemovedEvent;
|
import net.dv8tion.jda.api.events.emoji.EmojiRemovedEvent;
|
||||||
import net.dv8tion.jda.api.events.emoji.update.EmojiUpdateNameEvent;
|
import net.dv8tion.jda.api.events.emoji.update.EmojiUpdateNameEvent;
|
||||||
@ -381,4 +382,13 @@ public class EventService extends ListenerAdapter {
|
|||||||
listener.onEmojiRename(guild, event.getEmoji(), event.getOldName(), event.getNewName(), event);
|
listener.onEmojiRename(guild, event.getEmoji(), event.getOldName(), event.getNewName(), event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onChannelUpdateName(@NotNull ChannelUpdateNameEvent event) {
|
||||||
|
BatGuild guild = guildService.getGuild(event.getGuild().getId());
|
||||||
|
|
||||||
|
for (EventListener listener : LISTENERS) {
|
||||||
|
listener.onChannelUpdateName(guild, event);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user