Skip to content

Commit

Permalink
added format
Browse files Browse the repository at this point in the history
  • Loading branch information
nea89o committed Feb 8, 2018
1 parent 6f98b4b commit 1d2ac05
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
1 change: 1 addition & 0 deletions src/main/java/de/romjaki/privateroombot/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ public class Config {
String token;
String from_channel_id;
String category_id;
String format = "privat - %s";
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void onGuildVoiceJoin(GuildVoiceJoinEvent event) {
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();
}
Expand All @@ -40,7 +40,8 @@ public void onGuildVoiceMove(GuildVoiceMoveEvent event) {

@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();
Expand Down

0 comments on commit 1d2ac05

Please sign in to comment.