const removeelo = require("./removeelo.js")
const functions = require("../modules/functions.js")
const {getSettings} = require("../modules/functions.js")

exports.run = async (client, message, args, level) => { // eslint-disable-line no-unused-vars
    const settings = message.settings = getSettings(message.guild)
    if (args.length !== 2) {
        message.reply(settings.prefix + removeelo.help.usage)
        return
    }
    let user = message.guild.members.cache.find(user => user.id === message.mentions.users.first()?.id)
    if (user === undefined) {
        message.reply("Please mention a user.")
        return
    }
    const elo = parseInt(args[1])
    if (isNaN(elo)) {
        message.reply("Please enter a valid elo.")
        return
    }

    functions.changeElo(message.author, user, (0 - elo))
    message.reply(`Successfully removed ${elo} elo from ${user}`)
}

exports.conf = {
    enabled: true,
    guildOnly: true,
    aliases: [""],
    permLevel: "4v4Host"
}

exports.help = {
    name: "removeelo",
    category: "Administrative",
    description: "Removes elo from a player",
    usage: "removeelo [user] [amount]"
}