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


Java AudioManager.openAudioConnection方法代码示例

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


在下文中一共展示了AudioManager.openAudioConnection方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: joinChannel

import net.dv8tion.jda.core.managers.AudioManager; //导入方法依赖的package包/类
public void joinChannel(VoiceChannel targetChannel) throws MessagingException {
    if (targetChannel == null) {
        throw new MessagingException(I18n.get(getGuild()).getString("playerUserNotInChannel"));
    }

    if (!PermissionUtil.checkPermission(targetChannel, targetChannel.getGuild().getSelfMember(), Permission.VOICE_CONNECT)
            && !targetChannel.getMembers().contains(getGuild().getSelfMember())) {
        throw new MessagingException(I18n.get(getGuild()).getString("playerJoinConnectDenied"));
    }

    if (!PermissionUtil.checkPermission(targetChannel, targetChannel.getGuild().getSelfMember(), Permission.VOICE_SPEAK)) {
        throw new MessagingException(I18n.get(getGuild()).getString("playerJoinSpeakDenied"));
    }

    AudioManager manager = getGuild().getAudioManager();

    manager.openAudioConnection(targetChannel);

    log.info("Connected to voice channel " + targetChannel);
}
 
开发者ID:Frederikam,项目名称:GensokyoBot,代码行数:21,代码来源:GuildPlayer.java

示例2: connectToVoiceChannel

import net.dv8tion.jda.core.managers.AudioManager; //导入方法依赖的package包/类
@CheckReturnValue
private static VoiceConnectStatus connectToVoiceChannel(Message message, VoiceChannel channel, AudioManager audioManager) {
    List<Permission> permissions = message.getGuild().getMember(message.getJDA().getSelfUser()).getPermissions(channel);
    if (!permissions.contains(Permission.VOICE_CONNECT)) {
        return VoiceConnectStatus.MISSING_PERMISSIONS;
    }

    if (channel.getUserLimit() > 0 && !permissions.contains(Permission.VOICE_MOVE_OTHERS) && channel.getUserLimit() <= channel.getMembers().size()) {
        return VoiceConnectStatus.USER_LIMIT;
    }

    try {
        audioManager.openAudioConnection(channel);
    } catch (Exception ex) {
        return VoiceConnectStatus.USER_LIMIT;
    }
    return VoiceConnectStatus.CONNECTED;
}
 
开发者ID:avaire,项目名称:avaire,代码行数:19,代码来源:AudioHandler.java

示例3: 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

示例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: connectToVoiceChat

import net.dv8tion.jda.core.managers.AudioManager; //导入方法依赖的package包/类
public int connectToVoiceChat(AudioManager manager, Member member) {
    int res = 0;
    if (member.getVoiceState().inVoiceChannel()) {
        manager.openAudioConnection(member.getVoiceState().getChannel());
        getGuildAudioPlayer(manager.getGuild()).scheduler.changeVolume(20);
        res = 1;
    }
    return res;
}
 
开发者ID:elgoupil,项目名称:GoupilBot,代码行数:10,代码来源: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: createPlayer

import net.dv8tion.jda.core.managers.AudioManager; //导入方法依赖的package包/类
public GuildMusicPlayer createPlayer(long guildId, long textChannelId, long voiceChannelId) {
    GuildMusicPlayer gmp = getPlayer(guildId);
    if(gmp == null) {
        synchronized(this) {
            gmp = new GuildMusicPlayer(guildId, textChannelId, voiceChannelId);
            //gmp.link.connect(jda.getGuildById(guildId).getVoiceChannelById(voiceChannelId));
            AudioManager manager = jda.getGuildById(guildId).getAudioManager();
            manager.setSendingHandler(gmp);
            manager.openAudioConnection(jda.getGuildById(guildId).getVoiceChannelById(voiceChannelId));
            players.put(guildId, gmp);
        }
    }
    return gmp;
}
 
开发者ID:natanbc,项目名称:GabrielBot,代码行数:15,代码来源:Shard.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: joinVoiceChannel

import net.dv8tion.jda.core.managers.AudioManager; //导入方法依赖的package包/类
private void joinVoiceChannel(TextChannel channel) {
	Guild guild = channel.getGuild();
	AudioManager am = guild.getAudioManager();
	try {
		am.openAudioConnection(guild.getVoiceChannelsByName("Music", true).get(0));
	} catch(Exception e) {
		channel.sendMessage("You need to create a voice channel named `Music`!").queue();
	}
		
}
 
开发者ID:JoeZwet,项目名称:ncsBot,代码行数:11,代码来源:AudioCommandHandler.java

示例11: 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

示例12: 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

示例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("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


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