Adding Disconnect (Web and Command) #15
This commit is contained in:
parent
4445383f75
commit
bc32bafef6
@ -51,7 +51,7 @@ public class BotListener extends ListenerAdapter {
|
||||
|
||||
if(event.getMember().getRoles().size() == 0){
|
||||
logger.info(event.getUser().getName()+ "have no roles, move it!");
|
||||
new Move().exc(event.getMember(),event.getJDA().getRolesByName("Rat_d'égout",true),false,event.getJDA().getGuilds().get(0),event.getJDA().getGuilds().get(0).getManager());
|
||||
new Move().exc(event.getMember(),event.getJDA().getRolesByName("Populace",true),false,event.getJDA().getGuilds().get(0),event.getJDA().getGuilds().get(0).getManager());
|
||||
MainBot.roleFlag = false;
|
||||
}
|
||||
}
|
||||
@ -76,7 +76,7 @@ public class BotListener extends ListenerAdapter {
|
||||
logger.debug("I'm alone, close audio connection.");
|
||||
|
||||
Music music = (Music) MainBot.commandes.get("music");
|
||||
music.audio.stop(event);
|
||||
music.audio.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -128,13 +128,21 @@ public class Music implements Commande {
|
||||
}
|
||||
break;
|
||||
|
||||
case "disconnect":
|
||||
audio.stop();
|
||||
List<Message> messages = new ArrayList<Message>(){{
|
||||
add(event.getMessage());
|
||||
}};
|
||||
new MessageTimeOut(messages, 0).start();
|
||||
break;
|
||||
|
||||
default:
|
||||
Message message = event.getTextChannel().sendMessage(EmbedMessageUtils.getMusicError("Arguments inconu!")).complete();
|
||||
List<Message> messages = new ArrayList<Message>(){{
|
||||
List<Message> messagess = new ArrayList<Message>(){{
|
||||
add(message);
|
||||
add(event.getMessage());
|
||||
}};
|
||||
new MessageTimeOut(messages, MainBot.messageTimeOut).start();
|
||||
new MessageTimeOut(messagess, MainBot.messageTimeOut).start();
|
||||
break;
|
||||
|
||||
}
|
||||
|
21
src/main/java/net/Broken/RestApi/Commands/Disconnect.java
Normal file
21
src/main/java/net/Broken/RestApi/Commands/Disconnect.java
Normal file
@ -0,0 +1,21 @@
|
||||
package net.Broken.RestApi.Commands;
|
||||
|
||||
import net.Broken.Commands.Music;
|
||||
import net.Broken.MainBot;
|
||||
import net.Broken.RestApi.CommandInterface;
|
||||
import net.Broken.RestApi.Data.CommandPostData;
|
||||
import net.Broken.RestApi.Data.CommandResponseData;
|
||||
import net.Broken.audio.WebLoadUtils;
|
||||
import net.dv8tion.jda.core.entities.User;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
public class Disconnect implements CommandInterface{
|
||||
@Override
|
||||
public ResponseEntity<CommandResponseData> action(Music musicCommande, CommandPostData data, User user) {
|
||||
Music music = (Music) MainBot.commandes.get("music");
|
||||
music.audio.stop();
|
||||
return new ResponseEntity<>(new CommandResponseData(data.command,"Ok"), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
@ -258,12 +258,13 @@ public class AudioM {
|
||||
}
|
||||
}
|
||||
|
||||
public void stop (GuildVoiceLeaveEvent event) {
|
||||
public void stop () {
|
||||
|
||||
GuildMusicManager musicManager = getGuildAudioPlayer(event.getGuild());
|
||||
GuildMusicManager musicManager = getGuildAudioPlayer(guild);
|
||||
musicManager.scheduler.stop();
|
||||
musicManager.scheduler.flush();
|
||||
playedChanel = null;
|
||||
event.getGuild().getAudioManager().closeAudioConnection();
|
||||
guild.getAudioManager().closeAudioConnection();
|
||||
}
|
||||
|
||||
public GuildMusicManager getMusicManager() throws NullMusicManager, NotConectedException {
|
||||
|
@ -123,7 +123,11 @@ $(document).ready(function() {
|
||||
sendCommand(command);
|
||||
});
|
||||
|
||||
})
|
||||
$('#btn_disconnect').click(function () {
|
||||
sendCommand({command : "DISCONNECT"})
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -167,6 +171,9 @@ function getCurentMusic() {
|
||||
if ($('#btn_next').hasClass("disabled")) {
|
||||
$('#btn_next').removeClass("disabled");
|
||||
}
|
||||
if ($('#btn_disconnect').hasClass("disabled")) {
|
||||
$('#btn_disconnect').removeClass("disabled");
|
||||
}
|
||||
}
|
||||
else{
|
||||
if (!$('#btn_stop').hasClass("disabled")) {
|
||||
@ -188,6 +195,10 @@ function getCurentMusic() {
|
||||
if (!$('#btn_next').hasClass("disabled")) {
|
||||
$('#btn_next').addClass("disabled");
|
||||
}
|
||||
|
||||
if (!$('#btn_disconnect').hasClass("disabled")) {
|
||||
$('#btn_disconnect').addClass("disabled");
|
||||
}
|
||||
}
|
||||
$('#btn_play').children().text("play_arrow");
|
||||
|
||||
@ -215,8 +226,6 @@ function getCurentMusic() {
|
||||
$('#btn_play').removeClass("amber");
|
||||
$('#btn_play').addClass("green");
|
||||
updateControl(data);
|
||||
|
||||
|
||||
break;
|
||||
|
||||
case "LOADING":
|
||||
@ -255,6 +264,9 @@ function getCurentMusic() {
|
||||
if (!$('#flush_btn').hasClass("disabled")) {
|
||||
$('#flush_btn').addClass("disabled");
|
||||
}
|
||||
if (!$('#btn_disconnect').hasClass("disabled")) {
|
||||
$('#btn_disconnect').addClass("disabled");
|
||||
}
|
||||
|
||||
|
||||
$('#music_img').attr("src","/img/disconnected.png");
|
||||
@ -394,6 +406,9 @@ function updateControl(data){
|
||||
if ($('#btn_next').hasClass("disabled")) {
|
||||
$('#btn_next').removeClass("disabled");
|
||||
}
|
||||
if ($('#btn_disconnect').hasClass("disabled")) {
|
||||
$('#btn_disconnect').removeClass("disabled");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -416,6 +431,9 @@ function updateControl(data){
|
||||
if (!$('#btn_next').hasClass("disabled")) {
|
||||
$('#btn_next').addClass("disabled");
|
||||
}
|
||||
if (!$('#btn_disconnect').hasClass("disabled")) {
|
||||
$('#btn_disconnect').addClass("disabled");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -156,7 +156,17 @@
|
||||
<i class="material-icons">info</i>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="row center">
|
||||
<div class="col offset-s5 s2 center">
|
||||
<a class="btn-large red accent-4 z-depth-3 waves-effect waves-light" id="btn_disconnect">
|
||||
<i class="material-icons">call_end</i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="col s4" >
|
||||
<table>
|
||||
|
Loading…
Reference in New Issue
Block a user