Merge branch 'dev' into immediate-finds

This commit is contained in:
Nuckyz 2024-09-05 04:51:41 -03:00
commit 3338b38aaa
No known key found for this signature in database
GPG key ID: 440BF8296E1C4AD9
14 changed files with 62 additions and 50 deletions

View file

@ -1,7 +1,7 @@
{ {
"name": "vencord", "name": "vencord",
"private": "true", "private": "true",
"version": "1.9.9", "version": "1.10.1",
"description": "The cutest Discord client mod", "description": "The cutest Discord client mod",
"homepage": "https://github.com/Vendicated/Vencord#readme", "homepage": "https://github.com/Vendicated/Vencord#readme",
"bugs": { "bugs": {

View file

@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import { Logger } from "@utils/Logger";
import { makeCodeblock } from "@utils/text"; import { makeCodeblock } from "@utils/text";
import { sendBotMessage } from "./commandHelpers"; import { sendBotMessage } from "./commandHelpers";
@ -46,10 +47,10 @@ export let RequiredMessageOption: Option = ReqPlaceholder;
export const _init = function (cmds: Command[]) { export const _init = function (cmds: Command[]) {
try { try {
BUILT_IN = cmds; BUILT_IN = cmds;
OptionalMessageOption = cmds.find(c => c.name === "shrug")!.options![0]; OptionalMessageOption = cmds.find(c => (c.untranslatedName || c.displayName) === "shrug")!.options![0];
RequiredMessageOption = cmds.find(c => c.name === "me")!.options![0]; RequiredMessageOption = cmds.find(c => (c.untranslatedName || c.displayName) === "me")!.options![0];
} catch (e) { } catch (e) {
console.error("Failed to load CommandsApi"); new Logger("CommandsAPI").error("Failed to load CommandsApi", e, " - cmds is", cmds);
} }
return cmds; return cmds;
} as never; } as never;
@ -138,6 +139,8 @@ export function registerCommand<C extends Command>(command: C, plugin: string) {
throw new Error(`Command '${command.name}' already exists.`); throw new Error(`Command '${command.name}' already exists.`);
command.isVencordCommand = true; command.isVencordCommand = true;
command.untranslatedName ??= command.name;
command.untranslatedDescription ??= command.description;
command.id ??= `-${BUILT_IN.length + 1}`; command.id ??= `-${BUILT_IN.length + 1}`;
command.applicationId ??= "-1"; // BUILT_IN; command.applicationId ??= "-1"; // BUILT_IN;
command.type ??= ApplicationCommandType.CHAT_INPUT; command.type ??= ApplicationCommandType.CHAT_INPUT;

View file

@ -93,8 +93,10 @@ export interface Command {
isVencordCommand?: boolean; isVencordCommand?: boolean;
name: string; name: string;
untranslatedName?: string;
displayName?: string; displayName?: string;
description: string; description: string;
untranslatedDescription?: string;
displayDescription?: string; displayDescription?: string;
options?: Option[]; options?: Option[];

View file

@ -1,3 +0,0 @@
[class*="profileBadges"] {
flex: none;
}

View file

@ -16,8 +16,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import "./fixBadgeOverflow.css";
import { _getBadges, BadgePosition, BadgeUserArgs, ProfileBadge } from "@api/Badges"; import { _getBadges, BadgePosition, BadgeUserArgs, ProfileBadge } from "@api/Badges";
import DonateButton from "@components/DonateButton"; import DonateButton from "@components/DonateButton";
import ErrorBoundary from "@components/ErrorBoundary"; import ErrorBoundary from "@components/ErrorBoundary";
@ -79,7 +77,7 @@ export default definePlugin({
replace: "...$1.props,$& $1.image??" replace: "...$1.props,$& $1.image??"
}, },
{ {
match: /(?<=text:(\i)\.description,.{0,50})children:/, match: /(?<=text:(\i)\.description,.{0,200})children:/,
replace: "children:$1.component ? $self.renderBadgeComponent({ ...$1 }) :" replace: "children:$1.component ? $self.renderBadgeComponent({ ...$1 }) :"
}, },
// conditionally override their onClick with badge.onClick if it exists // conditionally override their onClick with badge.onClick if it exists

View file

@ -78,7 +78,7 @@ async function embedDidMount(this: Component<Props>) {
const replacementProxyURL = `https://dearrow-thumb.ajay.app/api/v1/getThumbnail?videoID=${videoId}&time=${thumbnails[0].timestamp}`; const replacementProxyURL = `https://dearrow-thumb.ajay.app/api/v1/getThumbnail?videoID=${videoId}&time=${thumbnails[0].timestamp}`;
embed.dearrow.oldThumb = dearrowByDefault ? embed.thumbnail.proxyURL : replacementProxyURL; embed.dearrow.oldThumb = dearrowByDefault ? embed.thumbnail.proxyURL : replacementProxyURL;
if (embed.thumbnail.proxyURL) embed.thumbnail.proxyURL = replacementProxyURL; if (dearrowByDefault) embed.thumbnail.proxyURL = replacementProxyURL;
} }
this.forceUpdate(); this.forceUpdate();

View file

@ -14,7 +14,7 @@ import { OnlineMemberCountStore } from "./OnlineMemberCountStore";
export function MemberCount({ isTooltip, tooltipGuildId }: { isTooltip?: true; tooltipGuildId?: string; }) { export function MemberCount({ isTooltip, tooltipGuildId }: { isTooltip?: true; tooltipGuildId?: string; }) {
const currentChannel = useStateFromStores([SelectedChannelStore], () => getCurrentChannel()); const currentChannel = useStateFromStores([SelectedChannelStore], () => getCurrentChannel());
const guildId = isTooltip ? tooltipGuildId! : currentChannel.guild_id; const guildId = isTooltip ? tooltipGuildId! : currentChannel?.guild_id;
const totalCount = useStateFromStores( const totalCount = useStateFromStores(
[GuildMemberCountStore], [GuildMemberCountStore],
@ -33,7 +33,7 @@ export function MemberCount({ isTooltip, tooltipGuildId }: { isTooltip?: true; t
const threadGroups = useStateFromStores( const threadGroups = useStateFromStores(
[ThreadMemberListStore], [ThreadMemberListStore],
() => ThreadMemberListStore.getMemberListSections(currentChannel.id) () => ThreadMemberListStore.getMemberListSections(currentChannel?.id)
); );
if (!isTooltip && (groups.length >= 1 || groups[0].id !== "unknown")) { if (!isTooltip && (groups.length >= 1 || groups[0].id !== "unknown")) {

View file

@ -15,8 +15,8 @@ export const OnlineMemberCountStore = proxyLazy(() => {
const onlineMemberMap = new Map<string, number>(); const onlineMemberMap = new Map<string, number>();
class OnlineMemberCountStore extends Flux.Store { class OnlineMemberCountStore extends Flux.Store {
getCount(guildId: string) { getCount(guildId?: string) {
return onlineMemberMap.get(guildId); return onlineMemberMap.get(guildId!);
} }
async _ensureCount(guildId: string) { async _ensureCount(guildId: string) {
@ -25,8 +25,8 @@ export const OnlineMemberCountStore = proxyLazy(() => {
await PrivateChannelsStore.preload(guildId, GuildChannelStore.getDefaultChannel(guildId).id); await PrivateChannelsStore.preload(guildId, GuildChannelStore.getDefaultChannel(guildId).id);
} }
ensureCount(guildId: string) { ensureCount(guildId?: string) {
if (onlineMemberMap.has(guildId)) return; if (!guildId || onlineMemberMap.has(guildId)) return;
preloadQueue.push(() => preloadQueue.push(() =>
this._ensureCount(guildId) this._ensureCount(guildId)

View file

@ -28,15 +28,14 @@ import { FluxStore } from "@webpack/types";
import { MemberCount } from "./MemberCount"; import { MemberCount } from "./MemberCount";
export const GuildMemberCountStore = findStore("GuildMemberCountStore") as FluxStore & { getMemberCount(guildId: string): number | null; }; export const GuildMemberCountStore = findStore("GuildMemberCountStore") as FluxStore & { getMemberCount(guildId?: string): number | null; };
export const ChannelMemberStore = findStore("ChannelMemberStore") as FluxStore & { export const ChannelMemberStore = findStore("ChannelMemberStore") as FluxStore & {
getProps(guildId: string, channelId: string): { groups: { count: number; id: string; }[]; }; getProps(guildId?: string, channelId?: string): { groups: { count: number; id: string; }[]; };
}; };
export const ThreadMemberListStore = findStore("ThreadMemberListStore") as FluxStore & { export const ThreadMemberListStore = findStore("ThreadMemberListStore") as FluxStore & {
getMemberListSections(channelId: string): { [sectionId: string]: { sectionId: string; userIds: string[]; }; }; getMemberListSections(channelId?: string): { [sectionId: string]: { sectionId: string; userIds: string[]; }; };
}; };
const settings = definePluginSettings({ const settings = definePluginSettings({
toolTip: { toolTip: {
type: OptionType.BOOLEAN, type: OptionType.BOOLEAN,

View file

@ -9,3 +9,8 @@
.vc-mentionAvatars-role-icon { .vc-mentionAvatars-role-icon {
margin: 0 2px 0.2rem 4px; margin: 0 2px 0.2rem 4px;
} }
/** don't display inside the ServerInfo modal owner mention */
.vc-gp-owner .vc-mentionAvatars-icon {
display: none;
}

View file

@ -57,7 +57,7 @@ export default definePlugin({
patches: [ patches: [
// Chat Mentions // Chat Mentions
{ {
find: 'location:"UserMention', find: ".USER_MENTION)",
replacement: [ replacement: [
{ {
match: /onContextMenu:\i,color:\i,\.\.\.\i(?=,children:)(?<=user:(\i),channel:(\i).{0,500}?)/, match: /onContextMenu:\i,color:\i,\.\.\.\i(?=,children:)(?<=user:(\i),channel:(\i).{0,500}?)/,

View file

@ -85,7 +85,7 @@ interface NotificationObject {
title: string; title: string;
content: string; content: string;
useBase64Icon: boolean; useBase64Icon: boolean;
icon: ArrayBuffer | string; icon: string;
sourceApp: string; sourceApp: string;
} }
@ -318,23 +318,29 @@ function shouldIgnoreForChannelType(channel: Channel) {
} }
function sendMsgNotif(titleString: string, content: string, message: Message) { function sendMsgNotif(titleString: string, content: string, message: Message) {
fetch(`https://cdn.discordapp.com/avatars/${message.author.id}/${message.author.avatar}.png?size=128`).then(response => response.arrayBuffer()).then(result => { fetch(`https://cdn.discordapp.com/avatars/${message.author.id}/${message.author.avatar}.png?size=128`)
const msgData: NotificationObject = { .then(response => response.blob())
type: 1, .then(blob => new Promise<string>(resolve => {
timeout: settings.store.lengthBasedTimeout ? calculateTimeout(content) : settings.store.timeout, const r = new FileReader();
height: calculateHeight(content), r.onload = () => resolve((r.result as string).split(",")[1]);
opacity: settings.store.opacity, r.readAsDataURL(blob);
volume: settings.store.volume, })).then(result => {
audioPath: settings.store.soundPath, const msgData: NotificationObject = {
title: titleString, type: 1,
content: content, timeout: settings.store.lengthBasedTimeout ? calculateTimeout(content) : settings.store.timeout,
useBase64Icon: true, height: calculateHeight(content),
icon: new TextDecoder().decode(result), opacity: settings.store.opacity,
sourceApp: "Vencord" volume: settings.store.volume,
}; audioPath: settings.store.soundPath,
title: titleString,
content: content,
useBase64Icon: true,
icon: result,
sourceApp: "Vencord"
};
sendToOverlay(msgData); sendToOverlay(msgData);
}); });
} }
function sendOtherNotif(content: string, titleString: string) { function sendOtherNotif(content: string, titleString: string) {

View file

@ -18,7 +18,7 @@
import { MessageObject } from "@api/MessageEvents"; import { MessageObject } from "@api/MessageEvents";
import { ChannelStore, ComponentDispatch, Constants, FluxDispatcher, GuildStore, InviteActions, MaskedLink, MessageActions, ModalImageClasses, PrivateChannelsStore, RestAPI, SelectedChannelStore, SelectedGuildStore, UserProfileActions, UserProfileStore, UserSettingsActionCreators, UserUtils } from "@webpack/common"; import { ChannelStore, ComponentDispatch, Constants, FluxDispatcher, GuildStore, InviteActions, MaskedLink, MessageActions, ModalImageClasses, PrivateChannelsStore, RestAPI, SelectedChannelStore, SelectedGuildStore, UserProfileActions, UserProfileStore, UserSettingsActionCreators, UserUtils } from "@webpack/common";
import { Guild, Message, User } from "discord-types/general"; import { Channel, Guild, Message, User } from "discord-types/general";
import { ImageModal, ImageModalProps, ModalRoot, ModalSize, openModal } from "./modal"; import { ImageModal, ImageModalProps, ModalRoot, ModalSize, openModal } from "./modal";
@ -54,12 +54,12 @@ export async function openInviteModal(code: string) {
}); });
} }
export function getCurrentChannel() { export function getCurrentChannel(): Channel | undefined {
return ChannelStore.getChannel(SelectedChannelStore.getChannelId()); return ChannelStore.getChannel(SelectedChannelStore.getChannelId());
} }
export function getCurrentGuild(): Guild | undefined { export function getCurrentGuild(): Guild | undefined {
return GuildStore.getGuild(getCurrentChannel()?.guild_id); return GuildStore.getGuild(getCurrentChannel()?.guild_id!);
} }
export function openPrivateChannel(userId: string) { export function openPrivateChannel(userId: string) {

View file

@ -98,7 +98,7 @@ export type Tooltip = ComponentType<{
/** Tooltip.Colors.BLACK */ /** Tooltip.Colors.BLACK */
color?: string; color?: string;
/** TooltipPositions.TOP */ /** TooltipPositions.TOP */
position?: string; position?: PopoutPosition;
tooltipClassName?: string; tooltipClassName?: string;
tooltipContentClassName?: string; tooltipContentClassName?: string;
@ -117,7 +117,7 @@ export type TooltipContainer = ComponentType<PropsWithChildren<{
/** Tooltip.Colors.BLACK */ /** Tooltip.Colors.BLACK */
color?: string; color?: string;
/** TooltipPositions.TOP */ /** TooltipPositions.TOP */
position?: string; position?: PopoutPosition;
spacing?: number; spacing?: number;
className?: string; className?: string;
@ -259,7 +259,7 @@ export type Select = ComponentType<PropsWithChildren<{
look?: 0 | 1; look?: 0 | 1;
className?: string; className?: string;
popoutClassName?: string; popoutClassName?: string;
popoutPosition?: "top" | "left" | "right" | "bottom" | "center" | "window_center"; popoutPosition?: PopoutPosition;
optionClassName?: string; optionClassName?: string;
autoFocus?: boolean; autoFocus?: boolean;
@ -300,7 +300,7 @@ export type SearchableSelect = ComponentType<PropsWithChildren<{
className?: string; className?: string;
popoutClassName?: string; popoutClassName?: string;
wrapperClassName?: string; wrapperClassName?: string;
popoutPosition?: "top" | "left" | "right" | "bottom" | "center" | "window_center"; popoutPosition?: PopoutPosition;
optionClassName?: string; optionClassName?: string;
autoFocus?: boolean; autoFocus?: boolean;
@ -383,6 +383,8 @@ declare enum PopoutAnimation {
FADE = "4" FADE = "4"
} }
type PopoutPosition = "top" | "bottom" | "left" | "right" | "center" | "window_center";
export type Popout = ComponentType<{ export type Popout = ComponentType<{
children( children(
thing: { thing: {
@ -394,7 +396,7 @@ export type Popout = ComponentType<{
}, },
data: { data: {
isShown: boolean; isShown: boolean;
position: string; position: PopoutPosition;
} }
): ReactNode; ): ReactNode;
shouldShow?: boolean; shouldShow?: boolean;
@ -402,7 +404,7 @@ export type Popout = ComponentType<{
closePopout(): void; closePopout(): void;
isPositioned: boolean; isPositioned: boolean;
nudge: number; nudge: number;
position: string; position: PopoutPosition;
setPopoutRef(ref: any): void; setPopoutRef(ref: any): void;
updatePosition(): void; updatePosition(): void;
}): ReactNode; }): ReactNode;
@ -411,13 +413,13 @@ export type Popout = ComponentType<{
onRequestClose?(): void; onRequestClose?(): void;
/** "center" and others */ /** "center" and others */
align?: string; align?: "left" | "right" | "center";
/** Popout.Animation */ /** Popout.Animation */
animation?: PopoutAnimation; animation?: PopoutAnimation;
autoInvert?: boolean; autoInvert?: boolean;
nudgeAlignIntoViewport?: boolean; nudgeAlignIntoViewport?: boolean;
/** "bottom" and others */ /** "bottom" and others */
position?: string; position?: PopoutPosition;
positionKey?: string; positionKey?: string;
spacing?: number; spacing?: number;
}> & { }> & {