No longer destructure at top level

This commit is contained in:
Nuckyz 2024-06-27 05:45:06 -03:00
parent 98c67e1165
commit e9081d2a52
No known key found for this signature in database
GPG key ID: 440BF8296E1C4AD9
6 changed files with 18 additions and 20 deletions

View file

@ -7,10 +7,10 @@
import ErrorBoundary from "@components/ErrorBoundary";
import { Devs } from "@utils/constants";
import definePlugin from "@utils/types";
import { findByProps } from "@webpack";
import { findByPropsAndExtract } from "@webpack";
import { Button, ChannelStore, Text } from "@webpack/common";
const { selectChannel } = findByProps("selectChannel", "selectVoiceChannel");
const selectChannel = findByPropsAndExtract("selectChannel", "selectVoiceChannel");
function jumpToMessage(channelId: string, messageId: string) {
const guildId = ChannelStore.getChannel(channelId)?.guild_id;

View file

@ -8,10 +8,10 @@ import { definePluginSettings } from "@api/Settings";
import { Devs } from "@utils/constants";
import { copyWithToast } from "@utils/misc";
import definePlugin, { OptionType } from "@utils/types";
import { findByProps } from "@webpack";
import { findByPropsAndExtract } from "@webpack";
import { Menu } from "@webpack/common";
const { convertNameToSurrogate } = findByProps("convertNameToSurrogate");
const convertNameToSurrogate = findByPropsAndExtract("convertNameToSurrogate");
interface Emoji {
type: string;

View file

@ -9,7 +9,7 @@ import { Link } from "@components/Link";
import { openInviteModal } from "@utils/discord";
import { Margins } from "@utils/margins";
import { closeAllModals, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal";
import { filters, findComponentByCode, mapMangledModule } from "@webpack";
import { findByProps, findComponentByCode } from "@webpack";
import { Button, FluxDispatcher, Forms, GuildStore, NavigationRouter, Text, TextInput, useEffect, useMemo, UserStore, useState } from "@webpack/common";
import { GUILD_ID, INVITE_KEY, RAW_SKU_ID } from "../../lib/constants";
@ -18,11 +18,8 @@ import { cl, DecorationModalStyles, requireAvatarDecorationModal, requireCreateS
import { AvatarDecorationModalPreview } from "../components";
const FileUpload = findComponentByCode("fileUploadInput,");
const { HelpMessage, HelpMessageTypes } = mapMangledModule('POSITIVE=3]="POSITIVE', {
HelpMessageTypes: filters.byProps("POSITIVE", "WARNING"),
HelpMessage: filters.byCode(".iconDiv")
});
const HelpMessage = findComponentByCode(".iconDiv,", "messageType");
const HelpMessageTypes = findByProps("POSITIVE", "WARNING");
function useObjectURL(object: Blob | MediaSource | null) {
const [url, setUrl] = useState<string | null>(null);

View file

@ -24,12 +24,12 @@ import { definePluginSettings, migratePluginSettings } from "@api/Settings";
import { CogWheel } from "@components/Icons";
import { Devs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types";
import { findByCode, findByProps, mapMangledModule } from "@webpack";
import { findByCode, findByPropsAndExtract, mapMangledModule } from "@webpack";
import { Menu } from "@webpack/common";
import { Guild } from "discord-types/general";
const { updateGuildNotificationSettings } = findByProps("updateGuildNotificationSettings");
const { toggleShowAllChannels } = mapMangledModule(".onboardExistingMember(", {
const updateGuildNotificationSettings = findByPropsAndExtract("updateGuildNotificationSettings");
const OnboardingChannelUtils = mapMangledModule(".onboardExistingMember(", {
toggleShowAllChannels: m => {
const s = String(m);
return s.length < 100 && !s.includes("onboardExistingMember") && !s.includes("getOptedInChannels");
@ -111,7 +111,7 @@ function applyDefaultSettings(guildId: string | null) {
});
}
if (settings.store.showAllChannels && isOptInEnabledForGuild(guildId)) {
toggleShowAllChannels(guildId);
OnboardingChannelUtils.toggleShowAllChannels(guildId);
}
}

View file

@ -14,7 +14,7 @@ import { Timestamp } from "@webpack/common";
import type { Message } from "discord-types/general";
import type { HTMLAttributes } from "react";
const { calendarFormat, dateFormat, isSameDay } = mapMangledModule("millisecondsInUnit:", {
const DateFormatUtils = mapMangledModule("millisecondsInUnit:", {
calendarFormat: filters.byCode("sameElse"),
dateFormat: filters.byCode(':").concat'),
isSameDay: filters.byCode("Math.abs(+"),
@ -46,14 +46,14 @@ function ReplyTimestamp({
return (
<Timestamp
className="vc-reply-timestamp"
compact={isSameDay(refTimestamp, baseTimestamp)}
compact={DateFormatUtils.isSameDay(refTimestamp, baseTimestamp)}
timestamp={refTimestamp}
isInline={false}
>
<Sep>[</Sep>
{isSameDay(refTimestamp, baseTimestamp)
? dateFormat(refTimestamp, "LT")
: calendarFormat(refTimestamp)
{DateFormatUtils.isSameDay(refTimestamp, baseTimestamp)
? DateFormatUtils.dateFormat(refTimestamp, "LT")
: DateFormatUtils.calendarFormat(refTimestamp)
}
<Sep>]</Sep>
</Timestamp>

View file

@ -22,11 +22,12 @@ import { isNonNullish } from "@utils/guards";
import { sleep } from "@utils/misc";
import { Queue } from "@utils/Queue";
import definePlugin from "@utils/types";
import { webpackDependantLazy } from "@webpack";
import { Constants, FluxDispatcher, RestAPI, UserProfileStore, UserStore, useState } from "@webpack/common";
import { type ComponentType, type ReactNode } from "react";
// LYING to the type checker here
const UserFlags = Constants.UserFlags as Record<string, number>;
const UserFlags = webpackDependantLazy(() => Constants.UserFlags as Record<string, number>);
const badges: Record<string, ProfileBadge> = {
active_developer: { id: "active_developer", description: "Active Developer", icon: "6bdc42827a38498929a4920da12695d9", link: "https://support-dev.discord.com/hc/en-us/articles/10113997751447" },
bug_hunter_level_1: { id: "bug_hunter_level_1", description: "Discord Bug Hunter", icon: "2717692c7dca7289b35297368a940dd0", link: "https://support.discord.com/hc/en-us/articles/360046057772-Discord-Bugs" },