Skip to content

Commit 67c55a3

Browse files
committed
Don’t try to use webhook if it’s not configured
1 parent a8f9f1e commit 67c55a3

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

library.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
postCategories: '',
2020
topicsOnly: ''
2121
},
22-
regex: /https:\/\/discordapp.com\/api\/webhooks\/([0-9].+?)\/(.+?)$/
22+
regex: /https:\/\/discordapp\.com\/api\/webhooks\/([0-9]+?)\/(.+?)$/
2323
};
2424

2525
plugin.init = function(params, callback) {
@@ -39,7 +39,10 @@
3939

4040
// Parse Webhook URL (1: ID, 2: Token)
4141
var match = plugin.config['webhookURL'].match(plugin.regex);
42-
hook = new Discord.WebhookClient(match[1], match[2]);
42+
43+
if (match) {
44+
hook = new Discord.WebhookClient(match[1], match[2]);
45+
}
4346
});
4447

4548
callback();
@@ -81,7 +84,10 @@
8184
.setFooter(data.user.username, thumbnail)
8285
.setTimestamp();
8386

84-
hook.sendMessage('', {embeds: [embed]}).catch(console.error);
87+
// Send notification:
88+
if (hook) {
89+
hook.sendMessage('', {embeds: [embed]}).catch(console.error);
90+
}
8591
}
8692
});
8793
}

0 commit comments

Comments
 (0)