make log messages more consistent
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 38s
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 38s
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.events.channel.ChannelCreateEvent;
|
||||
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.emoji.EmojiAddedEvent;
|
||||
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 onChannelUpdateName(@NonNull BatGuild guild, @NonNull ChannelUpdateNameEvent event) {
|
||||
}
|
||||
|
||||
default void onShutdown() {
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ public enum LogType {
|
||||
CHANNEL_DELETE(LogCategory.CHANNEL),
|
||||
VOICE_CHANNEL_JOIN(LogCategory.CHANNEL),
|
||||
VOICE_CHANNEL_LEAVE(LogCategory.CHANNEL),
|
||||
CHANNEL_UPDATE_NAME(LogCategory.CHANNEL),
|
||||
|
||||
/**
|
||||
* 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.events.channel.ChannelCreateEvent;
|
||||
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 org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
@ -50,7 +51,7 @@ public class ChannelListener implements EventListener {
|
||||
logFeature.sendLog(guild, LogType.CHANNEL_CREATE, EmbedUtils.successEmbed()
|
||||
.setDescription(new EmbedDescriptionBuilder("%s Created".formatted(type))
|
||||
.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());
|
||||
}
|
||||
@ -61,14 +62,28 @@ public class ChannelListener implements EventListener {
|
||||
String type = formatChannelType(channel);
|
||||
log.info("{} \"{}\" was deleted in guild \"{}\"", type, event.getChannel().getName(), guild.getName());
|
||||
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) {
|
||||
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());
|
||||
}
|
||||
|
||||
@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
|
||||
public void onGuildVoiceUpdate(@NonNull BatGuild guild, @NonNull BatUser user, @NonNull GenericGuildVoiceEvent event) {
|
||||
AudioChannelUnion channel = event.getVoiceState().getChannel();
|
||||
|
@ -44,7 +44,7 @@ public class GuildListener implements EventListener {
|
||||
.setDescription(new EmbedDescriptionBuilder("Invite Created")
|
||||
.appendLine("Invite: %s".formatted(expanded.getUrl()), 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)
|
||||
.build())
|
||||
.build()));
|
||||
@ -57,7 +57,7 @@ public class GuildListener implements EventListener {
|
||||
logFeature.sendLog(guild, LogType.EMOJI_ADD, EmbedUtils.successEmbed()
|
||||
.setDescription(new EmbedDescriptionBuilder("Emoji Added")
|
||||
.appendLine("Emoji: %s".formatted(emoji.getFormatted()), true)
|
||||
.appendLine("Name: %s".formatted(emoji.getName()), true)
|
||||
.appendLine("Name: `%s`".formatted(emoji.getName()), true)
|
||||
.build())
|
||||
.build());
|
||||
}
|
||||
@ -68,7 +68,7 @@ public class GuildListener implements EventListener {
|
||||
logFeature.sendLog(guild, LogType.EMOJI_REMOVE, EmbedUtils.successEmbed()
|
||||
.setDescription(new EmbedDescriptionBuilder("Emoji Removed")
|
||||
.appendLine("Emoji: %s".formatted(emoji.getFormatted()), true)
|
||||
.appendLine("Name: %s".formatted(emoji.getName()), true)
|
||||
.appendLine("Name: `%s`".formatted(emoji.getName()), true)
|
||||
.build())
|
||||
.build());
|
||||
}
|
||||
@ -79,8 +79,8 @@ public class GuildListener implements EventListener {
|
||||
logFeature.sendLog(guild, LogType.EMOJI_RENAME, EmbedUtils.successEmbed()
|
||||
.setDescription(new EmbedDescriptionBuilder("Emoji Renamed")
|
||||
.appendLine("Emoji: %s".formatted(emoji.getFormatted()), true)
|
||||
.appendLine("Old Name: %s".formatted(oldName), true)
|
||||
.appendLine("New Name: %s".formatted(newName), true)
|
||||
.appendLine("Old Name: `%s`".formatted(oldName), true)
|
||||
.appendLine("New Name: `%s`".formatted(newName), true)
|
||||
.build())
|
||||
.build());
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class MemberListener implements EventListener {
|
||||
logFeature.sendLog(guild, LogType.MEMBER_JOIN, EmbedUtils.successEmbed()
|
||||
.setDescription(new EmbedDescriptionBuilder("Member Joined")
|
||||
.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)
|
||||
.build())
|
||||
.setThumbnail(user.getDiscordUser().getEffectiveAvatarUrl())
|
||||
@ -70,7 +70,7 @@ public class MemberListener implements EventListener {
|
||||
logFeature.sendLog(guild, LogType.MEMBER_LEAVE, EmbedUtils.errorEmbed()
|
||||
.setDescription(new EmbedDescriptionBuilder("Member Left")
|
||||
.appendLine("Member: <@%s>".formatted(user.getId()), true)
|
||||
.appendLine("Username: %s".formatted(user.getName()), true)
|
||||
.appendLine("Username: `%s`".formatted(user.getName()), true)
|
||||
.build())
|
||||
.build());
|
||||
}
|
||||
@ -239,7 +239,7 @@ public class MemberListener implements EventListener {
|
||||
logFeature.sendLog(guild, LogType.MEMBER_BOOSTED, EmbedUtils.successEmbed()
|
||||
.setDescription(new EmbedDescriptionBuilder("Member Boosted")
|
||||
.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)
|
||||
.build())
|
||||
.build());
|
||||
@ -256,7 +256,7 @@ public class MemberListener implements EventListener {
|
||||
logFeature.sendLog(guild, LogType.MEMBER_BOOST_EXPIRE, EmbedUtils.errorEmbed()
|
||||
.setDescription(new EmbedDescriptionBuilder("Member Boost Expired")
|
||||
.appendLine("Member: %s".formatted(user.getDiscordUser().getAsMention()), true)
|
||||
.appendLine("Boosts Removed: %s".formatted(boostAmount), true)
|
||||
.appendLine("Boosts Removed: `%s`".formatted(boostAmount), true)
|
||||
.build())
|
||||
.build());
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import lombok.extern.log4j.Log4j2;
|
||||
import net.dv8tion.jda.api.entities.Invite;
|
||||
import net.dv8tion.jda.api.events.channel.ChannelCreateEvent;
|
||||
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.EmojiRemovedEvent;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@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