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){
|
if(event.getMember().getRoles().size() == 0){
|
||||||
logger.info(event.getUser().getName()+ "have no roles, move it!");
|
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;
|
MainBot.roleFlag = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -76,7 +76,7 @@ public class BotListener extends ListenerAdapter {
|
|||||||
logger.debug("I'm alone, close audio connection.");
|
logger.debug("I'm alone, close audio connection.");
|
||||||
|
|
||||||
Music music = (Music) MainBot.commandes.get("music");
|
Music music = (Music) MainBot.commandes.get("music");
|
||||||
music.audio.stop(event);
|
music.audio.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,13 +128,21 @@ public class Music implements Commande {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "disconnect":
|
||||||
|
audio.stop();
|
||||||
|
List<Message> messages = new ArrayList<Message>(){{
|
||||||
|
add(event.getMessage());
|
||||||
|
}};
|
||||||
|
new MessageTimeOut(messages, 0).start();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Message message = event.getTextChannel().sendMessage(EmbedMessageUtils.getMusicError("Arguments inconu!")).complete();
|
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(message);
|
||||||
add(event.getMessage());
|
add(event.getMessage());
|
||||||
}};
|
}};
|
||||||
new MessageTimeOut(messages, MainBot.messageTimeOut).start();
|
new MessageTimeOut(messagess, MainBot.messageTimeOut).start();
|
||||||
break;
|
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.stop();
|
||||||
|
musicManager.scheduler.flush();
|
||||||
playedChanel = null;
|
playedChanel = null;
|
||||||
event.getGuild().getAudioManager().closeAudioConnection();
|
guild.getAudioManager().closeAudioConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
public GuildMusicManager getMusicManager() throws NullMusicManager, NotConectedException {
|
public GuildMusicManager getMusicManager() throws NullMusicManager, NotConectedException {
|
||||||
|
@ -123,8 +123,12 @@ $(document).ready(function() {
|
|||||||
sendCommand(command);
|
sendCommand(command);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#btn_disconnect').click(function () {
|
||||||
|
sendCommand({command : "DISCONNECT"})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -167,6 +171,9 @@ function getCurentMusic() {
|
|||||||
if ($('#btn_next').hasClass("disabled")) {
|
if ($('#btn_next').hasClass("disabled")) {
|
||||||
$('#btn_next').removeClass("disabled");
|
$('#btn_next').removeClass("disabled");
|
||||||
}
|
}
|
||||||
|
if ($('#btn_disconnect').hasClass("disabled")) {
|
||||||
|
$('#btn_disconnect').removeClass("disabled");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if (!$('#btn_stop').hasClass("disabled")) {
|
if (!$('#btn_stop').hasClass("disabled")) {
|
||||||
@ -188,6 +195,10 @@ function getCurentMusic() {
|
|||||||
if (!$('#btn_next').hasClass("disabled")) {
|
if (!$('#btn_next').hasClass("disabled")) {
|
||||||
$('#btn_next').addClass("disabled");
|
$('#btn_next').addClass("disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$('#btn_disconnect').hasClass("disabled")) {
|
||||||
|
$('#btn_disconnect').addClass("disabled");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$('#btn_play').children().text("play_arrow");
|
$('#btn_play').children().text("play_arrow");
|
||||||
|
|
||||||
@ -215,8 +226,6 @@ function getCurentMusic() {
|
|||||||
$('#btn_play').removeClass("amber");
|
$('#btn_play').removeClass("amber");
|
||||||
$('#btn_play').addClass("green");
|
$('#btn_play').addClass("green");
|
||||||
updateControl(data);
|
updateControl(data);
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "LOADING":
|
case "LOADING":
|
||||||
@ -255,6 +264,9 @@ function getCurentMusic() {
|
|||||||
if (!$('#flush_btn').hasClass("disabled")) {
|
if (!$('#flush_btn').hasClass("disabled")) {
|
||||||
$('#flush_btn').addClass("disabled");
|
$('#flush_btn').addClass("disabled");
|
||||||
}
|
}
|
||||||
|
if (!$('#btn_disconnect').hasClass("disabled")) {
|
||||||
|
$('#btn_disconnect').addClass("disabled");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$('#music_img').attr("src","/img/disconnected.png");
|
$('#music_img').attr("src","/img/disconnected.png");
|
||||||
@ -394,6 +406,9 @@ function updateControl(data){
|
|||||||
if ($('#btn_next').hasClass("disabled")) {
|
if ($('#btn_next').hasClass("disabled")) {
|
||||||
$('#btn_next').removeClass("disabled");
|
$('#btn_next').removeClass("disabled");
|
||||||
}
|
}
|
||||||
|
if ($('#btn_disconnect').hasClass("disabled")) {
|
||||||
|
$('#btn_disconnect').removeClass("disabled");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -416,6 +431,9 @@ function updateControl(data){
|
|||||||
if (!$('#btn_next').hasClass("disabled")) {
|
if (!$('#btn_next').hasClass("disabled")) {
|
||||||
$('#btn_next').addClass("disabled");
|
$('#btn_next').addClass("disabled");
|
||||||
}
|
}
|
||||||
|
if (!$('#btn_disconnect').hasClass("disabled")) {
|
||||||
|
$('#btn_disconnect').addClass("disabled");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -156,7 +156,17 @@
|
|||||||
<i class="material-icons">info</i>
|
<i class="material-icons">info</i>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</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>
|
||||||
<div class="col s4" >
|
<div class="col s4" >
|
||||||
<table>
|
<table>
|
||||||
|
Loading…
Reference in New Issue
Block a user