Skip to content

Commit

Permalink
🐛 Module Unsplash: If no photos, return an error. And allow any forma…
Browse files Browse the repository at this point in the history
…t of photos.
  • Loading branch information
thomasbnt committed Aug 23, 2023
1 parent 26cdb7d commit 380ad7d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions modules/EditBannerServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}
}

Expand All @@ -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(() => {
Expand Down

0 comments on commit 380ad7d

Please sign in to comment.