Reformat code.
This commit is contained in:
parent
b8b7a99a8d
commit
ed610ebdae
|
@ -83,11 +83,8 @@ public class Main extends ListenerAdapter
|
||||||
{
|
{
|
||||||
String arg = content.substring("!join ".length());
|
String arg = content.substring("!join ".length());
|
||||||
onJoinCommand(event, guild, arg);
|
onJoinCommand(event, guild, arg);
|
||||||
}
|
} else if (content.equals("!join"))
|
||||||
else if (content.equals("!join"))
|
|
||||||
{
|
|
||||||
onJoinCommand(event);
|
onJoinCommand(event);
|
||||||
}
|
|
||||||
else if (content.startsWith("!play "))
|
else if (content.startsWith("!play "))
|
||||||
{
|
{
|
||||||
String arg = content.substring("!join ".length());
|
String arg = content.substring("!join ".length());
|
||||||
|
@ -111,12 +108,9 @@ public class Main extends ListenerAdapter
|
||||||
{
|
{
|
||||||
connectTo(channel); // Join the channel of the user
|
connectTo(channel); // Join the channel of the user
|
||||||
onConnecting(channel, event.getChannel()); // Tell the user about our success
|
onConnecting(channel, event.getChannel()); // Tell the user about our success
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
{
|
|
||||||
onUnknownChannel(event.getChannel(), "your voice channel"); // Tell the user about our failure
|
onUnknownChannel(event.getChannel(), "your voice channel"); // Tell the user about our failure
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle command with arguments.
|
* Handle command with arguments.
|
||||||
|
@ -133,9 +127,8 @@ public class Main extends ListenerAdapter
|
||||||
boolean isNumber = arg.matches("\\d+"); // This is a regular expression that ensures the input consists of digits
|
boolean isNumber = arg.matches("\\d+"); // This is a regular expression that ensures the input consists of digits
|
||||||
VoiceChannel channel = null;
|
VoiceChannel channel = null;
|
||||||
if (isNumber) // The input is an id?
|
if (isNumber) // The input is an id?
|
||||||
{
|
|
||||||
channel = guild.getVoiceChannelById(arg);
|
channel = guild.getVoiceChannelById(arg);
|
||||||
}
|
|
||||||
if (channel == null) // Then the input must be a name?
|
if (channel == null) // Then the input must be a name?
|
||||||
{
|
{
|
||||||
List<VoiceChannel> channels = guild.getVoiceChannelsByName(arg, true);
|
List<VoiceChannel> channels = guild.getVoiceChannelsByName(arg, true);
|
||||||
|
@ -171,7 +164,7 @@ public class Main extends ListenerAdapter
|
||||||
|
|
||||||
private String downloadSong(String arg) throws IOException, RuntimeException, InterruptedException
|
private String downloadSong(String arg) throws IOException, RuntimeException, InterruptedException
|
||||||
{
|
{
|
||||||
String cmd = "/usr/bin/youtube-dl -x --audio-format=wav "+arg;
|
String cmd = "/usr/bin/youtube-dl -x --audio-format=wav " + arg;
|
||||||
System.out.println("Running command: " + cmd);
|
System.out.println("Running command: " + cmd);
|
||||||
// Process exec = Runtime.getRuntime().exec().split(" "));
|
// Process exec = Runtime.getRuntime().exec().split(" "));
|
||||||
Process exec = new ProcessBuilder(cmd.split(" ")).redirectOutput(ProcessBuilder.Redirect.PIPE).start();
|
Process exec = new ProcessBuilder(cmd.split(" ")).redirectOutput(ProcessBuilder.Redirect.PIPE).start();
|
||||||
|
@ -187,7 +180,6 @@ public class Main extends ListenerAdapter
|
||||||
return destination;
|
return destination;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inform user about successful connection.
|
* Inform user about successful connection.
|
||||||
*
|
*
|
||||||
|
@ -205,7 +197,8 @@ public class Main extends ListenerAdapter
|
||||||
* The channel to connect to is not known to us.
|
* The channel to connect to is not known to us.
|
||||||
*
|
*
|
||||||
* @param channel
|
* @param channel
|
||||||
* The message channel (text channel abstraction) to send failure information to
|
* The message channel (text channel abstraction) to send failure
|
||||||
|
* information to
|
||||||
* @param comment
|
* @param comment
|
||||||
* The information of this channel
|
* The information of this channel
|
||||||
*/
|
*/
|
||||||
|
@ -230,7 +223,6 @@ public class Main extends ListenerAdapter
|
||||||
// EchoHandler handler = new EchoHandler();
|
// EchoHandler handler = new EchoHandler();
|
||||||
|
|
||||||
// The order of the following instructions does not matter!
|
// The order of the following instructions does not matter!
|
||||||
|
|
||||||
// Set the sending handler to our echo system
|
// Set the sending handler to our echo system
|
||||||
audioManager.setSendingHandler(musicHandler);
|
audioManager.setSendingHandler(musicHandler);
|
||||||
// Set the receiving handler to the same echo system, otherwise we can't echo anything
|
// Set the receiving handler to the same echo system, otherwise we can't echo anything
|
||||||
|
|
Loading…
Reference in New Issue