diff --git a/chat-commands.js b/chat-commands.js index 3afaa6546b..c15210f41a 100644 --- a/chat-commands.js +++ b/chat-commands.js @@ -777,9 +777,7 @@ const commands = { let roomid = target.trim(); if (!roomid) { // allow deleting personal rooms without typing out the room name - if (room.isPersonal && cmd === "deletegroupchat") { - roomid = room.id; - } else { + if (!room.isPersonal || cmd !== "deletegroupchat") { return this.parse(`/help deleteroom`); } } else { @@ -1063,7 +1061,7 @@ const commands = { } if (!this.can('declare')) return false; if (target.length > 80) return this.errorReply(`Error: Room description is too long (must be at most 80 characters).`); - let normalizedTarget = ' ' + target.toLowerCase().replace('[^a-zA-Z0-9]+', ' ').trim() + ' '; + let normalizedTarget = ' ' + target.toLowerCase().replace(/[^a-z0-9]+/g, ' ').trim() + ' '; if (normalizedTarget.includes(' welcome ')) { return this.errorReply(`Error: Room description must not contain the word "welcome".`); @@ -1263,6 +1261,7 @@ const commands = { } if (!target) return this.parse('/help roomowner'); target = this.splitTarget(target, true); + if (target) return this.errorReply(`This command does not support specifying a reason.`); let targetUser = this.targetUser; let name = this.targetUsername; let userid = toId(name); @@ -1737,6 +1736,7 @@ const commands = { unmute: function (target, room, user) { if (!target) return this.parse('/help unmute'); target = this.splitTarget(target); + if (target) return this.errorReply(`This command does not support specifying a reason.`); if (!this.canTalk()) return; if (!this.can('mute', null, room)) return false; @@ -2224,6 +2224,7 @@ const commands = { if (!this.can('promote')) return; target = this.splitTarget(target, true); + if (target) return this.errorReply(`This command does not support specifying a reason.`); let targetUser = this.targetUser; let userid = toId(this.targetUsername); let name = targetUser ? targetUser.name : this.targetUsername; @@ -3290,7 +3291,7 @@ const commands = { // errors can occur while rebasing or popping the stash; make sure to recover try { this.sendReply(`Rebasing...`); - [code, stdout, stderr] = await exec(`git rebase FETCH_HEAD`); + [code] = await exec(`git rebase FETCH_HEAD`); if (code) { // conflict while rebasing await exec(`git rebase --abort`); @@ -3299,7 +3300,7 @@ const commands = { if (stashedChanges) { this.sendReply(`Restoring saved changes...`); - [code, stdout, stderr] = await exec(`git stash pop`); + [code] = await exec(`git stash pop`); if (code) { // conflict while popping stash await exec(`git reset HEAD .`); @@ -3802,12 +3803,8 @@ const commands = { let targetUser = Users.getExact(target); if (!targetUser) return this.errorReply(`User '${target}' not found.`); - target = targetUser ? targetUser.userid : ''; - - if (target) { - room.battle.win(targetUser); - this.modlog('FORCEWIN', target); - } + room.battle.win(targetUser); + this.modlog('FORCEWIN', targetUser.userid); }, forcewinhelp: [ `/forcetie - Forces the current match to end in a tie. Requires: & ~`, @@ -3901,6 +3898,7 @@ const commands = { '!accept': true, accept: function (target, room, user, connection) { target = this.splitTarget(target); + if (target) return this.popupReply(`This command does not support specifying multiple users`); const targetUser = this.targetUser || this.pmTarget; if (!targetUser) return this.popupReply(`User "${this.targetUsername}" not found.`); Ladders.acceptChallenge(connection, targetUser); diff --git a/chat-formatter.js b/chat-formatter.js index 70bdd54b7a..98577e8cf1 100644 --- a/chat-formatter.js +++ b/chat-formatter.js @@ -64,7 +64,7 @@ class TextFormatter { // filter links first str = str.replace(linkRegex, uri => { - let fulluri = uri; + let fulluri; if (/^[a-z0-9.]+@/ig.test(uri)) { fulluri = 'mailto:' + uri; } else { diff --git a/chat-plugins/info.js b/chat-plugins/info.js index f15d3889fe..54a969ccf0 100644 --- a/chat-plugins/info.js +++ b/chat-plugins/info.js @@ -412,7 +412,6 @@ const commands = { let pokemon = Dex.getTemplate(p); if (pokemon.num === targetNum) { target = pokemon.species; - targetId = pokemon.id; break; } } @@ -1536,7 +1535,7 @@ const commands = { break; } - if (!totalMatches) return this.errorReply("No " + (target ? "matched " : "") + "formats found."); + if (!totalMatches) return this.errorReply("No matched formats found."); if (totalMatches === 1) { let rules = []; let rulesetHtml = ''; diff --git a/sim/battle.js b/sim/battle.js index 542b55a246..6f5eba6b69 100644 --- a/sim/battle.js +++ b/sim/battle.js @@ -214,9 +214,9 @@ class Battle extends Dex.ModdedDex { let result = this.runEvent('SetWeather', source, source, status); if (!result) { if (result === false) { - if (source && sourceEffect && sourceEffect.weather) { + if (sourceEffect && sourceEffect.weather) { this.add('-fail', source, sourceEffect, '[from]: ' + this.weather); - } else if (source && sourceEffect && sourceEffect.effectType === 'Ability') { + } else if (sourceEffect && sourceEffect.effectType === 'Ability') { this.add('-ability', source, sourceEffect, '[from] ' + this.weather, '[fail]'); } } diff --git a/sim/dex.js b/sim/dex.js index 949247f973..d4b85a4cfc 100644 --- a/sim/dex.js +++ b/sim/dex.js @@ -1041,21 +1041,20 @@ class ModdedDex { return false; } - /** @type {DataType[]} */ searchIn = searchIn || ['Pokedex', 'Movedex', 'Abilities', 'Items', 'Natures']; let searchFunctions = {Pokedex: 'getTemplate', Movedex: 'getMove', Abilities: 'getAbility', Items: 'getItem', Natures: 'getNature'}; let searchTypes = {Pokedex: 'pokemon', Movedex: 'move', Abilities: 'ability', Items: 'item', Natures: 'nature'}; /** @type {AnyObject[] | false} */ let searchResults = []; - for (const result of searchIn) { + for (const table of searchIn) { /** @type {AnyObject} */ // @ts-ignore - let res = this[searchFunctions[result]](target); + let res = this[searchFunctions[table]](target); if (res.exists && res.gen <= this.gen) { searchResults.push({ isInexact: isInexact, - searchType: searchTypes[result], + searchType: searchTypes[table], name: res.species ? res.species : res.name, }); } @@ -1077,8 +1076,9 @@ class ModdedDex { maxLd = 2; } searchResults = false; - for (let i = 0; i <= searchIn.length; i++) { - let searchObj = this.data[searchIn[i] || 'Aliases']; + for (const table of [...searchIn, 'Aliases']) { + // @ts-ignore + let searchObj = this.data[table]; if (!searchObj) { continue; } diff --git a/users.js b/users.js index b3cf7976dc..79a3b4c8e7 100644 --- a/users.js +++ b/users.js @@ -116,7 +116,7 @@ function merge(user1, user2) { function getUser(name, exactName = false) { if (!name || name === '!') return null; // @ts-ignore - if (name && name.userid) return name; + if (name.userid) return name; let userid = toId(name); let i = 0; if (!exactName) {