diff --git a/src/plugins/embedUserURLs/components.tsx b/src/plugins/embedUserURLs/components.tsx new file mode 100644 index 000000000..26f0d2ebb --- /dev/null +++ b/src/plugins/embedUserURLs/components.tsx @@ -0,0 +1,88 @@ +/* + * 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 . +*/ + +import { openUserProfile } from "@utils/discord"; +import { UserStore } from "@webpack/common"; +import { Message } from "discord-types/general"; + +export default ({ message }: { message: Message; }) => { + if (!message.content.match(/https:\/\/discord\.com\/users\/\d+/)) return null; + const userID = message.content.match(/https:\/\/discord\.com\/users\/(\d+)/)?.[1]; + if (!userID) return null; + const user = UserStore.getUser(userID); + if (!user) return null; + + return ( + openUserProfile(userID)} + /> + ); +}; + +const UserComponent = ({ avatar, name, activityText, onClick }) => { + const avatarStyle = { + borderRadius: "50%", + }; + + return ( +
(e.currentTarget.style.backgroundColor = "rgba(255, 255, 255, 0.1)")} + onMouseLeave={e => (e.currentTarget.style.backgroundColor = "transparent")} + > +
+
+
+ +
+
+
+ {name} +
+
+ {activityText} +
+
+
+
+
+ ); +}; + + diff --git a/src/plugins/embedUserURLs/index.tsx b/src/plugins/embedUserURLs/index.tsx new file mode 100644 index 000000000..c9ffa4739 --- /dev/null +++ b/src/plugins/embedUserURLs/index.tsx @@ -0,0 +1,43 @@ +/* + * 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 . +*/ + +import { addAccessory, removeAccessory } from "@api/MessageAccessories"; +import ErrorBoundary from "@components/ErrorBoundary"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; + +import UserURLEmbed from "./components"; + +export default definePlugin({ + name: "EmbedUserURLs", + description: "Embeds user URLs in messages.", + authors: [Devs.castdrian], + dependencies: ["MessageAccessoriesAPI"], + + async start() { + addAccessory("user-url-embed", props => ( + + + + )); + }, + + stop() { + removeAccessory("user-url-embed"); + }, +});