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


Java VoiceChannel类代码示例

本文整理汇总了Java中net.dv8tion.jda.core.entities.VoiceChannel的典型用法代码示例。如果您正苦于以下问题:Java VoiceChannel类的具体用法?Java VoiceChannel怎么用?Java VoiceChannel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


VoiceChannel类属于net.dv8tion.jda.core.entities包,在下文中一共展示了VoiceChannel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: open

import net.dv8tion.jda.core.entities.VoiceChannel; //导入依赖的package包/类
private void open(CMessage message, String[] args) {
    CGuild guild = charrizard.getCGuildManager().getGuild(message.getGuild());
    if (guild == null) {
        charrizard.getCGuildManager().createGuild(message.getGuild());
        guild = charrizard.getCGuildManager().getGuild(message.getGuild());
    }
    CAudio audio = guild.getAudio();
    if (audio.isConnected()) {
        return;
    }
    VoiceChannel channel = message.getGuild().getVoiceChannels().stream().filter(voice -> voice.getMembers().stream().filter(member -> member.getUser().getId().equals(message.getAuthor().getId())).findFirst().orElse(null) != null).findFirst().orElse(null);
    if (channel == null) {
        return;
    }
    audio.open(channel);
}
 
开发者ID:kacperduras,项目名称:Charrizard,代码行数:17,代码来源:AudioCommand.java

示例2: createGuild

import net.dv8tion.jda.core.entities.VoiceChannel; //导入依赖的package包/类
public void createGuild(Guild guild) {
    if (guild == null) {
        return;
    }
    if (getGuild(guild) != null) {
        return;
    }
    CGuild cGuild = new CGuild(guild, charrizard);
    for (TextChannel channel : guild.getTextChannels()) {
        cGuild.createTextChannel(channel);
    }
    for (VoiceChannel voiceChannel : guild.getVoiceChannels()) {
        cGuild.createVoiceChannel(voiceChannel);
    }
    guildCache.put(guild.getId(), cGuild);
}
 
开发者ID:kacperduras,项目名称:Charrizard,代码行数:17,代码来源:CGuildManager.java

示例3: createVoiceChannel

import net.dv8tion.jda.core.entities.VoiceChannel; //导入依赖的package包/类
public void createVoiceChannel(VoiceChannel channel) {
    if (channel == null) {
        return;
    }
    if (getVoiceChannel(channel) != null) {
        return;
    }
    String string = null;
    if (settings.getRedis().isEnabled()) {
        string = redisConnection.get("voice_" + getGuildId() + "_" + channel.getId());
    }
    int connections;
    if (string == null) {
        connections = 0;
    } else {
        connections = Integer.parseInt(string);
    }
    CVoiceChannel cVoiceChannel = new CVoiceChannel(channel, connections);
    voiceChannelCache.put(channel.getId(), cVoiceChannel);
}
 
开发者ID:kacperduras,项目名称:Charrizard,代码行数:21,代码来源:CGuild.java

示例4: genChannelSearch

import net.dv8tion.jda.core.entities.VoiceChannel; //导入依赖的package包/类
private ChannelSearch genChannelSearch(List<VoiceChannel> channels, boolean deleteChannel, CommandManager.ParsedCommandInvocation parsedCommandInvocation) {
    HashMap<String, VoiceChannel> channellist = new HashMap<>();
    StringBuilder channelnames = new StringBuilder();
    ArrayList<String> EMOJIS = new ArrayList<>(Arrays.asList(EMOTI));
    channels.forEach(c -> {
        String category;
        if (c.getParent() != null)
            category = c.getParent().getName();
        else
            category = "NONE";
        channelnames.append(EMOJIS.get(0)).append(" - ").append(c.getName()).append("(`").append(c.getId()).append("`) (Category: ").append(category).append(")\n");
        channellist.put(EMOJIS.get(0), c);
        EMOJIS.remove(0);
    });
    if (channellist.isEmpty()) {
        parsedCommandInvocation.getMessage().getTextChannel().sendMessage(EmbedUtil.error("Unknown Channel", "There is now channel with this name").build()).queue();
        return null;
    } else {
        Message msg = parsedCommandInvocation.getMessage().getTextChannel().sendMessage(new EmbedBuilder().setColor(Colors.COLOR_SECONDARY).setDescription(channelnames.toString()).build()).complete();
        channellist.keySet().forEach(e -> msg.addReaction(e).queue());
        return new ChannelSearch(msg, channellist, deleteChannel);
    }
}
 
开发者ID:Rubicon-Bot,项目名称:Rubicon,代码行数:24,代码来源:CommandAutochannel.java

示例5: joinVoiceChannel

import net.dv8tion.jda.core.entities.VoiceChannel; //导入依赖的package包/类
public static void joinVoiceChannel(Member member) {
	if (joined) {
		return;
	}

	if(member == null) {
		joinVoiceChannel(); // join default channel
		return;
	}

	VoiceChannel channel = member.getVoiceState().getChannel();

	// Check if member is not in a channel
	if(channel == null) {
		joinVoiceChannel(); // join default channel
		return;
	}

	joinVoiceChannel(channel);
}
 
开发者ID:Bleuzen,项目名称:Blizcord,代码行数:21,代码来源:Bot.java

示例6: getGuild

import net.dv8tion.jda.core.entities.VoiceChannel; //导入依赖的package包/类
private Guild getGuild(User user)
{
	for (Guild g : bot.getGuilds())
	{
		for (VoiceChannel v : g.getVoiceChannels())
		{
			for (Member m : v.getMembers())
			{
				if (m.getUser().getId().equalsIgnoreCase(user.getId()))
				{
					return g;
				}
			}
		}
	}
	
	return null;
}
 
开发者ID:SegfaultError11,项目名称:WeenieBot,代码行数:19,代码来源:WeenieBot.java

示例7: joinChannel

import net.dv8tion.jda.core.entities.VoiceChannel; //导入依赖的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

示例8: getHumanUsersInVC

import net.dv8tion.jda.core.entities.VoiceChannel; //导入依赖的package包/类
/**
 * @return Users who are not bots
 */
public List<Member> getHumanUsersInVC() {
    VoiceChannel vc = getChannel();
    if (vc == null) {
        return new ArrayList<>();
    }

    List<Member> members = vc.getMembers();
    ArrayList<Member> nonBots = new ArrayList<>();
    for (Member member : members) {
        if (!member.getUser().isBot()) {
            nonBots.add(member);
        }
    }
    return nonBots;
}
 
开发者ID:Frederikam,项目名称:GensokyoBot,代码行数:19,代码来源:GuildPlayer.java

示例9: execute

import net.dv8tion.jda.core.entities.VoiceChannel; //导入依赖的package包/类
@Override
public void execute(MessageReceivedEvent event, String[] args) {
    if (!event.getMember().getVoiceState().inVoiceChannel()) {
        event.getChannel().sendMessage("You need to be yourself in a voice channel!").queue();
        return;
    }
    String musicChannel = plugin.getBot().getGuildSettings(event.getGuild()).getSetting(MusicPlugin.MUSIC_CHANNEL_SETTING);
    VoiceChannel voiceChannel;
    if (musicChannel != null) {
        List<VoiceChannel> channels = event.getGuild().getVoiceChannelsByName(musicChannel, false);
        if (channels.isEmpty()) {
            event.getChannel().sendMessage("The channel the bot can play in doesn't exist anymore. Please ask an admin to fix it with the ``setmusicchannel`` command.").queue();
            return;
        }
        voiceChannel = channels.get(0);
    } else {
        voiceChannel = event.getMember().getVoiceState().getChannel();
    }

    plugin.getMusicManager().loadAndPlay(event.getTextChannel(), args[0], voiceChannel);
}
 
开发者ID:greatman,项目名称:legendarybot,代码行数:22,代码来源:PlayMusicCommand.java

示例10: execute

import net.dv8tion.jda.core.entities.VoiceChannel; //导入依赖的package包/类
@Override
public void execute(MessageReceivedEvent event, String[] args) {
    StringBuilder builder = new StringBuilder();
    for(String s : args) {
        builder.append(" ").append(s);
    }

    List<VoiceChannel> channels = event.getGuild().getVoiceChannelsByName(builder.toString().trim(), false);

    if (channels.isEmpty()) {
        event.getChannel().sendMessage("Channel " + builder.toString().trim() + " not found!").queue();
        return;
    }

    plugin.getBot().getGuildSettings(event.getGuild()).setSetting(MusicPlugin.MUSIC_CHANNEL_SETTING, builder.toString().trim());
    event.getChannel().sendMessage("Channel set! LegendaryBot will only play music in this channel.").queue();
}
 
开发者ID:greatman,项目名称:legendarybot,代码行数:18,代码来源:SetMusicChannelCommand.java

示例11: onCommand

import net.dv8tion.jda.core.entities.VoiceChannel; //导入依赖的package包/类
@Override
public boolean onCommand(Message message, String[] args) {
    GuildMusicManager musicManager = AudioHandler.getGuildAudioPlayer(message.getGuild());

    if (musicManager.getPlayer().getPlayingTrack() == null) {
        return sendErrorMessage(message, "Not connected to voice, request music first with `!play`");
    }

    VoiceChannel channel = message.getMember().getVoiceState().getChannel();
    if (channel == null) {
        return sendErrorMessage(message, "You must be connected to a voice channel to use this command!");
    }

    VoiceConnectStatus voiceConnectStatus = AudioHandler.connectToVoiceChannel(message, true);

    if (!voiceConnectStatus.isSuccess()) {
        MessageFactory.makeWarning(message, voiceConnectStatus.getErrorMessage()).queue();
        return false;
    }

    MessageFactory.makeSuccess(message, "I am now streaming music in **:channelName**")
        .set("channelName", channel.getName())
        .queue();
    return true;
}
 
开发者ID:avaire,项目名称:avaire,代码行数:26,代码来源:MoveHereCommand.java

示例12: connectToVoiceChannel

import net.dv8tion.jda.core.entities.VoiceChannel; //导入依赖的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

示例13: doInternal

import net.dv8tion.jda.core.entities.VoiceChannel; //导入依赖的package包/类
@Override
protected boolean doInternal(MessageReceivedEvent message, BotContext context, String content) throws DiscordException {
    if (!message.getMember().getVoiceState().inVoiceChannel()) {
        messageService.onError(message.getTextChannel(), "discord.command.here.notInChannel");
        return fail(message);
    }
    PlaybackInstance instance = playerService.getInstance(message.getGuild());
    if (!instance.isActive()) {
        messageService.onError(message.getTextChannel(), "discord.command.audio.notStarted");
        return fail(message);
    }
    VoiceChannel channel = playerService.connectToChannel(instance, message.getMember());
    if (channel != null) {
        return ok(message, "discord.command.here.connected", channel.getName());
    }
    return fail(message, "discord.command.here.error");
}
 
开发者ID:GoldRenard,项目名称:JuniperBotJ,代码行数:18,代码来源:HereCommand.java

示例14: getDesiredChannel

import net.dv8tion.jda.core.entities.VoiceChannel; //导入依赖的package包/类
private VoiceChannel getDesiredChannel(Member member) {
    MusicConfig musicConfig = getConfig(member.getGuild());
    VoiceChannel channel = null;
    if (musicConfig != null) {
        if (musicConfig.isUserJoinEnabled() && member.getVoiceState().inVoiceChannel()) {
            channel = member.getVoiceState().getChannel();
        }
        if (channel == null && musicConfig.getChannelId() != null) {
            channel = discordService.getJda().getVoiceChannelById(musicConfig.getChannelId());
        }
    }
    if (channel == null) {
        channel = discordService.getDefaultMusicChannel(member.getGuild().getIdLong());
    }
    return channel;
}
 
开发者ID:GoldRenard,项目名称:JuniperBotJ,代码行数:17,代码来源:PlayerServiceImpl.java

示例15: getDefaultMusicChannel

import net.dv8tion.jda.core.entities.VoiceChannel; //导入依赖的package包/类
@Override
public VoiceChannel getDefaultMusicChannel(long guildId) {
    if (!isConnected()) {
        return null;
    }
    Guild guild = jda.getGuildById(guildId);
    if (guild == null) {
        return null;
    }
    VoiceChannel channel;
    String channels = messageService.getMessage("discord.command.audio.channels");
    if (StringUtils.isNotEmpty(channels)) {
        for (String name : channels.split(",")) {
            channel = guild.getVoiceChannelsByName(name, true).stream().findAny().orElse(null);
            if (channel != null) {
                return channel;
            }
        }
    }
    return guild.getVoiceChannels().stream().findAny().orElse(null);
}
 
开发者ID:GoldRenard,项目名称:JuniperBotJ,代码行数:22,代码来源:DiscordServiceImpl.java


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