nodebb-plugin-onekite-discord 1.0.17 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/library.js +22 -0
- package/package.json +1 -1
- package/plugin.json +4 -0
package/library.js
CHANGED
|
@@ -184,6 +184,9 @@ Plugin.addAdminNavigation = (header) => {
|
|
|
184
184
|
};
|
|
185
185
|
|
|
186
186
|
Plugin.onTopicPost = async (data) => {
|
|
187
|
+
// Skip scheduled topics — they fire action:topics.scheduled.notify at publish time
|
|
188
|
+
if (data?.topic?.scheduled) return;
|
|
189
|
+
|
|
187
190
|
const settings = await getSettings();
|
|
188
191
|
if (!settings.webhookUrl) return;
|
|
189
192
|
|
|
@@ -197,6 +200,25 @@ Plugin.onTopicPost = async (data) => {
|
|
|
197
200
|
await sendDiscord(settings.webhookUrl, { content: built.content, embeds: [built.embed] });
|
|
198
201
|
};
|
|
199
202
|
|
|
203
|
+
Plugin.onScheduledTopicsPublish = async (data) => {
|
|
204
|
+
const topicsData = data?.topics;
|
|
205
|
+
if (!Array.isArray(topicsData) || topicsData.length === 0) return;
|
|
206
|
+
|
|
207
|
+
const settings = await getSettings();
|
|
208
|
+
if (!settings.webhookUrl) return;
|
|
209
|
+
|
|
210
|
+
await Promise.all(topicsData.map(async (topic) => {
|
|
211
|
+
const tid = topic?.tid;
|
|
212
|
+
if (!tid) return;
|
|
213
|
+
if (!cidAllowed(topic.cid, settings.cids)) return;
|
|
214
|
+
|
|
215
|
+
const built = await buildEmbed({ tid, isReply: false });
|
|
216
|
+
if (!built) return;
|
|
217
|
+
|
|
218
|
+
await sendDiscord(settings.webhookUrl, { content: built.content, embeds: [built.embed] });
|
|
219
|
+
}));
|
|
220
|
+
};
|
|
221
|
+
|
|
200
222
|
Plugin.onTopicReply = async (data) => {
|
|
201
223
|
const settings = await getSettings();
|
|
202
224
|
if (!settings.notifyReplies || !settings.webhookUrl) return;
|
package/package.json
CHANGED