got import messages working!

This commit is contained in:
Aster Fialla
2026-02-15 01:29:56 -05:00
parent 2e63532dc7
commit 5d80895918
2 changed files with 9 additions and 13 deletions

View File

@@ -43,29 +43,24 @@ cmds.set('help', {
cmds.set('import', { cmds.set('import', {
description: enums.help.IMPORT, description: enums.help.IMPORT,
async execute(message) { async execute(message) {
try { const attachmentUrl = message.attachments.size > 0 ? message.attachments.first().url : null;
const attachmentUrl = message.attachments.size > 0 ? message.attachments.first().url : null;
const successfullyAdded = importHelper.pluralKitImport(message.author.id, attachmentUrl); return await importHelper.pluralKitImport(message.author.id, attachmentUrl).then(async (successfullyAdded) => {
console.log(successfullyAdded + "added");
await message.reply(successfullyAdded); await message.reply(successfullyAdded);
} }).catch(async (error) => {
catch(error) {
console.log(error.message) console.log(error.message)
if (error instanceof AggregateError) { if (error instanceof AggregateError) {
console.log(error);
// 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}.\nThese errors occurred: ${error.join('\n')}`; let errorsText = `${error.message}.\nThese errors occurred:\n${error.errors.join('\n')}`;
await message.reply(errorsText); await message.reply(errorsText);
} }
// If just one error was returned. // If just one error was returned.
else { else {
return await message.reply(error.message); return await message.reply(error.message);
} }
})
}
}
},
}) })
export const commands = cmds; export const commands = cmds;

View File

@@ -28,7 +28,8 @@ ih.pluralKitImport = async function (authorId, attachmentUrl) {
errors.push(`${pkMember.name}: ${e.message}`); errors.push(`${pkMember.name}: ${e.message}`);
}); });
} }
const aggregatedText = addedMembers > 0 ? `Successfully added members: ${addedMembers.join(', ')}` : enums.err.NO_MEMBERS_IMPORTED; console.log(addedMembers);
const aggregatedText = addedMembers.length > 0 ? `Successfully added members: ${addedMembers.join(', ')}` : enums.err.NO_MEMBERS_IMPORTED;
if (errors.length > 0) { if (errors.length > 0) {
throw new AggregateError(errors, aggregatedText); throw new AggregateError(errors, aggregatedText);
} }