diff --git a/src/commands.js b/src/commands.js index bec40bc..5a7edc1 100644 --- a/src/commands.js +++ b/src/commands.js @@ -19,6 +19,10 @@ cmds.set('member', { else if (reply instanceof EmbedBuilder) { await message.reply({embeds: [reply.toJSON()]}) } + else if (typeof reply === 'object') { + const errorsText = reply.errors.length > 0 ? reply.errors.join('\n- ') : null; + return await message.reply({content: `${reply.success} ${errorsText ? "\nThese errors occurred:\n" + errorsText : ""}`, embeds: [reply.embed.toJSON()]}) + } } }) diff --git a/src/helpers/memberHelper.js b/src/helpers/memberHelper.js index 51c2f60..72c3442 100644 --- a/src/helpers/memberHelper.js +++ b/src/helpers/memberHelper.js @@ -17,7 +17,9 @@ const commandList = ['--help', 'new', 'remove', 'name', 'list', 'displayName', ' * @param {string[]} args - The message arguments * @param {string | null} attachmentUrl - The message attachment url. * @param {string | null} attachmentExpiration - The message attachment expiration (if uploaded via Fluxer) - * @returns {Promise | Promise } A message, or an informational embed. + * @returns {Promise} A success message. + * @returns {Promise } A list of 25 members as an embed. + * @returns {Promise<{EmbedBuilder, [], string}>} A member info embed + info/errors. * @throws {Error} */ mh.parseMemberCommand = async function (authorId, authorFull, args, attachmentUrl = null, attachmentExpiration = null) { @@ -99,8 +101,9 @@ mh.addNewMember = async function (authorId, args, attachmentURL = null) { const proxy = args[3]; const propic = args[4] ?? attachmentURL; - return await mh.addFullMember(authorId, memberName, displayName, proxy, propic).then(() => { - return mh.getMemberInfo(authorId, memberName).catch((e) => {throw e}) + return await mh.addFullMember(authorId, memberName, displayName, proxy, propic).then(async(response) => { + const memberInfoEmbed = await mh.getMemberInfo(authorId, memberName).catch((e) => {throw e}) + return {embed: memberInfoEmbed, errors: response.errors, success: `${memberName} has been added successfully.`}; }).catch(e => { throw e; })