diff options
author | Brandon <bwaggone@umich.edu> | 2018-04-07 19:44:58 -0400 |
---|---|---|
committer | Brandon <bwaggone@umich.edu> | 2018-04-07 19:44:58 -0400 |
commit | 05395d976b90ec672a6edc7b81180fff3a679140 (patch) | |
tree | 62a3b5a66edc1041e06ddad189958f796a7f3bce | |
parent | 6d8c86d7683e18cdc62370c479a9db24cc8b100c (diff) | |
download | SoundChan-05395d976b90ec672a6edc7b81180fff3a679140.tar.gz SoundChan-05395d976b90ec672a6edc7b81180fff3a679140.tar.bz2 SoundChan-05395d976b90ec672a6edc7b81180fff3a679140.zip |
Add local file support (hardcoded mp3s)
-rw-r--r-- | src/main/java/soundchan/Main.java | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/src/main/java/soundchan/Main.java b/src/main/java/soundchan/Main.java index 8b1ccfc..651d16b 100644 --- a/src/main/java/soundchan/Main.java +++ b/src/main/java/soundchan/Main.java @@ -33,6 +33,8 @@ public class Main extends ListenerAdapter { .setToken(properties.getProperty("botToken")) .buildBlocking(); + localFilePath = properties.getProperty("localFilePath"); + jda.addEventListener(new Main()); } @@ -57,6 +59,7 @@ public class Main extends ListenerAdapter { private long monitoredGuildId = -1; private Guild monitoredGuild; + private static String localFilePath; private final AudioPlayerManager playerManager; private final Map<Long, GuildMusicManager> musicManagers; @@ -121,19 +124,28 @@ public class Main extends ListenerAdapter { } if(monitoredGuild != null){ - if ("~play".equals(command[0]) && command.length == 2) { - loadAndPlay(channel, command[1]); - } else if ("~skip".equals(command[0])) { - skipTrack(channel); - } else if ("~volume".equals(command[0]) && command.length == 2) { - changeVolume(channel, command[1]); - } else if ("~pause".equals(command[0])) { - pauseTrack(channel); - } else if ("~unpause".equals(command[0])) { - unpauseTrack(channel); - } else if ("~list".equals(command[0])) { - listTracks(channel); - } + + // "!" Signifies that you're looking to play a sound effect + if(command[0].startsWith("!") && command[0].length() > 1){ + loadAndPlay(channel, localFilePath + "\\" + command[0].substring(1) + ".mp3"); + } + + // "~" Signifies that you're looking to play a song/sound from a url + if(command[0].startsWith("~") && command[0].length() > 1){ + if ("~play".equals(command[0]) && command.length == 2) { + loadAndPlay(channel, command[1]); + } else if ("~skip".equals(command[0])) { + skipTrack(channel); + } else if ("~volume".equals(command[0]) && command.length == 2) { + changeVolume(channel, command[1]); + } else if ("~pause".equals(command[0])) { + pauseTrack(channel); + } else if ("~unpause".equals(command[0])) { + unpauseTrack(channel); + } else if ("~list".equals(command[0])) { + listTracks(channel); + } + } } |