add member nickname update log
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 39s
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 39s
This commit is contained in:
parent
3f93df131d
commit
6eca92b4cf
@ -21,7 +21,8 @@ public enum LogType {
|
||||
* Member Events
|
||||
*/
|
||||
MEMBER_JOIN(LogCategory.MEMBER, "Member Join"),
|
||||
MEMBER_LEAVE(LogCategory.MEMBER, "Member Leave");
|
||||
MEMBER_LEAVE(LogCategory.MEMBER, "Member Leave"),
|
||||
MEMBER_NICKNAME_CHANGE(LogCategory.MEMBER, "Member Nickname Change");
|
||||
|
||||
/**
|
||||
* The category of the log type
|
||||
|
@ -50,9 +50,16 @@ public class SetSubCommand extends BatSubCommand {
|
||||
EmbedDescriptionBuilder description = new EmbedDescriptionBuilder("Log Channel");
|
||||
description.appendLine("Successfully set the log channel for all log types to %s".formatted(targetChannel.getAsMention()), false);
|
||||
description.emptyLine();
|
||||
for (LogType logType : LogType.values()) {
|
||||
description.appendLine(logType.getName(), true);
|
||||
profile.setLogChannel(logType, targetChannel);
|
||||
for (int i = 0; i < LogCategory.values().length; i++) {
|
||||
LogCategory category = LogCategory.values()[i];
|
||||
if (i != 0) {
|
||||
description.emptyLine();
|
||||
}
|
||||
description.appendLine("**__%s__**".formatted(category.getName()), false);
|
||||
for (LogType logType : LogType.getLogTypesByCategory(category.getName())) {
|
||||
description.appendLine(logType.getName(), true);
|
||||
profile.setLogChannel(logType, targetChannel);
|
||||
}
|
||||
}
|
||||
|
||||
event.replyEmbeds(EmbedUtils.successEmbed()
|
||||
|
@ -10,6 +10,7 @@ import cc.fascinated.bat.model.BatUser;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.events.guild.member.GuildMemberJoinEvent;
|
||||
import net.dv8tion.jda.api.events.guild.member.GuildMemberRemoveEvent;
|
||||
import net.dv8tion.jda.api.events.guild.member.update.GuildMemberUpdateNicknameEvent;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -51,4 +52,17 @@ public class MemberListener implements EventListener {
|
||||
.build())
|
||||
.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildMemberUpdateNickname(@NonNull BatGuild guild, @NonNull BatUser user, String oldName, String newName, @NonNull GuildMemberUpdateNicknameEvent event) {
|
||||
if (user.getDiscordUser().isBot()) return;
|
||||
|
||||
logFeature.sendLog(guild, LogType.MEMBER_NICKNAME_CHANGE, EmbedUtils.genericEmbed()
|
||||
.setDescription(new EmbedDescriptionBuilder("Member Nickname Changed")
|
||||
.appendLine("Member: %s".formatted(user.getDiscordUser().getAsMention()), true)
|
||||
.appendLine("Old Nickname: `%s`".formatted(oldName == null ? user.getName() : oldName), true)
|
||||
.appendLine("New Nickname: `%s`".formatted(newName == null ? "Removed Nickname" : newName), true)
|
||||
.build())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.model.DiscordMessage;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.events.message.MessageDeleteEvent;
|
||||
import net.dv8tion.jda.api.events.message.MessageUpdateEvent;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
Loading…
x
Reference in New Issue
Block a user