mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-06-02 22:08:36 -05:00
Fix a variety of bugs in PM commands
Most of these were introduced in the PM refactor, but an honorable mention goes to the global command regex.
This commit is contained in:
parent
53dd09fba0
commit
5a16c884da
|
|
@ -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.",
|
||||
|
|
|
|||
|
|
@ -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:<br />" +
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user