当前位置: 首页>>代码示例>>Java>>正文


Java AudioManager.isConnected方法代码示例

本文整理汇总了Java中net.dv8tion.jda.core.managers.AudioManager.isConnected方法的典型用法代码示例。如果您正苦于以下问题:Java AudioManager.isConnected方法的具体用法?Java AudioManager.isConnected怎么用?Java AudioManager.isConnected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.dv8tion.jda.core.managers.AudioManager的用法示例。


在下文中一共展示了AudioManager.isConnected方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
 
开发者ID:avaire,项目名称:avaire,代码行数:24,代码来源:AudioHandler.java

示例2: open

import net.dv8tion.jda.core.managers.AudioManager; //导入方法依赖的package包/类
public void open(VoiceChannel channel) {
    if (channel == null) {
        return;
    }
    AudioManager manager = guild.getAudioManager();
    if (manager.isConnected()) {
        return;
    }
    manager.openAudioConnection(channel);
    manager.setAutoReconnect(true);
    manager.setSelfMuted(true);
}
 
开发者ID:kacperduras,项目名称:Charrizard,代码行数:13,代码来源:CAudio.java

示例3: close

import net.dv8tion.jda.core.managers.AudioManager; //导入方法依赖的package包/类
public void close() {
    AudioManager manager = guild.getAudioManager();
    if (!manager.isConnected()) {
        return;
    }
    manager.closeAudioConnection();
}
 
开发者ID:kacperduras,项目名称:Charrizard,代码行数:8,代码来源:CAudio.java

示例4: 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;
}
 
开发者ID:SegfaultError11,项目名称:WeenieBot,代码行数:38,代码来源:WeenieBot.java

示例5: disconnectFromVoiceChat

import net.dv8tion.jda.core.managers.AudioManager; //导入方法依赖的package包/类
public int disconnectFromVoiceChat(AudioManager manager) {
    int res = 0;
    if (manager.isConnected()) {
        getGuildAudioPlayer(manager.getGuild()).player.stopTrack();
        getGuildAudioPlayer(manager.getGuild()).scheduler.clearQueue();
        manager.closeAudioConnection();
        res = 1;
    }
    return res;
}
 
开发者ID:elgoupil,项目名称:GoupilBot,代码行数:11,代码来源:Music.java

示例6: 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);
    }
}
 
开发者ID:greatman,项目名称:legendarybot,代码行数:12,代码来源:MusicManager.java

示例7: 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;
}
 
开发者ID:avaire,项目名称:avaire,代码行数:16,代码来源:AudioHandler.java

示例8: 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;
    }
  }
}
 
开发者ID:sedmelluq,项目名称:lavaplayer,代码行数:9,代码来源:MusicController.java

示例9: 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();
            }
        }
    }
}
 
开发者ID:Godson777,项目名称:KekBot,代码行数:16,代码来源:MusicPlayer.java

示例10: 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);
	}
}
 
开发者ID:JoeZwet,项目名称:ncsBot,代码行数:11,代码来源:AudioCommandHandler.java

示例11: isConnected

import net.dv8tion.jda.core.managers.AudioManager; //导入方法依赖的package包/类
public boolean isConnected() {
    AudioManager manager = guild.getAudioManager();
    return manager.isConnected();
}
 
开发者ID:kacperduras,项目名称:Charrizard,代码行数:5,代码来源:CAudio.java

示例12: 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));
    }
 
开发者ID:Devoxin,项目名称:JukeBot,代码行数:47,代码来源:Select.java

示例13: 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));

    }
 
开发者ID:Devoxin,项目名称:JukeBot,代码行数:51,代码来源:Play.java

示例14: 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));

    }
 
开发者ID:Devoxin,项目名称:JukeBot,代码行数:46,代码来源:ScSearch.java

示例15: isConnected

import net.dv8tion.jda.core.managers.AudioManager; //导入方法依赖的package包/类
private boolean isConnected(AudioManager audioManager) {
    return audioManager.isConnected() || audioManager.isAttemptingToConnect();
}
 
开发者ID:avaire,项目名称:avaire,代码行数:4,代码来源:GarbageCollectorJob.java


注:本文中的net.dv8tion.jda.core.managers.AudioManager.isConnected方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。