Java 类net.dv8tion.jda.core.entities.VoiceChannel 实例源码

项目:Charrizard    文件:AudioCommand.java   
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);
}
项目:Charrizard    文件:CGuildManager.java   
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);
}
项目:Charrizard    文件:CGuild.java   
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);
}
项目:Rubicon    文件:CommandAutochannel.java   
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);
    }
}
项目:Blizcord    文件:Bot.java   
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);
}
项目:Blizcord    文件:Bot.java   
public static void joinVoiceChannel(VoiceChannel voiceChannel) {
    if (joined) {
        return;
    }

    if(voiceChannel == null) {
        return;
    }

    try {
        guild.getAudioManager().openAudioConnection(voiceChannel);
        joined = true;
    } catch(Exception e) {
        controlChannel.sendMessage("Failed to join voice channel: " + voiceChannel + "\n"
                + "Do I have the permission to join it?").queue();
    }
}
项目:WeenieBot    文件:WeenieBot.java   
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;
}
项目:GensokyoBot    文件:GuildPlayer.java   
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);
}
项目:GensokyoBot    文件:GuildPlayer.java   
/**
 * @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;
}
项目:legendarybot    文件:PlayMusicCommand.java   
@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);
}
项目:legendarybot    文件:SetMusicChannelCommand.java   
@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();
}
项目:avaire    文件:MoveHereCommand.java   
@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;
}
项目:avaire    文件:AudioHandler.java   
@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;
}
项目:avaire    文件:AudioHandler.java   
@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;
}
项目:JuniperBotJ    文件:HereCommand.java   
@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");
}
项目:JuniperBotJ    文件:PlayerServiceImpl.java   
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;
}
项目:JuniperBotJ    文件:DiscordServiceImpl.java   
@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);
}
项目:GabrielBot    文件:TrackLoader.java   
public void trackLoaded(AudioTrack track, User user, boolean silent) {
    if(event.getGuild().getSelfMember().getVoiceState().getChannel() == null) {
        VoiceChannel vc = event.getMember().getVoiceState().getChannel();
        if(vc == null) {
            event.getChannel().sendMessage("Please rejoin the voice channel and try again").queue();
            return;
        }
        if(!event.getGuild().getSelfMember().hasPermission(vc, Permission.VOICE_CONNECT, Permission.VOICE_SPEAK)) {
            event.getChannel().sendMessage("Please give me permission to connect and speak in the voice channel").queue();
            return;
        }
        event.getGuild().getAudioManager().openAudioConnection(vc);
    }
    guildMusicPlayer.scheduler.queueTrack(track, user);
    if(!silent) {
        event.getChannel().sendMessage("Added to queue **" + track.getInfo().title.replace("*", "\\*") + "** (" + Utils.getDuration(track.getDuration()) + ")").queue();
    }
}
项目:GabrielBot    文件:MusicCommands.java   
private static boolean checkVC(GuildMessageReceivedEvent event) {
    VoiceChannel mc = event.getMember().getVoiceState().getChannel();
    VoiceChannel bc = event.getGuild().getSelfMember().getVoiceState().getChannel();
    if (mc == null) {
        event.getChannel().sendMessage(bc == null ?
                "You must be connected to a voice channel" :
                "You must be on the same voice channel as me"
        ).queue();
        return true;
    }
    if (bc == null) return false;
    if (bc.getIdLong() != mc.getIdLong()) {
        event.getChannel().sendMessage("You must be on the same voice channel as me").queue();
        return true;
    }
    return false;
}
项目:Tazbot    文件:UnlinkCommand.java   
private String getLinkedAsString(LinkUnlink instance) {
    List<VoiceChannel> channels = instance.getChannels();
    List<String> channelNames = new ArrayList<String>();
    channels.forEach(c -> {
        String name = c.getName();
        if (name.startsWith(LinkUnlink.PREFIX)) {
            name = name.substring(LinkUnlink.PREFIX.length());
        }
        channelNames.add(c.getName());
    });

    if (instance.isLinked()) {
        return "The following channels are linked: " + StringUtils.join(channelNames, ", ");
    }
    else {
        return "No channels currently linked.";
    }
}
项目:Tazbot    文件:LinkCommand.java   
private String getLinkedAsString(LinkUnlink instance) {
    List<VoiceChannel> channels = instance.getChannels();
    List<String> channelNames = new ArrayList<String>();
    channels.forEach(c -> {
        String name = c.getName();
        if (name.startsWith(LinkUnlink.PREFIX)) {
            name = name.substring(LinkUnlink.PREFIX.length());
        }
        channelNames.add(c.getName());
    });

    if (instance.isLinked()) {
        return "The following channels are linked: " + StringUtils.join(channelNames, ", ");
    }
    else {
        return "No channels currently linked.";
    }
}
项目:MusicBot    文件:Bot.java   
@Override
public void onReady(ReadyEvent event) {
    this.jda = event.getJDA();
    if(jda.getGuilds().isEmpty())
    {
        Logger log = LoggerFactory.getLogger("MusicBot");
        log.warn("This bot is not on any guilds! Use the following link to add the bot to your guilds!");
        log.warn(event.getJDA().asBot().getInviteUrl(JMusicBot.RECOMMENDED_PERMS));
    }
    credit(event.getJDA());
    jda.getGuilds().forEach((guild) -> {
        try
        {
            String defpl = getSettings(guild).getDefaultPlaylist();
            VoiceChannel vc = guild.getVoiceChannelById(getSettings(guild).getVoiceId());
            if(defpl!=null && vc!=null)
            {
                if(setUpHandler(guild).playFromDefault())
                    guild.getAudioManager().openAudioConnection(vc);
            }
        }
        catch(Exception ex) {System.err.println(ex);}
    });
}
项目:MusicBot    文件:SettingsCmd.java   
@Override
protected void execute(CommandEvent event) {
    Settings s = bot.getSettings(event.getGuild());
    MessageBuilder builder = new MessageBuilder()
            .append("\uD83C\uDFA7 **")
            .append(event.getSelfUser().getName())
            .append("** settings:");
    TextChannel tchan = event.getGuild().getTextChannelById(s.getTextId());
    VoiceChannel vchan = event.getGuild().getVoiceChannelById(s.getVoiceId());
    Role role = event.getGuild().getRoleById(s.getRoleId());
    EmbedBuilder ebuilder = new EmbedBuilder()
            .setColor(event.getSelfMember().getColor())
            .setDescription("Text Channel: "+(tchan==null ? "Any" : "**#"+tchan.getName()+"**")
                    + "\nVoice Channel: "+(vchan==null ? "Any" : "**"+vchan.getName()+"**")
                    + "\nDJ Role: "+(role==null ? "None" : "**"+role.getName()+"**")
                    + "\nRepeat Mode: **"+(s.getRepeatMode() ? "On" : "Off")+"**"
                    + "\nDefault Playlist: "+(s.getDefaultPlaylist()==null ? "None" : "**"+s.getDefaultPlaylist()+"**")
                    )
            .setFooter(event.getJDA().getGuilds().size()+" servers | "
                    +event.getJDA().getGuilds().stream().filter(g -> g.getSelfMember().getVoiceState().inVoiceChannel()).count()
                    +" audio connections", null);
    event.getChannel().sendMessage(builder.setEmbed(ebuilder.build()).build()).queue();
}
项目:MusicBot    文件:SetvcCmd.java   
@Override
protected void execute(CommandEvent event) {
    if(event.getArgs().isEmpty())
    {
        event.reply(event.getClient().getError()+" Please include a voice channel or NONE");
    }
    else if(event.getArgs().equalsIgnoreCase("none"))
    {
        bot.clearVoiceChannel(event.getGuild());
        event.reply(event.getClient().getSuccess()+" Music can now be played in any channel");
    }
    else
    {
        List<VoiceChannel> list = FinderUtil.findVoiceChannel(event.getArgs(), event.getGuild());
        if(list.isEmpty())
            event.reply(event.getClient().getWarning()+" No Voice Channels found matching \""+event.getArgs()+"\"");
        else if (list.size()>1)
            event.reply(event.getClient().getWarning()+FormatUtil.listOfVChannels(list, event.getArgs()));
        else
        {
            bot.setVoiceChannel(list.get(0));
            event.reply(event.getClient().getSuccess()+" Music can now only be played in **"+list.get(0).getName()+"**");
        }
    }
}
项目:MinehutBOT    文件:ReloadCommand.java   
@Override
public boolean onCommand(UserClient sender, Guild guild, TextChannel channel, Message message, String[] args) throws CommandException {
    Chat.removeMessage(message);

    try {
        bot.getConfig().load();
        MinehutBot.log.info("Config reloaded!");
    } catch (IOException e) {
        MinehutBot.log.error("Error reloading config", e);
        throw new CommandException("Error reloading config");
    }

    if (Bot.getMainGuild().getAudioManager().getConnectedChannel() == null) {
        String audioChannelId = MinehutBot.get().getConfig().getAudioChannelId();

        if (audioChannelId != null && !audioChannelId.isEmpty()) {
            VoiceChannel audioChannel = MinehutBot.get().getDiscordClient().getVoiceChannelById(MinehutBot.get().getConfig().getAudioChannelId());

            if (audioChannel != null) {
                audioChannel.getGuild().getAudioManager().openAudioConnection(audioChannel);
            }
        }
    }

    return true;
}
项目:JDA    文件:WebSocketClient.java   
public ConnectionRequest updateAudioConnection(long guildId, VoiceChannel connectedChannel)
{
    try
    {
        audioQueueLock.acquire();
        return updateAudioConnection0(guildId, connectedChannel);
    }
    catch (InterruptedException e)
    {
        LOG.error("There was an error updating the audio connection", e);
    }
    finally
    {
        audioQueueLock.release();
    }
    return null;
}
项目:Charrizard    文件:CAudio.java   
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);
}
项目:Supreme-Bot    文件:Standard.java   
public static final List<Member> muteAll(VoiceChannel voiceChannel, boolean mute) {
    try {
        final Member self_member = getSelfMemberByGuild(voiceChannel.getGuild());
        final List<Member> members = voiceChannel.getMembers().stream().filter((member) -> {
            return (member != self_member && !self_member.equals(member));
        }).collect(Collectors.toList());
        members.stream().forEach((member) -> {
            voiceChannel.getGuild().getController().setMute(member, mute).queue();
        });
        return members;
    } catch (Exception ex) {
        return new ArrayList<>();
    }
}
项目:Supreme-Bot    文件:MusicCommand.java   
static final TrackManager createTrackManager(Guild guild, VoiceChannel voiceChannel) {
    if (guild == null) {
        return null;
    }
    final AudioPlayer player = manager.createPlayer();
    final TrackManager trackManager = new TrackManager(player, guild, voiceChannel);
    player.addListener(trackManager);
    guild.getAudioManager().setSendingHandler(new PlayerSendHandler(player));
    trackManagers.put(guild, trackManager);
    return trackManager;
}
项目:Supreme-Bot    文件:MusicCommand.java   
static final TrackManager getTrackManager(Guild guild, VoiceChannel voiceChannel) {
    if (guild == null) {
        return null;
    }
    final TrackManager trackManager = getTrackManager(guild);
    if (trackManager != null) {
        return trackManager;
    } else {
        return createTrackManager(guild, voiceChannel);
    }
}
项目:Supreme-Bot    文件:MusicMessageManager.java   
public MusicMessageManager(MessageEvent event, Guild guild, VoiceChannel voiceChannel) {
    super(event.sendAndWaitMessageFormat(Standard.toBold("LIVE MUSIC INFO")), 2, TimeUnit.SECONDS);
    this.guild = guild;
    trackManager = MusicCommand.getTrackManager(guild, voiceChannel);
    ReactionListener.registerListener(message, AdvancedEmote.parse(Emoji.NO), (reaction, emote, guild_, user) -> deleteThis(), true);
    ReactionListener.registerListener(message, AdvancedEmote.parse(Emoji.REPEAT), (reaction, emote, guild_, user) -> trackManager.toggleLoopType(), true);
    ReactionListener.registerListener(message, AdvancedEmote.parse(Emoji.TRACK_PREVIOUS), (reaction, emote, guild_, user) -> trackManager.playPrevious(), true);
    ReactionListener.registerListener(message, AdvancedEmote.parse(Emoji.REWIND), (reaction, emote, guild_, user) -> {
        AudioTrack track = getPlayingAudioTrack();
        if (track == null) {
            deleteThis();
        } else if (track.isSeekable()) {
            track.setPosition(Math.max(0, track.getPosition() - 5_000));
        }
    }, true);
    ReactionListener.registerListener(message, AdvancedEmote.parse(Emoji.PLAY_PAUSE), (reaction, emote, guild_, user) -> MusicCommand.setPause(guild, !MusicCommand.isPaused(guild)), true);
    ReactionListener.registerListener(message, AdvancedEmote.parse(Emoji.FAST_FORWARD), (reaction, emote, guild_, user) -> {
        AudioTrack track = getPlayingAudioTrack();
        if (track == null) {
            deleteThis();
        } else if (track.isSeekable()) {
            track.setPosition(Math.min(track.getPosition() + 10_000, track.getDuration()));
        }
    }, true);
    ReactionListener.registerListener(message, AdvancedEmote.parse(Emoji.TRACK_NEXT), (reaction, emote, guild_, user) -> MusicCommand.skip(guild), true);
    ReactionListener.registerListener(message, AdvancedEmote.parse(Emoji.VOLUME_NONE), (reaction, emote, guild_, user) -> MusicCommand.setVolume(guild, 0), true);
    ReactionListener.registerListener(message, AdvancedEmote.parse(Emoji.VOLUME_LOW), (reaction, emote, guild_, user) -> MusicCommand.setVolume(guild, MusicCommand.getVolume(guild) - 10), true);
    ReactionListener.registerListener(message, AdvancedEmote.parse(Emoji.VOLUME_HIGH), (reaction, emote, guild_, user) -> MusicCommand.setVolume(guild, MusicCommand.getVolume(guild) + 10), true);
    ReactionListener.registerListener(message, AdvancedEmote.parse(Emoji.SHUFFLE), (reaction, emote, guild_, user) -> trackManager.shuffleQueue(1), true);
    ReactionListener.registerListener(message, AdvancedEmote.parse(Emoji.STOP), (reaction, emote, guild_, user) -> {
        deleteThis();
        MusicCommand.stop(guild, trackManager);
    }, true);
    ReactionListener.registerListener(message, AdvancedEmote.parse(Emoji.TOP), (reaction, emote, guild_, user) -> {
        deleteThis();
        new MusicMessageManager(event, guild, voiceChannel);
    }, true);
}
项目:Supreme-Bot    文件:TrackManager.java   
public TrackManager(AudioPlayer player, Guild guild, VoiceChannel voiceChannel) {
    this.player = player;
    if (player == null) {
        throw new NullPointerException("The player must not be null!");
    }
    this.guild = guild;
    this.voiceChannel = voiceChannel;
    if (guild == null) {
        throw new NullPointerException("The guild must not be null!");
    }
}
项目:Supreme-Bot    文件:TrackManager.java   
public final TrackManager setVoiceChannel(VoiceChannel voiceChannel) {
    if (voiceChannel == null) {
        throw new NullPointerException("The VoiceChannel must not be null!");
    }
    if ((this.voiceChannel != null && !this.voiceChannel.equals(voiceChannel)) || (guild.getAudioManager().isConnected() && !voiceChannel.equals(guild.getAudioManager().getConnectedChannel()))) {
        Updater.submit(() -> guild.getAudioManager().closeAudioConnection());
    }
    if (this.voiceChannel == null || (!guild.getAudioManager().isConnected() || !voiceChannel.equals(guild.getAudioManager().getConnectedChannel()))) {
        guild.getAudioManager().openAudioConnection(voiceChannel);
    }
    this.voiceChannel = voiceChannel;
    return this;
}
项目:Endless    文件:FormatUtil.java   
public static String listOfVcChannels(List<VoiceChannel> list, String query)
{
    String out = " Multiple roles found matching \""+query+"\":";
    for(int i=0; i<6 && i<list.size(); i++)
        out+="\n - "+list.get(i).getName()+" (ID:"+list.get(i).getId()+")";
    if(list.size()>6)
        out+="\n**And "+(list.size()-6)+" more...**";
    return out;
}
项目:Rubicon    文件:CommandAutochannel.java   
private void invokeDelete(CommandManager.ParsedCommandInvocation parsedCommandInvocation) {
    String[] args = parsedCommandInvocation.getArgs();
    Guild guild = parsedCommandInvocation.getMessage().getGuild();

    StringBuilder names = new StringBuilder();
    for (int i = 1; i < args.length; i++) {
        names.append(args[i]).append(" ");
    }
    String name = names.toString();
    name = names.replace(name.lastIndexOf(" "), name.lastIndexOf(" ") + 1, "").toString();
    List<VoiceChannel> channels = guild.getVoiceChannelsByName(name, false);
    String oldEntry = RubiconBot.getMySQL().getGuildValue(guild, "autochannels");
    List<VoiceChannel> autochannels = new ArrayList<>();
    channels.forEach(c -> {
        if (oldEntry.contains(c.getId()))
            autochannels.add(c);
    });
    if (autochannels.isEmpty()) {
        Message mymsg = parsedCommandInvocation.getTextChannel().sendMessage(EmbedUtil.error("Unknown Channel", "There is now channel with this name").build()).complete();
        new Timer().schedule(new TimerTask() {
            @Override
            public void run() {
                mymsg.delete().queue();
            }
        }, 5000);
        return;
    }
    if (autochannels.size() > 1) {

        ChannelSearch search = genChannelSearch(autochannels, true, parsedCommandInvocation);
        searches.put(guild, search);
    } else {
        VoiceChannel channel = channels.get(0);
        if (!oldEntry.contains(channel.getId())) {
            parsedCommandInvocation.getMessage().getTextChannel().sendMessage(EmbedUtil.error("Unknown channel", "This channel isn't an autochannel").build()).queue();
            return;
        }
        deleteChannel(channel, parsedCommandInvocation);
    }
}
项目:Rubicon    文件:CommandAutochannel.java   
private void deleteChannel(VoiceChannel channel, CommandManager.ParsedCommandInvocation parsedCommandInvocation) {
    Guild guild = parsedCommandInvocation.getMessage().getGuild();

    String oldEntry = RubiconBot.getMySQL().getGuildValue(guild, "autochannels");
    String newEntry = oldEntry.replace(channel.getId() + ",", "");
    RubiconBot.getMySQL().updateGuildValue(guild, "autochannels", newEntry);
    Message mymsg = parsedCommandInvocation.getMessage().getChannel().sendMessage(EmbedUtil.success("Deleted channel", "Autochannel " + channel.getName() + " successfully removed").build()).complete();
    new Timer().schedule(new TimerTask() {
        @Override
        public void run() {
            mymsg.delete().queue();
        }
    }, 5000);
    channel.delete().queue();
}
项目:Rubicon    文件:CommandAutochannel.java   
public static void deleteChannel(VoiceChannel channel, Message message, MessageReactionAddEvent event) {
    String oldEntry = RubiconBot.getMySQL().getGuildValue(event.getGuild(), "autochannels");
    String newEntry = oldEntry.replace(channel.getId() + ",", "");
    RubiconBot.getMySQL().updateGuildValue(event.getGuild(), "autochannels", newEntry);
    message.editMessage(EmbedUtil.success("Deleted channel", "Autochannel " + channel.getName() + " successfully removed").build()).complete();
    new Timer().schedule(new TimerTask() {
        @Override
        public void run() {
            message.delete().queue();
        }
    }, 5000);
    channel.delete().queue();
}
项目:Rubicon    文件:CommandMoveAll.java   
@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
    String[] args = parsedCommandInvocation.getArgs();
    Message message = parsedCommandInvocation.getMessage();
    Guild guild = parsedCommandInvocation.getMessage().getGuild();
    if (args.length == 0) {
        return createHelpMessage(parsedCommandInvocation);
    }
    if (!message.getMember().getVoiceState().inVoiceChannel())
        return new MessageBuilder().setEmbed(EmbedUtil.error("Not connected", "Please connect to a voice channel to use this command").build()).build();

    String name;
    name = message.getContentRaw().replace(parsedCommandInvocation.getCommandInvocation(), "");
    name = name.replace(parsedCommandInvocation.getPrefix(),"");
    name = name.substring(1);
    List<VoiceChannel> channels = message.getGuild().getVoiceChannelsByName(name, true);
    if (channels.isEmpty())
        return new MessageBuilder().setEmbed(EmbedUtil.error("Channel not found", "This channel doesen't exist").build()).build();
    VoiceChannel channel = channels.get(0);
    if (channel.equals(message.getMember().getVoiceState().getChannel()))
        return new MessageBuilder().setEmbed(EmbedUtil.error("Same channel", "You are already connected to that channel").build()).build();
    GuildController controller = message.getGuild().getController();
    if(!guild.getSelfMember().hasPermission(Permission.VOICE_MOVE_OTHERS)) {
        return  new MessageBuilder().setEmbed(EmbedUtil.error("Cannot move you!","Cannot move all members in the Channel").build()).build();
    }
    message.getMember().getVoiceState().getChannel().getMembers().forEach(m -> {
        if(!parsedCommandInvocation.getSelfMember().canInteract(m))
            return;
        controller.moveVoiceMember(m, channel).queue();
    });
    return new MessageBuilder().setEmbed(EmbedUtil.success("Connected", "Connected all users in your channel to `" + channel.getName() + "`").build()).build();
}
项目:Rubicon    文件:AutochannelListener.java   
@Override
public void onGuildVoiceJoin(GuildVoiceJoinEvent e) {
    VoiceChannel ch = e.getChannelJoined();
    if(isAutoChannel(e.getGuild(), ch)) {
        VoiceChannel newChannel = (VoiceChannel) e.getGuild().getController().createCopyOfChannel(ch).setName(ch.getName() + " [AC]").complete();
        e.getGuild().getController().moveVoiceMember(e.getMember(), newChannel).queue();
    }
}
项目:Rubicon    文件:AutochannelListener.java   
@Override
public void onGuildVoiceMove(GuildVoiceMoveEvent e) {
    VoiceChannel ch = e.getChannelJoined();
    if(isAutoChannel(e.getGuild(), ch)) {
        VoiceChannel newChannel = (VoiceChannel) e.getGuild().getController().createCopyOfChannel(ch).setName(ch.getName() + " [AC]").complete();
        e.getGuild().getController().moveVoiceMember(e.getMember(), newChannel).queue();
    }
    if(e.getChannelLeft().getMembers().size() == 0) {
        if (e.getChannelLeft().getName().contains("[AC]")) {
            e.getChannelLeft().delete().queue();
        }
    }
}