|
|
@ -29,6 +29,7 @@ import net.dv8tion.jda.api.JDABuilder; |
|
|
|
import net.dv8tion.jda.api.entities.*; |
|
|
|
import net.dv8tion.jda.api.entities.*; |
|
|
|
import net.dv8tion.jda.api.entities.channel.middleman.AudioChannel; |
|
|
|
import net.dv8tion.jda.api.entities.channel.middleman.AudioChannel; |
|
|
|
import net.dv8tion.jda.api.events.guild.voice.GuildVoiceUpdateEvent; |
|
|
|
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.events.message.MessageReceivedEvent; |
|
|
|
import net.dv8tion.jda.api.hooks.ListenerAdapter; |
|
|
|
import net.dv8tion.jda.api.hooks.ListenerAdapter; |
|
|
|
import net.dv8tion.jda.api.managers.AudioManager; |
|
|
|
import net.dv8tion.jda.api.managers.AudioManager; |
|
|
@ -238,20 +239,35 @@ public final class Chords extends ListenerAdapter |
|
|
|
|
|
|
|
|
|
|
|
String cmd = split[0].toLowerCase(); |
|
|
|
String cmd = split[0].toLowerCase(); |
|
|
|
|
|
|
|
|
|
|
|
if (!cmd.startsWith("!")) |
|
|
|
if (cmd.startsWith("!")) |
|
|
|
return; // doesn't start with prefix char
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd = cmd.substring(1); // strip prefix char
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// String arg = "";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (commands.containsKey(cmd)) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
Command command = commands.get(cmd); |
|
|
|
cmd = cmd.substring(1); // strip prefix char
|
|
|
|
command.call(invocation); |
|
|
|
|
|
|
|
} else |
|
|
|
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) |
|
|
|
} catch (Exception ex) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -261,6 +277,8 @@ public final class Chords extends ListenerAdapter |
|
|
|
event.getChannel().sendMessage("Error: " + ex.getMessage()).queue(); |
|
|
|
event.getChannel().sendMessage("Error: " + ex.getMessage()).queue(); |
|
|
|
log("UERR", "Command error:" + ex.getMessage()); |
|
|
|
log("UERR", "Command error:" + ex.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: this will handle uploading files, maybe
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void queueDownload(TrackRequest request) |
|
|
|
public void queueDownload(TrackRequest request) |
|
|
@ -488,7 +506,7 @@ public final class Chords extends ListenerAdapter |
|
|
|
String progressDetails = ""; |
|
|
|
String progressDetails = ""; |
|
|
|
if (track.getProgress() >= 0) |
|
|
|
if (track.getProgress() >= 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (track.getProgress() >= lastProgressUpdate + 10.0) |
|
|
|
if (track.getProgress() >= lastProgressUpdate + 5.0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
shouldUpdate = true; |
|
|
|
shouldUpdate = true; |
|
|
|
lastProgressUpdate = track.getProgress(); |
|
|
|
lastProgressUpdate = track.getProgress(); |
|
|
|