Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/Vendicated/Vencord into disc…
Browse files Browse the repository at this point in the history
…ord-types
  • Loading branch information
ryan-0324 committed Sep 5, 2024
2 parents f0730b3 + 8890c8c commit 8d2dd91
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 32 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vencord",
"private": "true",
"version": "1.9.9",
"version": "1.10.1",
"description": "The cutest Discord client mod",
"homepage": "https://github.com/Vendicated/Vencord#readme",
"bugs": {
Expand Down
11 changes: 7 additions & 4 deletions src/api/Commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import { Logger } from "@utils/Logger";
import { makeCodeblock } from "@utils/text";
import { ApplicationCommandOptionType, ApplicationCommandType } from "@vencord/discord-types";

Expand Down Expand Up @@ -47,10 +48,10 @@ export let RequiredMessageOption: Option = ReqPlaceholder;
export const _init = function (cmds: Command[]) {
try {
BUILT_IN = cmds;
OptionalMessageOption = cmds.find(c => c.name === "shrug")!.options![0]!;
RequiredMessageOption = cmds.find(c => c.name === "me")!.options![0]!;
} catch {
console.error("Failed to load CommandsAPI");
OptionalMessageOption = cmds.find(c => (c.untranslatedName || c.displayName) === "shrug")!.options![0]!;
RequiredMessageOption = cmds.find(c => (c.untranslatedName || c.displayName) === "me")!.options![0]!;
} catch (e) {
new Logger("CommandsAPI").error("Failed to load CommandsApi", e, " - cmds is", cmds);
}
return cmds;
} as never;
Expand Down Expand Up @@ -140,6 +141,8 @@ export function registerCommand(command: Command, plugin: string) {
throw new Error(`Command '${command.name}' already exists.`);

command.isVencordCommand = true;
command.untranslatedName ??= command.name;
command.untranslatedDescription ??= command.description;
command.id ??= `-${BUILT_IN.length + 1}`;
command.applicationId ??= "-1"; // BUILT_IN;
command.type ??= ApplicationCommandType.CHAT;
Expand Down
2 changes: 2 additions & 0 deletions src/api/Commands/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ export interface Command {
isVencordCommand?: boolean;

name: string;
untranslatedName?: string;
displayName?: string;
description: string;
untranslatedDescription?: string;
displayDescription?: string;

options?: Option[];
Expand Down
3 changes: 0 additions & 3 deletions src/plugins/_api/badges/fixBadgeOverflow.css

This file was deleted.

4 changes: 1 addition & 3 deletions src/plugins/_api/badges/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import "./fixBadgeOverflow.css";

import { _getBadges, BadgePosition, type BadgeUserArgs, type ProfileBadge } from "@api/Badges";
import DonateButton from "@components/DonateButton";
import ErrorBoundary from "@components/ErrorBoundary";
Expand Down Expand Up @@ -78,7 +76,7 @@ export default definePlugin({
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 }) :"
},
// conditionally override their onClick with badge.onClick if it exists
Expand Down
11 changes: 6 additions & 5 deletions src/plugins/memberCount/MemberCount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { OnlineMemberCountStore } from "./OnlineMemberCountStore";
export function MemberCount({ isTooltip, tooltipGuildId }: { isTooltip?: true; tooltipGuildId?: string; }) {
const currentChannel = useStateFromStores([SelectedChannelStore], () => getCurrentChannel());

const guildId = isTooltip ? tooltipGuildId! : currentChannel!.guild_id!;
const guildId = isTooltip ? tooltipGuildId! : currentChannel?.guild_id;

const totalCount = useStateFromStores(
[GuildMemberCountStore],
Expand All @@ -24,17 +24,18 @@ export function MemberCount({ isTooltip, tooltipGuildId }: { isTooltip?: true; t

let onlineCount = useStateFromStores(
[OnlineMemberCountStore],
() => OnlineMemberCountStore.getCount(guildId)
() => OnlineMemberCountStore.getCount(guildId!)
);

const { groups } = useStateFromStores(
[ChannelMemberStore],
() => ChannelMemberStore.getProps(guildId, currentChannel?.id)
() => ChannelMemberStore.getProps(guildId!, currentChannel?.id)
);

const threadGroups = useStateFromStores(
[ThreadMemberListStore],
() => ThreadMemberListStore.getMemberListSections(currentChannel!.id)
// @ts-expect-error
() => ThreadMemberListStore.getMemberListSections(currentChannel?.id)
);

if (!isTooltip && (groups.length >= 1 || groups[0]!.id !== StatusType.UNKNOWN)) {
Expand All @@ -47,7 +48,7 @@ export function MemberCount({ isTooltip, tooltipGuildId }: { isTooltip?: true; t
}

useEffect(() => {
OnlineMemberCountStore.ensureCount(guildId);
OnlineMemberCountStore.ensureCount(guildId!);
}, [guildId]);

if (totalCount == null)
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/memberCount/OnlineMemberCountStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export const OnlineMemberCountStore = proxyLazy(() => {
const onlineMemberMap = new Map<string, number>();

class OnlineMemberCountStore extends Flux.Store {
getCount(guildId: string) {
return onlineMemberMap.get(guildId);
getCount(guildId?: string) {
return onlineMemberMap.get(guildId!);
}

async _ensureCount(guildId: string) {
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/memberCount/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ import { findStoreLazy } from "@webpack";
import { MemberCount } from "./MemberCount";

export const GuildMemberCountStore: Store & {
getMemberCount: (guildId?: string | null | undefined) => number | null | undefined;
getMemberCount: (guildId?: string | null) => number | null | undefined;
} = findStoreLazy("GuildMemberCountStore");

export const ChannelMemberStore: Store & {
getProps: (guildId: string, channelId?: string | null | undefined) => {
getProps: (guildId: string, channelId?: string | null) => {
groups: { count: number; id: string; }[];
};
} = findStoreLazy("ChannelMemberStore");
Expand Down
5 changes: 5 additions & 0 deletions src/plugins/mentionAvatars/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@
.vc-mentionAvatars-role-icon {
margin: 0 2px 0.2rem 4px;
}

/** don't display inside the ServerInfo modal owner mention */
.vc-gp-owner .vc-mentionAvatars-icon {
display: none;
}
2 changes: 1 addition & 1 deletion src/plugins/roleColorEverywhere/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default definePlugin({
patches: [
// Chat Mentions
{
find: 'location:"UserMention',
find: ".USER_MENTION)",
replacement: [
{
match: /onContextMenu:\i,color:\i,\.\.\.\i(?=,children:)(?<=user:(\i),channel:(\i).{0,500}?)/,
Expand Down
11 changes: 8 additions & 3 deletions src/plugins/xsOverlay/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ interface NotificationObject {
title: string;
content: string;
useBase64Icon: boolean;
icon: ArrayBuffer | string;
icon: string;
sourceApp: string;
}

Expand Down Expand Up @@ -262,7 +262,12 @@ function shouldIgnoreForChannelType(channel: ChannelRecord) {
}

async function sendMsgNotif(titleString: string, content: string, message: MessageJSON) {
const result = await (await fetch(`https://cdn.discordapp.com/avatars/${message.author.id}/${message.author.avatar}.png?size=128`)).arrayBuffer();
const blob = await (await fetch(`https://cdn.discordapp.com/avatars/${message.author.id}/${message.author.avatar}.png?size=128`)).blob();
const result = await new Promise<string>(resolve => {
const r = new FileReader();
r.onload = () => { resolve((r.result as string).split(",", 2)[1]!); };
r.readAsDataURL(blob);
});

sendToOverlay({
type: 1,
Expand All @@ -274,7 +279,7 @@ async function sendMsgNotif(titleString: string, content: string, message: Messa
title: titleString,
content: content,
useBase64Icon: true,
icon: new TextDecoder().decode(result),
icon: result,
sourceApp: "Vencord"
});
}
Expand Down
18 changes: 10 additions & 8 deletions src/webpack/common/types/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export type Tooltip = ComponentType<{
/** Tooltip.Colors.BLACK */
color?: string;
/** TooltipPositions.TOP */
position?: string;
position?: PopoutPosition;

tooltipClassName?: string;
tooltipContentClassName?: string;
Expand All @@ -111,7 +111,7 @@ export type TooltipContainer = ComponentType<PropsWithChildren<{
/** Tooltip.Colors.BLACK */
color?: string;
/** TooltipPositions.TOP */
position?: string;
position?: PopoutPosition;
spacing?: number;

className?: string;
Expand Down Expand Up @@ -253,7 +253,7 @@ export type Select = ComponentType<PropsWithChildren<{
look?: 0 | 1;
className?: string;
popoutClassName?: string;
popoutPosition?: "top" | "left" | "right" | "bottom" | "center" | "window_center";
popoutPosition?: PopoutPosition;
optionClassName?: string;

autoFocus?: boolean;
Expand Down Expand Up @@ -294,7 +294,7 @@ export type SearchableSelect = ComponentType<PropsWithChildren<{
className?: string;
popoutClassName?: string;
wrapperClassName?: string;
popoutPosition?: "top" | "left" | "right" | "bottom" | "center" | "window_center";
popoutPosition?: PopoutPosition;
optionClassName?: string;

autoFocus?: boolean;
Expand Down Expand Up @@ -377,6 +377,8 @@ declare enum PopoutAnimation {
FADE = "4"
}

type PopoutPosition = "top" | "bottom" | "left" | "right" | "center" | "window_center";

export type Popout = ComponentType<{
children: (
thing: {
Expand All @@ -388,15 +390,15 @@ export type Popout = ComponentType<{
},
data: {
isShown: boolean;
position: string;
position: PopoutPosition;
}
) => ReactNode;
shouldShow?: boolean;
renderPopout: (args: {
closePopout: () => void;
isPositioned: boolean;
nudge: number;
position: string;
position: PopoutPosition;
setPopoutRef: (ref: any) => void;
updatePosition: () => void;
}) => ReactNode;
Expand All @@ -405,13 +407,13 @@ export type Popout = ComponentType<{
onRequestClose?: () => void;

/** "center" and others */
align?: string;
align?: "left" | "right" | "center";
/** Popout.Animation */
animation?: PopoutAnimation;
autoInvert?: boolean;
nudgeAlignIntoViewport?: boolean;
/** "bottom" and others */
position?: string;
position?: PopoutPosition;
positionKey?: string;
spacing?: number;
}> & {
Expand Down

0 comments on commit 8d2dd91

Please sign in to comment.