This commit is contained in:
Dragon Fire
2020-10-24 14:25:32 -04:00
parent 40080cadef
commit ebd26a7b0e
25 changed files with 42 additions and 44 deletions
+1 -1
View File
@@ -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(' ', '-')
}
]
});
+2 -2
View File
@@ -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',
+1 -1
View File
@@ -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}.
+2 -2
View File
@@ -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(' ', ' 👏 '));
}
};
+2 -2
View File
@@ -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())
}
]
});
+1 -1
View File
@@ -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'));
}
};
+4 -3
View File
@@ -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('\'', '');
}
};
+1 -1
View File
@@ -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) {
+1 -1
View File
@@ -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()
}
]
});
+4 -7
View File
@@ -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) {
+1 -1
View File
@@ -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) {
+1 -1
View File
@@ -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>(.+)<\/h1>/i)[1].replace(/<\/br>/g, ''));
return msg.say(text.match(/<h1>(.+)<\/h1>/i)[1].replaceAll('</br>', ''));
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
+2 -2
View File
@@ -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!`);
+1 -1
View File
@@ -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(/<br>/g, '')
.replaceAll('<br>', '')
.replace(/<\/?div>/g, '')
.trim();
}
+1 -1
View File
@@ -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.')
}
]
});
+1 -1
View File
@@ -70,7 +70,7 @@ module.exports = class NeopetsItemCommand extends Command {
name: details.match(/<h1>(.+)<\/h1>/)[1],
details: details.match(/<em>(.+)<\/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
};
}
+1 -1
View File
@@ -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(' ', '-'))
}
]
});
+1 -1
View File
@@ -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}>`;
}
};
+2 -2
View File
@@ -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!`);
+2 -2
View File
@@ -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`
}
]
});