thelounge/src/plugins/inputs/ban.js
Taavi Väänänen 324fb9023e
Add /kickban
This commit adds a new command, /kickban, that is a combination of /kick
and /ban: it kicks the specific user from the channel and then sets the
+b mode to ban the user from the channel.
2021-11-30 12:07:11 +02:00

50 lines
913 B
JavaScript

"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 !== Chan.Type.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;
}
};