use of io.github.lxgaming.discordbot.discord.handlers.AudioPlayerLoadResultHandler in project DiscordBot by LXGaming.
the class PlayCommand method execute.
@Override
public void execute(TextChannel textChannel, Member member, Message message, List<String> arguments) {
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setAuthor(textChannel.getJDA().getSelfUser().getName(), null, textChannel.getJDA().getSelfUser().getEffectiveAvatarUrl());
embedBuilder.setColor(DiscordUtil.DEFAULT);
if (member.getGuild().getAudioManager().getConnectedChannel() == null) {
embedBuilder.setColor(DiscordUtil.ERROR);
embedBuilder.setTitle("Not connected to voice channel!", null);
DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
return;
}
if (arguments == null || arguments.isEmpty()) {
if (DiscordBot.getInstance().getDiscord().getAudioPlayer().isPaused()) {
DiscordBot.getInstance().getDiscord().getAudioPlayer().setPaused(false);
embedBuilder.setColor(DiscordUtil.SUCCESS);
embedBuilder.setTitle("Playback resumed.", null);
} else {
DiscordBot.getInstance().getDiscord().getAudioPlayer().setPaused(true);
embedBuilder.setColor(DiscordUtil.WARNING);
embedBuilder.setTitle("Playback paused.", null);
}
DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
return;
}
for (Iterator<String> iterator = arguments.iterator(); iterator.hasNext(); ) {
String string = iterator.next();
if (!string.startsWith("https://")) {
continue;
}
DiscordBot.getInstance().getDiscord().getAudioPlayerManager().loadItem(string, new AudioPlayerLoadResultHandler(textChannel, member));
embedBuilder.setColor(DiscordUtil.SUCCESS);
embedBuilder.setTitle("Processing...", null);
DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
}
}
Aggregations