Skip to content

Commit

Permalink
"check if channelid exists before sending the image"
Browse files Browse the repository at this point in the history
  • Loading branch information
Josee9988 committed May 22, 2021
1 parent fcaf21c commit a264cea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

---

## [**1.2.1**] - 2021-05-22

``

### Added

* Check of the channel id can be gathered before sending the random image.

## [**1.2.0**] - 2021-05-20

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion src/commands/commands-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export default class CommandsController {
}
const randomPhoto = Math.floor((Math.random() * Object.keys(photos).length) + 1);

if (dimg.channelId) { // if the channel is specified send the image
if (dimg.channelId && this.client.channels.cache.get(dimg.channelId)) { // if the channel is specified send the image
if (!photos[randomPhoto] || !photos[randomPhoto].url) {
console.error("Url does not exist for server " + dimg.serverId + " with the photo object being like: " + photos[randomPhoto] + "object:");
return;
Expand Down

0 comments on commit a264cea

Please sign in to comment.