Fix ignoreAccidentalMessages not working. Fix another weird error with message edits.
parent
0a9f26eaff
commit
92ac21aa33
13
src/main.js
13
src/main.js
|
@ -13,6 +13,7 @@ const snippets = require('./plugins/snippets');
|
||||||
const webserver = require('./plugins/webserver');
|
const webserver = require('./plugins/webserver');
|
||||||
const greeting = require('./plugins/greeting');
|
const greeting = require('./plugins/greeting');
|
||||||
const attachments = require("./data/attachments");
|
const attachments = require("./data/attachments");
|
||||||
|
const {ACCIDENTAL_THREAD_MESSAGES} = require('./data/constants');
|
||||||
|
|
||||||
const messageQueue = new Queue();
|
const messageQueue = new Queue();
|
||||||
|
|
||||||
|
@ -62,7 +63,16 @@ bot.on('messageCreate', async msg => {
|
||||||
|
|
||||||
// Private message handling is queued so e.g. multiple message in quick succession don't result in multiple channels being created
|
// Private message handling is queued so e.g. multiple message in quick succession don't result in multiple channels being created
|
||||||
messageQueue.add(async () => {
|
messageQueue.add(async () => {
|
||||||
const thread = await threads.findOrCreateThreadForUser(msg.author);
|
let thread = await threads.findOpenThreadByUserId(msg.author.id);
|
||||||
|
|
||||||
|
// New thread
|
||||||
|
if (! thread) {
|
||||||
|
// Ignore messages that shouldn't usually open new threads, such as "ok", "thanks", etc.
|
||||||
|
if (config.ignoreAccidentalThreads && msg.content && ACCIDENTAL_THREAD_MESSAGES.includes(msg.content.trim())) return;
|
||||||
|
|
||||||
|
thread = await threads.createNewThreadForUser(msg.author);
|
||||||
|
}
|
||||||
|
|
||||||
await thread.receiveUserReply(msg);
|
await thread.receiveUserReply(msg);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -73,6 +83,7 @@ bot.on('messageCreate', async msg => {
|
||||||
* 2) If that message was moderator chatter in the thread, update the corresponding chat message in the DB
|
* 2) If that message was moderator chatter in the thread, update the corresponding chat message in the DB
|
||||||
*/
|
*/
|
||||||
bot.on('messageUpdate', async (msg, oldMessage) => {
|
bot.on('messageUpdate', async (msg, oldMessage) => {
|
||||||
|
if (! msg) return;
|
||||||
if (msg.author.bot) return;
|
if (msg.author.bot) return;
|
||||||
if (await blocked.isBlocked(msg.author.id)) return;
|
if (await blocked.isBlocked(msg.author.id)) return;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue