diff --git a/src/plugins/inputs/mode.js b/src/plugins/inputs/mode.js index a86f3e26..9af07079 100644 --- a/src/plugins/inputs/mode.js +++ b/src/plugins/inputs/mode.js @@ -42,7 +42,7 @@ exports.input = function ({irc, nick}, chan, cmd, args) { devoice: "-v", }[cmd]; - const limit = parseInt(irc.network.supports("modes")) || 1; + const limit = parseInt(irc.network.supports("MODES")) || 1; for (let i = 0; i < target.length; i += limit) { const targets = target.slice(i, i + limit); diff --git a/test/commands/mode.js b/test/commands/mode.js index ab27a9a4..c85cafaf 100644 --- a/test/commands/mode.js +++ b/test/commands/mode.js @@ -20,6 +20,13 @@ describe("Commands", function () { lastCommand: null, nick: "xPaw", irc: { + network: { + supports(type) { + if (type.toUpperCase() === "MODES") { + return "4"; + } + }, + }, raw(...args) { testableNetwork.lastCommand = args.join(" "); }, @@ -82,9 +89,18 @@ describe("Commands", function () { ModeCommand.input(testableNetwork, channel, "devoice", ["xPaw"]); expect(testableNetwork.lastCommand).to.equal("MODE #thelounge -v xPaw"); - // Multiple arguments are supported, sent as separate commands - ModeCommand.input(testableNetwork, channel, "devoice", ["xPaw", "Max-P"]); - expect(testableNetwork.lastCommand).to.equal("MODE #thelounge -v Max-P"); + ModeCommand.input(testableNetwork, channel, "voice", ["xPaw", "Max-P"]); + expect(testableNetwork.lastCommand).to.equal("MODE #thelounge +vv xPaw Max-P"); + + // since the limit for modes on tests is 4, it should send two commands + ModeCommand.input(testableNetwork, channel, "devoice", [ + "xPaw", + "Max-P", + "hey", + "idk", + "thelounge", + ]); + expect(testableNetwork.lastCommand).to.equal("MODE #thelounge -v thelounge"); }); }); });