mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 15:07:42 +02:00
Omit catch block errors when not needed
This commit is contained in:
@@ -67,7 +67,7 @@ client.on('message', async msg => {
|
||||
if (!call.active) return;
|
||||
try {
|
||||
await call.send(origin ? call.recipient : call.origin, msg);
|
||||
} catch (err) {
|
||||
} catch {
|
||||
return; // eslint-disable-line no-useless-return
|
||||
}
|
||||
});
|
||||
@@ -80,7 +80,7 @@ client.on('guildMemberRemove', async member => {
|
||||
const leaveMsg = leaveMsgs[Math.floor(Math.random() * leaveMsgs.length)];
|
||||
await channel.send(leaveMsg.replace(/{{user}}/gi, `**${member.user.tag}**`));
|
||||
return null;
|
||||
} catch (err) {
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -59,7 +59,7 @@ module.exports = class WhatAnimeCommand extends Command {
|
||||
.get('https://trace.moe/api/me')
|
||||
.query({ token: WHATANIME_KEY });
|
||||
return { status: body.quota > 0, refresh: body.quota_ttl };
|
||||
} catch (err) {
|
||||
} catch {
|
||||
return { status: false, refresh: Infinity };
|
||||
}
|
||||
}
|
||||
@@ -89,7 +89,7 @@ module.exports = class WhatAnimeCommand extends Command {
|
||||
token: data.tokenthumb
|
||||
});
|
||||
return body;
|
||||
} catch (err) {
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ module.exports = class UserCommand extends Command {
|
||||
• ${roles.length ? trimArray(roles, 6).join(', ') : 'None'}
|
||||
`;
|
||||
embed.setColor(member.displayHexColor);
|
||||
} catch (err) {
|
||||
} catch {
|
||||
embed.setFooter('Failed to resolve member, showing basic user information instead.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ module.exports = class MathCommand extends Command {
|
||||
try {
|
||||
const evaluated = math.evaluate(expression).toString();
|
||||
return msg.reply(evaluated).catch(() => msg.reply('Invalid expression.'));
|
||||
} catch (err) {
|
||||
} catch {
|
||||
return msg.reply('Invalid expression.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ module.exports = class UnitsCommand extends Command {
|
||||
try {
|
||||
const value = math.unit(amount, base).toNumber(target);
|
||||
return msg.say(`${formatNumber(amount)} ${base} is ${formatNumber(value)} ${target}.`);
|
||||
} catch (err) {
|
||||
} catch {
|
||||
return msg.say('Either an invalid unit type was provided or the unit types do not match.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ module.exports = class PhoneCommand extends Command {
|
||||
this.client.phone.set(id, new PhoneCall(this.client, msg.channel, channel));
|
||||
await this.client.phone.get(id).start();
|
||||
return null;
|
||||
} catch (err) {
|
||||
} catch {
|
||||
return msg.reply('Failed to start the call. Try again later!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ module.exports = class PortalSendCommand extends Command {
|
||||
const displayName = msg.channel.type === 'text' ? msg.guild.name : 'DM';
|
||||
await channel.send(`**${this.portalEmoji} ${msg.author.tag} (${displayName}):** ${message}`);
|
||||
return msg.say(`Message sent to **${channel.name}** in **${channel.guild.name}**!`);
|
||||
} catch (err) {
|
||||
} catch {
|
||||
return msg.reply('Failed to send the message. Try again later!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ module.exports = class PruneCommand extends Command {
|
||||
const messages = await msg.channel.messages.fetch({ limit: count + 1 });
|
||||
await msg.channel.bulkDelete(messages, true);
|
||||
return null;
|
||||
} catch (err) {
|
||||
} catch {
|
||||
return msg.reply('There are no messages younger than two weeks that can be deleted.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ module.exports = class RenameAllCommand extends Command {
|
||||
for (const member of msg.guild.members.cache.values()) {
|
||||
try {
|
||||
await member.setNickname(nickname);
|
||||
} catch (err) {
|
||||
} catch {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ module.exports = class GoogleCommand extends Command {
|
||||
const nsfw = msg.channel.nsfw || false;
|
||||
try {
|
||||
href = await this.customSearch(query, nsfw);
|
||||
} catch (err) {
|
||||
} catch {
|
||||
href = `http://lmgtfy.com/?iie=1&q=${encodeURIComponent(query)}`;
|
||||
}
|
||||
if (!href) return msg.say('Could not find any results.');
|
||||
|
||||
@@ -15,7 +15,7 @@ module.exports = class HiCommand extends Command {
|
||||
try {
|
||||
await msg.react('👋');
|
||||
return null;
|
||||
} catch (err) {
|
||||
} catch {
|
||||
return msg.reply('Hi there!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ module.exports = class SayCommand extends Command {
|
||||
try {
|
||||
if (msg.channel.type === 'text' && msg.deletable) await msg.delete();
|
||||
return msg.say(text);
|
||||
} catch (err) {
|
||||
} catch {
|
||||
return msg.say(text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ module.exports = class HelpCommand extends Command {
|
||||
msgs.push(await msg.direct({ embed }));
|
||||
if (msg.channel.type !== 'dm') msgs.push(await msg.say('📬 Sent you a DM with information.'));
|
||||
return msgs;
|
||||
} catch (err) {
|
||||
} catch {
|
||||
return msg.reply('Failed to send DM. You probably have DMs disabled.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ module.exports = class ReportCommand extends Command {
|
||||
try {
|
||||
const channel = await this.client.channels.fetch(REPORT_CHANNEL_ID);
|
||||
await channel.send({ embed });
|
||||
} catch (err) {
|
||||
} catch {
|
||||
await this.sendOwnerDM(embed);
|
||||
}
|
||||
} else {
|
||||
@@ -57,7 +57,7 @@ module.exports = class ReportCommand extends Command {
|
||||
for (const owner of this.client.owners) {
|
||||
try {
|
||||
await owner.send({ embed });
|
||||
} catch (err) {
|
||||
} catch {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ module.exports = class ImageArgumentType extends ArgumentType {
|
||||
try {
|
||||
await request.get(value);
|
||||
return true;
|
||||
} catch (err) {
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user