Skip to content

Commit

Permalink
"added extra checks for the send method"
Browse files Browse the repository at this point in the history
  • Loading branch information
Josee9988 committed Jun 26, 2021
1 parent be88dcd commit 58e5d19
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/commands/commands-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,13 @@ export default class CommandsController {
if (forceChannelToBeTheSame) { // if we want the channel of the caller to be the same as the DB. (!dimg now)
if (!checkIfUserIsAdmin(message)) return;
if (server.channelId == message.channel.id) {
await this.fetchAndSendPhoto(server);
await this.fetchAndSendPhoto(server).catch(() => console.error(`fetchAndSendPhoto failed for server ${server}`));
} else { // if the caller channel isn't the same show error
await message.channel.send(
":interrobang:To use this command, talk in the previously selected channel");
}
} else { // if it is called from setAlbumLink to display the 1st photo, after the !dimg albumlink
await this.fetchAndSendPhoto(server);
await this.fetchAndSendPhoto(server).catch(() => console.error(`fetchAndSendPhoto failed for server ${server}`));
}
} else { // albumlink or channel id aren't set
await message.channel.send(
Expand All @@ -152,7 +152,7 @@ export default class CommandsController {
// iterate over every document and send the photos to every respective server
for (const dimg of dimgs) {
if (dimg.albumLink != null || dimg.channelId != null)
await this.fetchAndSendPhoto(dimg);
await this.fetchAndSendPhoto(dimg).catch(() => console.error(`fetchAndSendPhoto failed for server ${dimg.serverId}`));
}
}
}
Expand Down

0 comments on commit 58e5d19

Please sign in to comment.