mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-02-24 23:38:32 +00:00
Removed excessive number of ifs
This commit is contained in:
parent
98ee690bdd
commit
ce99871a4d
1 changed files with 7 additions and 11 deletions
|
@ -13,9 +13,7 @@ import { ChannelStore, Menu, MessageStore, NavigationRouter, PresenceStore, Priv
|
||||||
import { type Message } from "discord-types/general";
|
import { type Message } from "discord-types/general";
|
||||||
|
|
||||||
interface IMessageCreate {
|
interface IMessageCreate {
|
||||||
type: "MESSAGE_CREATE";
|
|
||||||
optimistic: boolean;
|
optimistic: boolean;
|
||||||
isPushNotification: boolean;
|
|
||||||
channelId: string;
|
channelId: string;
|
||||||
guildId: string;
|
guildId: string;
|
||||||
message: Message;
|
message: Message;
|
||||||
|
@ -122,21 +120,19 @@ export default definePlugin({
|
||||||
description: "Still get notifications from specific sources when in do not disturb mode. Right-click on users/channels/guilds to set them to bypass do not disturb mode.",
|
description: "Still get notifications from specific sources when in do not disturb mode. Right-click on users/channels/guilds to set them to bypass do not disturb mode.",
|
||||||
authors: [Devs.Inbestigator],
|
authors: [Devs.Inbestigator],
|
||||||
flux: {
|
flux: {
|
||||||
async MESSAGE_CREATE({ optimistic, type, message, guildId, channelId }: IMessageCreate) {
|
async MESSAGE_CREATE({ optimistic, message, guildId, channelId }: IMessageCreate) {
|
||||||
try {
|
try {
|
||||||
if (optimistic || type !== "MESSAGE_CREATE") return;
|
|
||||||
if (message.state === "SENDING") return;
|
|
||||||
if (message.content === "") return;
|
|
||||||
const currentUser = UserStore.getCurrentUser();
|
const currentUser = UserStore.getCurrentUser();
|
||||||
if (message.author.id === currentUser.id) return;
|
const userStatus = await PresenceStore.getStatus(currentUser.id);
|
||||||
if (await PresenceStore.getStatus(currentUser.id) !== "dnd") return;
|
if (optimistic || message.state === "SENDING" || message.content === "" || message.author.id === currentUser.id || userStatus !== "dnd") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const mentioned = MessageStore.getMessage(channelId, message.id)?.mentioned;
|
const mentioned = MessageStore.getMessage(channelId, message.id)?.mentioned;
|
||||||
if ((bypasses.guilds.includes(guildId) || bypasses.channels.includes(channelId)) && mentioned) {
|
if ((bypasses.guilds.includes(guildId) || bypasses.channels.includes(channelId)) && mentioned) {
|
||||||
await showNotification(message, guildId);
|
await showNotification(message, guildId);
|
||||||
} else if (bypasses.users.includes(message.author.id)) {
|
} else if (bypasses.users.includes(message.author.id)) {
|
||||||
if (channelId === await PrivateChannelsStore.getOrEnsurePrivateChannel(message.author.id)) {
|
const userChannelId = await PrivateChannelsStore.getOrEnsurePrivateChannel(message.author.id);
|
||||||
await showNotification(message);
|
if (channelId === userChannelId || (mentioned && settings.store.allowOutsideOfDms === true)) {
|
||||||
} else if (mentioned && (settings.store.allowOutsideOfDms === true)) {
|
|
||||||
await showNotification(message, guildId);
|
await showNotification(message, guildId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue