fix: apply reported changes

This commit is contained in:
ryan-0324 2024-09-04 16:11:52 -04:00
parent 4489c73316
commit 25522c1c09
11 changed files with 64 additions and 35 deletions

View file

@ -623,7 +623,7 @@ export default {
// From the API documentation
ignoredRemovals: [["TEAM_PSEUDO_USER"]],
},
UserPremiumType: {
PremiumType: {
type: "enum",
},
},

File diff suppressed because one or more lines are too long

View file

@ -4,6 +4,9 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import type { ComponentClass, ElementType, ForwardRefExoticComponent } from "react";
import type { Nullish, Subtract } from "../internal";
import type { Emitter } from "./Emitter";
import type { PersistedStore } from "./PersistedStore";
import type { Store } from "./Store";
@ -26,8 +29,19 @@ export * from "./utils";
export interface Flux {
get initialized(): typeof Store["initialized"];
/** @todo */
connectStores: (a?: any, b?: any, c?: any) => (a?: any) => any;
connectStores: <
Props extends {},
State extends {},
ForwardRef extends boolean | undefined = undefined
>(
stores: Store[],
getStateFromStores: (props: Props) => State,
options?: {
forwardRef?: ForwardRef /* = false */;
} | Nullish
) => <P extends Props & State>(type: ElementType<P>) => ForwardRef extends true
? ForwardRefExoticComponent<Subtract<P, State> & Props>
: ComponentClass<Subtract<P, State> & Props>;
DeviceSettingsStore: typeof UserAgnosticStore;
Emitter: Emitter;
initialize: typeof Store["initialize"];

View file

@ -10,10 +10,10 @@ import type { IconSource } from "./misc";
import type { RecordBase } from "./Record";
import type { UserRecord } from "./UserRecord";
export type ApplicationRecordOwnProperties = Pick<ApplicationRecord, "aliases" | "bot" | "coverImage" | "description" | "developers" | "embeddedActivityConfig" | "eulaId" | "executables" | "flags" | "guild" | "guildId" | "hashes" | "hook" | "icon" | "id" | "integrationTypesConfig" | "isMonetized" | "isVerified" | "maxParticipants" | "name" | "overlay" | "overlayCompatibilityHook" | "overlayMethods" | "overlayWarn" | "primarySkuId" | "privacyPolicyUrl" | "publishers" | "roleConnectionsVerificationUrl" | "slug" | "splash" | "storefront_available" | "storeListingSkuId" | "tags" | "team" | "termsOfServiceUrl" | "thirdPartySkus" | "type">;
export type ApplicationRecordOwnProperties = Pick<ApplicationRecord, "aliases" | "bot" | "coverImage" | "customInstallUrl" | "description" | "developers" | "embeddedActivityConfig" | "eulaId" | "executables" | "flags" | "guild" | "guildId" | "hashes" | "hook" | "icon" | "id" | "installParams" | "integrationTypesConfig" | "isMonetized" | "isVerified" | "maxParticipants" | "name" | "overlay" | "overlayCompatibilityHook" | "overlayMethods" | "overlayWarn" | "primarySkuId" | "privacyPolicyUrl" | "publishers" | "roleConnectionsVerificationUrl" | "slug" | "splash" | "storefront_available" | "storeListingSkuId" | "tags" | "team" | "termsOfServiceUrl" | "thirdPartySkus" | "type">;
export type ApplicationProperties = Optional<PartialOnUndefined<Omit<ApplicationRecordOwnProperties, "embeddedActivityConfig" | "executables" | "isMonetized" | "isVerified">>, Nullish, "id" | "integrationTypesConfig" | "maxParticipants" | "name" | "primarySkuId" | "privacyPolicyUrl" | "roleConnectionsVerificationUrl" | "storefront_available" | "storeListingSkuId" | "team" | "termsOfServiceUrl" | "type", true>
& SnakeCasedProperties<PartialOnUndefined<Pick<ApplicationRecordOwnProperties, "embeddedActivityConfig" | "isMonetized" | "isVerified">>>
export type ApplicationProperties = Optional<PartialOnUndefined<Omit<ApplicationRecordOwnProperties, "customInstallUrl" | "embeddedActivityConfig" | "executables" | "installParams" | "isMonetized" | "isVerified">>, Nullish, "id" | "integrationTypesConfig" | "maxParticipants" | "name" | "primarySkuId" | "privacyPolicyUrl" | "roleConnectionsVerificationUrl" | "storefront_available" | "storeListingSkuId" | "team" | "termsOfServiceUrl" | "type", true>
& SnakeCasedProperties<PartialOnUndefined<Pick<ApplicationRecordOwnProperties, "customInstallUrl" | "embeddedActivityConfig" | "installParams" | "isMonetized" | "isVerified">>>
& { executables: Readonly<ApplicationRecord["executables"]>; };
export declare class ApplicationRecord<
@ -37,6 +37,7 @@ export declare class ApplicationRecord<
aliases: string[];
bot: UserRecord | null;
coverImage: string | null;
customInstallUrl: string | undefined;
description: string | null;
developers: CompanyRecord[];
embeddedActivityConfig: EmbeddedActivityConfig | undefined;
@ -50,6 +51,7 @@ export declare class ApplicationRecord<
hook: boolean;
icon: string | null;
id: string;
installParams: ApplicationInstallParams | undefined;
integrationTypesConfig: Partial<Record<ApplicationIntegrationType, ApplicationIntegrationTypeConfig>> | null;
isMonetized: boolean;
isVerified: boolean;
@ -122,13 +124,10 @@ export interface ApplicationExecutable {
os: string;
}
export enum ApplicationIntegrationType {
GUILD_INSTALL = 0,
USER_INSTALL = 1,
}
export interface ApplicationIntegrationTypeConfig {
oauth2InstallParams: ApplicationInstallParams | undefined;
export interface ApplicationInstallParams {
/** Permissions serialized as a string. */
permissions: string;
scopes: OAuth2Scope[];
}
// Original name: OAuth2Scopes
@ -178,10 +177,13 @@ export enum OAuth2Scope {
WEBHOOK_INCOMING = "webhook.incoming",
}
export interface ApplicationInstallParams {
/** Permissions serialized as a string. */
permissions: string;
scopes: OAuth2Scope[];
export enum ApplicationIntegrationType {
GUILD_INSTALL = 0,
USER_INSTALL = 1,
}
export interface ApplicationIntegrationTypeConfig {
oauth2InstallParams: ApplicationInstallParams | undefined;
}
export enum ApplicationFlags {

View file

@ -5,8 +5,8 @@
*/
import type { Nullish } from "../internal";
import type { ApplicationInstallParams, ApplicationIntegrationType, ApplicationRecord } from "./ApplicationRecord";
import type { UserPremiumType } from "./UserRecord";
import type { ApplicationInstallParams, ApplicationIntegrationType, ApplicationRecordOwnProperties } from "./ApplicationRecord";
import type { PremiumType } from "./UserRecord";
export type UserProfile<FetchFailed extends boolean = boolean> = FetchFailed extends true
? UserProfileFetchFailed
@ -26,7 +26,7 @@ export interface UserProfileBase {
popoutAnimationParticleType?: any /* | Nullish */;
premiumGuildSince: Date | null;
premiumSince: Date | null;
premiumType?: UserPremiumType | Nullish;
premiumType?: PremiumType | Nullish;
profileEffectExpiresAt?: number | Nullish;
profileEffectId?: string | undefined;
profileFetchFailed: boolean;
@ -43,9 +43,7 @@ export interface UserProfileFetchFailed extends UserProfileBase {
profileFetchFailed: true;
}
export interface ProfileApplicationData extends Pick<ApplicationRecord, "flags" | "id" | "primarySkuId" | "storefront_available"> {
customInstallUrl: string | undefined;
installParams: ApplicationInstallParams | undefined;
export interface ProfileApplicationData extends Pick<ApplicationRecordOwnProperties, "customInstallUrl" | "flags" | "id" | "installParams" | "primarySkuId" | "storefront_available"> {
integrationTypesConfig: Partial<Record<ApplicationIntegrationType, {
oauth2_install_params?: ApplicationInstallParams;
} | null>>;

View file

@ -80,7 +80,7 @@ export declare class UserRecord<
nsfwAllowed: boolean;
personalConnectionId: string | null;
phone: string | null;
premiumType: UserPremiumType | Nullish;
premiumType: PremiumType | Nullish;
premiumUsageFlags: number;
publicFlags: UserFlags;
purchasedFlags: number;
@ -95,7 +95,7 @@ export interface AvatarDecorationData {
}
// Original name: PremiumTypes
export enum UserPremiumType {
export enum PremiumType {
/** Nitro Classic */
TIER_1 = 1,
/** Nitro Standard */

File diff suppressed because one or more lines are too long

View file

@ -81,6 +81,21 @@ export type Stringable
export type StringProperties<T>
= { [Key in keyof T as Exclude<Key, symbol>]: T[Key]; };
/** @internal */
export type Subtract<T, U> = {
[TKey in keyof T as keyof {
[UKey in keyof U as UKey extends TKey
? TKey extends UKey
? UKey
: never
: never
]: never;
} extends never
? TKey
: never
]: T[TKey];
};
/** @internal */
export type UnionToIntersection<Union> = (
Union extends unknown

View file

@ -17,7 +17,7 @@
*/
import { mergeDefaults } from "@utils/mergeDefaults";
import type { ChannelType, InteractionType, MessageActivity, MessageAttachment, MessageEmbedType, MessageFlags, MessageInteractionMetadata, MessagePoll, MessageReference, MessageRoleSubscriptionData, MessageType, Sticker, StickerItem, UserClanData, UserFlags, UserPremiumType } from "@vencord/discord-types";
import type { ChannelType, InteractionType, MessageActivity, MessageAttachment, MessageEmbedType, MessageFlags, MessageInteractionMetadata, MessagePoll, MessageReference, MessageRoleSubscriptionData, MessageType, PremiumType, Sticker, StickerItem, UserClanData, UserFlags } from "@vencord/discord-types";
import { findByCodeLazy } from "@webpack";
import { MessageActionCreators, SnowflakeUtils } from "@webpack/common";
import type { LiteralToPrimitive, PartialDeep, SnakeCasedProperties } from "type-fest";
@ -154,7 +154,7 @@ export interface UserJSON {
locale?: string;
mfa_enabled?: boolean;
system?: boolean;
premium_type?: UserPremiumType | 0;
premium_type?: PremiumType | 0;
public_flags?: UserFlags;
username: string;
verified?: boolean;

View file

@ -23,7 +23,7 @@ import { ApngBlendOp, ApngDisposeOp, importApngJs } from "@utils/dependencies";
import { getCurrentGuild } from "@utils/discord";
import { Logger } from "@utils/Logger";
import definePlugin, { OptionType } from "@utils/types";
import { DraftType, type Emoji, EmojiIntention, EmojiType, type MessageAttachment, type MessageEmbed, type MessageRecord, type PersistedStore, type Sticker, StickerFormat, type Store, UserPremiumType } from "@vencord/discord-types";
import { DraftType, type Emoji, EmojiIntention, EmojiType, type MessageAttachment, type MessageEmbed, type MessageRecord, type PersistedStore, PremiumType, type Sticker, StickerFormat, type Store } from "@vencord/discord-types";
import { findByCodeLazy, findByPropsLazy, findStoreLazy, proxyLazyWebpack } from "@webpack";
import { AlertActionCreators, ChannelStore, EmojiStore, FluxDispatcher, Forms, GuildMemberStore, IconUtils, lodash, MarkupUtils, Permissions, PermissionStore, promptToUpload, UserSettingsProtoActionCreators, UserStore } from "@webpack/common";
import { applyPalette, GIFEncoder, quantize } from "gifenc";
@ -389,7 +389,7 @@ export default definePlugin({
},
get canUseStickers() {
return (UserStore.getCurrentUser()!.premiumType ?? 0) > UserPremiumType.TIER_1;
return (UserStore.getCurrentUser()!.premiumType ?? 0) > PremiumType.TIER_1;
},
handleProtoChange(proto: any, user: any) {
@ -398,7 +398,7 @@ export default definePlugin({
const premiumType: number = user?.premium_type ?? UserStore.getCurrentUser()?.premiumType ?? 0;
if (premiumType !== UserPremiumType.TIER_2) {
if (premiumType !== PremiumType.TIER_2) {
proto.appearance ??= AppearanceSettingsActionCreators.create();
if (UserSettingsProtoStore.settings.appearance?.theme != null) {
@ -427,7 +427,7 @@ export default definePlugin({
handleGradientThemeSelect(backgroundGradientPresetId: number | undefined, theme: number, original: () => void) {
const premiumType = UserStore.getCurrentUser()?.premiumType;
if (premiumType === UserPremiumType.TIER_2 || backgroundGradientPresetId == null) {
if (premiumType === PremiumType.TIER_2 || backgroundGradientPresetId == null) {
original();
return;
}

View file

@ -26,7 +26,7 @@ import { Margins } from "@utils/margins";
import { classes, copyWithToast } from "@utils/misc";
import { useAwaiter } from "@utils/react";
import definePlugin, { OptionType } from "@utils/types";
import { type GuildRecord, type ProfileThemeColors, UserPremiumType, type UserProfile, type UserRecord } from "@vencord/discord-types";
import { type GuildRecord, PremiumType, type ProfileThemeColors, type UserProfile, type UserRecord } from "@vencord/discord-types";
import { extractAndLoadChunksLazy, findComponentByCodeLazy } from "@webpack";
import { Button, Flex, Forms, Text, UserProfileStore, UserStore, useState } from "@webpack/common";
import type { ReactNode } from "react";
@ -229,7 +229,7 @@ export default definePlugin({
const colors = decode(profile.bio);
if (colors) {
profile.premiumType = UserPremiumType.TIER_2;
profile.premiumType = PremiumType.TIER_2;
profile.themeColors = colors;
}
}