thelounge/src/plugins/inputs/ban.ts
Max Leiter facde53b09
[ts-migrate][src] Rename files from JS/JSX to TS/TSX
Co-authored-by: ts-migrate <>
2022-05-21 11:47:10 -07:00

50 lines
912 B
TypeScript

"use strict";
const Chan = require("../../models/chan");
const Msg = require("../../models/msg");
exports.commands = ["ban", "unban", "banlist", "kickban"];
exports.input = function ({irc}, chan, cmd, args) {
if (chan.type !== ChanType.CHANNEL) {
chan.pushMessage(
this,
new Msg({
type: Msg.Type.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({
type: Msg.Type.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;
}
};