Skip to content

Commit

Permalink
Merge pull request #23 from Josee9988/fix/set-channel-not-working
Browse files Browse the repository at this point in the history
Fix/set channel not working
  • Loading branch information
Josee9988 authored Jun 21, 2021
2 parents 452ce9a + 0a52cc3 commit 1ddfd07
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

---

## [**1.3.2**] - 2021-06-20

### Fixed

* Set channel now doesn't depend on the guild cache.

## [**1.3.1**] - 2021-06-20

### Added
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "daily-image-discord-bot",
"displayName": "Daily Image Bot",
"version": "1.3.1",
"version": "1.3.2",
"description": "A discord bot that sends a daily image from a Google photos album, right to your selected discord channel",
"main": "out/index.js",
"scripts": {
Expand Down
9 changes: 5 additions & 4 deletions src/commands/commands-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export default class CommandsController {

switch (CMD_NAME.toLocaleLowerCase()) {
case "albumlink":
case "albumLink":
await this.setAlbumLink(message, args);
break;
case "channel":
Expand All @@ -49,6 +50,7 @@ export default class CommandsController {
helpCommand(message);
break;
case "sendmsg":
case "msgsend":
await this.setSendMsg(message, args);
break;
case "info":
Expand Down Expand Up @@ -91,7 +93,7 @@ export default class CommandsController {
*/
private async setChannel(message: Message, channelToBeSet: string[]): Promise<void> {
if (!checkIfUserIsAdmin(message)) return;
const channelId = await this.client.channels.cache.find(
const channelId = message.guild.channels.cache.find(
(channel: { name: string; }) => channel.name === channelToBeSet[0]);
if (channelId && channelId.id) {
await this.databaseController.setChannel(message.guild.id, channelId.id);
Expand Down Expand Up @@ -147,9 +149,8 @@ export default class CommandsController {
}
} else { // CRON started the job. and we don't have the message available
let dimgs = await this.databaseController.findAll();
for (const dimg of dimgs) { // iterate over every document and send the photos to every respective server
await this.fetchAndSendPhoto(dimg);
}
// iterate over every document and send the photos to every respective server
for (const dimg of dimgs) await this.fetchAndSendPhoto(dimg);
}
}

Expand Down

0 comments on commit 1ddfd07

Please sign in to comment.