From 380ad7d2ea003d7486934e212997d8fcf7a1ffef Mon Sep 17 00:00:00 2001 From: Thomas Bnt Date: Wed, 23 Aug 2023 12:56:22 +0200 Subject: [PATCH] :bug: Module Unsplash: If no photos, return an error. And allow any format of photos. --- modules/EditBannerServer.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/EditBannerServer.js b/modules/EditBannerServer.js index 7bedec9..9192cde 100644 --- a/modules/EditBannerServer.js +++ b/modules/EditBannerServer.js @@ -35,13 +35,12 @@ async function getRandomImage(client, query, username, collectionsId) { const resultRequestUnsplash = await unsplash.photos.getRandom({ query: query ? query : 'nature clouds', count: 1, - orientation: 'landscape', contentFilter: 'high', username: username ? username : null, collectionIds: collectionsId ? collectionsId : null }) if (resultRequestUnsplash.errors) { - client.logger.error('error occurred: ', resultRequestUnsplash.errors[0]) + return client.logger.error(`[Module Unsplash] ${resultRequestUnsplash.errors[0]}`) } else { // return only image url regular and author name return { @@ -52,7 +51,7 @@ async function getRandomImage(client, query, username, collectionsId) { } } } catch (error) { - client.logger.error('error occurred: ', error) + client.logger.error('[Module Unsplash] Erreur rencontrée : ', error) } } @@ -75,6 +74,7 @@ module.exports = function EditBannerCRON(client) { client.config.optionalModules.unsplash.optionalUsername, client.config.optionalModules.unsplash.optionalCollectionsID ).then((img) => { + if (img === undefined) return client.logger.error('[Module Unsplash] Aucune image n\'a été récupérée.') const imageUrl = img.url client.logger.info(`Changement de la bannière du serveur ${guild.name} ...`) guild.setBanner(imageUrl).then(() => {