Compare commits
1 Commits
c28a476682
...
7ec9037fb5
Author | SHA1 | Date | |
---|---|---|---|
|
7ec9037fb5 |
@ -63,7 +63,7 @@ dependencies {
|
||||
implementation 'com.google.apis:google-api-services-youtube:v3-rev20210410-1.31.0'
|
||||
|
||||
|
||||
implementation group: 'org.jsoup', name: 'jsoup', version: '1.15.1'
|
||||
implementation group: 'org.jsoup', name: 'jsoup', version: '1.14.3'
|
||||
|
||||
|
||||
implementation("org.springframework.boot:spring-boot-starter-thymeleaf") {
|
||||
|
182
src/main/java/net/Broken/Commands/Music.java
Normal file
182
src/main/java/net/Broken/Commands/Music.java
Normal file
@ -0,0 +1,182 @@
|
||||
package net.Broken.Commands;
|
||||
|
||||
import net.Broken.Commande;
|
||||
import net.Broken.MainBot;
|
||||
import net.Broken.Tools.EmbedMessageUtils;
|
||||
import net.Broken.Tools.MessageTimeOut;
|
||||
import net.Broken.audio.AudioM;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.VoiceChannel;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Music commands
|
||||
*/
|
||||
|
||||
public class Music implements Commande {
|
||||
private Logger logger = LogManager.getLogger();
|
||||
|
||||
|
||||
@Override
|
||||
public void action(String[] args, MessageReceivedEvent event) {
|
||||
AudioM audio = AudioM.getInstance(event.getGuild());
|
||||
if(args.length >= 1){
|
||||
switch (args[0]){
|
||||
case "play":
|
||||
event.getTextChannel().sendTyping().queue();
|
||||
|
||||
if(args.length>=2){
|
||||
if(event.getMember().getVoiceState().inVoiceChannel()){
|
||||
|
||||
VoiceChannel voiceChanel = event.getMember().getVoiceState().getChannel();
|
||||
logger.info("Connecting to "+voiceChanel.getName()+"...");
|
||||
if(args.length ==2){
|
||||
audio.loadAndPlay(event,voiceChanel,args[1],30,false);
|
||||
}
|
||||
else if(args.length == 3){
|
||||
try{
|
||||
int limit = Integer.parseInt(args[2]);
|
||||
audio.loadAndPlay(event,voiceChanel,args[1],limit,false);
|
||||
}catch (NumberFormatException e){
|
||||
audio.loadAndPlay(event,voiceChanel,args[1],30,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
Message message = event.getTextChannel().sendMessage(EmbedMessageUtils.getMusicError("You are not in a voice channel !")).complete();
|
||||
List<Message> messages = new ArrayList<Message>(){{
|
||||
add(message);
|
||||
add(event.getMessage());
|
||||
}};
|
||||
new MessageTimeOut(messages, MainBot.messageTimeOut).start();
|
||||
}
|
||||
}
|
||||
else{
|
||||
Message message = event.getTextChannel().sendMessage(EmbedMessageUtils.getMusicError("Missing argument!")).complete();
|
||||
List<Message> messages = new ArrayList<Message>(){{
|
||||
add(message);
|
||||
add(event.getMessage());
|
||||
}};
|
||||
new MessageTimeOut(messages, MainBot.messageTimeOut).start();
|
||||
}
|
||||
|
||||
break;
|
||||
case "pause":
|
||||
audio.pause(event);
|
||||
break;
|
||||
case "resume":
|
||||
audio.resume(event);
|
||||
break;
|
||||
case "next":
|
||||
audio.skipTrack(event);
|
||||
break;
|
||||
case "stop":
|
||||
audio.stop(event);
|
||||
break;
|
||||
case "info":
|
||||
audio.info(event);
|
||||
break;
|
||||
case "flush":
|
||||
audio.flush(event);
|
||||
break;
|
||||
case "list":
|
||||
audio.list(event);
|
||||
break;
|
||||
case "add":
|
||||
event.getTextChannel().sendTyping().queue();
|
||||
if(args.length ==2){
|
||||
audio.add(event,args[1],30,false);
|
||||
}
|
||||
else if(args.length == 3){
|
||||
try{
|
||||
int limit = Integer.parseInt(args[2]);
|
||||
audio.add(event,args[1],limit,false);
|
||||
}catch (NumberFormatException e){
|
||||
audio.add(event,args[1],30,false);
|
||||
}
|
||||
}
|
||||
else{
|
||||
Message message = event.getTextChannel().sendMessage(EmbedMessageUtils.getMusicError("Missing argument!")).complete();
|
||||
List<Message> messages = new ArrayList<Message>(){{
|
||||
add(message);
|
||||
add(event.getMessage());
|
||||
}};
|
||||
new MessageTimeOut(messages, MainBot.messageTimeOut).start();
|
||||
}
|
||||
break;
|
||||
|
||||
case "addNext":
|
||||
event.getTextChannel().sendTyping().queue();
|
||||
if(args.length >=2){
|
||||
audio.add(event,args[1],1,true);
|
||||
}
|
||||
else{
|
||||
Message message = event.getTextChannel().sendMessage(EmbedMessageUtils.getMusicError("Missing argument!")).complete();
|
||||
List<Message> messages = new ArrayList<Message>(){{
|
||||
add(message);
|
||||
add(event.getMessage());
|
||||
}};
|
||||
new MessageTimeOut(messages, MainBot.messageTimeOut).start();
|
||||
}
|
||||
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("Unknown argument!")).complete();
|
||||
List<Message> messagess = new ArrayList<Message>(){{
|
||||
add(message);
|
||||
add(event.getMessage());
|
||||
}};
|
||||
new MessageTimeOut(messagess, MainBot.messageTimeOut).start();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
else{
|
||||
Message message = event.getTextChannel().sendMessage(EmbedMessageUtils.getMusicError("Missing argument!")).complete();
|
||||
List<Message> messages = new ArrayList<Message>(){{
|
||||
add(message);
|
||||
add(event.getMessage());
|
||||
}};
|
||||
new MessageTimeOut(messages, MainBot.messageTimeOut).start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrivateUsable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAdminCmd() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the command is usable only by bot level admin user
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
@Override
|
||||
public boolean isBotAdminCmd() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNSFW() {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package net.Broken.RestApi;
|
||||
|
||||
import net.Broken.Commands.Music;
|
||||
import net.Broken.RestApi.Data.CommandPostData;
|
||||
import net.Broken.RestApi.Data.CommandResponseData;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.Broken.RestApi.Commands;
|
||||
|
||||
import net.Broken.Commands.Music;
|
||||
import net.Broken.RestApi.CommandInterface;
|
||||
import net.Broken.RestApi.Data.CommandPostData;
|
||||
import net.Broken.RestApi.Data.CommandResponseData;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.Broken.RestApi.Commands;
|
||||
|
||||
import net.Broken.Commands.Music;
|
||||
import net.Broken.RestApi.CommandInterface;
|
||||
import net.Broken.RestApi.Data.CommandPostData;
|
||||
import net.Broken.RestApi.Data.CommandResponseData;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.Broken.RestApi.Commands;
|
||||
|
||||
import net.Broken.Commands.Music;
|
||||
import net.Broken.RestApi.CommandInterface;
|
||||
import net.Broken.RestApi.Data.CommandPostData;
|
||||
import net.Broken.RestApi.Data.CommandResponseData;
|
||||
|
@ -1,5 +1,7 @@
|
||||
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;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.Broken.RestApi.Commands;
|
||||
|
||||
import net.Broken.Commands.Music;
|
||||
import net.Broken.RestApi.CommandInterface;
|
||||
import net.Broken.RestApi.Data.CommandPostData;
|
||||
import net.Broken.RestApi.Data.CommandResponseData;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.Broken.RestApi.Commands;
|
||||
|
||||
import net.Broken.Commands.Music;
|
||||
import net.Broken.RestApi.CommandInterface;
|
||||
import net.Broken.RestApi.Data.CommandPostData;
|
||||
import net.Broken.RestApi.Data.CommandResponseData;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.Broken.RestApi.Commands;
|
||||
|
||||
import net.Broken.Commands.Music;
|
||||
import net.Broken.RestApi.CommandInterface;
|
||||
import net.Broken.RestApi.Data.CommandPostData;
|
||||
import net.Broken.RestApi.Data.CommandResponseData;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.Broken.RestApi.Commands;
|
||||
|
||||
import net.Broken.Commands.Music;
|
||||
import net.Broken.RestApi.CommandInterface;
|
||||
import net.Broken.RestApi.Data.CommandPostData;
|
||||
import net.Broken.RestApi.Data.CommandResponseData;
|
||||
|
@ -1,11 +1,13 @@
|
||||
package net.Broken.RestApi.Commands;
|
||||
|
||||
import net.Broken.Commands.Music;
|
||||
import net.Broken.RestApi.CommandInterface;
|
||||
import net.Broken.RestApi.Data.CommandPostData;
|
||||
import net.Broken.RestApi.Data.CommandResponseData;
|
||||
import net.Broken.audio.AudioM;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
|
@ -2,7 +2,6 @@ package net.Broken;
|
||||
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
||||
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -21,8 +20,6 @@ public interface SlashCommand {
|
||||
|
||||
List<OptionData> getOptions();
|
||||
|
||||
List<SubcommandData> getSubcommands();
|
||||
|
||||
/**
|
||||
* Determines if the command is usable only by bot level admin user
|
||||
* @return boolean
|
||||
|
@ -11,7 +11,6 @@ import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
||||
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.json.JSONObject;
|
||||
@ -64,11 +63,6 @@ public class Cat implements SlashCommand {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SubcommandData> getSubcommands() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determines if the command is usable only by bot level admin user
|
||||
|
@ -1,164 +0,0 @@
|
||||
package net.Broken.SlashCommands;
|
||||
|
||||
|
||||
import net.Broken.MainBot;
|
||||
import net.Broken.SlashCommand;
|
||||
import net.Broken.Tools.EmbedMessageUtils;
|
||||
import net.Broken.Tools.MessageTimeOut;
|
||||
import net.Broken.audio.AudioM;
|
||||
import net.dv8tion.jda.api.MessageBuilder;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.VoiceChannel;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
||||
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Command that return a random picture of cat.
|
||||
*/
|
||||
public class Music implements SlashCommand {
|
||||
private Logger logger = LogManager.getLogger();
|
||||
;
|
||||
|
||||
@Override
|
||||
public void action(SlashCommandEvent event) {
|
||||
AudioM audio = AudioM.getInstance(event.getGuild());
|
||||
String action = event.getSubcommandName();
|
||||
event.deferReply().queue();
|
||||
switch (action) {
|
||||
case "play":
|
||||
if (event.getMember().getVoiceState().inVoiceChannel()) {
|
||||
VoiceChannel voiceChanel = event.getMember().getVoiceState().getChannel();
|
||||
logger.info("Connecting to " + voiceChanel.getName() + "...");
|
||||
OptionMapping url = event.getOption("url");
|
||||
if (event.getOption("playlist-limit") == null) {
|
||||
audio.loadAndPlay(event, voiceChanel, url.getAsString(), 30, false);
|
||||
} else {
|
||||
long limit = event.getOption("playlist-limit").getAsLong();
|
||||
audio.loadAndPlay(event, voiceChanel, url.getAsString(), (int) limit, false);
|
||||
}
|
||||
} else {
|
||||
Message message = new MessageBuilder().setEmbeds(EmbedMessageUtils.getMusicError("You are not in a voice channel !")).build();
|
||||
event.getHook().sendMessage(message).queue();
|
||||
}
|
||||
break;
|
||||
// case "add":
|
||||
// event.getTextChannel().sendTyping().queue();
|
||||
// if(args.length ==2){
|
||||
// audio.add(event,args[1],30,false);
|
||||
// }
|
||||
// else if(args.length == 3){
|
||||
// try{
|
||||
// int limit = Integer.parseInt(args[2]);
|
||||
// audio.add(event,args[1],limit,false);
|
||||
// }catch (NumberFormatException e){
|
||||
// audio.add(event,args[1],30,false);
|
||||
// }
|
||||
// }
|
||||
// else{
|
||||
// Message message = event.getTextChannel().sendMessage(EmbedMessageUtils.getMusicError("Missing argument!")).complete();
|
||||
// List<Message> messages = new ArrayList<Message>(){{
|
||||
// add(message);
|
||||
// add(event.getMessage());
|
||||
// }};
|
||||
// new MessageTimeOut(messages, MainBot.messageTimeOut).start();
|
||||
// }
|
||||
// break;
|
||||
// case "addNext":
|
||||
// event.getTextChannel().sendTyping().queue();
|
||||
// if(args.length >=2){
|
||||
// audio.add(event,args[1],1,true);
|
||||
// }
|
||||
// else{
|
||||
// Message message = event.getTextChannel().sendMessage(EmbedMessageUtils.getMusicError("Missing argument!")).complete();
|
||||
// List<Message> messages = new ArrayList<Message>(){{
|
||||
// add(message);
|
||||
// add(event.getMessage());
|
||||
// }};
|
||||
// new MessageTimeOut(messages, MainBot.messageTimeOut).start();
|
||||
// }
|
||||
// break;
|
||||
case "pause":
|
||||
audio.pause(event);
|
||||
break;
|
||||
case "resume":
|
||||
audio.resume(event);
|
||||
break;
|
||||
case "next":
|
||||
audio.skipTrack(event);
|
||||
break;
|
||||
case "stop":
|
||||
case "disconnect":
|
||||
audio.stop(event);
|
||||
break;
|
||||
case "info":
|
||||
audio.info(event);
|
||||
break;
|
||||
case "flush":
|
||||
audio.flush(event);
|
||||
break;
|
||||
case "list":
|
||||
audio.list(event);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Music Bot !";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OptionData> getOptions() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SubcommandData> getSubcommands() {
|
||||
ArrayList<SubcommandData> subCommandList = new ArrayList<>();
|
||||
subCommandList.add(new SubcommandData("play", "Play somme music")
|
||||
.addOption(OptionType.STRING, "url", "The URL of the video to play", true)
|
||||
.addOption(OptionType.INTEGER, "playlist-limit", "If a playlist is loaded, enter the max number of loaded tracks"));
|
||||
subCommandList.add(new SubcommandData("add", "Add music to queue")
|
||||
.addOption(OptionType.STRING, "url", " The URL of the video to play", true));
|
||||
subCommandList.add(new SubcommandData("pause", "Pause playback"));
|
||||
subCommandList.add(new SubcommandData("resume", "Resume playback"));
|
||||
subCommandList.add(new SubcommandData("stop", "Stop playback"));
|
||||
subCommandList.add(new SubcommandData("next", "Next music"));
|
||||
subCommandList.add(new SubcommandData("info", "Get currently playing info"));
|
||||
subCommandList.add(new SubcommandData("flush", "Flush queue"));
|
||||
subCommandList.add(new SubcommandData("list", "Get queue"));
|
||||
return subCommandList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determines if the command is usable only by bot level admin user
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
@Override
|
||||
public boolean isBotAdminCmd() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNSFW() {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -63,13 +63,7 @@ public class SlashCommandLoader {
|
||||
|
||||
public static void registerSlashCommands(CommandListUpdateAction commandListUpdateAction){
|
||||
MainBot.slashCommands.forEach((k,v)->{
|
||||
CommandData command = new CommandData(k, v.getDescription());
|
||||
if(v.getOptions() != null)
|
||||
command.addOptions(v.getOptions());
|
||||
if(v.getSubcommands() != null){
|
||||
command.addSubcommands(v.getSubcommands());
|
||||
}
|
||||
commandListUpdateAction.addCommands(command);
|
||||
commandListUpdateAction.addCommands(new CommandData(k, v.getDescription()).addOptions(v.getOptions()));
|
||||
});
|
||||
commandListUpdateAction.queue();
|
||||
}
|
||||
|
@ -11,12 +11,9 @@ import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo;
|
||||
import net.Broken.MainBot;
|
||||
import net.Broken.RestApi.Data.UserAudioTrackData;
|
||||
import net.Broken.Tools.EmbedMessageUtils;
|
||||
import net.dv8tion.jda.api.MessageBuilder;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.entities.VoiceChannel;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@ -80,7 +77,7 @@ public class AudioM {
|
||||
* @param playlistLimit Limit of playlist
|
||||
* @param onHead True for adding audio track on top of playlist
|
||||
*/
|
||||
public void loadAndPlay(SlashCommandEvent event, VoiceChannel voiceChannel, final String trackUrl, int playlistLimit, boolean onHead) {
|
||||
public void loadAndPlay(MessageReceivedEvent event, VoiceChannel voiceChannel, final String trackUrl, int playlistLimit, boolean onHead) {
|
||||
GuildMusicManager musicManager = getGuildAudioPlayer();
|
||||
playedChanel = voiceChannel;
|
||||
|
||||
@ -88,9 +85,9 @@ public class AudioM {
|
||||
@Override
|
||||
public void trackLoaded(AudioTrack track) {
|
||||
logger.info("[" + guild + "] Single Track detected!");
|
||||
UserAudioTrack uat = new UserAudioTrack(event.getUser(), track);
|
||||
Message message = new MessageBuilder().setEmbeds(EmbedMessageUtils.getMusicOk("Add " + track.getInfo().title + " to playlist")).build();
|
||||
event.getHook().sendMessage(message).queue();
|
||||
UserAudioTrack uat = new UserAudioTrack(event.getAuthor(), track);
|
||||
event.getTextChannel().sendMessage(EmbedMessageUtils.getMusicOk("Add " + track.getInfo().title + " to playlist")).queue();
|
||||
|
||||
play(guild, voiceChannel, musicManager, uat, onHead);
|
||||
}
|
||||
|
||||
@ -98,24 +95,27 @@ public class AudioM {
|
||||
public void playlistLoaded(AudioPlaylist playlist) {
|
||||
logger.info("[" + guild + "] Playlist detected! Limit: " + playlistLimit);
|
||||
AudioTrack firstTrack = playlist.getSelectedTrack();
|
||||
Message message = new MessageBuilder().setEmbeds(EmbedMessageUtils.getMusicOk("Add " + firstTrack.getInfo().title + " and 30 first videos to playlist !")).build();
|
||||
event.getHook().sendMessage(message).queue();
|
||||
playListLoader(playlist, playlistLimit, event.getUser(), onHead);
|
||||
|
||||
event.getTextChannel().sendMessage(EmbedMessageUtils.getMusicOk("Add " + firstTrack.getInfo().title + " and 30 first videos to playlist !")).queue();
|
||||
|
||||
|
||||
playListLoader(playlist, playlistLimit, event.getAuthor(), onHead);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void noMatches() {
|
||||
logger.warn("[" + guild + "] Cant find media!");
|
||||
Message message = new MessageBuilder().setEmbeds(EmbedMessageUtils.getMusicError("Video not found !")).build();
|
||||
event.getHook().sendMessage(message).queue();
|
||||
event.getTextChannel().sendMessage(EmbedMessageUtils.getMusicError("Video not found !")).queue();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadFailed(FriendlyException exception) {
|
||||
logger.error("[" + guild + "] Can't load media!");
|
||||
logger.error(exception.getMessage());
|
||||
Message message = new MessageBuilder().setEmbeds(EmbedMessageUtils.getMusicError("Playback error !")).build();
|
||||
event.getHook().sendMessage(message).queue();
|
||||
event.getTextChannel().sendMessage(EmbedMessageUtils.getMusicError("Playback error !")).queue();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -208,11 +208,10 @@ public class AudioM {
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
public void skipTrack(SlashCommandEvent event) {
|
||||
public void skipTrack(MessageReceivedEvent event) {
|
||||
GuildMusicManager musicManager = getGuildAudioPlayer();
|
||||
musicManager.scheduler.nextTrack();
|
||||
Message message = new MessageBuilder().setEmbeds(EmbedMessageUtils.getMusicOk("Next music !")).build();
|
||||
event.getHook().sendMessage(message).queue();
|
||||
event.getTextChannel().sendMessage(EmbedMessageUtils.getMusicOk("Next music!")).queue();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -220,11 +219,11 @@ public class AudioM {
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
public void pause(SlashCommandEvent event) {
|
||||
public void pause(MessageReceivedEvent event) {
|
||||
GuildMusicManager musicManager = getGuildAudioPlayer();
|
||||
musicManager.scheduler.pause();
|
||||
Message message = new MessageBuilder().setEmbeds(EmbedMessageUtils.getMusicOk("Playback paused")).build();
|
||||
event.getHook().sendMessage(message).queue();
|
||||
|
||||
event.getTextChannel().sendMessage(EmbedMessageUtils.getMusicOk("Music paused")).queue();
|
||||
|
||||
|
||||
}
|
||||
@ -234,11 +233,11 @@ public class AudioM {
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
public void resume(SlashCommandEvent event) {
|
||||
public void resume(MessageReceivedEvent event) {
|
||||
GuildMusicManager musicManager = getGuildAudioPlayer();
|
||||
musicManager.scheduler.resume();
|
||||
Message message = new MessageBuilder().setEmbeds(EmbedMessageUtils.getMusicOk("Playback resumed")).build();
|
||||
event.getHook().sendMessage(message).queue();
|
||||
|
||||
event.getTextChannel().sendMessage(EmbedMessageUtils.getMusicOk("Music resumed")).queue();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -246,19 +245,18 @@ public class AudioM {
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
public void info(SlashCommandEvent event) {
|
||||
public void info(MessageReceivedEvent event) {
|
||||
GuildMusicManager musicManager = getGuildAudioPlayer();
|
||||
AudioTrackInfo info = musicManager.scheduler.getInfo();
|
||||
UserAudioTrack userAudioTrack = musicManager.scheduler.getCurrentPlayingTrack();
|
||||
Message message = new MessageBuilder().setEmbeds(EmbedMessageUtils.getMusicOk(info.title + "\n" + info.uri + "\nSubmitted by: " + userAudioTrack.getSubmittedUser().getName())).build();
|
||||
event.getHook().sendMessage(message).queue();
|
||||
|
||||
event.getTextChannel().sendMessage(EmbedMessageUtils.getMusicOk(info.title + "\n" + info.uri + "\nSubmitted by: " + userAudioTrack.getSubmittedUser().getName())).queue();
|
||||
}
|
||||
|
||||
public void flush(SlashCommandEvent event) {
|
||||
public void flush(MessageReceivedEvent event) {
|
||||
GuildMusicManager musicManager = getGuildAudioPlayer();
|
||||
musicManager.scheduler.flush();
|
||||
Message message = new MessageBuilder().setEmbeds(EmbedMessageUtils.getMusicOk("Flush playlist!")).build();
|
||||
event.getHook().sendMessage(message).queue();
|
||||
event.getTextChannel().sendMessage(EmbedMessageUtils.getMusicOk("Flush playlist!")).queue();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -266,7 +264,7 @@ public class AudioM {
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
public void list(SlashCommandEvent event) {
|
||||
public void list(MessageReceivedEvent event) {
|
||||
GuildMusicManager musicManager = getGuildAudioPlayer();
|
||||
List<UserAudioTrackData> list = musicManager.scheduler.getList();
|
||||
StringBuilder resp = new StringBuilder();
|
||||
@ -279,8 +277,7 @@ public class AudioM {
|
||||
resp.append("\n");
|
||||
}
|
||||
}
|
||||
Message message = new MessageBuilder().setEmbeds(EmbedMessageUtils.getMusicOk("Playlist:\n\n" + resp.toString())).build();
|
||||
event.getHook().sendMessage(message).queue();
|
||||
event.getTextChannel().sendMessage(EmbedMessageUtils.getMusicOk("Playlist:\n\n" + resp.toString())).queue();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -291,12 +288,11 @@ public class AudioM {
|
||||
* @param playListLimit Limit of playlist
|
||||
* @param onHead True for adding audio track on top of playlist
|
||||
*/
|
||||
public void add(SlashCommandEvent event, String url, int playListLimit, boolean onHead) {
|
||||
public void add(MessageReceivedEvent event, String url, int playListLimit, boolean onHead) {
|
||||
if (playedChanel != null) {
|
||||
loadAndPlay(event, playedChanel, url, playListLimit, onHead);
|
||||
} else {
|
||||
Message message = new MessageBuilder().setEmbeds(EmbedMessageUtils.getMusicError("Not connected to vocal chanel !")).build();
|
||||
event.getHook().sendMessage(message).queue();
|
||||
event.getTextChannel().sendMessage(EmbedMessageUtils.getMusicError("Not connected to vocal chanel !")).queue();
|
||||
}
|
||||
}
|
||||
|
||||
@ -305,13 +301,12 @@ public class AudioM {
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
public void stop(SlashCommandEvent event) {
|
||||
public void stop(MessageReceivedEvent event) {
|
||||
musicManager.scheduler.stop();
|
||||
musicManager.scheduler.flush();
|
||||
|
||||
if (event != null) {
|
||||
Message message = new MessageBuilder().setEmbeds(EmbedMessageUtils.getMusicOk("Music stopped")).build();
|
||||
event.getHook().sendMessage(message).queue();
|
||||
event.getTextChannel().sendMessage(EmbedMessageUtils.getMusicOk("Music stopped")).queue();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user