summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.markdown3
-rw-r--r--src/main/java/de/romjaki/privateroombot/Config.java1
-rw-r--r--src/main/java/de/romjaki/privateroombot/VoiceChannelJoinListener.java5
3 files changed, 6 insertions, 3 deletions
diff --git a/README.markdown b/README.markdown
index f76d0d5..5e7a24f 100644
--- a/README.markdown
+++ b/README.markdown
@@ -13,7 +13,8 @@ also add a file called `config.json` with the following content:
{
"token": "TOKEN",
"from_channel_id": "the channel you want people to join in order to get an own channel. see ID's",
- "category_id": "the channel category you want all channels to be collected in. see ID's"
+ "category_id": "the channel category you want all channels to be collected in. see ID's",
+ "format": "(optional). put the name of the private room channel in here. %s will be replaced with the name."
}
```
you can get your bots token from [the discord developers page][1]
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();