forked from PluralFlux/PluralFlux
changed commands.js to not have user interaction within the catch
This commit is contained in:
@@ -33,18 +33,15 @@ cmds.memberCommand = async function(message, args) {
|
||||
let reply;
|
||||
try {
|
||||
reply = await memberHelper.parseMemberCommand(message.author.id, authorFull, args, attachmentUrl, attachmentExpires)
|
||||
}
|
||||
catch(e) {
|
||||
} catch (e) {
|
||||
return await message.reply(e.message);
|
||||
}
|
||||
|
||||
if (typeof reply === 'string') {
|
||||
await message.reply(reply);
|
||||
}
|
||||
else if (reply instanceof EmbedBuilder) {
|
||||
} else if (reply instanceof EmbedBuilder) {
|
||||
await message.reply({embeds: [reply]})
|
||||
}
|
||||
else if (typeof reply === 'object') {
|
||||
} else if (typeof reply === 'object') {
|
||||
// The little dash is so that the errors print out in bullet points in Fluxer
|
||||
const errorsText = reply.errors.length > 0 ? '- ' + reply.errors.join('\n- ') : null;
|
||||
return await message.reply({
|
||||
@@ -96,29 +93,30 @@ cmds.importCommand = async function(message, args) {
|
||||
if ((message.content.includes('--help') || (args[0] === '' && args.length === 1)) && !attachmentUrl) {
|
||||
return await message.reply(enums.help.IMPORT);
|
||||
}
|
||||
let errorsText;
|
||||
try {
|
||||
const successfullyAdded = await importHelper.pluralKitImport(message.author.id, attachmentUrl)
|
||||
await message.reply(successfullyAdded);
|
||||
}
|
||||
catch(error) {
|
||||
return await message.reply(successfullyAdded);
|
||||
} catch (error) {
|
||||
if (error instanceof AggregateError) {
|
||||
// errors.message can be a list of successfully added members, or say that none were successful.
|
||||
let errorsText = `${error.message}.\n\n${enums.err.ERRORS_OCCURRED}\n\n${error.errors.join('\n')}`;
|
||||
errorsText = `${error.message}.\n\n${enums.err.ERRORS_OCCURRED}\n\n${error.errors.join('\n')}`;
|
||||
}
|
||||
// If just one error was returned.
|
||||
else {
|
||||
console.error(error);
|
||||
errorsText = error.message;
|
||||
}
|
||||
}
|
||||
if (errorsText.length > 2000) {
|
||||
const returnedBuffer = messageHelper.returnBufferFromText(errorsText);
|
||||
await message.reply({
|
||||
content: returnedBuffer.text, files: [{name: 'text.txt', data: returnedBuffer.file}]
|
||||
})
|
||||
} else {
|
||||
await message.reply(errorsText);
|
||||
}
|
||||
}
|
||||
// If just one error was returned.
|
||||
else {
|
||||
console.error(error);
|
||||
return await message.reply(error.message);
|
||||
}
|
||||
await message.reply(errorsText)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const commands = cmds;
|
||||
Reference in New Issue
Block a user