Skip to content

Commit

Permalink
"implemented the logic for the new message"
Browse files Browse the repository at this point in the history
  • Loading branch information
Josee9988 committed Jun 21, 2021
1 parent ef8f9d8 commit 96b6d53
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/commands/commands-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ export default class CommandsController {
*/
private async fetchAndSendPhoto(dimg: IDimg): Promise<void> {
let isDetectedAFetchFail: boolean = false;
let msg1Detected = dimg.sendMsg ? dimg.sendMsg : sendRandomPhotoMessage.msg1;
if (dimg.albumLink === null || dimg.albumLink === undefined || dimg.albumLink.length < 20) return;
const photos: ImageInfo[] | any = await GooglePhotosAlbum.fetchImageUrls(dimg.albumLink).catch(() => isDetectedAFetchFail = true);
if (!photos || isDetectedAFetchFail) {
Expand All @@ -172,6 +173,7 @@ export default class CommandsController {
}
await this.client.channels.cache.get(dimg.channelId)
.send(photos[randomPhoto].url).catch((e: any) => console.error(`Couldn't send photo ${photos[randomPhoto]} with url ${photos[randomPhoto].url}.\nE: ${e}`));
await this.client.channels.cache.get(dimg.channelId).send(`${msg1Detected}`);
await this.client.channels.cache.get(dimg.channelId)
.send(`${sendRandomPhotoMessage.msg2}**${new Date(photos[randomPhoto].imageUpdateDate).toLocaleDateString()}**`);
}
Expand Down

0 comments on commit 96b6d53

Please sign in to comment.