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;
|
let reply;
|
||||||
try {
|
try {
|
||||||
reply = await memberHelper.parseMemberCommand(message.author.id, authorFull, args, attachmentUrl, attachmentExpires)
|
reply = await memberHelper.parseMemberCommand(message.author.id, authorFull, args, attachmentUrl, attachmentExpires)
|
||||||
}
|
} catch (e) {
|
||||||
catch(e) {
|
|
||||||
return await message.reply(e.message);
|
return await message.reply(e.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof reply === 'string') {
|
if (typeof reply === 'string') {
|
||||||
await message.reply(reply);
|
await message.reply(reply);
|
||||||
}
|
} else if (reply instanceof EmbedBuilder) {
|
||||||
else if (reply instanceof EmbedBuilder) {
|
|
||||||
await message.reply({embeds: [reply]})
|
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
|
// 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;
|
const errorsText = reply.errors.length > 0 ? '- ' + reply.errors.join('\n- ') : null;
|
||||||
return await message.reply({
|
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) {
|
if ((message.content.includes('--help') || (args[0] === '' && args.length === 1)) && !attachmentUrl) {
|
||||||
return await message.reply(enums.help.IMPORT);
|
return await message.reply(enums.help.IMPORT);
|
||||||
}
|
}
|
||||||
|
let errorsText;
|
||||||
try {
|
try {
|
||||||
const successfullyAdded = await importHelper.pluralKitImport(message.author.id, attachmentUrl)
|
const successfullyAdded = await importHelper.pluralKitImport(message.author.id, attachmentUrl)
|
||||||
await message.reply(successfullyAdded);
|
return await message.reply(successfullyAdded);
|
||||||
}
|
} catch (error) {
|
||||||
catch(error) {
|
|
||||||
if (error instanceof AggregateError) {
|
if (error instanceof AggregateError) {
|
||||||
// errors.message can be a list of successfully added members, or say that none were successful.
|
// 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) {
|
if (errorsText.length > 2000) {
|
||||||
const returnedBuffer = messageHelper.returnBufferFromText(errorsText);
|
const returnedBuffer = messageHelper.returnBufferFromText(errorsText);
|
||||||
await message.reply({
|
await message.reply({
|
||||||
content: returnedBuffer.text, files: [{name: 'text.txt', data: returnedBuffer.file}]
|
content: returnedBuffer.text, files: [{name: 'text.txt', data: returnedBuffer.file}]
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
await message.reply(errorsText);
|
await message.reply(errorsText)
|
||||||
}
|
|
||||||
}
|
|
||||||
// If just one error was returned.
|
|
||||||
else {
|
|
||||||
console.error(error);
|
|
||||||
return await message.reply(error.message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const commands = cmds;
|
export const commands = cmds;
|
||||||
Reference in New Issue
Block a user