const {Command} = require('../../lib.js')



const mCommandModel = require('../../models/mcommands');

module.exports = class  skip extends Command
{
    constructor(client)
    {
        super(client, {
            name: 'skip',
            group:'music',
            memberName: 'skip',
            description: 'Skips the currently playing music'
         })
    }
    async run(message, args)
    {
        const Author = message.author
        console.log('Skip: -', Author.username);
        const guild = message.guild.id
        const channel = message.channel.id
        const voice = message.member.voice.channel.id;
        const {ChannelType} = require('discord.js');
        if(message.guild.channels.cache.some(channel =>(channel.type == ChannelType.GuildText && channel.members.has('356104008366030863')&& channel.members.has(Author.id))))
        {
            addToDB('skip', guild, channel,voice);

            message.delete();
        }
        else
        {
            message.reply('Not in voice channel!')
        }
        
        
       
    }
}
function addToDB(Command, guild, channel, voice)
{
    var command = new mCommandModel();
    command.command = Command;
    command.guild = guild;
    command.textchannel = channel;
    command.voice = voice;
    command.save(err=>
    {
        if(err)console.error(err)
        console.log(Command, '- added to DB')
    })
}