switch voice channel log
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 1m15s

This commit is contained in:
Lee 2024-07-05 21:38:21 +01:00
parent fdd36d4385
commit a7af4108c6
3 changed files with 15 additions and 1 deletions

View File

@ -58,7 +58,7 @@ public class LogFeature extends Feature {
if (content == null) {
return "No content";
}
if (content.contains("`")) { // Workaround for markdown formatting
if (content.contains("`")) { // Workaround for Markdown formatting
content = content.replace("`", "'");
}
// More than 512 characters or is more than 4 lines

View File

@ -42,6 +42,7 @@ public enum LogType {
CHANNEL_DELETE(LogCategory.CHANNEL),
VOICE_CHANNEL_JOIN(LogCategory.CHANNEL),
VOICE_CHANNEL_LEAVE(LogCategory.CHANNEL),
VOICE_CHANNEL_SWITCH(LogCategory.CHANNEL),
CHANNEL_CONFIGURATION(LogCategory.CHANNEL),
THREAD_ARCHIVE(LogCategory.CHANNEL),

View File

@ -108,6 +108,7 @@ public class ChannelListener implements EventListener {
@Override
public void onGuildVoiceUpdate(@NonNull BatGuild guild, @NonNull BatUser user, @NonNull GenericGuildVoiceEvent event) {
AudioChannelUnion channel = event.getVoiceState().getChannel();
VoiceChannel oldChannel = lastVoiceChannel.get(user);
if (channel != null) {
VoiceChannel voiceChannel = channel.asVoiceChannel();
lastVoiceChannel.put(user, voiceChannel);
@ -120,6 +121,18 @@ public class ChannelListener implements EventListener {
if (!joined) {
lastVoiceChannel.remove(user);
}
// User switched channels
if (oldChannel != null && !oldChannel.equals(voiceChannel)) {
log.info("User \"{}\" switched from voice channel \"{}\" to \"{}\" in guild \"{}\"", user.getName(), oldChannel.getName(), voiceChannel.getName(), guild.getName());
String switchDescription = new EmbedDescriptionBuilder("Member Switched Voice Channel")
.appendLine("User: %s".formatted(user.getDiscordUser().getAsMention()), true)
.appendLine("Channel: %s -> %s".formatted(oldChannel.getAsMention(), voiceChannel.getAsMention()), true)
.build();
logFeature.sendLog(guild, LogType.VOICE_CHANNEL_SWITCH, EmbedUtils.successEmbed().setDescription(switchDescription).build());
return;
}
log.info("User \"{}\" {} voice channel \"{}\" in guild \"{}\"", user.getName(), joined ? "joined" : "left", voiceChannel.getName(), guild.getName());
String description = new EmbedDescriptionBuilder("Member %s Voice Channel".formatted(joined ? "Joined" : "Left"))
.appendLine("User: %s".formatted(user.getDiscordUser().getAsMention()), true)