本文整理汇总了Java中net.dv8tion.jda.core.managers.AudioManager.isAttemptingToConnect方法的典型用法代码示例。如果您正苦于以下问题:Java AudioManager.isAttemptingToConnect方法的具体用法?Java AudioManager.isAttemptingToConnect怎么用?Java AudioManager.isAttemptingToConnect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.dv8tion.jda.core.managers.AudioManager
的用法示例。
在下文中一共展示了AudioManager.isAttemptingToConnect方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: connectToVoiceChannel
import net.dv8tion.jda.core.managers.AudioManager; //导入方法依赖的package包/类
@CheckReturnValue
public static VoiceConnectStatus connectToVoiceChannel(Message message, boolean moveChannelIfConnected) {
AudioManager audioManager = message.getGuild().getAudioManager();
if (!audioManager.isAttemptingToConnect()) {
VoiceChannel channel = message.getMember().getVoiceState().getChannel();
if (channel == null) {
return VoiceConnectStatus.NOT_CONNECTED;
}
if (audioManager.isConnected()) {
if (channel.getIdLong() == audioManager.getConnectedChannel().getIdLong()) {
return VoiceConnectStatus.CONNECTED;
}
if (moveChannelIfConnected) {
return connectToVoiceChannel(message, channel, audioManager);
}
return VoiceConnectStatus.CONNECTED;
}
return connectToVoiceChannel(message, channel, audioManager);
}
return VoiceConnectStatus.CONNECTED;
}
示例2: joinChannel
import net.dv8tion.jda.core.managers.AudioManager; //导入方法依赖的package包/类
private boolean joinChannel(VoiceChannel channel, Guild guild)
{
log.info("Attempt to join channel: <" + channel.getName() + ">");
// Gets the audio manager, and opens an audio connection (Connects to the voice channel)
AudioManager manager = guild.getAudioManager();
if (manager.isConnected() || manager.isAttemptingToConnect())
{
manager.closeAudioConnection();
manager.openAudioConnection(channel);
}
else
manager.openAudioConnection(channel);
// Waits for the connection to occur.
int iterations = 0;
while (!manager.isConnected())
{
try
{
if (iterations >= MAX_ATTEMPTS)
break;
Thread.sleep(100);
iterations++;
}
catch (InterruptedException e)
{
log.warn("Interrupted while attempting to connect to voice channel.");
return false;
}
}
log.info("Successfully joined channel: <" + channel.getName() + ">");
return true;
}
示例3: connectToVoiceChannel
import net.dv8tion.jda.core.managers.AudioManager; //导入方法依赖的package包/类
/**
* Connect the bot to a voice channel
* @param audioManager The AudioManager of a guild
* @param voiceChannel The voice channel to connect in.
*/
private static void connectToVoiceChannel(AudioManager audioManager, VoiceChannel voiceChannel) {
audioManager.setSelfMuted(false);
if (!audioManager.isConnected() && !audioManager.isAttemptingToConnect()) {
audioManager.openAudioConnection(voiceChannel);
}
}
示例4: getTotalListenersSize
import net.dv8tion.jda.core.managers.AudioManager; //导入方法依赖的package包/类
@CheckReturnValue
public static int getTotalListenersSize() {
int total = 0;
for (GuildMusicManager manager : MUSIC_MANAGER.values()) {
if (manager.getLastActiveMessage() == null) {
continue;
}
AudioManager audioManager = manager.getLastActiveMessage().getGuild().getAudioManager();
if (audioManager.isConnected() || audioManager.isAttemptingToConnect()) {
total++;
}
}
return total;
}
示例5: connectToFirstVoiceChannel
import net.dv8tion.jda.core.managers.AudioManager; //导入方法依赖的package包/类
private static void connectToFirstVoiceChannel(AudioManager audioManager) {
if (!audioManager.isConnected() && !audioManager.isAttemptingToConnect()) {
for (VoiceChannel voiceChannel : audioManager.getGuild().getVoiceChannels()) {
audioManager.openAudioConnection(voiceChannel);
break;
}
}
}
示例6: connectToUsersVoiceChannel
import net.dv8tion.jda.core.managers.AudioManager; //导入方法依赖的package包/类
private void connectToUsersVoiceChannel(CommandContext context) {
AudioManager audioManager = context.getGuild().getAudioManager();
if (!audioManager.isConnected() && !audioManager.isAttemptingToConnect()) {
Optional<VoiceChannel> voiceChannel = context.getGuild().getVoiceChannels().stream().filter(c -> c.getMembers().contains(context.getMember())).findFirst();
if (!voiceChannel.isPresent()) {
context.getTextChannel().sendMessage(KekBot.respond(context, Action.GET_IN_VOICE_CHANNEL)).queue();
} else {
audioManager.openAudioConnection(voiceChannel.get());
if (!isMeme(context.getGuild())) {
context.getTextChannel().sendMessage(context.getAuthor().getAsMention() + " is now hosting a music session in: `" + voiceChannel.get().getName() + "`" + KekBot.replacePrefix(context.getGuild(), ", use {p}music to get the list of all music commands.")).queue();
musicManagers.get(Long.parseLong(context.getGuild().getId())).scheduler.currentPlayer = context.getAuthor();
}
}
}
}
示例7: play
import net.dv8tion.jda.core.managers.AudioManager; //导入方法依赖的package包/类
private void play(Guild guild, GuildMusicManager musicManager, AudioTrack track, TextChannel channel,
AudioManager audioManager) {
if (!audioManager.isConnected() && !audioManager.isAttemptingToConnect()) {
channel.sendMessage("You need to add me to a voice channel first!").queue();
return;
}
if (audioManager.isConnected()) {
musicManager.scheduler.queue(track);
}
}
示例8: execute
import net.dv8tion.jda.core.managers.AudioManager; //导入方法依赖的package包/类
public void execute(GuildMessageReceivedEvent e, String query) {
final Permissions permissions = new Permissions();
if (query.length() == 0) {
e.getChannel().sendMessage(new EmbedBuilder()
.setColor(JukeBot.embedColour)
.setTitle("No Search Query Specified")
.setDescription("Specify a term to search YouTube for")
.build()
).queue();
return;
}
final AudioManager manager = e.getGuild().getAudioManager();
final AudioHandler player = JukeBot.getPlayer(manager);
if (!permissions.checkVoiceChannel(e.getMember())) {
e.getChannel().sendMessage(new EmbedBuilder()
.setColor(JukeBot.embedColour)
.setTitle("No Mutual VoiceChannel")
.setDescription("Join my VoiceChannel to use this command.")
.build()
).queue();
return;
}
if (!manager.isAttemptingToConnect() && !manager.isConnected()) {
ConnectionError connectionStatus = permissions.canConnect(e.getMember().getVoiceState().getChannel());
if (null != connectionStatus) {
e.getChannel().sendMessage(new EmbedBuilder()
.setColor(JukeBot.embedColour)
.setTitle(connectionStatus.title)
.setDescription(connectionStatus.description)
.build()
).queue();
return;
}
manager.openAudioConnection(e.getMember().getVoiceState().getChannel());
player.setChannel(e.getChannel());
}
JukeBot.playerManager.loadItem("ytsearch:" + query, new SongResultHandler(e, player, true));
}
示例9: execute
import net.dv8tion.jda.core.managers.AudioManager; //导入方法依赖的package包/类
public void execute(GuildMessageReceivedEvent e, String query) {
if (query.length() == 0) {
e.getChannel().sendMessage(new EmbedBuilder()
.setColor(JukeBot.embedColour)
.setTitle("Specify something")
.setDescription("YouTube: Search Term/URL\nSoundCloud: URL")
.build()
).queue();
return;
}
final AudioManager manager = e.getGuild().getAudioManager();
final AudioHandler player = JukeBot.getPlayer(manager);
if (!permissions.checkVoiceChannel(e.getMember())) {
e.getChannel().sendMessage(new EmbedBuilder()
.setColor(JukeBot.embedColour)
.setTitle("No Mutual VoiceChannel")
.setDescription("Join my VoiceChannel to use this command.")
.build()
).queue();
return;
}
if (!manager.isAttemptingToConnect() && !manager.isConnected()) {
ConnectionError connectionStatus = permissions.canConnect(e.getMember().getVoiceState().getChannel());
if (null != connectionStatus) {
e.getChannel().sendMessage(new EmbedBuilder()
.setColor(JukeBot.embedColour)
.setTitle(connectionStatus.title)
.setDescription(connectionStatus.description)
.build()
).queue();
return;
}
manager.openAudioConnection(e.getMember().getVoiceState().getChannel());
player.setChannel(e.getChannel());
}
final String userQuery = query.replaceAll("[<>]", "");
if (userQuery.startsWith("http"))
JukeBot.playerManager.loadItem(userQuery, new SongResultHandler(e, player, false));
else
JukeBot.playerManager.loadItem( "ytsearch:" + userQuery, new SongResultHandler(e, player, false));
}
示例10: execute
import net.dv8tion.jda.core.managers.AudioManager; //导入方法依赖的package包/类
public void execute(GuildMessageReceivedEvent e, String query) {
if (query.length() == 0) {
e.getChannel().sendMessage(new EmbedBuilder()
.setColor(JukeBot.embedColour)
.setTitle("No Search Query Specified")
.setDescription("Specify a term to search SoundCloud for")
.build()
).queue();
return;
}
final AudioManager manager = e.getGuild().getAudioManager();
final AudioHandler player = JukeBot.getPlayer(manager);
if (!permissions.checkVoiceChannel(e.getMember())) {
e.getChannel().sendMessage(new EmbedBuilder()
.setColor(JukeBot.embedColour)
.setTitle("No Mutual VoiceChannel")
.setDescription("Join my VoiceChannel to use this command.")
.build()
).queue();
return;
}
if (!manager.isAttemptingToConnect() && !manager.isConnected()) {
ConnectionError connectionStatus = permissions.canConnect(e.getMember().getVoiceState().getChannel());
if (null != connectionStatus) {
e.getChannel().sendMessage(new EmbedBuilder()
.setColor(JukeBot.embedColour)
.setTitle(connectionStatus.title)
.setDescription(connectionStatus.description)
.build()
).queue();
return;
}
manager.openAudioConnection(e.getMember().getVoiceState().getChannel());
player.setChannel(e.getChannel());
}
JukeBot.playerManager.loadItem("scsearch:" + query, new SongResultHandler(e, player, false));
}
示例11: isConnected
import net.dv8tion.jda.core.managers.AudioManager; //导入方法依赖的package包/类
private boolean isConnected(AudioManager audioManager) {
return audioManager.isConnected() || audioManager.isAttemptingToConnect();
}