Skip to content

Commit

Permalink
fixed "random" disconnects of KittyBot while playing music
Browse files Browse the repository at this point in the history
  • Loading branch information
topi314 committed Jan 29, 2021
1 parent ff163f5 commit 4646b4e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void run(Options options, CommandContext ctx){
}
int volume = options.getInt("volume");
if(volume < 0 || volume > 100){
ctx.error("Volume");
ctx.error("Volume needs to between 0 and 100");
return;
}
player.setVolume(volume);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ public void run(Options options, CommandContext ctx){
var groupName = options.getString("group");

emoteAction.queue(emote -> {
var group = ctx.get(SettingsModule.class).getSelfAssignableRoleGroups(ctx.getGuildId()).stream().filter(g -> g.getName().equalsIgnoreCase(groupName)).findFirst();
if(group.isEmpty()){
ctx.error("Please provide a valid group");
return;
}

ctx.get(SettingsModule.class).addSelfAssignableRoles(ctx.getGuildId(), Collections.singleton(new SelfAssignableRole(roleId, emote.getIdLong(), ctx.getGuildId(), group.get().getId())));
ctx.reply("Added self assignable role");
var group = ctx.get(SettingsModule.class).getSelfAssignableRoleGroups(ctx.getGuildId()).stream().filter(g -> g.getName().equalsIgnoreCase(groupName)).findFirst();
if(group.isEmpty()){
ctx.error("Please provide a valid group");
return;
}

ctx.get(SettingsModule.class).addSelfAssignableRoles(ctx.getGuildId(), Collections.singleton(new SelfAssignableRole(roleId, emote.getIdLong(), ctx.getGuildId(), group.get().getId())));
ctx.reply("Added self assignable role");
}, error -> ctx.error("Please provide a valid emote from this server")
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ public void onPlayerResume(IPlayer player){
@Override
public void onTrackStart(IPlayer player, AudioTrack track){
sendMusicController();
cancelDestroy();
}

@Override
Expand All @@ -215,6 +216,7 @@ public void onTrackEnd(IPlayer player, AudioTrack track, AudioTrackEndReason end
public void next(){
var next = this.queue.poll();
if(next == null){
this.player.stopTrack();
planDestroy();
return;
}
Expand All @@ -226,7 +228,7 @@ public void planDestroy(){
if(this.future != null){
return;
}
this.future = this.modules.schedule(() -> this.modules.get(MusicModule.class).destroy(this.guildId, -1L), 3, TimeUnit.MINUTES);
this.future = this.modules.schedule(() -> this.modules.get(MusicModule.class).destroy(this.guildId, -1L), 4, TimeUnit.MINUTES);
}

public void updateMusicController(){
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/messages/status_messages.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ watching you 👀
watching ${total_guilds} guilds 👀
watching ${total_users} users 👀
playing with new slash commands
competing with Xenia
playing JDA
watching JDA
watching Discord

0 comments on commit 4646b4e

Please sign in to comment.