Dragory 2020-08-16 18:51:20 +03:00
commit 0540ac3b90
No known key found for this signature in database
GPG Key ID: 5F387BA66DF8AAC1
1 changed files with 8 additions and 8 deletions

View File

@ -91,15 +91,15 @@ function initBaseMessageHandlers() {
*/ */
bot.on("messageCreate", async msg => { bot.on("messageCreate", async msg => {
if (! utils.messageIsOnInboxServer(msg)) return; if (! utils.messageIsOnInboxServer(msg)) return;
if (msg.author.bot) return; if (msg.author.id === bot.user.id) return;
const thread = await threads.findByChannelId(msg.channel.id); const thread = await threads.findByChannelId(msg.channel.id);
if (! thread) return; if (! thread) return;
if (msg.content.startsWith(config.prefix) || msg.content.startsWith(config.snippetPrefix)) { if (! msg.author.bot && (msg.content.startsWith(config.prefix) || msg.content.startsWith(config.snippetPrefix))) {
// Save commands as "command messages" // Save commands as "command messages"
thread.saveCommandMessageToLogs(msg); thread.saveCommandMessageToLogs(msg);
} else if (config.alwaysReply) { } else if (! msg.author.bot && config.alwaysReply) {
// AUTO-REPLY: If config.alwaysReply is enabled, send all chat messages in thread channels as replies // AUTO-REPLY: If config.alwaysReply is enabled, send all chat messages in thread channels as replies
if (! utils.isStaff(msg.member)) return; // Only staff are allowed to reply if (! utils.isStaff(msg.member)) return; // Only staff are allowed to reply
@ -150,7 +150,7 @@ function initBaseMessageHandlers() {
*/ */
bot.on("messageUpdate", async (msg, oldMessage) => { bot.on("messageUpdate", async (msg, oldMessage) => {
if (! msg || ! msg.author) return; if (! msg || ! msg.author) return;
if (msg.author.bot) return; if (msg.author.id === bot.user.id) return;
if (await blocked.isBlocked(msg.author.id)) return; if (await blocked.isBlocked(msg.author.id)) return;
// Old message content doesn't persist between bot restarts // Old message content doesn't persist between bot restarts
@ -161,7 +161,7 @@ function initBaseMessageHandlers() {
if (newContent.trim() === oldContent.trim()) return; if (newContent.trim() === oldContent.trim()) return;
// 1) If this edit was in DMs // 1) If this edit was in DMs
if (msg.channel instanceof Eris.PrivateChannel) { if (! msg.author.bot && msg.channel instanceof Eris.PrivateChannel) {
const thread = await threads.findOpenThreadByUserId(msg.author.id); const thread = await threads.findOpenThreadByUserId(msg.author.id);
if (! thread) return; if (! thread) return;
@ -170,7 +170,7 @@ function initBaseMessageHandlers() {
} }
// 2) If this edit was a chat message in the thread // 2) If this edit was a chat message in the thread
else if (utils.messageIsOnInboxServer(msg) && utils.isStaff(msg.member)) { else if (utils.messageIsOnInboxServer(msg) && (msg.author.bot || utils.isStaff(msg.member))) {
const thread = await threads.findOpenThreadByChannelId(msg.channel.id); const thread = await threads.findOpenThreadByChannelId(msg.channel.id);
if (! thread) return; if (! thread) return;
@ -183,9 +183,9 @@ function initBaseMessageHandlers() {
*/ */
bot.on("messageDelete", async msg => { bot.on("messageDelete", async msg => {
if (! msg.author) return; if (! msg.author) return;
if (msg.author.bot) return; if (msg.author.id === bot.user.id) return;
if (! utils.messageIsOnInboxServer(msg)) return; if (! utils.messageIsOnInboxServer(msg)) return;
if (! utils.isStaff(msg.member)) return; if (! msg.author.bot && ! utils.isStaff(msg.member)) return;
const thread = await threads.findOpenThreadByChannelId(msg.channel.id); const thread = await threads.findOpenThreadByChannelId(msg.channel.id);
if (! thread) return; if (! thread) return;