More things
This commit is contained in:
parent
f1dd39885b
commit
770078f236
|
@ -23,7 +23,6 @@ import { Margins } from "@utils/margins";
|
|||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { find, findByProps } from "@webpack";
|
||||
import { Card, ChannelStore, Forms, GuildStore, PermissionsBits, Switch, TextInput, Tooltip, useState } from "@webpack/common";
|
||||
import { RC } from "@webpack/types";
|
||||
import { Channel, Message, User } from "discord-types/general";
|
||||
|
||||
type PermissionName = "CREATE_INSTANT_INVITE" | "KICK_MEMBERS" | "BAN_MEMBERS" | "ADMINISTRATOR" | "MANAGE_CHANNELS" | "MANAGE_GUILD" | "CHANGE_NICKNAME" | "MANAGE_NICKNAMES" | "MANAGE_ROLES" | "MANAGE_WEBHOOKS" | "MANAGE_GUILD_EXPRESSIONS" | "CREATE_GUILD_EXPRESSIONS" | "VIEW_AUDIT_LOG" | "VIEW_CHANNEL" | "VIEW_GUILD_ANALYTICS" | "VIEW_CREATOR_MONETIZATION_ANALYTICS" | "MODERATE_MEMBERS" | "SEND_MESSAGES" | "SEND_TTS_MESSAGES" | "MANAGE_MESSAGES" | "EMBED_LINKS" | "ATTACH_FILES" | "READ_MESSAGE_HISTORY" | "MENTION_EVERYONE" | "USE_EXTERNAL_EMOJIS" | "ADD_REACTIONS" | "USE_APPLICATION_COMMANDS" | "MANAGE_THREADS" | "CREATE_PUBLIC_THREADS" | "CREATE_PRIVATE_THREADS" | "USE_EXTERNAL_STICKERS" | "SEND_MESSAGES_IN_THREADS" | "CONNECT" | "SPEAK" | "MUTE_MEMBERS" | "DEAFEN_MEMBERS" | "MOVE_MEMBERS" | "USE_VAD" | "PRIORITY_SPEAKER" | "STREAM" | "USE_EMBEDDED_ACTIVITIES" | "USE_SOUNDBOARD" | "USE_EXTERNAL_SOUNDS" | "REQUEST_TO_SPEAK" | "MANAGE_EVENTS" | "CREATE_EVENTS";
|
||||
|
@ -58,7 +57,7 @@ const PermissionUtil = findByProps("computePermissions", "canEveryoneRole") as {
|
|||
computePermissions({ ...args }): bigint;
|
||||
};
|
||||
|
||||
const Tag = find(m => m.Types?.[0] === "BOT") as RC<{ type?: number, className?: string, useRemSizes?: boolean; }> & { Types: Record<string, number>; };
|
||||
const Tag = find(m => m.Types?.[0] === "BOT") as React.ComponentType<{ type?: number, className?: string, useRemSizes?: boolean; }> & { Types: Record<string, number>; };
|
||||
|
||||
const isWebhook = (message: Message, user: User) => !!message?.webhookId && user.isNonUserBot();
|
||||
|
||||
|
|
|
@ -1,94 +0,0 @@
|
|||
/*
|
||||
* Vencord, a modification for Discord's desktop app
|
||||
* Copyright (c) 2023 Vendicated and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { definePluginSettings, Settings, useSettings } from "@api/Settings";
|
||||
import { OptionType } from "@utils/types";
|
||||
import { findStore } from "@webpack";
|
||||
|
||||
export const enum PinOrder {
|
||||
LastMessage,
|
||||
Custom
|
||||
}
|
||||
|
||||
export const settings = definePluginSettings({
|
||||
pinOrder: {
|
||||
type: OptionType.SELECT,
|
||||
description: "Which order should pinned DMs be displayed in?",
|
||||
options: [
|
||||
{ label: "Most recent message", value: PinOrder.LastMessage, default: true },
|
||||
{ label: "Custom (right click channels to reorder)", value: PinOrder.Custom }
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
const PrivateChannelSortStore = findStore("PrivateChannelSortStore");
|
||||
|
||||
export let snapshotArray: string[];
|
||||
let snapshot: Set<string> | undefined;
|
||||
|
||||
const getArray = () => (Settings.plugins.PinDMs.pinnedDMs || void 0)?.split(",") as string[] | undefined;
|
||||
const save = (pins: string[]) => {
|
||||
snapshot = void 0;
|
||||
Settings.plugins.PinDMs.pinnedDMs = pins.join(",");
|
||||
};
|
||||
const takeSnapshot = () => {
|
||||
snapshotArray = getArray() ?? [];
|
||||
return snapshot = new Set<string>(snapshotArray);
|
||||
};
|
||||
const requireSnapshot = () => snapshot ?? takeSnapshot();
|
||||
|
||||
export function usePinnedDms() {
|
||||
useSettings(["plugins.PinDMs.pinnedDMs"]);
|
||||
|
||||
return requireSnapshot();
|
||||
}
|
||||
|
||||
export function isPinned(id: string) {
|
||||
return requireSnapshot().has(id);
|
||||
}
|
||||
|
||||
export function togglePin(id: string) {
|
||||
const snapshot = requireSnapshot();
|
||||
if (!snapshot.delete(id)) {
|
||||
snapshot.add(id);
|
||||
}
|
||||
|
||||
save([...snapshot]);
|
||||
}
|
||||
|
||||
export function sortedSnapshot() {
|
||||
requireSnapshot();
|
||||
if (settings.store.pinOrder === PinOrder.LastMessage)
|
||||
return PrivateChannelSortStore.getPrivateChannelIds().filter(isPinned);
|
||||
|
||||
return snapshotArray;
|
||||
}
|
||||
|
||||
export function getPinAt(idx: number) {
|
||||
return sortedSnapshot()[idx];
|
||||
}
|
||||
|
||||
export function movePin(id: string, direction: -1 | 1) {
|
||||
const pins = getArray()!;
|
||||
const a = pins.indexOf(id);
|
||||
const b = a + direction;
|
||||
|
||||
[pins[a], pins[b]] = [pins[b], pins[a]];
|
||||
|
||||
save(pins);
|
||||
}
|
|
@ -29,8 +29,8 @@ import { Message, ReactionEmoji, User } from "discord-types/general";
|
|||
|
||||
const UserSummaryItem = findComponentByCode("defaultRenderUser", "showDefaultAvatarsForNullUsers");
|
||||
const AvatarStyles = findByProps("moreUsers", "emptyUser", "avatarContainer", "clickableAvatar");
|
||||
let Scroll: any = null;
|
||||
|
||||
let Scroll: any = null;
|
||||
const queue = new Queue();
|
||||
let reactions: Record<string, ReactionCacheEntry>;
|
||||
|
||||
|
|
|
@ -108,6 +108,7 @@ export let ModalCloseButton: Modals["ModalCloseButton"];
|
|||
|
||||
export const Modals = find<Modals>(filters.byProps("ModalRoot", "ModalCloseButton"), m => {
|
||||
({ ModalRoot, ModalHeader, ModalContent, ModalFooter, ModalCloseButton } = m);
|
||||
|
||||
return m;
|
||||
});
|
||||
|
||||
|
|
|
@ -226,7 +226,7 @@ function patchFactories(factories: Record<string, (module: any, exports: any, re
|
|||
callback(exports.default);
|
||||
}
|
||||
} catch (err) {
|
||||
logger.error("Error while firing callback for Webpack subscription:\n", err, filter, callback);
|
||||
logger.error("Error while firing callback for Webpack waitFor subscription:\n", err, filter, callback);
|
||||
}
|
||||
}
|
||||
} as any as { toString: () => string, original: any, (...args: any[]): void; };
|
||||
|
|
Loading…
Reference in a new issue