put braces around throw e

This commit is contained in:
Aster Fialla
2026-02-14 21:10:20 -05:00
committed by pieartsy
parent 7c7b1f0202
commit 89fe2c70b2
5 changed files with 31 additions and 29 deletions

View File

@@ -24,7 +24,9 @@ client.on(Events.MessageCreate, async (message) => {
// If message doesn't start with the bot prefix, it could still be a message with a proxy tag. If it's not, return.
if (!content.startsWith(messageHelper.prefix)) {
await webhookHelper.sendMessageAsMember(client, message, content).catch(e => throw e);
await webhookHelper.sendMessageAsMember(client, message, content).catch((e) => {
throw e
});
return;
}
@@ -36,7 +38,9 @@ client.on(Events.MessageCreate, async (message) => {
const command = commands.get(commandName);
if (command) {
await command.execute(message, client, args).catch(e => throw e);
await command.execute(message, client, args).catch(e => {
throw e
});
}
}
catch(error) {

View File

@@ -9,7 +9,7 @@ cmds.set('member', {
description: enums.help.SHORT_DESC_MEMBER,
async execute(message, client, args) {
const authorFull = `${message.author.username}#${message.author.discriminator}`
const reply = await memberHelper.parseMemberCommand(message.author.id, authorFull, args, message.attachments[0] = null).catch(e => throw e);
const reply = await memberHelper.parseMemberCommand(message.author.id, authorFull, args, message.attachments[0] = null).catch(e =>{throw e});
if (typeof reply === 'string') {
return await message.reply(reply);
}

View File

@@ -17,21 +17,19 @@ const commandList = ['--help', 'add', 'remove', 'name', 'listall', 'displayName'
* @param {string | null} attachmentUrl - The message attachment url.
* @returns {Promise<string> | Promise <EmbedBuilder>} A message, or an informational embed.
*/
mh.parseMemberCommand = async function(author, args, attachmentUrl){
const authorId = author.id;
const authorFull = `${author.username}${author.discriminator}`;
mh.parseMemberCommand = async function(authorId, authorFull, args, attachmentUrl){
let member;
// checks whether command is in list, otherwise assumes it's a name
if(!commandList.includes(args[0])) {
member = await getMemberInfo(authorId, args[0]);
member = await mh.getMemberInfo(authorId, args[0]).catch((e) =>{throw e});
}
switch(args[0]) {
case '--help':
return enums.help.MEMBER;
case 'add':
return await mh.addNewMember(authorId, args).catch((e) => throw e);
return await mh.addNewMember(authorId, args).catch((e) =>{throw e});
case 'remove':
return await mh.removeMember(authorId, args).catch((e) => throw e);
return await mh.removeMember(authorId, args).catch((e) =>{throw e});
case 'name':
return enums.help.NAME;
case 'displayname':
@@ -41,19 +39,19 @@ mh.parseMemberCommand = async function(author, args, attachmentUrl){
case 'propic':
return enums.help.PROPIC;
case 'list':
return await mh.getAllMembersInfo(authorId, authorFull).catch((e) => throw e);
return await mh.getAllMembersInfo(authorId, authorFull).catch((e) =>{throw e});
case '':
return enums.help.MEMBER;
}
switch(args[1]) {
case 'name':
return await mh.updateName(authorId, args).catch((e) => throw e);
return await mh.updateName(authorId, args).catch((e) =>{throw e});
case 'displayname':
return await mh.updateDisplayName(authorId, args).catch((e) => throw e);
return await mh.updateDisplayName(authorId, args).catch((e) =>{throw e});
case 'proxy':
return await mh.updateProxy(authorId, args).catch((e) => throw e);
return await mh.updateProxy(authorId, args).catch((e) =>{throw e});
case 'propic':
return await mh.updatePropic(authorId, args, attachmentUrl).catch((e) => throw e);
return await mh.updatePropic(authorId, args, attachmentUrl).catch((e) =>{throw e});
default:
return member;
}
@@ -103,7 +101,7 @@ mh.updateName = async function (authorId, args) {
if (!name || trimmedName === null) {
throw new RangeError(`Display name ${enums.err.NO_VALUE}`);
}
return await mh.updateMemberField(authorId, args).catch((e) => throw e);
return await mh.updateMemberField(authorId, args).catch((e) =>{throw e});
}
/**
@@ -130,13 +128,13 @@ mh.updateDisplayName = async function(authorId, args) {
return `Display name for ${memberName} is: \"${member.displayname}\".`;
}
throw new RangeError(`Display name ${enums.err.NO_VALUE}`);
}).catch((e) => throw e);
}).catch((e) =>{throw e});
}
else if (displayName.length > 32) {
throw new RangeError(enums.err.DISPLAY_NAME_TOO_LONG);
}
return await mh.updateMemberField(authorId, args).catch((e) => throw e);
return await mh.updateMemberField(authorId, args).catch((e) =>{throw e});
}
/**
@@ -154,9 +152,9 @@ mh.updateProxy = async function(authorId, args) {
}
const proxyExists = await mh.checkIfProxyExists(authorId, args[2]).then((proxyExists) => {
return proxyExists;
}).catch((e) => throw e);
}).catch((e) =>{throw e});
if (!proxyExists) {
return await mh.updateMemberField(authorId, args).catch((e) => throw e);
return await mh.updateMemberField(authorId, args).catch((e) =>{throw e});
}
}
@@ -182,7 +180,7 @@ mh.checkIfProxyExists = async function(authorId, proxy) {
throw new Error(enums.err.PROXY_EXISTS);
}
return false;
}).catch(e => throw e);
}).catch(e =>{throw e});
}
/**
@@ -217,7 +215,7 @@ mh.updatePropic = async function(authorId, args, attachment) {
throw new Error(`${enums.err.PROPIC_CANNOT_LOAD}: ${err.message}`);
});
if (loadedImage) {
return await mh.updateMemberField(authorId, updatedArgs).catch((e) => throw e);
return await mh.updateMemberField(authorId, updatedArgs).catch((e) =>{throw e});
}
}
@@ -350,7 +348,7 @@ mh.getMemberInfo = async function(authorId, memberName) {
{name: 'Proxy tag: ', value: member.proxy ?? 'unset', inline: true},
)
.setImage(member.propic);
}).catch((e) => throw e)
}).catch((e) =>{throw e})
}
/**
@@ -363,7 +361,7 @@ mh.getMemberInfo = async function(authorId, memberName) {
* @throws {Error}
*/
mh.getAllMembersInfo = async function(authorId, authorName) {
const members = await mh.getMembersByAuthor(authorId).catch(e => throw e);
const members = await mh.getMembersByAuthor(authorId).catch(e =>{throw e});
const fields = [...members.entries()].map(([member]) => ({
name: member.name,
value: `(Proxy: \`${member.proxy}\`)`,

View File

@@ -39,7 +39,7 @@ msgh.parseCommandArgs = function(content, commandName) {
* @returns {Object} The proxy message object.
*/
msgh.parseProxyTags = async function (authorId, attachment, content){
const members = await memberHelper.getMembersByAuthor(authorId).catch(e => throw e);
const members = await memberHelper.getMembersByAuthor(authorId).catch(e =>{throw e});
const proxyMessage = {}
members.filter(member => member.proxy).forEach(member => {

View File

@@ -15,7 +15,7 @@ const name = 'PluralFlux Proxy Webhook';
* @throws {Error} When the proxy message is not in a server.
*/
wh.sendMessageAsMember = async function(client, message, content) {
const proxyMatch = await messageHelper.parseProxyTags(message.author.id, message.attachments[0] ?? null, content).catch(e => throw e);
const proxyMatch = await messageHelper.parseProxyTags(message.author.id, message.attachments[0] ?? null, content).catch(e =>{throw e});
// If the message doesn't match a proxy, just return.
if (!proxyMatch.proxy) {
return;
@@ -24,8 +24,8 @@ wh.sendMessageAsMember = async function(client, message, content) {
if (!message.guildId) {
throw new Error(enums.err.NOT_IN_SERVER);
}
const member = await memberHelper.getMemberByProxy(message.author.id, proxyMatch.proxy).catch(e => throw e);
await replaceMessage(client, message, message.channelId, proxyMatch.message, member).catch(e => throw e);
const member = await memberHelper.getMemberByProxy(message.author.id, proxyMatch.proxy).catch(e =>{throw e});
await replaceMessage(client, message, message.channelId, proxyMatch.message, member).catch(e =>{throw e});
}
/**
@@ -40,7 +40,7 @@ wh.sendMessageAsMember = async function(client, message, content) {
async function replaceMessage(client, message, channelId, text, member) {
if (text.length > 0) {
const channel = client.channels.get(channelId);
const webhook = await getOrCreateWebhook(client, channel).catch((e) => throw e);
const webhook = await getOrCreateWebhook(client, channel).catch((e) =>{throw e});
const username = member.displayname ?? member.name;
await webhook.send({content: text, username: username, avatar_url: member.propic});
await message.delete();
@@ -74,7 +74,7 @@ async function replaceMessage(client, message, channelId, text, member) {
async function getOrCreateWebhook(client, channel) {
// If channel doesn't allow webhooks
if (!channel?.createWebhook) throw new Error(enums.err.NO_WEBHOOKS_ALLOWED);
let webhook = await getWebhook(client, channel).catch((e) => throw e);
let webhook = await getWebhook(client, channel).catch((e) =>{throw e});
if (!webhook) {
webhook = await channel.createWebhook({name: name});
}