diff options
author | romangraef <roman.graef@gmail.com> | 2018-02-08 20:39:29 +0100 |
---|---|---|
committer | romangraef <roman.graef@gmail.com> | 2018-02-08 20:39:29 +0100 |
commit | 1d2ac0569fe71691a36e094357080a6b2ac2d7b6 (patch) | |
tree | f59a653ec340a610a94c505fbef556564e69f5b4 | |
parent | 6f98b4b74c95602ce514f32a96596b72e926d03b (diff) | |
download | privateroombot-1d2ac0569fe71691a36e094357080a6b2ac2d7b6.tar.gz privateroombot-1d2ac0569fe71691a36e094357080a6b2ac2d7b6.tar.bz2 privateroombot-1d2ac0569fe71691a36e094357080a6b2ac2d7b6.zip |
added format
-rw-r--r-- | README.markdown | 3 | ||||
-rw-r--r-- | src/main/java/de/romjaki/privateroombot/Config.java | 1 | ||||
-rw-r--r-- | src/main/java/de/romjaki/privateroombot/VoiceChannelJoinListener.java | 5 |
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(); |