diff --git a/chat-plugins/datasearch.js b/chat-plugins/datasearch.js index 0a540d3aed..5b1cedc535 100644 --- a/chat-plugins/datasearch.js +++ b/chat-plugins/datasearch.js @@ -87,7 +87,7 @@ exports.commands = { return runSearch({ target: target, cmd: 'dexsearch', - canAll: (!this.broadcastMessage || room.isPersonal), + canAll: (!this.broadcastMessage || (room && room.isPersonal)), message: (this.broadcastMessage ? "" : message), }).then(response => { if (!this.runBroadcast()) return; @@ -98,7 +98,7 @@ exports.commands = { } else if (response.dt) { CommandParser.commands.data.call(this, response.dt, room, user, connection, 'dt'); } - room.update(); + this.update(); }); }, @@ -150,7 +150,7 @@ exports.commands = { } else if (response.dt) { CommandParser.commands.data.call(this, response.dt, room, user, connection, 'dt'); } - room.update(); + this.update(); }); }, randompokemonhelp: ["/randompokemon - Generates random Pok\u00e9mon based on given search conditions.", @@ -167,7 +167,7 @@ exports.commands = { return runSearch({ target: target, cmd: 'movesearch', - canAll: (!this.broadcastMessage || room.isPersonal), + canAll: (!this.broadcastMessage || (room && room.isPersonal)), message: (this.broadcastMessage ? "" : message), }).then(response => { if (!this.runBroadcast()) return; @@ -178,7 +178,7 @@ exports.commands = { } else if (response.dt) { CommandParser.commands.data.call(this, response.dt, room, user, connection, 'dt'); } - room.update(); + this.update(); }); }, movesearchhelp: ["/movesearch [parameter], [parameter], [parameter], ... - Searches for moves that fulfill the selected criteria.", @@ -200,7 +200,7 @@ exports.commands = { return runSearch({ target: target, cmd: 'itemsearch', - canAll: (!this.broadcastMessage || room.isPersonal), + canAll: (!this.broadcastMessage || (room && room.isPersonal)), message: (this.broadcastMessage ? "" : message), }).then(response => { if (!this.runBroadcast()) return; @@ -211,7 +211,7 @@ exports.commands = { } else if (response.dt) { CommandParser.commands.data.call(this, response.dt, room, user, connection, 'dt'); } - room.update(); + this.update(); }); }, itemsearchhelp: ["/itemsearch [move description] - finds items that match the given key words.", @@ -244,7 +244,7 @@ exports.commands = { } else if (response.reply) { this.sendReplyBox(response.reply); } - room.update(); + this.update(); }); }, learnhelp: ["/learn [pokemon], [move, move, ...] - Displays how a Pok\u00e9mon can learn the given moves, if it can at all.", diff --git a/chat-plugins/info.js b/chat-plugins/info.js index 558e3df8bf..c00c909e0b 100644 --- a/chat-plugins/info.js +++ b/chat-plugins/info.js @@ -1242,7 +1242,7 @@ exports.commands = { '!restarthelp': true, restarthelp: function (target, room, user) { - if (room.id === 'lobby' && !this.can('lockdown')) return false; + if (!Rooms.global.lockdown && !this.can('lockdown')) return false; if (!this.runBroadcast()) return; this.sendReplyBox( "The server is restarting. Things to know:
" + diff --git a/command-parser.js b/command-parser.js index e37d054e04..2378348f61 100644 --- a/command-parser.js +++ b/command-parser.js @@ -273,6 +273,9 @@ class CommandContext { logModCommand(text) { this.room.modlog(text); } + update() { + if (this.room) this.room.update(); + } can(permission, target, room) { if (!this.user.can(permission, target, room)) { this.errorReply(this.cmdToken + this.namespaces.concat(this.cmd).join(" ") + " - Access denied."); @@ -661,7 +664,7 @@ let parse = exports.parse = function (message, room, user, connection, pmTarget, } let relatedRoom = null; - if (!user.inRooms.has(room.id) || room === Rooms.global) { + if (!pmTarget && (!user.inRooms.has(room.id) || room === Rooms.global)) { if (!CommandParser.globalPattern.test(message)) return; relatedRoom = room; } diff --git a/commands.js b/commands.js index c98b2712ca..943bb17b6a 100644 --- a/commands.js +++ b/commands.js @@ -395,7 +395,7 @@ let commands = exports.commands = { inv: 'invite', invite: function (target, room, user) { if (!target) return this.parse('/help invite'); - if (room) target = this.splitTarget(target); + if (room) target = this.splitTarget(target) || room.id; let targetRoom = Rooms.search(target); if (targetRoom && !targetRoom.checkModjoin(user)) { targetRoom = undefined; @@ -415,12 +415,12 @@ let commands = exports.commands = { if (!targetUser) return this.errorReply(`The user "${this.targetUsername}" was not found.`); if (!targetRoom.checkModjoin(targetUser)) { - if (room.getAuth(targetUser) !== ' ') { + if (targetRoom.getAuth(targetUser) !== ' ') { return this.errorReply(`The user "${targetUser.name}" does not have permission to join "${targetRoom.title}".`); } this.parse(`/roomvoice ${targetUser.name}`, false, targetRoom); if (!targetRoom.checkModjoin(targetUser)) { - if (room.getAuth(targetUser) !== ' ') { + if (targetRoom.getAuth(targetUser) !== ' ') { return this.errorReply(`The user "${targetUser.name}" does not have permission to join "${targetRoom.title}".`); } return this.errorReply(`You do not have permission to invite people into this room.`); @@ -1101,7 +1101,7 @@ let commands = exports.commands = { if (cmd === 'roomauth1') userLookup = '\n\nTo look up auth for a user, use /userauth ' + target; let targetRoom = room; if (target) targetRoom = Rooms.search(target); - if (!targetRoom || !targetRoom.checkModjoin(user)) return this.errorReply(`The room "${target}" does not exist.`); + if (!targetRoom || targetRoom.id === 'global' || !targetRoom.checkModjoin(user)) return this.errorReply(`The room "${target}" does not exist.`); if (!targetRoom.auth) return this.sendReply("/roomauth - The room '" + (targetRoom.title || target) + "' isn't designed for per-room moderation and therefore has no auth list." + userLookup); let rankLists = {}; @@ -2139,6 +2139,7 @@ let commands = exports.commands = { }, unblacklisthelp: ["/unblacklist [username] - Unblacklists the user from the room you are in. Requires: # & ~"], + blacklists: 'showblacklist', showbl: 'showblacklist', showblacklist: function (target, room, user) { if (!this.can('mute', null, room)) return false;