use of net.dv8tion.jda.core.managers.AudioManager in project Ardent by adamint.
the class FancyPlay method noArgs.
@Override
public void noArgs(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
if (args.length > 1) {
AudioManager audioManager = guild.getAudioManager();
String url = message.getRawContent().replace(GuildUtils.getPrefix(guild) + args[0], "");
boolean shouldDeleteMessage = shouldDeleteMessages(guild);
boolean implement = false;
if (!audioManager.isConnected()) {
VoiceChannel success = joinChannel(guild, guild.getMember(user), this, audioManager, channel);
if (success != null) {
loadAndPlay(message, user, this, (TextChannel) channel, url, success, false, false);
implement = true;
}
} else {
loadAndPlay(message, user, this, (TextChannel) sendTo(channel, guild), url, audioManager.getConnectedChannel(), false, false);
implement = true;
}
if (implement) {
if (shouldDeleteMessage) {
try {
message.delete().queue();
} catch (PermissionException ex) {
guild.getOwner().getUser().openPrivateChannel().queue(privateChannel -> {
privateChannel.sendMessage("Auto-deleting music play messages is enabled, " + "but you need to give me the `MANAGE MESSAGES` permission so I can " + "actually delete the messages.").queue();
});
}
}
}
} else
sendTranslatedMessage("You need to specify a song name or URL", channel, user);
}
use of net.dv8tion.jda.core.managers.AudioManager in project Ardent by adamint.
the class MusicLeave method noArgs.
@Override
public void noArgs(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
AudioManager audioManager = guild.getAudioManager();
Member member = guild.getMember(user);
if (audioManager.isConnected()) {
if (UserUtils.hasManageServerOrStaff(member) || UserUtils.isBotCommander(member) || audioManager.getConnectedChannel().getMembers().size() == 2) {
String name = audioManager.getConnectedChannel().getName();
audioManager.closeAudioConnection();
sendTranslatedMessage("Disconnected from {0}".replace("{0}", name), channel, user);
} else
sendTranslatedMessage("You need the Manage Server permission to do this", channel, user);
} else
sendTranslatedMessage("I'm not in a voice channel!", channel, user);
}
Aggregations