package com.bwfcwalshy.flarebot.commands.general;

import com.bwfcwalshy.flarebot.commands.Command;
import com.bwfcwalshy.flarebot.commands.CommandType;
import net.dv8tion.jda.core.entities.Member;
import net.dv8tion.jda.core.entities.Message;
import net.dv8tion.jda.core.entities.TextChannel;
import net.dv8tion.jda.core.entities.User;

public class JoinCommand implements Command {

    @Override
    public void onCommand(User sender, TextChannel channel, Message message, String[] args, Member member) {
        if(member.getVoiceState().inVoiceChannel()){
            if(channel.getGuild().getAudioManager().isAttemptingToConnect()){
                channel.sendMessage("Currently connecting to a voice channel! Try again soon!");
                return;
            }
            channel.getGuild().getAudioManager().openAudioConnection(member.getVoiceState().getChannel());
        }
    }

    @Override
    public String getCommand() {
        return "join";
    }

    @Override
    public String getDescription() {
        return "Tell me to join your voice channel.";
    }

    @Override
    public CommandType getType() {
        return CommandType.GENERAL;
    }
}

@@ -146,16 +146,56 @@
 ndType;%0A
+import net.dv8tion.jda.core.Permission;%0A
 import n
@@ -590,24 +590,309 @@
 Channel())%7B%0A
+            if(!channel.getGuild().getSelfMember()%0A                    .hasPermission(member.getVoiceState().getChannel(), Permission.VOICE_CONNECT))%7B%0A                channel.sendMessage(%22I do not have permissions to join that channel!%22).queue();%0A                return;%0A            %7D%0A
             

Add a permission check to JoinCommand.java