a lil cleanup and add role perms when adding and removing a role to the log
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 59s

This commit is contained in:
Lee
2024-07-04 18:04:15 +01:00
parent 313f43172d
commit 75da7a4b51
2 changed files with 22 additions and 4 deletions

View File

@ -3,6 +3,7 @@ package cc.fascinated.bat.features.logging.listeners;
import cc.fascinated.bat.common.EmbedDescriptionBuilder;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.HexColorUtils;
import cc.fascinated.bat.common.RoleUtils;
import cc.fascinated.bat.event.EventListener;
import cc.fascinated.bat.features.logging.LogFeature;
import cc.fascinated.bat.features.logging.LogType;
@ -71,26 +72,28 @@ public class RoleListener implements EventListener {
public void onRoleCreate(@NonNull BatGuild guild, @NonNull RoleCreateEvent event) {
Role role = event.getRole();
log.info("Role \"{}\" was created in guild \"{}\"", role.getName(), guild.getName());
logFeature.sendLog(guild, LogType.ROLE_CREATE, EmbedUtils.successEmbed()
.setDescription(new EmbedDescriptionBuilder("Role Created")
.appendLine("Role: %s".formatted(role.getAsMention()), true)
.appendLine("Color: `%s`".formatted(
role.getColor() == null ? "Default" : HexColorUtils.colorToHex(role.getColor())
), true)
.appendLine("Permissions: %s".formatted(RoleUtils.getFormattedPermissions(role)), true)
.build())
.build());
}
@Override
public void onRoleDelete(@NonNull BatGuild guild, @NonNull RoleDeleteEvent event) {
log.info("Role \"{}\" was deleted in guild \"{}\"", event.getRole().getName(), guild.getName());
Role role = event.getRole();
log.info("Role \"{}\" was deleted in guild \"{}\"", role.getName(), guild.getName());
logFeature.sendLog(guild, LogType.ROLE_DELETE, EmbedUtils.successEmbed()
.setDescription(new EmbedDescriptionBuilder("Role Deleted")
.appendLine("Role: `%s`".formatted(event.getRole().getName()), true)
.appendLine("Role: `%s`".formatted(role.getName()), true)
.appendLine("Color: `%s`".formatted(
event.getRole().getColor() == null ? "Default" : HexColorUtils.colorToHex(event.getRole().getColor())
role.getColor() == null ? "Default" : HexColorUtils.colorToHex(role.getColor())
), true)
.appendLine("Permissions: %s".formatted(RoleUtils.getFormattedPermissions(role)), true)
.build())
.build());
}