const
declarations for variables that are never reassigned JS-0242548 case "spellcheck":
549 if (envVars.QBSPELL != "off") {
550 (async () => {
551 let timeout = envVars.QBSPTIMEOUT || 10000;552 if (usedSpellingRecently.has(message.author.id)) return message.reply(embed.error(`You need to wait ${timeout / 1000} seconds before asking for spellcheck again.`, "ERR_RATE_LIMIT", "Slow down!"));
553 if (args?.length < 1) return message.reply(embed.error("You didn't include any text to spell check.", "ERR_NO_TEXT", "Where's the text?"));
554 if (args?.join().length > 500) return message.reply(embed.error("You can only spellcheck 500 characters at most.", "ERR_500_EXCEEDED", "Too long!"));
498 if (profile) profile = `https://ddragon.leagueoflegends.com/cdn/${LeagueAPI.getDDragonLocalDataVersion()}/img/profileicon/${profile}.png`;
499 let addlData = await LeagueAPI.getLeagueRanking(acctObj) || [];
500 message.channel.stopTyping(true);
501 let mbed = embed.simple(502 "", "", `League Info for ${acctObj.name}`)
503 .setURL(`https://${opggRegions[LeagueAPI.region]}.op.gg/summoner/userName=${acctObj.name.replace(/ /g, "+")}`)
504 .setFooter('Click the "League Info" title above to go to this summoner\'s OP.GG page.', icons.bulb)
436 }
437 try {
438 let gotData = await fetch(`https://finnhub.io/api/v1/quote?symbol=${args[0].toUpperCase()}&token=${configFile.stockToken || envVars.QBSTOCKS}`);
439 let stockData = await gotData.json();440 if (!gotData.ok) {
441 message.reply(embed.error("There was an error getting stock info.", `${stockData.cod || gotData.status}: ${stockData.message || gotData.statusText}`));
442 return;
435 return null;
436 }
437 try {
438 let gotData = await fetch(`https://finnhub.io/api/v1/quote?symbol=${args[0].toUpperCase()}&token=${configFile.stockToken || envVars.QBSTOCKS}`);439 let stockData = await gotData.json();
440 if (!gotData.ok) {
441 message.reply(embed.error("There was an error getting stock info.", `${stockData.cod || gotData.status}: ${stockData.message || gotData.statusText}`));
359 break;
360 case "weathermetric":
361 case "weather": {
362 let timeout = configFile.weatherTimeout || envVars.QBWTIMEOUT || 15000363 if (usedWeatherRecently.has(message.author.id)) {
364 message.reply(embed.error(`You need to wait ${timeout / 1000} seconds before asking for the weather again.`, "ERR_RATE_LIMIT", "Slow down!"));
365 } else {
Variables that are never re-assigned a new value after their initial declaration should be declared with the const
keyword.
This prevents the programmer from erroneously re-assigning to a read-only variable, and informs those reading the code that a variable is a constant value.
let pi = Math.PI
for (let x of xs) {
use(x);
}
let { a, b } = object;
use(a, b);
const pi = Math.PI
for (const x of xs) {
use(x);
}
const { a, b } = object;
use(a, b);