forked from PluralFlux/PluralFlux
got images working for pluralkit import!
This commit is contained in:
@@ -61,6 +61,7 @@ client.on(Events.Ready, () => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await client.login(token);
|
await client.login(token);
|
||||||
|
// await db.check_connection();
|
||||||
console.log('Gateway connected');
|
console.log('Gateway connected');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Login failed:', err);
|
console.error('Login failed:', err);
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ mh.checkImageFormatValidity = async function(imageUrl) {
|
|||||||
if (blobFile.size > 1000000 || !acceptableImages.includes(blobFile.type)) throw new Error(enums.err.PROPIC_FAILS_REQUIREMENTS);
|
if (blobFile.size > 1000000 || !acceptableImages.includes(blobFile.type)) throw new Error(enums.err.PROPIC_FAILS_REQUIREMENTS);
|
||||||
return true;
|
return true;
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
throw new Error(`${enums.err.PROPIC_CANNOT_LOAD}: ${error.message}`);
|
throw new Error(`${enums.err.PROPIC_CANNOT_LOAD}: ${error.message}, ${error.cause}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,7 +249,7 @@ mh.removeMember = async function(authorId, args) {
|
|||||||
* @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.
|
||||||
*/
|
*/
|
||||||
mh.addFullMember = async function(authorId, memberName, displayName = null, proxy = null, propic= null) {
|
mh.addFullMember = async function(authorId, memberName, displayName = null, proxy = null, propic= null) {
|
||||||
const member = await mh.getMemberByName(authorId, memberName).catch((e) =>{console.log("Now we can add the member.")});
|
const member = await mh.getMemberByName(authorId, memberName).catch(() =>{console.log("Now we can add the member.")});
|
||||||
if (member) {
|
if (member) {
|
||||||
throw new Error(`Can't add ${memberName}. ${enums.err.MEMBER_EXISTS}`);
|
throw new Error(`Can't add ${memberName}. ${enums.err.MEMBER_EXISTS}`);
|
||||||
}
|
}
|
||||||
@@ -263,10 +263,7 @@ mh.addFullMember = async function(authorId, memberName, displayName = null, prox
|
|||||||
await mh.checkIfProxyExists(authorId, proxy).catch((e) =>{throw e});
|
await mh.checkIfProxyExists(authorId, proxy).catch((e) =>{throw e});
|
||||||
}
|
}
|
||||||
if (propic) {
|
if (propic) {
|
||||||
const isValidImage = await mh.checkImageFormatValidity(img).catch((e) =>{throw e});
|
await mh.checkImageFormatValidity(propic).catch((e) =>{throw e});
|
||||||
if (isValidImage) {
|
|
||||||
return await mh.updateMemberField(authorId, updatedArgs).catch((e) =>{throw e});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return await db.members.create({
|
return await db.members.create({
|
||||||
@@ -300,7 +297,7 @@ mh.updateMemberField = async function(authorId, args) {
|
|||||||
fluxerPropicWarning = mh.setExpirationWarning(args[3]);
|
fluxerPropicWarning = mh.setExpirationWarning(args[3]);
|
||||||
}
|
}
|
||||||
return await db.members.update({[columnName]: value}, { where: { name: memberName, userid: authorId } }).then(() => {
|
return await db.members.update({[columnName]: value}, { where: { name: memberName, userid: authorId } }).then(() => {
|
||||||
return `Updated ${columnName} for ${memberName} to "${value}"${fluxerPropicWarning ?? ''}.`;
|
return `Updated ${columnName} for ${memberName} to ${value}${fluxerPropicWarning ?? ''}.`;
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
if (e === EmptyResultError) {
|
if (e === EmptyResultError) {
|
||||||
throw new EmptyResultError(`Can't update ${memberName}. ${enums.err.NO_MEMBER}: ${e.message}`);
|
throw new EmptyResultError(`Can't update ${memberName}. ${enums.err.NO_MEMBER}: ${e.message}`);
|
||||||
@@ -321,7 +318,7 @@ mh.setExpirationWarning = function(expirationString) {
|
|||||||
let expirationDate = new Date(expirationString);
|
let expirationDate = new Date(expirationString);
|
||||||
if (!isNaN(expirationDate.valueOf())) {
|
if (!isNaN(expirationDate.valueOf())) {
|
||||||
expirationDate = expirationDate.toDateString();
|
expirationDate = expirationDate.toDateString();
|
||||||
return `\n**NOTE:** Because this profile picture was uploaded via Fluxer, it will currently expire on *${expirationDate}*. To avoid this, upload the picture to another website like <https://imgbb.com/> and link to it directly.`
|
return `\n**NOTE:** Because this profile picture was uploaded via Fluxer, it will currently expire on *${expirationDate}*. To avoid this, upload the picture to another website like <https://imgbb.com/> and link to it directly`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,9 +22,7 @@ ih.pluralKitImport = async function (authorId, attachmentUrl) {
|
|||||||
const addedMembers = [];
|
const addedMembers = [];
|
||||||
for (let pkMember of pkMembers) {
|
for (let pkMember of pkMembers) {
|
||||||
const proxy = pkMember.proxy_tags[0] ? `${pkMember.proxy_tags[0].prefix ?? ''}text${pkMember.proxy_tags[0].suffix ?? ''}` : null;
|
const proxy = pkMember.proxy_tags[0] ? `${pkMember.proxy_tags[0].prefix ?? ''}text${pkMember.proxy_tags[0].suffix ?? ''}` : null;
|
||||||
|
await memberHelper.addFullMember(authorId, pkMember.name, pkMember.display_name, proxy, pkMember.avatar_url).then((member) => {
|
||||||
// can't add profile pic until i figure out how to convert webp
|
|
||||||
await memberHelper.addFullMember(authorId, pkMember.name, pkMember.display_name, proxy).then((member) => {
|
|
||||||
addedMembers.push(member.name);
|
addedMembers.push(member.name);
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
errors.push(`${pkMember.name}: ${e.message}`);
|
errors.push(`${pkMember.name}: ${e.message}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user