Mise à jour de l'api avec de nouveaux appels aux fonctions (le superbe DiscordCCommande)
This commit is contained in:
parent
c32da2f131
commit
d5ebc5ec27
@ -1,4 +1,4 @@
|
|||||||
package com.bernard.discord.commands;
|
package com.bernard.julsoundbox;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@ -10,7 +10,8 @@ import java.util.Queue;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
import com.bernard.discord.api.Command;
|
import com.bernard.juliabot.api.Command;
|
||||||
|
import com.bernard.juliabot.api.DiscordCCommande;
|
||||||
import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler;
|
import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler;
|
||||||
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
|
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
|
||||||
import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager;
|
import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager;
|
||||||
@ -48,8 +49,9 @@ public class JulSoundBox {
|
|||||||
Random randomizator;
|
Random randomizator;
|
||||||
static boolean play;
|
static boolean play;
|
||||||
|
|
||||||
@Command(name = "playing",grp="snd",group="SoundBox", admin = false, description = "Demande à JuL'IA quel son elle est en train de jouer")
|
@Command(name = "playing",aliases = "kestujoues", admin = false, description = "Demande à JuL'IA quel son elle est en train de jouer")
|
||||||
public void playing(Guild guild, Message message) {
|
public void playing(DiscordCCommande ccommande) {
|
||||||
|
Message message = ccommande.getMessage();
|
||||||
if(soundHandler.currentTrack == null && playlist.isEmpty()) {
|
if(soundHandler.currentTrack == null && playlist.isEmpty()) {
|
||||||
notifyUser("Ben je suis en fait en train de jouer .... rien du tout", message.getAuthor(), message.getChannel());
|
notifyUser("Ben je suis en fait en train de jouer .... rien du tout", message.getAuthor(), message.getChannel());
|
||||||
return;
|
return;
|
||||||
@ -105,8 +107,11 @@ public class JulSoundBox {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(name = "come",grp="snd",group="SoundBox", admin = true, description = "Ammène julia dans le salon vocal auquel l'utilisateur est connécté")
|
@Command(name = "come", admin = true, description = "Ammène julia dans le salon vocal auquel l'utilisateur est connecté")
|
||||||
public void come(Guild guild, Message message, User user) {
|
public void come(DiscordCCommande ccommande) {
|
||||||
|
Message message = ccommande.getMessage();
|
||||||
|
User user = message.getAuthor();
|
||||||
|
Guild guild = ccommande.getMessage().getGuild();
|
||||||
final GuildVoiceState memberVoiceState = guild.getMember(user).getVoiceState();
|
final GuildVoiceState memberVoiceState = guild.getMember(user).getVoiceState();
|
||||||
System.out.println("Coming into channel of voice state "+memberVoiceState);
|
System.out.println("Coming into channel of voice state "+memberVoiceState);
|
||||||
if(!memberVoiceState.inVoiceChannel())
|
if(!memberVoiceState.inVoiceChannel())
|
||||||
@ -117,8 +122,12 @@ public class JulSoundBox {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(name = "go",grp="snd",group="SoundBox", admin = true, description = "Ammène julia dans le salon spécifié")
|
@Command(name = "go", admin = true, description = "Ammène julia dans le salon spécifié")
|
||||||
public void go(Guild guild, Message message, User user) {
|
public void go(DiscordCCommande ccommande) {
|
||||||
|
Message message = ccommande.getMessage();
|
||||||
|
User user = message.getAuthor();
|
||||||
|
Guild guild = ccommande.getMessage().getGuild();
|
||||||
|
|
||||||
String channelName = message.getContentRaw().substring(message.getContentRaw().indexOf("go")+3);
|
String channelName = message.getContentRaw().substring(message.getContentRaw().indexOf("go")+3);
|
||||||
System.out.println("Going to channel : "+channelName);
|
System.out.println("Going to channel : "+channelName);
|
||||||
switch(channelName) {
|
switch(channelName) {
|
||||||
@ -141,8 +150,11 @@ public class JulSoundBox {
|
|||||||
manager.openAudioConnection(currentChannel);
|
manager.openAudioConnection(currentChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(name = "play",grp="snd",group="SoundBox", admin = true, description = "Reprends ou lance la lecture d'un son")
|
@Command(name = "play", admin = true, description = "Reprends ou lance la lecture d'un son")
|
||||||
public void play(Guild guild, Message message, User user) {
|
public void play(DiscordCCommande ccommande) {
|
||||||
|
Message message = ccommande.getMessage();
|
||||||
|
User user = message.getAuthor();
|
||||||
|
|
||||||
String soundName = null;
|
String soundName = null;
|
||||||
if(message.getContentRaw().endsWith("play")) {
|
if(message.getContentRaw().endsWith("play")) {
|
||||||
if(soundHandler.currentTrack != null || !playlist.isEmpty()) {
|
if(soundHandler.currentTrack != null || !playlist.isEmpty()) {
|
||||||
@ -186,8 +198,11 @@ public class JulSoundBox {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(name = "play2",grp="snd",group="SoundBox", admin = true, description = "Reprends ou lance la lecture d'un son2")
|
@Command(name = "play2", admin = true, description = "Reprends ou lance la lecture d'un son2")
|
||||||
public void play2(Guild guild, Message message, User user) {
|
public void play2(DiscordCCommande ccommande) {
|
||||||
|
Message message = ccommande.getMessage();
|
||||||
|
User user = message.getAuthor();
|
||||||
|
|
||||||
String soundName = message.getContentRaw().substring(message.getContentRaw().indexOf("play2")+6);
|
String soundName = message.getContentRaw().substring(message.getContentRaw().indexOf("play2")+6);
|
||||||
System.out.println("Trying to play : "+soundName);
|
System.out.println("Trying to play : "+soundName);
|
||||||
playerManager.loadItem("/var/julia/julsoundbox/sounds/" + soundName + soundExtension, new AudioLoadResultHandler() {
|
playerManager.loadItem("/var/julia/julsoundbox/sounds/" + soundName + soundExtension, new AudioLoadResultHandler() {
|
||||||
@ -214,8 +229,11 @@ public class JulSoundBox {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(name = "queue",grp="snd",group="SoundBox", admin = true, description = "Ajoute un son à la liste de lecture")
|
@Command(name = "queue",admin = true, description = "Ajoute un son à la liste de lecture")
|
||||||
public void queue(Guild guild, Message message, User user) {
|
public void queue(DiscordCCommande ccommande) {
|
||||||
|
Message message = ccommande.getMessage();
|
||||||
|
User user = message.getAuthor();
|
||||||
|
|
||||||
String soundName = null;
|
String soundName = null;
|
||||||
if(message.getContentRaw().indexOf("queue")+5 == message.getContentRaw().length()) {
|
if(message.getContentRaw().indexOf("queue")+5 == message.getContentRaw().length()) {
|
||||||
File[] songsFiles = new File("/var/julia/julsoundbox/sounds/").listFiles();
|
File[] songsFiles = new File("/var/julia/julsoundbox/sounds/").listFiles();
|
||||||
@ -251,8 +269,11 @@ public class JulSoundBox {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(name = "unqueue",grp="snd",group="SoundBox", admin = true, description = "Enlève un son de la liste de lecture")//TODO test
|
@Command(name = "unqueue", admin = true, description = "Enlève un son de la liste de lecture")//TODO test
|
||||||
public void unqueue(Guild guild, Message message, User user) {
|
public void unqueue(DiscordCCommande ccommande) {
|
||||||
|
Message message = ccommande.getMessage();
|
||||||
|
User user = message.getAuthor();
|
||||||
|
|
||||||
String soundId = message.getContentRaw().substring(message.getContentRaw().indexOf("unqueue")+8);
|
String soundId = message.getContentRaw().substring(message.getContentRaw().indexOf("unqueue")+8);
|
||||||
if(soundId.matches("^[0-9]+$")) {
|
if(soundId.matches("^[0-9]+$")) {
|
||||||
Iterator<AudioTrack> it = playlist.iterator();
|
Iterator<AudioTrack> it = playlist.iterator();
|
||||||
@ -276,22 +297,22 @@ public class JulSoundBox {
|
|||||||
soundHandler.update();
|
soundHandler.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(name = "pause",grp="snd",group="SoundBox", admin = true, description = "Met le son joué en pause (wow)")
|
@Command(name = "pause", admin = true, description = "Met le son joué en pause (wow)")
|
||||||
public void pause(Guild guild, Message message, User user) {
|
public void pause(DiscordCCommande ccommande) {
|
||||||
soundHandler.update(false);
|
soundHandler.update(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(name = "chut",grp="snd",group="SoundBox", admin = true, description = "Arette le son que JuL'IA joue (un !!play reprendra le morceau suivant ")
|
@Command(name = "chut", admin = true, description = "Arette le son que JuL'IA joue (un !!play reprendra le morceau suivant ")
|
||||||
public void chut(Guild guild, Message message, User user) {
|
public void chut(DiscordCCommande ccommande) {
|
||||||
play = false;
|
play = false;
|
||||||
soundHandler.next();
|
soundHandler.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(name = "soundInit",grp="snd",group="SoundBox", admin = true, description = "Evite que tout le programme ne crashe .... a ne pas oublier (en attendant que tout 'fonctionne' ...)")
|
@Command(name = "soundInit", admin = true, description = "Evite que tout le programme ne crashe .... a ne pas oublier (en attendant que tout 'fonctionne' ...)")
|
||||||
public void soundInit(Guild guild) {
|
public void soundInit(DiscordCCommande ccommande) {
|
||||||
playerManager = new DefaultAudioPlayerManager();
|
playerManager = new DefaultAudioPlayerManager();
|
||||||
soundHandler = new BernardSoundHandler();
|
soundHandler = new BernardSoundHandler();
|
||||||
manager = guild.getAudioManager();
|
manager = ccommande.getMessage().getGuild().getAudioManager();
|
||||||
AudioSourceManagers.registerLocalSource(playerManager);
|
AudioSourceManagers.registerLocalSource(playerManager);
|
||||||
manager.setSendingHandler(soundHandler);
|
manager.setSendingHandler(soundHandler);
|
||||||
currentChannel = null;
|
currentChannel = null;
|
||||||
@ -367,7 +388,7 @@ public class JulSoundBox {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] provide20MsAudio() {
|
public byte[] provide20MsAudio() {
|
||||||
return lastFrame.data;
|
return lastFrame.getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user