From 733de54d016c756664411dd15eec6a03991ad95a Mon Sep 17 00:00:00 2001 From: Inbestigator <119569726+Inbestigator@users.noreply.github.com> Date: Wed, 6 Mar 2024 10:10:56 -0800 Subject: [PATCH] Trycatch --- src/plugins/bypassDND/index.tsx | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/plugins/bypassDND/index.tsx b/src/plugins/bypassDND/index.tsx index dd98acc2d..111e04b4f 100644 --- a/src/plugins/bypassDND/index.tsx +++ b/src/plugins/bypassDND/index.tsx @@ -141,22 +141,26 @@ export default definePlugin({ authors: [Devs.Inbestigator], flux: { async MESSAGE_CREATE({ optimistic, type, message, guildId, channelId }: IMessageCreate) { - if (optimistic || type !== "MESSAGE_CREATE") return; - if (message.state === "SENDING") return; - if (!message.content) return; - const currentUser = UserStore.getCurrentUser(); - if (message.author.id === currentUser.id) return; - if (await PresenceStore.getStatus(currentUser.id) != 'dnd') return; - if ((bypasses.guilds.includes(guildId) || bypasses.channels.includes(channelId)) && (message.content.includes(`<@${currentUser.id}>`) || message.mentions.some(mention => mention.id === currentUser.id))) { - await showChannelNotification(message); - return; - } - if (bypasses.users.includes(message.author.id)) { - if (channelId === await PrivateChannelsStore.getOrEnsurePrivateChannel(message.author.id)) { - await showUserNotification(message); - } else if ((message.content.includes(`<@${currentUser.id}>`) || message.mentions.some(mention => mention.id === currentUser.id)) && settings.store.allowOutsideOfDms) { + try { + if (optimistic || type !== "MESSAGE_CREATE") return; + if (message.state === "SENDING") return; + if (!message.content) return; + const currentUser = UserStore.getCurrentUser(); + if (message.author.id === currentUser.id) return; + if (await PresenceStore.getStatus(currentUser.id) != 'dnd') return; + if ((bypasses.guilds.includes(guildId) || bypasses.channels.includes(channelId)) && (message.content.includes(`<@${currentUser.id}>`) || message.mentions.some(mention => mention.id === currentUser.id))) { await showChannelNotification(message); + return; } + if (bypasses.users.includes(message.author.id)) { + if (channelId === await PrivateChannelsStore.getOrEnsurePrivateChannel(message.author.id)) { + await showUserNotification(message); + } else if ((message.content.includes(`<@${currentUser.id}>`) || message.mentions.some(mention => mention.id === currentUser.id)) && settings.store.allowOutsideOfDms) { + await showChannelNotification(message); + } + } + } catch (error) { + console.error(error); } } },