text: var {
    MessageEmbed
  } = require("discord.js")
  var ee = require("../../botconfig/embed.json")
  var config = require("../../botconfig/config.json")
  var {
    format,
    isrequestchannel,
    delay,
    edit_request_message_queue_info,
    edit_request_message_track_info,
    arrayMove
  } = require("../functions")
  
  //function for playling song
  async function request(client, message, args, type) {
    var search = args.join(" ");
    var res;
    var player = client.manager.players.get(message.guild.id);
    if(!player)
      player = client.manager.create({
        guild: message.guild.id,
        voiceChannel: message.member.voice.channel.id,
        textChannel: message.channel.id,
        selfDeafen: config.settings.selfDeaf,
      });
    let state = player.state;
    if (state !== "CONNECTED") { 
      //set the variables
      player.set("message", message);
      player.set("playerauthor", message.author.id);
      player.connect();
      player.stop();
    }
    res = await client.manager.search({
      query: search,
      source: type.split(":")[1]
    }, message.author);
    // Check the load type as this command is not that advanced for basics
    if (res.loadType === "LOAD_FAILED") {
      throw res.exception;
    } else if (res.loadType === "PLAYLIST_LOADED") {
      playlist_()
    } else {
      song_()
    }
    //function for calling the song
    async function song_() {
  
      //if no tracks found return info msg
      if (!res.tracks[0]) {
        return message.channel.send(`**❌ Found nothing for: \`${search}\`**`);
      }
      //create a player if not created
  
      //if the player is not connected, then connect and create things
      if (player.state !== "CONNECTED") {
        //set the variables
        player.set("message", message);
        player.set("playerauthor", message.author.id);
        player.connect();
        //add track
        player.queue.add(res.tracks[0]);
        //play track
        player.play();
        player.pause(false);
  
      }
      else if(!player.queue || !player.queue.current){
        //add track
        player.queue.add(res.tracks[0]);
        //play track
        player.play();
        player.pause(false);
      }
      //otherwise
      else {
        //add track
        player.queue.add(res.tracks[0]);
      }
    }
    //function for playist
    async function playlist_() {
      if (!res.tracks[0]) {
        return message.channel.send(`**❌ Found nothing for: \`${search}\`**`);
      }
      //if the player is not connected, then connect and create things
      if (player.state !== "CONNECTED") {
        //set the variables
        player.set("message", message);
        player.set("playerauthor", message.author.id);
        player.connect();
        //add track
        player.queue.add(res.tracks);
        //play track
        player.play();
        player.pause(false);
      }
      else if(!player.queue || !player.queue.current){
        //add track
        player.queue.add(res.tracks);
        //play track
        player.play();
        player.pause(false);
      }
      else {
        player.queue.add(res.tracks);
      }
    }
  }
  
  module.exports = request;
  /**
   * @INFO
   * Bot Coded by Tennessine07
   * @INFO
   */
  