Skip to content

Commit fa1cb52

Browse files
authored
Update Discord URL Regex (#10)
The old domain will be shutdown November 7th, see discord/discord-api-docs#1585
1 parent e45c2b2 commit fa1cb52

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
[![npm](https://img.shields.io/npm/v/nodebb-plugin-discord-notification.svg)](https://www.npmjs.com/package/nodebb-plugin-discord-notification) [![npm downloads](https://img.shields.io/npm/dt/nodebb-plugin-discord-notification.svg)](https://www.npmjs.com/package/nodebb-plugin-discord-notification) ![NodeBB Compatibility](https://packages.nodebb.org/api/v1/plugins/nodebb-plugin-discord-notification/compatibility.png)
44

5-
Send notifications of new posts and topics via [Discord](https://discordapp.com/) webhook.
5+
Send notifications of new posts and topics via [Discord](https://discord.com/) webhook.
66

77
It’s like [NodeBB Slack](https://github.com/pichalite/nodebb-plugin-slack-extended) plugin, but for Discord. Fancy rich embeds included.
88

99
## Configuration
1010

1111
1. Install the plugin and activate it.
1212
2. Create a Discord webhook (Server Settings → Webhooks).
13-
You’ll get an URL like `https://discordapp.com/api/webhooks/<Webhook ID>/<Webhook Token>`.
13+
You’ll get an URL like `https://discord.com/api/webhooks/<Webhook ID>/<Webhook Token>`.
1414
3. Fill in **Webhook URL** field on the plugin settings page.
1515
4. Restart NodeBB.
1616

library.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
topicsOnly: '',
2323
messageContent: ''
2424
},
25-
regex: /https:\/\/discordapp\.com\/api\/webhooks\/([0-9]+?)\/(.+?)$/
25+
regex: /https:\/\/discord(?:app)?\.com\/api\/webhooks\/([0-9]+?)\/(.+?)$/
2626
};
2727

2828
plugin.init = function(params, callback) {
@@ -89,7 +89,7 @@
8989
var messageContent = plugin.config['messageContent'] || '';
9090

9191
// Make the rich embed:
92-
var embed = new Discord.RichEmbed()
92+
var embed = new Discord.MessageEmbed()
9393
.setColor(data.category.bgColor)
9494
.setURL(forumURL + '/topic/' + data.topic.slug)
9595
.setTitle(data.category.name + ': ' + data.topic.title)
@@ -99,7 +99,7 @@
9999

100100
// Send notification:
101101
if (hook) {
102-
hook.sendMessage(messageContent, {embeds: [embed]}).catch(console.error);
102+
hook.send(messageContent, {embeds: [embed]}).catch(console.error);
103103
}
104104
}
105105
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"license": "MIT",
2525
"main": "library.js",
2626
"dependencies": {
27-
"discord.js": "^11.1.0"
27+
"discord.js": "^12.3.0"
2828
},
2929
"nbbpm": {
3030
"compatibility": "^1.11.0"

0 commit comments

Comments
 (0)