package ml.duncte123.skybot.commands.music;

import ml.duncte123.skybot.Command;
import ml.duncte123.skybot.SkyBot;
import ml.duncte123.skybot.utils.Config;
import net.dv8tion.jda.core.EmbedBuilder;
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;

import java.time.Instant;

public class LeaveCommand extends Command {

    public final static String help = "make the bot leave your channel.";

    @Override
    public boolean called(String[] args, GuildMessageReceivedEvent event) {
        boolean botInChannel = false;

        if(event.getGuild().getAudioManager().isConnected()){
            botInChannel = true;

            if(!event.getGuild().getAudioManager().getConnectedChannel().getMembers().contains(event.getMember())){
                EmbedBuilder eb = new EmbedBuilder()
                        .setColor(Config.defaultColour)
                .addField(SkyBot.au.embedTitle, "I'm sorry, but you have to be in the same channel as me to use any music related commands", false);
                eb.setFooter(Config.defaultName, Config.defaultIcon)
                .setTimestamp(Instant.now());
                event.getChannel().sendMessage(eb.build()).queue();
                return false;
            }

        }else{
            EmbedBuilder eb = new EmbedBuilder()
                    .setColor(Config.defaultColour)
                    .addField(SkyBot.au.embedTitle, "I'm not in a channel atm", false)
                    .setFooter(Config.defaultName, Config.defaultIcon)
                    .setTimestamp(Instant.now());
            event.getChannel().sendMessage(eb.build()).queue();
        }


        return botInChannel;
    }

    @Override
    public void action(String[] args, GuildMessageReceivedEvent event) {
        SkyBot.au.getMusicManager(event.getGuild()).player.stopTrack();
        event.getGuild().getAudioManager().setSendingHandler(null);
        event.getGuild().getAudioManager().closeAudioConnection();
        EmbedBuilder eb = new EmbedBuilder()
                .setColor(Config.defaultColour)
                .addField(SkyBot.au.embedTitle, "Leaving your channel", false)
                .setFooter(Config.defaultName, Config.defaultIcon)
                .setTimestamp(Instant.now());
        event.getChannel().sendMessage(eb.build()).queue();

    }

    @Override
    public String help() {
        // TODO Auto-generated method stub
        return help;
    }
}

@@ -109,16 +109,59 @@
 SkyBot;%0A
+import ml.duncte123.skybot.utils.AirUtils;%0A
 import m
@@ -820,120 +820,52 @@
     
-EmbedBuilder eb = new EmbedBuilder()%0A                        .setColor(Config.defaultColour)%0A                .ad
+event.getChannel().sendMessage(AirUtils.embe
 dFie
@@ -984,622 +984,191 @@
 nds%22
-, false);%0A                eb.setFooter(Config.defaultName, Config.defaultIcon)%0A                .setTimestamp(Instant.now());%0A                event.getChannel().sendMessage(eb.build()).queue();%0A                return false;%0A            %7D%0A%0A        %7Delse%7B%0A            EmbedBuilder eb = new EmbedBuilder()%0A                    .setColor(Config.defaultColour)%0A                    .addField(SkyBot.au.embedTitle, %22I'm not in a channel atm%22, false)%0A                    .setFooter(Config.defaultName, Config.defaultIcon)%0A                    .setTimestamp(Instant.now());%0A            event.getChannel().sendMessage(eb.build(
+)).queue();%0A                return false;%0A            %7D%0A%0A        %7Delse%7B%0A            event.getChannel().sendMessage(AirUtils.embedField(SkyBot.au.embedTitle, %22I'm not in a channel atm%22
 )).q

Clean LeaveCommand