forked from Fascinated/Bat
add member nickname update log
This commit is contained in:
parent
3f93df131d
commit
6eca92b4cf
@ -21,7 +21,8 @@ public enum LogType {
|
|||||||
* Member Events
|
* Member Events
|
||||||
*/
|
*/
|
||||||
MEMBER_JOIN(LogCategory.MEMBER, "Member Join"),
|
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
|
* The category of the log type
|
||||||
|
@ -50,10 +50,17 @@ public class SetSubCommand extends BatSubCommand {
|
|||||||
EmbedDescriptionBuilder description = new EmbedDescriptionBuilder("Log Channel");
|
EmbedDescriptionBuilder description = new EmbedDescriptionBuilder("Log Channel");
|
||||||
description.appendLine("Successfully set the log channel for all log types to %s".formatted(targetChannel.getAsMention()), false);
|
description.appendLine("Successfully set the log channel for all log types to %s".formatted(targetChannel.getAsMention()), false);
|
||||||
description.emptyLine();
|
description.emptyLine();
|
||||||
for (LogType logType : LogType.values()) {
|
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);
|
description.appendLine(logType.getName(), true);
|
||||||
profile.setLogChannel(logType, targetChannel);
|
profile.setLogChannel(logType, targetChannel);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
event.replyEmbeds(EmbedUtils.successEmbed()
|
event.replyEmbeds(EmbedUtils.successEmbed()
|
||||||
.setDescription(description.build())
|
.setDescription(description.build())
|
||||||
|
@ -10,6 +10,7 @@ import cc.fascinated.bat.model.BatUser;
|
|||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import net.dv8tion.jda.api.events.guild.member.GuildMemberJoinEvent;
|
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.GuildMemberRemoveEvent;
|
||||||
|
import net.dv8tion.jda.api.events.guild.member.update.GuildMemberUpdateNicknameEvent;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@ -51,4 +52,17 @@ public class MemberListener implements EventListener {
|
|||||||
.build())
|
.build())
|
||||||
.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.BatUser;
|
||||||
import cc.fascinated.bat.model.DiscordMessage;
|
import cc.fascinated.bat.model.DiscordMessage;
|
||||||
import lombok.NonNull;
|
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.MessageDeleteEvent;
|
||||||
import net.dv8tion.jda.api.events.message.MessageUpdateEvent;
|
import net.dv8tion.jda.api.events.message.MessageUpdateEvent;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
Loading…
Reference in New Issue
Block a user