refactor(*): remove unused exception variables (#193)

This commit is contained in:
Almeida 2021-05-06 19:23:47 +01:00 committed by GitHub
parent 38ab38645b
commit a4a7eb41b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 35 additions and 35 deletions

View file

@ -4,11 +4,11 @@ const path = require('path');
try {
fs.accessSync(path.resolve(__dirname, 'bot.env'));
require('dotenv').config({ path: path.resolve(__dirname, 'bot.env') });
} catch (e) {
} catch {
try {
fs.accessSync(path.resolve(__dirname, 'api.env'));
require('dotenv').config({ path: path.resolve(__dirname, 'api.env') });
} catch (e) {
} catch {
throw new Error("bot.env or api.env required");
}
}

View file

@ -4,7 +4,7 @@ export class AddTypeAndPermissionsToApiPermissions1573158035867 implements Migra
public async up(queryRunner: QueryRunner): Promise<any> {
try {
await queryRunner.dropPrimaryKey("api_permissions");
} catch (e) {} // tslint:disable-line
} catch {} // tslint:disable-line
const table = (await queryRunner.getTable("api_permissions"))!;
if (table.indices.length) {

View file

@ -52,7 +52,7 @@ export async function postCaseToCaseLogChannel(
try {
await pluginData.client.editMessage(channelId, messageId, caseEmbed);
return null;
} catch (e) {} // tslint:disable-line:no-empty
} catch {} // tslint:disable-line:no-empty
}
try {
@ -63,7 +63,7 @@ export async function postCaseToCaseLogChannel(
});
}
return postedMessage;
} catch (e) {
} catch {
pluginData.state.logs.log(LogType.BOT_ALERT, {
body: `Failed to post case #${theCase.case_number} to the case log channel`,
});

View file

@ -14,7 +14,7 @@ export async function censorMessage(
try {
await pluginData.client.deleteMessage(savedMessage.channel_id, savedMessage.id, "Censored");
} catch (e) {
} catch {
return;
}

View file

@ -13,7 +13,7 @@ export async function rehostAttachment(attachment: Attachment, targetChannel: Te
let downloaded;
try {
downloaded = await downloadFile(attachment.url, 3);
} catch (e) {
} catch {
return "Failed to download attachment after 3 tries";
}
@ -23,7 +23,7 @@ export async function rehostAttachment(attachment: Attachment, targetChannel: Te
file: await fsp.readFile(downloaded.path),
});
return rehostMessage.attachments[0].url;
} catch (e) {
} catch {
return "Failed to rehost attachment";
}
}

View file

@ -15,7 +15,7 @@ export async function moveMember(
await modMember.edit({
channelID: target.voiceState.channelID,
});
} catch (e) {
} catch {
sendErrorMessage(pluginData, errorChannel, "Failed to move you. Are you in a voice channel?");
return;
}

View file

@ -21,7 +21,7 @@ export async function sendWhere(
let invite: Invite;
try {
invite = await createOrReuseInvite(voice);
} catch (e) {
} catch {
sendErrorMessage(pluginData, channel, "Cannot create an invite to that channel!");
return;
}

View file

@ -23,7 +23,7 @@ export async function saveMessagesToDB(
}
await pluginData.state.savedMessages.createFromMsg(thisMsg, { is_permanent: true });
} catch (e) {
} catch {
failed.push(id);
}
}

View file

@ -69,7 +69,7 @@ export const ForcebanCmd = modActionsCmd({
try {
// FIXME: Use banUserId()?
await pluginData.guild.banMember(user.id, 1, reason != null ? encodeURIComponent(reason) : undefined);
} catch (e) {
} catch {
sendErrorMessage(pluginData, msg.channel, "Failed to forceban member");
return;
}

View file

@ -77,7 +77,7 @@ export const MassbanCmd = modActionsCmd({
});
pluginData.state.events.emit("ban", userId, banReason);
} catch (e) {
} catch {
failedBans.push(userId);
}
}

View file

@ -69,7 +69,7 @@ export const MassunbanCmd = modActionsCmd({
reason: `Mass unban: ${unbanReason}`,
postInCaseLogOverride: false,
});
} catch (e) {
} catch {
failedUnbans.push({ userId, reason: UnbanFailReasons.UNBAN_FAILED });
}
}

View file

