diff --git a/src/main/java/moe/nekojimi/chords/Chords.java b/src/main/java/moe/nekojimi/chords/Chords.java index b117e60..8f17d04 100644 --- a/src/main/java/moe/nekojimi/chords/Chords.java +++ b/src/main/java/moe/nekojimi/chords/Chords.java @@ -29,6 +29,7 @@ import net.dv8tion.jda.api.JDABuilder; import net.dv8tion.jda.api.entities.*; import net.dv8tion.jda.api.entities.channel.middleman.AudioChannel; import net.dv8tion.jda.api.events.guild.voice.GuildVoiceUpdateEvent; +import net.dv8tion.jda.api.events.message.MessageEmbedEvent; import net.dv8tion.jda.api.events.message.MessageReceivedEvent; import net.dv8tion.jda.api.hooks.ListenerAdapter; import net.dv8tion.jda.api.managers.AudioManager; @@ -238,20 +239,35 @@ public final class Chords extends ListenerAdapter String cmd = split[0].toLowerCase(); - if (!cmd.startsWith("!")) - return; // doesn't start with prefix char - - cmd = cmd.substring(1); // strip prefix char - -// String arg = ""; - - if (commands.containsKey(cmd)) + if (cmd.startsWith("!")) { - Command command = commands.get(cmd); - command.call(invocation); - } else + cmd = cmd.substring(1); // strip prefix char + + if (commands.containsKey(cmd)) + { + Command command = commands.get(cmd); + command.call(invocation); + } else + { + helpCommand.call(invocation); + } + } else if (!event.getMessage().getAttachments().isEmpty()) { - helpCommand.call(invocation); + for (Message.Attachment attach : event.getMessage().getAttachments()) + { + if (attach.getContentType().startsWith("audio") || attach.getContentType().startsWith("video")) + { + try + { + invocation = new Invocation(event, List.of(new URL(attach.getUrl()).toExternalForm())); + invocation.setRequestMessage(message); + playCommand.call(invocation); + } catch (MalformedURLException ex) + { + Logger.getLogger(Chords.class.getName()).log(Level.WARNING, null, ex); + } + } + } } } catch (Exception ex) { @@ -261,6 +277,8 @@ public final class Chords extends ListenerAdapter event.getChannel().sendMessage("Error: " + ex.getMessage()).queue(); log("UERR", "Command error:" + ex.getMessage()); } + + // TODO: this will handle uploading files, maybe } public void queueDownload(TrackRequest request) @@ -488,7 +506,7 @@ public final class Chords extends ListenerAdapter String progressDetails = ""; if (track.getProgress() >= 0) { - if (track.getProgress() >= lastProgressUpdate + 10.0) + if (track.getProgress() >= lastProgressUpdate + 5.0) { shouldUpdate = true; lastProgressUpdate = track.getProgress();