const errorHandler = require("../../handlers/errors.js")

module.exports = async d => {
    const code = d.command.code

    const r = code.split("$onlyForIDs[").length - 1

    const inside = code.split("$onlyForIDs[")[r].split("]")[0]

    const IDs = inside.split(";")

    const errorMessage = IDs.pop()

    if (!IDs.some(id => id === d.message.author.id)) return errorHandler(d, errorMessage)

    return {
        code: code.replaceLast(`$onlyForIDs[${inside}]`, "")
    }
}