@ -50,7 +50,7 @@ export const UnbanCmd = modActionsCmd({
try {
ignoreEvent(pluginData, IgnoredEventType.Unban, user.id);
await pluginData.guild.unbanMember(user.id, reason != null ? encodeURIComponent(reason) : undefined);
} catch (e) {
} catch {
sendErrorMessage(pluginData, msg.channel, "Failed to unban member; are you sure they're banned?");
return;
}

View file

@ -83,7 +83,7 @@ export async function actualKickMemberCmd(
try {
await memberToKick.ban(1, encodeURIComponent("kick -clean"));
} catch (e) {
} catch {
sendErrorMessage(pluginData, msg.channel, "Failed to ban the user to clean messages (-clean)");
}
@ -92,7 +92,7 @@ export async function actualKickMemberCmd(
try {
await pluginData.guild.unbanMember(memberToKick.id, encodeURIComponent("kick -clean"));
} catch (e) {
} catch {
sendErrorMessage(pluginData, msg.channel, "Failed to unban the user after banning them (-clean)");
}
}

View file

@ -30,7 +30,7 @@ export async function clearExpiredMutes(pluginData: GuildPluginData<MutesPluginT
}
lock.unlock();
} catch (e) {
} catch {
pluginData.state.serverLogs.log(LogType.BOT_ALERT, {
body: `Failed to remove mute role from {userMention(member)}`,
member: stripObjectToScalars(member),

View file

@ -126,7 +126,7 @@ export async function muteUser(
// TODO: Add back the voiceState check once we figure out how to get voice state for guild members that are loaded on-demand
try {
await member.edit({ channelID: moveToVoiceChannel });
} catch (e) {} // tslint:disable-line
} catch {} // tslint:disable-line
}
}

View file

@ -34,7 +34,7 @@ export async function scheduledPostLoop(pluginData: GuildPluginData<PostPluginTy
channel: stripObjectToScalars(channel),
messageId: postedMessage.id,
});
} catch (e) {
} catch {
pluginData.state.logs.log(LogType.BOT_ALERT, {
body: `Failed to post scheduled message by {userMention(author)} to {channelMention(channel)}`,
channel: stripObjectToScalars(channel),

View file

@ -36,7 +36,7 @@ export async function postDueRemindersLoop(pluginData: GuildPluginData<Reminders
},
});
}
} catch (e) {
} catch {
// Probably random Discord internal server error or missing permissions or somesuch
// Try again next round unless we've already tried to post this a bunch of times
const tries = pluginData.state.tries.get(reminder.id) || 0;

View file

@ -82,7 +82,7 @@ export const RoleAddCmd = selfGrantableRolesCmd({
await msg.member.edit({
roles: Array.from(newRoleIds),
});
} catch (e) {
} catch {
sendErrorMessage(
pluginData,
msg.channel,

View file

@ -56,7 +56,7 @@ export const RoleRemoveCmd = selfGrantableRolesCmd({
`<@!${msg.author.id}> Removed ${removedRolesStr.join(", ")} ${removedRolesWord}`,
);
}
} catch (e) {
} catch {
sendSuccessMessage(
pluginData,
msg.channel,

View file

@ -17,7 +17,7 @@ export async function disableBotSlowmodeForChannel(
for (const slowmodeUser of users) {
try {
await clearBotSlowmodeFromUserId(pluginData, channel, slowmodeUser.user_id);
} catch (e) {
} catch {
// Removing the slowmode failed. Record this so the permissions can be changed manually, and remove the database entry.
failedUsers.push(slowmodeUser.user_id);
await pluginData.state.slowmodes.clearSlowmodeUser(channel.id, slowmodeUser.user_id);

View file

@ -19,7 +19,7 @@ export const StarboardReactionAddEvt = starboardEvt({
// Message is not cached, fetch it
try {
msg = await msg.channel.getMessage(msg.id);
} catch (e) {
} catch {
// Sometimes we get this event for messages we can't fetch with getMessage; ignore silently
return;
}

View file

@ -25,7 +25,7 @@ export const AboutCmd = utilityCmd({
try {
const lcl = new LCL(rootDir);
lastCommit = await lcl.getLastCommit();
} catch (e) {} // tslint:disable-line:no-empty
} catch {} // tslint:disable-line:no-empty
let lastUpdate;
let version;

View file

@ -32,7 +32,7 @@ export const NicknameCmd = utilityCmd({
await args.member.edit({
nick: args.nickname,
});
} catch (e) {
} catch {
msg.channel.createMessage(errorMessage("Failed to change nickname"));
return;
}

View file

@ -23,7 +23,7 @@ export const NicknameResetCmd = utilityCmd({
await args.member.edit({
nick: "",
});
} catch (e) {
} catch {
msg.channel.createMessage(errorMessage("Failed to reset nickname"));
return;
}

View file

@ -38,7 +38,7 @@ export const VcdisconnectCmd = utilityCmd({
await args.member.edit({
channelID: null,
});
} catch (e) {
} catch {
sendErrorMessage(pluginData, msg.channel, "Failed to disconnect member");
return;
}

View file

@ -75,7 +75,7 @@ export const VcmoveCmd = utilityCmd({
await args.member.edit({
channelID: channel.id,
});
} catch (e) {
} catch {
sendErrorMessage(pluginData, msg.channel, "Failed to move member");
return;
}
@ -174,7 +174,7 @@ export const VcmoveAllCmd = utilityCmd({
currMember.edit({
channelID: channel.id,
});
} catch (e) {
} catch {
if (msg.member.id === currMember.id) {
sendErrorMessage(pluginData, msg.channel, "Unknown error when trying to move members");
return;

View file

@ -46,7 +46,7 @@ export const SendWelcomeMessageEvt = welcomeMessageEvt({
if (config.send_dm) {
try {
await sendDM(member.user, formatted, "welcome message");
} catch (e) {
} catch {
pluginData.state.logs.log(LogType.DM_FAILED, {
source: "welcome message",
user: stripObjectToScalars(member.user),
@ -60,7 +60,7 @@ export const SendWelcomeMessageEvt = welcomeMessageEvt({
try {
await createChunkedMessage(channel, formatted);
} catch (e) {
} catch {
pluginData.state.logs.log(LogType.BOT_ALERT, {
body: `Failed send a welcome message for {userMention(member)} to {channelMention(channel)}`,
member: stripObjectToScalars(member),

View file

@ -526,7 +526,7 @@ export function getUrlsInString(str: string, onlyUnique = false): MatchedURL[] {
try {
matchUrl = new URL(withProtocol) as MatchedURL;
matchUrl.input = match;
} catch (e) {
} catch {
return urls;
}

View file

@ -22,7 +22,7 @@ export const AuthStore: Module<AuthState, RootState> = {
await dispatch("setApiKey", storedKey);
return;
}
} catch (e) {} // tslint:disable-line
} catch {} // tslint:disable-line
console.log("Unable to validate key, removing from localStorage"); // tslint:disable-line
localStorage.removeItem("apiKey");