0.9.0
& numerous changes to Music functionality
This commit is contained in:
parent
5c7f2991ec
commit
d64f157159
2
pom.xml
2
pom.xml
|
@ -7,7 +7,7 @@
|
|||
<groupId>moe.oko</groupId>
|
||||
<artifactId>Kiafumi</artifactId>
|
||||
<name>Kiafumi</name>
|
||||
<version>0.9.0-pre</version>
|
||||
<version>0.9.0</version>
|
||||
<packaging>jar</packaging>
|
||||
<url>https://oko.moe/kiafumi.htm</url>
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.io.IOException;
|
|||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static moe.oko.Kiafumi.util.LoggingManager.info;
|
||||
import static moe.oko.Kiafumi.util.LoggingManager.slashLog;
|
||||
|
||||
/**
|
||||
|
@ -82,7 +83,8 @@ public class MusicCommand extends CommandClass {
|
|||
e.getHook().sendMessage("Skipping the current track.").queue();
|
||||
} else {
|
||||
info.addSkip(e.getUser());
|
||||
e.getHook().sendMessage("**%s** has voted to skip the track".formatted(e.getUser().getName())).queue();
|
||||
e.getHook().sendMessage("**%s** has voted to skip the track (%s/%s)"
|
||||
.formatted(e.getUser().getName(), votes, requiredVotes)).queue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -110,10 +112,19 @@ public class MusicCommand extends CommandClass {
|
|||
else {
|
||||
var trackList = new StringBuilder();
|
||||
var queuedTracks = getTrackManager(e.getGuild()).getQueuedTracks();
|
||||
queuedTracks.forEach(audioInfo -> trackList.append(buildQueueString(audioInfo)));
|
||||
e.getHook().sendMessageEmbeds(new EmbedBuilder()
|
||||
.setColor(EmbedUI.SUCCESS)
|
||||
.addField("Queue", "**>** " + trackList.toString(), false).build()).queue();
|
||||
final short[] trackSize = {-1};
|
||||
queuedTracks.forEach(audioInfo -> {
|
||||
trackList.append(buildQueueString(audioInfo));
|
||||
trackSize[0]++;
|
||||
});
|
||||
var eb = new EmbedBuilder().setColor(EmbedUI.SUCCESS);
|
||||
if (trackList.length() >= 990) {
|
||||
eb.addField("Queue", "**>** " + trackList.toString(), false);
|
||||
} else {
|
||||
eb.addField("Queue", "**>** " + getPlayer(e.getGuild()).getPlayingTrack().getInfo().title
|
||||
+ "\n" + trackSize[0] + " other tracks..", false).build();
|
||||
}
|
||||
e.getHook().sendMessageEmbeds(eb.build()).queue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -143,18 +154,25 @@ public class MusicCommand extends CommandClass {
|
|||
|
||||
@Override
|
||||
public void playlistLoaded(AudioPlaylist audioPlaylist) {
|
||||
if (input.startsWith("ytsearch:"))
|
||||
getTrackManager(server).queue(audioPlaylist.getSelectedTrack(), author);
|
||||
else {
|
||||
for (int i = audioPlaylist.getTracks().indexOf(audioPlaylist.getSelectedTrack()) + 1; i < audioPlaylist.getTracks().size(); i++)
|
||||
getTrackManager(server).queue(audioPlaylist.getTracks().get(i), author);
|
||||
if (input.startsWith("ytsearch:")) {
|
||||
getTrackManager(server).queue(audioPlaylist.getTracks().get(0), author);
|
||||
var trackInfo = audioPlaylist.getTracks().get(0).getInfo();
|
||||
eb = new EmbedBuilder()
|
||||
.setColor(EmbedUI.SUCCESS)
|
||||
.setAuthor("Playing")
|
||||
.setDescription("[%s](%s)".formatted(trackInfo.title, trackInfo.uri))
|
||||
.addField("Info", "Channel: %s\nLength: %s".formatted(trackInfo.author, getTimestamp(trackInfo.length)), false)
|
||||
.setFooter("Requested by: " + author.getEffectiveName());
|
||||
} else {
|
||||
for (AudioTrack audioTrack : audioPlaylist.getTracks()) {
|
||||
getTrackManager(server).queue(audioTrack, author);
|
||||
eb = new EmbedBuilder()
|
||||
.setColor(EmbedUI.SUCCESS)
|
||||
.setAuthor("Loaded tracks")
|
||||
.setDescription("**%s** tracks added to the queue.".formatted(audioPlaylist.getTracks().size()))
|
||||
.setFooter("Requested by: " + author.getEffectiveName());
|
||||
}
|
||||
}
|
||||
|
||||
eb = new EmbedBuilder()
|
||||
.setColor(EmbedUI.SUCCESS)
|
||||
.setAuthor("Loaded tracks")
|
||||
.setDescription("**%s** tracks added to the queue.".formatted(audioPlaylist.getTracks().size()))
|
||||
.setFooter("Requested by: " + author.getEffectiveName());
|
||||
hook.sendMessageEmbeds(eb.build()).queue();
|
||||
}
|
||||
|
||||
|
@ -168,7 +186,7 @@ public class MusicCommand extends CommandClass {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void loadFailed(FriendlyException e) { hook.sendMessage(e.getLocalizedMessage()).queue(); }
|
||||
public void loadFailed(FriendlyException e) { hook.sendMessage("Unable to play track.").queue(); }
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue