diff --git a/Xiao.js b/Xiao.js index c5ce136b..22829c04 100644 --- a/Xiao.js +++ b/Xiao.js @@ -158,7 +158,7 @@ client.on('guildMemberRemove', async member => { if (channel.topic && channel.topic.includes('')) return null; try { const leaveMessage = client.leaveMessages[Math.floor(Math.random() * client.leaveMessages.length)]; - await channel.send(leaveMessage.replace(/{{user}}/gi, `**${member.user.tag}**`)); + await channel.send(leaveMessage.replaceAll('{{user}}', `**${member.user.tag}**`)); return null; } catch { return null; diff --git a/commands/code/lint-rule.js b/commands/code/lint-rule.js index e6f43be9..261e6a89 100644 --- a/commands/code/lint-rule.js +++ b/commands/code/lint-rule.js @@ -18,7 +18,7 @@ module.exports = class LintRuleCommand extends Command { key: 'rule', prompt: 'Which rule would you like to get information on?', type: 'string', - parse: rule => rule.toLowerCase().replace(/ /g, '-') + parse: rule => rule.toLowerCase().replaceAll(' ', '-') } ] }); diff --git a/commands/edit-image/shields-io-badge.js b/commands/edit-image/shields-io-badge.js index 1cae5126..e67aea34 100644 --- a/commands/edit-image/shields-io-badge.js +++ b/commands/edit-image/shields-io-badge.js @@ -22,13 +22,13 @@ module.exports = class ShieldsIoBadgeCommand extends Command { key: 'subject', prompt: 'What is the subject of the badge?', type: 'string', - parse: subject => encodeURIComponent(subject.replace(/-/g, '--').replace(/_/g, '__')) + parse: subject => encodeURIComponent(subject.replaceAll('-', '--').replaceAll('_', '__')) }, { key: 'status', prompt: 'What is the status of the badge?', type: 'string', - parse: status => encodeURIComponent(status.replace(/-/g, '--').replace(/_/g, '__')) + parse: status => encodeURIComponent(status.replaceAll('-', '--').replaceAll('_', '__')) }, { key: 'color', diff --git a/commands/edit-meme/be-like-bill.js b/commands/edit-meme/be-like-bill.js index f9d52fc1..b9dbf429 100644 --- a/commands/edit-meme/be-like-bill.js +++ b/commands/edit-meme/be-like-bill.js @@ -51,7 +51,7 @@ module.exports = class BeLikeBillCommand extends Command { const ctx = canvas.getContext('2d'); ctx.drawImage(base, 0, 0); ctx.font = 'normal bold 23px Arial'; - const text = await wrapText(ctx, texts[Math.floor(Math.random() * texts.length)].replace(/{{name}}/gi, name), 569); + const text = await wrapText(ctx, texts[Math.floor(Math.random() * texts.length)].replaceAll('{{name}}', name), 569); ctx.fillText(stripIndents` This is ${name}. diff --git a/commands/edit-text/clap.js b/commands/edit-text/clap.js index 807c5c54..7f0e2d06 100644 --- a/commands/edit-text/clap.js +++ b/commands/edit-text/clap.js @@ -14,7 +14,7 @@ module.exports = class ClapCommand extends Command { prompt: 'What 👏 text 👏 would 👏 you 👏 like 👏 to 👏 convert?', type: 'string', validate: text => { - if (text.replace(/ /g, ' 👏 ').length < 2000) return true; + if (text.replaceAll(' ', ' 👏 ').length < 2000) return true; return 'Invalid text, your text is too long.'; } } @@ -23,6 +23,6 @@ module.exports = class ClapCommand extends Command { } run(msg, { text }) { - return msg.say(text.replace(/ /g, ' 👏 ')); + return msg.say(text.replaceAll(' ', ' 👏 ')); } }; diff --git a/commands/edit-text/latlmes.js b/commands/edit-text/latlmes.js index 76a62942..de89a7fb 100644 --- a/commands/edit-text/latlmes.js +++ b/commands/edit-text/latlmes.js @@ -20,14 +20,14 @@ module.exports = class LatlmesCommand extends Command { prompt: 'What section of the news should the link display?', type: 'string', max: 100, - parse: query => encodeURIComponent(query.replace(/ /g, '-').toLowerCase()) + parse: query => encodeURIComponent(query.replaceAll(' ', '-').toLowerCase()) }, { key: 'query', prompt: 'What would you like the link to display as?', type: 'string', max: 500, - parse: query => encodeURIComponent(query.replace(/ /g, '-').toLowerCase()) + parse: query => encodeURIComponent(query.replaceAll(' ', '-').toLowerCase()) } ] }); diff --git a/commands/edit-text/snake-speak.js b/commands/edit-text/snake-speak.js index ffcaf941..b8d95d0e 100644 --- a/commands/edit-text/snake-speak.js +++ b/commands/edit-text/snake-speak.js @@ -23,6 +23,6 @@ module.exports = class SnakeSpeakCommand extends Command { } run(msg, { text }) { - return msg.say(text.replace(/s/gi, 'sssss')); + return msg.say(text.replaceAll('s', 'sssss').replaceAll('S', 'SSSSS')); } }; diff --git a/commands/edit-text/temmie.js b/commands/edit-text/temmie.js index 3678f847..051321b2 100644 --- a/commands/edit-text/temmie.js +++ b/commands/edit-text/temmie.js @@ -42,8 +42,9 @@ module.exports = class TemmieCommand extends Command { temmize(text) { return wordTrans(text, dictionary) - .replace(/ing/gi, 'in') - .replace(/!/g, '!!!!111!1!') - .replace(/'/g, ''); + .replaceAll('ing', 'in') + .replaceAll('ING', 'IN') + .replaceAll('!', '!!!!111!1!') + .replaceAll('\'', ''); } }; diff --git a/commands/events/apod.js b/commands/events/apod.js index 6bcc6864..4a9f5149 100644 --- a/commands/events/apod.js +++ b/commands/events/apod.js @@ -40,7 +40,7 @@ module.exports = class ApodCommand extends Command { ) .setImage(body.media_type === 'image' ? body.url : null) .setURL(body.url) - .setFooter(`Image Credits: ${body.copyright ? body.copyright.replace(/\n/g, '/') : 'Public Domain'}`) + .setFooter(`Image Credits: ${body.copyright ? body.copyright.replaceAll('\n', '/') : 'Public Domain'}`) .setTimestamp(); return msg.embed(embed); } catch (err) { diff --git a/commands/events/time.js b/commands/events/time.js index c4e77e9e..92169a4d 100644 --- a/commands/events/time.js +++ b/commands/events/time.js @@ -33,7 +33,7 @@ module.exports = class TimeCommand extends Command { label: 'time zone', prompt: 'Which time zone do you want to get the time of?', type: 'string', - parse: timeZone => timeZone.replace(/ /g, '_').toLowerCase() + parse: timeZone => timeZone.replaceAll(' ', '_').toLowerCase() } ] }); diff --git a/commands/games-sp/hunger-games.js b/commands/games-sp/hunger-games.js index 57903edd..d2aff4f0 100644 --- a/commands/games-sp/hunger-games.js +++ b/commands/games-sp/hunger-games.js @@ -89,13 +89,10 @@ module.exports = class HungerGamesCommand extends Command { } parseEvent(event, tributes) { - return event - .replace(/\(Player1\)/gi, `**${tributes[0]}**`) - .replace(/\(Player2\)/gi, `**${tributes[1]}**`) - .replace(/\(Player3\)/gi, `**${tributes[2]}**`) - .replace(/\(Player4\)/gi, `**${tributes[3]}**`) - .replace(/\(Player5\)/gi, `**${tributes[4]}**`) - .replace(/\(Player6\)/gi, `**${tributes[5]}**`); + for (let i = 0; i < 6; i++) { + event = event.replaceAll(`(Player${i + 1})`, `**${tributes[i]}**`); + } + return event; } makeEvents(tributes, kills, eventsArr, deaths, results) { diff --git a/commands/games-sp/mad-libs.js b/commands/games-sp/mad-libs.js index d48b522a..352610f0 100644 --- a/commands/games-sp/mad-libs.js +++ b/commands/games-sp/mad-libs.js @@ -51,7 +51,7 @@ module.exports = class MadLibsCommand extends Command { this.client.games.delete(msg.channel.id); let finished = lib.text; for (let i = 0; i < choices.length; i++) { - finished = finished.replace(new RegExp(`\\{${i}\\}`, 'g'), `**${choices[i]}**`); + finished = finished.replaceAll(`{${i}}`, `**${choices[i]}**`); } return msg.say(finished); } catch (err) { diff --git a/commands/random-res/never-have-i-ever.js b/commands/random-res/never-have-i-ever.js index 430dc81e..e7b2c76b 100644 --- a/commands/random-res/never-have-i-ever.js +++ b/commands/random-res/never-have-i-ever.js @@ -23,7 +23,7 @@ module.exports = class NeverHaveIEverCommand extends Command { async run(msg) { try { const { text } = await request.get('http://www.neverhaveiever.org/randomtext.php'); - return msg.say(text.match(/

(.+)<\/h1>/i)[1].replace(/<\/br>/g, '')); + return msg.say(text.match(/

(.+)<\/h1>/i)[1].replaceAll('
', '')); } catch (err) { return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); } diff --git a/commands/search/bulbapedia.js b/commands/search/bulbapedia.js index 90c32f56..bdd77204 100644 --- a/commands/search/bulbapedia.js +++ b/commands/search/bulbapedia.js @@ -51,8 +51,8 @@ module.exports = class BulbapediaCommand extends Command { .setTitle(data.title) .setAuthor('Bulbapedia', 'https://i.imgur.com/ePpoeFA.png', 'https://bulbapedia.bulbagarden.net/') .setThumbnail(data.thumbnail ? data.thumbnail.source : null) - .setURL(`https://bulbapedia.bulbagarden.net/wiki/${encodeURIComponent(query).replace(/\)/g, '%29')}`) - .setDescription(shorten(data.extract.replace(/\n/g, '\n\n'))); + .setURL(`https://bulbapedia.bulbagarden.net/wiki/${encodeURIComponent(query).replaceAll(')', '%29')}`) + .setDescription(shorten(data.extract.replaceAll('\n', '\n\n'))); return msg.embed(embed); } catch (err) { return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); diff --git a/commands/search/lyrics.js b/commands/search/lyrics.js index 157b46a4..f0f6e40e 100644 --- a/commands/search/lyrics.js +++ b/commands/search/lyrics.js @@ -53,7 +53,7 @@ module.exports = class LyricsCommand extends Command { const { text } = await request.get(`https://www.azlyrics.com/lyrics/${artist}/${song}.html`); const lyrics = text.match(lyricRegex)[1]; return lyrics - .replace(/
/g, '') + .replaceAll('
', '') .replace(/<\/?div>/g, '') .trim(); } diff --git a/commands/search/mdn.js b/commands/search/mdn.js index 7d3efc51..3b64ffff 100644 --- a/commands/search/mdn.js +++ b/commands/search/mdn.js @@ -22,7 +22,7 @@ module.exports = class MDNCommand extends Command { key: 'query', prompt: 'What article would you like to search for?', type: 'string', - parse: query => query.replace(/#/g, '.prototype.') + parse: query => query.replaceAll('#', '.prototype.') } ] }); diff --git a/commands/search/neopets-item.js b/commands/search/neopets-item.js index a4802464..30dc250b 100644 --- a/commands/search/neopets-item.js +++ b/commands/search/neopets-item.js @@ -70,7 +70,7 @@ module.exports = class NeopetsItemCommand extends Command { name: details.match(/

(.+)<\/h1>/)[1], details: details.match(/(.+)<\/em>/)[1], image: `https://items.jellyneo.net/assets/imgs/items/${id[1]}.gif`, - price: price ? Number.parseInt(price[1].replace(/,/g, ''), 10) : null, + price: price ? Number.parseInt(price[1].replaceAll(',', ''), 10) : null, currency: price ? price[2] : null }; } diff --git a/commands/search/npm.js b/commands/search/npm.js index 7bd36796..1b04f4c0 100644 --- a/commands/search/npm.js +++ b/commands/search/npm.js @@ -25,7 +25,7 @@ module.exports = class NPMCommand extends Command { label: 'package', prompt: 'What package would you like to get information on?', type: 'string', - parse: pkg => encodeURIComponent(pkg.replace(/ /g, '-')) + parse: pkg => encodeURIComponent(pkg.replaceAll(' ', '-')) } ] }); diff --git a/commands/search/paladins.js b/commands/search/paladins.js index 8e1e8b59..150a2de8 100644 --- a/commands/search/paladins.js +++ b/commands/search/paladins.js @@ -102,6 +102,6 @@ module.exports = class PaladinsCommand extends Command { case 'Damage': emojiID = DAMAGE_EMOJI_ID; break; case 'Front Line': emojiID = FRONT_LINE_EMOJI_ID; break; } - return `<:${className.replace(/ /g, '')}:${emojiID}>`; + return `<:${className.replaceAll(' ', '')}:${emojiID}>`; } }; diff --git a/commands/search/wikipedia.js b/commands/search/wikipedia.js index 92ccc68a..e90d6787 100644 --- a/commands/search/wikipedia.js +++ b/commands/search/wikipedia.js @@ -51,8 +51,8 @@ module.exports = class WikipediaCommand extends Command { .setTitle(data.title) .setAuthor('Wikipedia', 'https://i.imgur.com/Z7NJBK2.png', 'https://www.wikipedia.org/') .setThumbnail(data.thumbnail ? data.thumbnail.source : null) - .setURL(`https://en.wikipedia.org/wiki/${encodeURIComponent(query).replace(/\)/g, '%29')}`) - .setDescription(shorten(data.extract.replace(/\n/g, '\n\n'))); + .setURL(`https://en.wikipedia.org/wiki/${encodeURIComponent(query).replaceAll(')', '%29')}`) + .setDescription(shorten(data.extract.replaceAll('\n', '\n\n'))); return msg.embed(embed); } catch (err) { return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); diff --git a/commands/voice/soundboard.js b/commands/voice/soundboard.js index 4d113782..7ec7d29c 100644 --- a/commands/voice/soundboard.js +++ b/commands/voice/soundboard.js @@ -52,11 +52,11 @@ module.exports = class SoundboardCommand extends Command { prompt: `What sound do you want to play? Either ${list(sounds, 'or')}.`, type: 'string', validate: sound => { - const choice = sound.toLowerCase().replace(/ /g, '-'); + const choice = sound.toLowerCase().replaceAll(' ', '-'); if (sounds.includes(choice)) return true; return `You provided an invalid sound. Please choose either ${list(sounds, 'or')}.`; }, - parse: sound => `${sound.toLowerCase().replace(/ /g, '-')}.mp3` + parse: sound => `${sound.toLowerCase().replaceAll(' ', '-')}.mp3` } ] }); diff --git a/package.json b/package.json index 47dc8d85..5156dbbc 100644 --- a/package.json +++ b/package.json @@ -28,23 +28,23 @@ }, "homepage": "https://github.com/dragonfire535/xiao#readme", "engines": { - "node": ">=12" + "node": ">=15" }, "dependencies": { "@discordjs/collection": "^0.1.6", "@discordjs/opus": "^0.3.2", "@vitalets/google-translate-api": "^4.0.0", - "aki-api": "^5.1.1", + "aki-api": "^5.2.0", "canvas": "^2.6.1", "cheerio": "^1.0.0-rc.3", "cloc": "^2.7.0", "common-tags": "^1.8.0", "custom-translate": "^2.2.8", "didyoumean2": "^4.1.0", - "discord.js": "^12.3.1", + "discord.js": "^12.4.1", "discord.js-commando": "github:discordjs/Commando", "dotenv": "^8.2.0", - "eslint": "^7.11.0", + "eslint": "^7.12.0", "gifencoder": "^2.0.1", "gm": "^1.23.1", "html-entities": "^1.3.1", diff --git a/structures/pokemon/Pokemon.js b/structures/pokemon/Pokemon.js index d9eb2316..a1ace237 100644 --- a/structures/pokemon/Pokemon.js +++ b/structures/pokemon/Pokemon.js @@ -6,7 +6,7 @@ module.exports = class Pokemon { constructor(store, data) { this.store = store; this.id = data.id; - const slugName = firstUpperCase(data.name).replace(/-/g, ' '); + const slugName = firstUpperCase(data.name).replaceAll('-', ' '); this.name = data.names.length ? data.names.find(entry => entry.language.name === 'en').name : slugName; @@ -22,7 +22,7 @@ module.exports = class Pokemon { this.varieties = data.varieties.map(variety => { const name = firstUpperCase(variety.pokemon.name .replace(new RegExp(`${this.slug}-?`, 'i'), '') - .replace(/-/g, ' ')); + .replaceAll('-', ' ')); return { id: variety.pokemon.name, name: name || null, diff --git a/structures/pokemon/PokemonStore.js b/structures/pokemon/PokemonStore.js index 263f960c..5fffe8de 100644 --- a/structures/pokemon/PokemonStore.js +++ b/structures/pokemon/PokemonStore.js @@ -28,6 +28,6 @@ module.exports = class PokemonStore extends Collection { } makeSlug(query) { - return encodeURIComponent(query.toLowerCase().replace(/ /g, '-').replace(/[^a-zA-Z0-9-]/g, '')); + return encodeURIComponent(query.toLowerCase().replaceAll(' ', '-').replace(/[^a-zA-Z0-9-]/g, '')); } }; diff --git a/util/Util.js b/util/Util.js index fdce88f9..54158368 100644 --- a/util/Util.js +++ b/util/Util.js @@ -156,7 +156,7 @@ module.exports = class Util { } static embedURL(title, url, display) { - return `[${title}](${url.replace(/\)/g, '%27')}${display ? ` "${display}"` : ''})`; + return `[${title}](${url.replaceAll(')', '%29')}${display ? ` "${display}"` : ''})`; } static stripInvites(str, { guild = true, bot = true, text = '[redacted invite]' } = {}) { @@ -209,7 +209,7 @@ module.exports = class Util { if (removeLineBreaks) clean = clean.replace(/\r|\n|\f/g, ''); clean = entities.decode(clean); clean = clean - .replace(/
', '\n') .replace(/<\/?i>/g, '*') .replace(/<\/?b>/g, '**') .replace(/~!|!~/g, '||');