fix @Vendicated insanities

This commit is contained in:
nin0 2025-05-22 19:47:48 -04:00
parent 3fb6b6e2c2
commit ff61e5ea04
Signed by: nin0
SSH key fingerprint: SHA256:NOoDnFVvZNFvqfXCIhzr6oCTDImZAbTTuyAysZ8Ufk8
3 changed files with 25 additions and 20 deletions

View file

@ -1,11 +1,11 @@
import { ComponentTypes, ThumbnailComponent } from "oceanic.js";
export type ThumbnailProps = Omit<ThumbnailComponent, "type" | "media"> & { children: ThumbnailComponent["media"]; };
export function Thumbnail({ children, ...props }: ThumbnailProps): ThumbnailComponent {
return {
type: ComponentTypes.THUMBNAIL,
media: children,
...props
};
export function Thumbnail(props: { src: string }): ThumbnailComponent {
return {
type: ComponentTypes.THUMBNAIL,
media: {
url: props.src
},
...props
};
}

View file

@ -1,13 +1,22 @@
import { br } from "./br";
export const Fragment = Symbol("ComponentsJsx.Fragment");
type FunctionComponent = (props: any) => any;
export function createElement(type: typeof Fragment | FunctionComponent, props: any, ...children: any[]) {
if (type === Fragment) {
return children;
}
export function createElement(
type: typeof Fragment | FunctionComponent,
props: any,
...children: any[]
) {
if (type === Fragment) {
return children;
}
props ??= {};
props.children = children;
return type(props);
props ??= {};
props.children = children;
// @ts-ignore
if (type === "br") return "\n";
return type(props);
}

View file

@ -8,11 +8,7 @@ import { User as DiscordUser } from "oceanic.js";
export function User(props: { user: DiscordUser }) {
const { user } = props;
return (
<Section
accessory={
<Thumbnail children={{ url: user.avatarURL("png", 128) }} />
}
>
<Section accessory={<Thumbnail src={user.avatarURL("png", 128)} />}>
<TextDisplay>### User</TextDisplay>
<TextDisplay>
{user.globalName || user.username}