use of me.fero.ascent.lavaplayer.GuildMusicManager in project ascent_bot by FeroniK.
the class LoadFav method handle.
@Override
public void handle(CommandContext ctx) {
TextChannel channel = ctx.getChannel();
long guildId = ctx.getGuild().getIdLong();
long userId = ctx.getMember().getIdLong();
ArrayList<HashMap<String, String>> favourites = RedisDataStore.getInstance().getFavourites(guildId, userId);
if (favourites.isEmpty()) {
channel.sendMessageEmbeds(Embeds.createBuilder(null, "Your list is empty...", null, null, null).build()).queue();
return;
}
ArrayList<String> urls = new ArrayList<>();
for (HashMap<String, String> entry : favourites) {
urls.add(entry.get("link"));
}
GuildMusicManager musicManager = PlayerManager.getInstance().getMusicManager(ctx.getGuild());
channel.sendMessageEmbeds(Embeds.createBuilder(null, "Loading " + ctx.getMember().getEffectiveName() + "'s favourite tracks", null, null, null).build()).queue();
for (String url : urls) {
PlayerManager.getInstance().audioPlayerManager.loadItemOrdered(musicManager, url, new AudioLoadResultHandler() {
@Override
public void trackLoaded(AudioTrack track) {
track.setUserData(ctx.getAuthor().getIdLong());
musicManager.scheduler.queue(track);
}
@Override
public void playlistLoaded(AudioPlaylist playlist) {
}
@Override
public void noMatches() {
}
@Override
public void loadFailed(FriendlyException exception) {
}
});
}
}
use of me.fero.ascent.lavaplayer.GuildMusicManager in project ascent_bot by FeroniK.
the class Loop method handle.
@Override
@SuppressWarnings("ConstantConditions")
public void handle(CommandContext ctx) {
final TextChannel channel = ctx.getChannel();
final Member member = ctx.getMember();
GuildMusicManager musicManager = PlayerManager.getInstance().getMusicManager(ctx.getGuild());
List<String> args = ctx.getArgs();
EmbedBuilder builder = EmbedUtils.getDefaultEmbed();
builder.setFooter("Requested by " + member.getEffectiveName(), member.getEffectiveAvatarUrl());
if (!args.isEmpty() && args.get(0).equalsIgnoreCase("status")) {
builder.setDescription("➿ Loop is " + (musicManager.scheduler.isRepeating ? "Enabled" : "Disabled"));
channel.sendMessageEmbeds(builder.build()).queue();
return;
}
final boolean newRepeating = !musicManager.scheduler.isRepeating;
musicManager.scheduler.isRepeating = newRepeating;
builder.setDescription("➿ Loop is " + (newRepeating ? "Enabled" : "Disabled"));
channel.sendMessageEmbeds(builder.build()).queue();
}
use of me.fero.ascent.lavaplayer.GuildMusicManager in project ascent_bot by FeroniK.
the class Lyrics method handle.
@Override
public void handle(CommandContext ctx) {
TextChannel channel = ctx.getChannel();
List<String> args = ctx.getArgs();
GLA gla = new GLA();
if (!args.isEmpty()) {
// try {
// SongSearch search = gla.search(String.join(" ", args));
// if(search.getHits().isEmpty()) {
// channel.sendMessageEmbeds(Embeds.createBuilder("Error!", "Cannot fetch lyrics", null, null, null).build()).queue();
// return;
// }
// String s = search.getHits().get(0).fetchLyrics().trim();
// String s1 = s.replaceAll("\\[.*?\\]", "");
//
// if(s1.length() >= 2000) {
// channel.sendMessageEmbeds(Embeds.createBuilder(null, "[Click here for lyrics](" + search.getHits().get(0).getUrl() + ")", null, null, null).build()).queue();
// return;
// }
// Member member = ctx.getMember();
// channel.sendMessageEmbeds(Embeds.createBuilder(search.getHits().get(0).getTitle(), s1, "Requested by " + member.getEffectiveName(), member.getEffectiveAvatarUrl(), null).build()).queue();
// return;
// } catch (IOException e) {
// e.printStackTrace();
// channel.sendMessageEmbeds(Embeds.createBuilder("Error!", "Cannot fetch lyrics", null, null, null).build()).queue();
// return;
// }
this.getLyrics(String.join(" ", args));
return;
}
GuildMusicManager musicManager = PlayerManager.getInstance().getMusicManager(ctx.getGuild());
AudioPlayer audioPlayer = musicManager.audioPlayer;
if (audioPlayer.getPlayingTrack() == null) {
EmbedBuilder builder = Embeds.createBuilder("Error!", "No track playing", null, null, null);
channel.sendMessageEmbeds(builder.build()).queue();
return;
}
AudioTrack playingTrack = audioPlayer.getPlayingTrack();
try {
SongSearch search = gla.search(playingTrack.getInfo().title);
LinkedList<SongSearch.Hit> hits = search.getHits();
if (hits.isEmpty()) {
channel.sendMessageEmbeds(Embeds.createBuilder("Error!", "Cannot fetch lyrics", null, null, null).build()).queue();
return;
}
String s = search.getHits().get(0).fetchLyrics().trim();
String s1 = s.replaceAll("\\[.*?\\]", "");
if (s1.length() >= 2000) {
channel.sendMessageEmbeds(Embeds.createBuilder(null, "(Click here for lyrics)[" + search.getHits().get(0).getUrl() + "]", null, null, null).build()).queue();
return;
}
Member member = ctx.getMember();
channel.sendMessageEmbeds(Embeds.createBuilder(search.getHits().get(0).getTitle(), s1, "Requested by " + member.getEffectiveName(), member.getEffectiveAvatarUrl(), null).build()).queue();
} catch (IOException e) {
e.printStackTrace();
channel.sendMessageEmbeds(Embeds.createBuilder("Error!", "Cannot fetch lyrics", null, null, null).build()).queue();
}
}
use of me.fero.ascent.lavaplayer.GuildMusicManager in project ascent_bot by FeroniK.
the class Resume method handle.
@Override
@SuppressWarnings("ConstantConditions")
public void handle(@NotNull CommandContext ctx) {
final TextChannel channel = ctx.getChannel();
GuildMusicManager musicManager = PlayerManager.getInstance().getMusicManager(ctx.getGuild());
AudioPlayer audioPlayer = musicManager.audioPlayer;
if (audioPlayer.getPlayingTrack() == null) {
channel.sendMessageEmbeds(Embeds.createBuilder("Error!", "There is no track currently playing", null, null, null).build()).queue();
return;
}
AudioPlayer player = musicManager.scheduler.player;
if (!player.isPaused()) {
channel.sendMessageEmbeds(Embeds.createBuilder("Error!", "Player is already playing", null, null, null).build()).queue();
return;
}
player.setPaused(false);
channel.sendMessageEmbeds(Embeds.createBuilder(null, "Player resumed", null, null, null).build()).queue();
}
use of me.fero.ascent.lavaplayer.GuildMusicManager in project ascent_bot by FeroniK.
the class RmDuplicates method handle.
@Override
public void handle(CommandContext ctx) {
TextChannel channel = ctx.getChannel();
GuildMusicManager musicManager = PlayerManager.getInstance().getMusicManager(ctx.getGuild());
if (musicManager.scheduler.queue.isEmpty()) {
channel.sendMessageEmbeds(Embeds.createBuilder("Error!", "Queue is currently empty", null, null, null).build()).queue();
return;
}
if (musicManager.scheduler.removeDuplicates()) {
channel.sendMessageEmbeds(Embeds.createBuilder(null, "Removed duplicates from the queue.", null, null, null).build()).queue();
return;
}
channel.sendMessageEmbeds(Embeds.createBuilder(null, "No duplicates found", null, null, null).build()).queue();
}
Aggregations