"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const msg_1 = __importDefault(require("../../models/msg"));
const msg_2 = require("../../../shared/types/msg");
const chan_1 = require("../../../shared/types/chan");
const commands = ["ban", "unban", "banlist", "kickban"];
const input = function ({ irc }, chan, cmd, args) {
    if (chan.type !== chan_1.ChanType.CHANNEL) {
        chan.pushMessage(this, new msg_1.default({
            type: msg_2.MessageType.ERROR,
            text: `${cmd} command can only be used in channels.`,
        }));
        return;
    }
    if (cmd !== "banlist" && args.length === 0) {
        if (args.length === 0) {
            chan.pushMessage(this, new msg_1.default({
                type: msg_2.MessageType.ERROR,
                text: `Usage: /${cmd} <nick>`,
            }));
            return;
        }
    }
    switch (cmd) {
        case "kickban":
            irc.raw("KICK", chan.name, args[0], args.slice(1).join(" "));
        // fall through
        case "ban":
            irc.ban(chan.name, args[0]);
            break;
        case "unban":
            irc.unban(chan.name, args[0]);
            break;
        case "banlist":
            irc.banlist(chan.name);
            break;
    }
};
exports.default = {
    commands,
    input,
};
