Skip to content

Commit

Permalink
Merge pull request #25 from Josee9988/feature/handle-permission-errors
Browse files Browse the repository at this point in the history
Feature/handle permission errors
  • Loading branch information
Josee9988 authored Jun 23, 2021
2 parents d2a1602 + 91215e6 commit 938fb78
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

---

## [**1.3.5**] - 2021-06-23

### Fixed

* Add check before sending a message to the owner.
* "permission-error-handler" import created

## [**1.3.4**] - 2021-06-23

### Fixed
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.4",
"version": "1.3.5",
"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
1 change: 1 addition & 0 deletions src/commands/informational-commands.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {Message} from "discord.js";
import {helpMessage, infoMessage} from "./command-messages-data";
import {connection} from "mongoose";
import permissionErrorHandler from "./../errors/permission-error-handler";

/**
* Help command, triggered by "!dimg help".
Expand Down
2 changes: 1 addition & 1 deletion src/errors/permission-error-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
* @param messageSend the message that was about to send, or any info related.
* @param error the possible error that caused the catch.
*/
function permissionErrorHandler(messageSend: string, error?: any): void {
export default function permissionErrorHandler(messageSend: string, error?: any): void {
console.error(`Couldn't send the message "${messageSend}"\nError found. ${error}`)
}
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ client.on('guildCreate', (guild: Guild) => { // when the bot joins a server
guild.systemChannel.send("Thanks for inviting me to your awesome serverπŸ’–, use **`!dimg help`** for more information :D.")
.catch(() => console.log("Couldn't send welcome message."));

// When the bot is added to a new server, it will send a DM to the server owner.
client.users.cache.get(guild.ownerID).send(welcomeOwnerPrivatelyMessage.msg)
.catch((e: any) => console.error(('Couldn\'t send a welcome DM message to the owner, ERROR:' + e)));
if (client.users.cache.get(guild.ownerID)) // When the bot is added to a new server, it will send a DM to the server owner.
client.users.cache.get(guild.ownerID).send(welcomeOwnerPrivatelyMessage.msg)
.catch((e: any) => console.error(('Couldn\'t send a welcome DM message to the owner, ERROR:' + e)));
});

// event listener "guildDelete".
Expand Down

0 comments on commit 938fb78

Please sign in to comment.