Dealing with users without profile.

This commit is contained in:
2024-09-11 05:16:53 +02:00
parent c3355200dd
commit 94e1575c30
3 changed files with 31 additions and 16 deletions

View File

@@ -9,18 +9,20 @@ const save = require('./save.js');
function saveProfileDetails(user) {
if(config.library.profile.image) {
const image = user.profile ? user.profile.image : user.image;
const filepath = interpolate(config.library.profile.image, user, null, {
// pass profile image as item to interpolate extension variable
url: user.profile.image
url: image
});
fetchItem(user.profile.image).then(stream => save(filepath, stream)).catch(error => {
fetchItem(image).then(stream => save(filepath, stream)).catch(error => {
console.log('\x1b[33m%s\x1b[0m', `Could not save profile image for '${user.name}': ${error}`);
});
}
if(config.library.profile.description) {
if(user.profile.description) {
if(user.profile && user.profile.description) {
const filepath = interpolate(config.library.profile.description, user);
const stream = textToStream(user.profile.description);