mirror of
https://github.com/pieartsy/PluralFlux.git
synced 2026-04-14 20:15:28 +10:00
edited addFullMember to throw error if member was not added successfully
This commit is contained in:
@@ -84,7 +84,7 @@ mh.addNewMember = async function(authorId, args) {
|
|||||||
success += displayName ? `\nDisplay name: ${member.dataValues.displayname}` : "";
|
success += displayName ? `\nDisplay name: ${member.dataValues.displayname}` : "";
|
||||||
return success;
|
return success;
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
throw new Error(`${enums.err.ADD_ERROR}: ${e.message}`)
|
throw e;
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,7 +154,8 @@ mh.updateDisplayName = async function(authorId, args) {
|
|||||||
* @throws {RangeError | Error} When an empty proxy was provided, or no proxy exists.
|
* @throws {RangeError | Error} When an empty proxy was provided, or no proxy exists.
|
||||||
*/
|
*/
|
||||||
mh.updateProxy = async function(authorId, args) {
|
mh.updateProxy = async function(authorId, args) {
|
||||||
if (args[1] && args[1] === "--help" || !args[1]) {
|
console.log(args)
|
||||||
|
if (args[2] && args[2] === "--help" || !args[2]) {
|
||||||
return enums.help.PROXY;
|
return enums.help.PROXY;
|
||||||
}
|
}
|
||||||
const proxyExists = await mh.checkIfProxyExists(authorId, args[2]).then((proxyExists) => {
|
const proxyExists = await mh.checkIfProxyExists(authorId, args[2]).then((proxyExists) => {
|
||||||
@@ -249,7 +250,7 @@ mh.removeMember = async function(authorId, args) {
|
|||||||
* @param {string | null} displayName - The display name of the member.
|
* @param {string | null} displayName - The display name of the member.
|
||||||
* @param {string | null} proxy - The proxy tag of the member.
|
* @param {string | null} proxy - The proxy tag of the member.
|
||||||
* @param {string | null} propic - The profile picture URL of the member.
|
* @param {string | null} propic - The profile picture URL of the member.
|
||||||
* @param {string | null} isImport - Whether calling from the import function or not.
|
* @param {boolean} isImport - Whether calling from the import function or not.
|
||||||
* @returns {Promise<model>} A successful addition.
|
* @returns {Promise<model>} A successful addition.
|
||||||
* @throws {Error | RangeError} When the member already exists, there are validation errors, or adding a member doesn't work.
|
* @throws {Error | RangeError} When the member already exists, there are validation errors, or adding a member doesn't work.
|
||||||
*/
|
*/
|
||||||
@@ -280,15 +281,16 @@ mh.addFullMember = async function(authorId, memberName, displayName = null, prox
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await db.members.create({
|
const member = await db.members.create({
|
||||||
name: memberName,
|
name: memberName,
|
||||||
userid: authorId,
|
userid: authorId,
|
||||||
displayname: displayName,
|
displayname: displayName,
|
||||||
proxy: proxy,
|
proxy: proxy,
|
||||||
propic: validPropic ? propic : null,
|
propic: validPropic ? propic : null,
|
||||||
}).catch(e => {
|
});
|
||||||
throw new Error(`Can't add ${memberName}. ${enums.err.ADD_ERROR}: ${e.message}`)
|
if (!member) {
|
||||||
})
|
new Error(`${enums.err.ADD_ERROR}: ${e.message}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ ih.pluralKitImport = async function (authorId, attachmentUrl) {
|
|||||||
errors.push(`${pkMember.name}: ${e.message}`);
|
errors.push(`${pkMember.name}: ${e.message}`);
|
||||||
});
|
});
|
||||||
await memberHelper.checkImageFormatValidity(pkMember.avatar_url).catch(e => {
|
await memberHelper.checkImageFormatValidity(pkMember.avatar_url).catch(e => {
|
||||||
errors.push(`${pkMember.name}: ${e.message} Added anyway with no profile picture.`)});
|
errors.push(`${pkMember.name}: ${e.message}`)});
|
||||||
}
|
}
|
||||||
const aggregatedText = addedMembers.length > 0 ? `Successfully added members: ${addedMembers.join(', ')}` : enums.err.NO_MEMBERS_IMPORTED;
|
const aggregatedText = addedMembers.length > 0 ? `Successfully added members: ${addedMembers.join(', ')}` : enums.err.NO_MEMBERS_IMPORTED;
|
||||||
if (errors.length > 0) {
|
if (errors.length > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user