Search in sources :

Example 36 with VoiceChannel

use of net.dv8tion.jda.core.entities.VoiceChannel in project TheLighterBot by PhotonBursted.

the class FileController method retrievePermChannels.

private void retrievePermChannels() throws SQLException {
    retrieveData("SELECT *\n" + "FROM \"PermChannels\"", result -> {
        try {
            TextChannel tc = l.getBot().getTextChannelById(result.getLong("tc_id"));
            VoiceChannel vc = l.getBot().getVoiceChannelById(result.getLong("vc_id"));
            if (tc != null && vc != null) {
                l.getChannelController().getPermChannels().putStoring(tc, vc);
            }
        } catch (SQLException ex) {
            log.error("Something went wrong retrieving the permanent channels", ex);
        }
    });
}
Also used : TextChannel(net.dv8tion.jda.core.entities.TextChannel) VoiceChannel(net.dv8tion.jda.core.entities.VoiceChannel)

Example 37 with VoiceChannel

use of net.dv8tion.jda.core.entities.VoiceChannel in project TheLighterBot by PhotonBursted.

the class UnlinkChannelCommand method execute.

@Override
protected void execute() {
    if (!ev.getMember().getVoiceState().inVoiceChannel()) {
        handleError(MessageContent.NOT_IN_VOICE_CHANNEL);
    }
    VoiceChannel vc = ev.getMember().getVoiceState().getChannel();
    if (!l.getChannelController().isLinked(vc)) {
        handleError(MessageContent.CHANNEL_NOT_LINKED);
    }
    TextChannel tc = l.getChannelController().getLinkedChannels().getForVoiceChannel(vc);
    l.getChannelController().getLinkedChannels().removeByValueStoring(vc);
    if (l.getChannelController().isPermanent(vc)) {
        l.getChannelController().getPermChannels().removeByValueStoring(vc);
    }
    LoggerUtils.logAndDelete(log, String.format("A link has been removed:\n" + " - VC: %s (%s)\n" + " - TC: %s (%s)", vc.getName(), vc.getId(), tc.getName(), tc.getId()));
    l.getDiscordController().sendMessage(ev, String.format("Successfully unlinked **%s** from **%s**!", vc.getName(), tc.getAsMention()), DiscordController.AUTOMATIC_REMOVAL_INTERVAL);
}
Also used : TextChannel(net.dv8tion.jda.core.entities.TextChannel) VoiceChannel(net.dv8tion.jda.core.entities.VoiceChannel)

Example 38 with VoiceChannel

use of net.dv8tion.jda.core.entities.VoiceChannel in project legendarybot by greatman.

the class PlayMusicCommand method execute.

@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);
}
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