summaryrefslogtreecommitdiff
path: root/src/main/java/de/romjaki/privateroombot
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/romjaki/privateroombot')
-rw-r--r--src/main/java/de/romjaki/privateroombot/Config.java1
-rw-r--r--src/main/java/de/romjaki/privateroombot/VoiceChannelJoinListener.java5
2 files changed, 4 insertions, 2 deletions
diff --git a/src/main/java/de/romjaki/privateroombot/Config.java b/src/main/java/de/romjaki/privateroombot/Config.java
index 738070b..f27474d 100644
--- a/src/main/java/de/romjaki/privateroombot/Config.java
+++ b/src/main/java/de/romjaki/privateroombot/Config.java
@@ -19,4 +19,5 @@ public class Config {
String token;
String from_channel_id;
String category_id;
+ String format = "privat - %s";
}
diff --git a/src/main/java/de/romjaki/privateroombot/VoiceChannelJoinListener.java b/src/main/java/de/romjaki/privateroombot/VoiceChannelJoinListener.java
index e6401e2..08dcc66 100644
--- a/src/main/java/de/romjaki/privateroombot/VoiceChannelJoinListener.java
+++ b/src/main/java/de/romjaki/privateroombot/VoiceChannelJoinListener.java
@@ -21,7 +21,7 @@ public class VoiceChannelJoinListener extends ListenerAdapter {
Guild guild = event.getGuild();
Member member = event.getMember();
Category category = guild.getCategoryById(CONFIG.category_id);
- VoiceChannel newChannel = (VoiceChannel) category.createVoiceChannel(member.getEffectiveName() + " - privat").complete();
+ VoiceChannel newChannel = (VoiceChannel) category.createVoiceChannel(String.format(CONFIG.format, member.getEffectiveName())).complete();
newChannel.createPermissionOverride(member).setAllow(Permission.VOICE_MOVE_OTHERS).queue();
guild.getController().moveVoiceMember(member, newChannel).queue();
}
@@ -40,7 +40,8 @@ public class VoiceChannelJoinListener extends ListenerAdapter {
@Override
public void onGuildVoiceLeave(GuildVoiceLeaveEvent event) {
- if (!event.getChannelLeft().getParent().getId().equals(CONFIG.category_id)) {
+ Category cat = event.getChannelLeft().getParent();
+ if (cat == null || !cat.getId().equals(CONFIG.category_id)) {
return;
}
VoiceChannel channel = event.getChannelLeft();