summaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorromangraef <roman.graef@gmail.com>2018-02-08 20:39:29 +0100
committerromangraef <roman.graef@gmail.com>2018-02-08 20:39:29 +0100
commit1d2ac0569fe71691a36e094357080a6b2ac2d7b6 (patch)
treef59a653ec340a610a94c505fbef556564e69f5b4 /src/main/java
parent6f98b4b74c95602ce514f32a96596b72e926d03b (diff)
downloadprivateroombot-1d2ac0569fe71691a36e094357080a6b2ac2d7b6.tar.gz
privateroombot-1d2ac0569fe71691a36e094357080a6b2ac2d7b6.tar.bz2
privateroombot-1d2ac0569fe71691a36e094357080a6b2ac2d7b6.zip
added format
Diffstat (limited to 'src/main/java')
-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();