Search in sources :

Example 6 with VoiceChannel

use of net.dv8tion.jda.core.entities.VoiceChannel in project Rubicon by Rubicon-Bot.

the class AutochannelListener method onGuildVoiceJoin.

@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();
    }
}
Also used : VoiceChannel(net.dv8tion.jda.core.entities.VoiceChannel)

Example 7 with VoiceChannel

use of net.dv8tion.jda.core.entities.VoiceChannel in project Rubicon by Rubicon-Bot.

the class CommandMoveAll method execute.

@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();
}
Also used : GuildController(net.dv8tion.jda.core.managers.GuildController) Message(net.dv8tion.jda.core.entities.Message) MessageBuilder(net.dv8tion.jda.core.MessageBuilder) VoiceChannel(net.dv8tion.jda.core.entities.VoiceChannel) Guild(net.dv8tion.jda.core.entities.Guild)

Example 8 with VoiceChannel

use of net.dv8tion.jda.core.entities.VoiceChannel in project Rubicon by Rubicon-Bot.

the class CommandAutochannel method handleReaction.

public static void handleReaction(MessageReactionAddEvent event) {
    if (!searches.containsKey(event.getGuild()))
        return;
    ChannelSearch search = searches.get(event.getGuild());
    if (!event.getMessageId().equals(search.message.getId()))
        return;
    String emote = event.getReactionEmote().getName();
    event.getReaction().removeReaction(event.getUser()).queue();
    if (!search.channels.containsKey(emote))
        return;
    if (search.delete) {
        VoiceChannel channel = search.channels.get(emote);
        deleteChannel(channel, event.getTextChannel().getMessageById(event.getMessageId()).complete(), event);
    } else {
        VoiceChannel channel = search.channels.get(emote);
        String oldEntry = RubiconBot.getMySQL().getGuildValue(event.getGuild(), "autochannels");
        String newEntry = oldEntry + ", " + channel.getId();
        RubiconBot.getMySQL().updateGuildValue(event.getGuild(), "autochannels", newEntry);
        Message mymsg = event.getTextChannel().getMessageById(event.getMessageId()).complete().editMessage(EmbedUtil.success("Created Autochannel", "Successfully created autochannel -> " + channel.getName() + "").build()).complete();
        new Timer().schedule(new TimerTask() {

            @Override
            public void run() {
                mymsg.delete().queue();
            }
        }, 5000);
    }
    event.getTextChannel().getMessageById(event.getMessageId()).complete().getReactions().forEach(r -> r.removeReaction().queue());
}
Also used : Message(net.dv8tion.jda.core.entities.Message) VoiceChannel(net.dv8tion.jda.core.entities.VoiceChannel)

Example 9 with VoiceChannel

use of net.dv8tion.jda.core.entities.VoiceChannel in project Rubicon by Rubicon-Bot.

the class CommandAutochannel method addChannel.

public void addChannel(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");
    if (channels.isEmpty()) {
        Message mymsg = parsedCommandInvocation.getMessage().getTextChannel().sendMessage(EmbedUtil.error("Not found", "There is no Channel with the specified name").build()).complete();
        new Timer().schedule(new TimerTask() {

            @Override
            public void run() {
                mymsg.delete().queue();
            }
        }, 5000);
        return;
    }
    if (channels.size() > 1) {
        ChannelSearch search = genChannelSearch(channels, false, parsedCommandInvocation);
        searches.put(guild, search);
    } else {
        VoiceChannel channel = channels.get(0);
        String newEntry = oldEntry + ", " + channel.getId();
        RubiconBot.getMySQL().updateGuildValue(guild, "autochannels", newEntry);
        Message mymsg = parsedCommandInvocation.getMessage().getChannel().sendMessage(EmbedUtil.success("Created Autochannel", "Successfully created autochannel -> " + channel.getName() + "").build()).complete();
        new Timer().schedule(new TimerTask() {

            @Override
            public void run() {
                mymsg.delete().queue();
            }
        }, 5000);
    }
}
Also used : Message(net.dv8tion.jda.core.entities.Message) VoiceChannel(net.dv8tion.jda.core.entities.VoiceChannel) Guild(net.dv8tion.jda.core.entities.Guild)

Example 10 with VoiceChannel

use of net.dv8tion.jda.core.entities.VoiceChannel in project FredBoat by Frederikam.

the class GuildPlayer method joinChannel.

public void joinChannel(Member usr) throws MessagingException {
    VoiceChannel targetChannel = getUserCurrentVoiceChannel(usr);
    joinChannel(targetChannel);
}
Also used : VoiceChannel(net.dv8tion.jda.core.entities.VoiceChannel)

Aggregations

VoiceChannel (net.dv8tion.jda.core.entities.VoiceChannel)38 TextChannel (net.dv8tion.jda.core.entities.TextChannel)13 Guild (net.dv8tion.jda.core.entities.Guild)8 EmbedBuilder (net.dv8tion.jda.core.EmbedBuilder)7 Message (net.dv8tion.jda.core.entities.Message)7 AudioManager (net.dv8tion.jda.core.managers.AudioManager)6 GuildPlayer (fredboat.audio.player.GuildPlayer)5 ArrayList (java.util.ArrayList)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 Collectors (java.util.stream.Collectors)3 Member (net.dv8tion.jda.core.entities.Member)3 Player (com.arsenarsen.lavaplayerbridge.player.Player)2 Track (com.arsenarsen.lavaplayerbridge.player.Track)2 AudioTrack (com.sedmelluq.discord.lavaplayer.track.AudioTrack)2 AudioTrackContext (fredboat.audio.queue.AudioTrackContext)2 SplitAudioTrackContext (fredboat.audio.queue.SplitAudioTrackContext)2 Consumer (java.util.function.Consumer)2 Nullable (javax.annotation.Nullable)2 User (net.dv8tion.jda.core.entities.User)2 JDAImpl (net.dv8tion.jda.core.entities.impl.JDAImpl)2