Merge branch 'dev' into feat/usercss

This commit is contained in:
Lewis Crichton 2024-01-04 16:07:22 +00:00 committed by GitHub
commit 15749dc8ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 277 additions and 153 deletions

View file

@ -1,6 +1,6 @@
# Vencord # Vencord
[![Codeberg Mirror](https://img.shields.io/static/v1?style=for-the-badge&label=Codeberg%20Mirror&message=codeberg.org/Ven/cord&color=2185D0&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABmJLR0QA/wD/AP+gvaeTAAAKbUlEQVR4nNVae3AV5RX/nW/3Pva+b24e5HHzIICQKGoiYiW8NFBFgohaa6ctglpbFSujSGurzUinohWsOij/gGX6R2fqOK0d1FYTEZXaTrWCBbEikJCEyCvkeXNvkrunf+zdkJDkPnex/c3cmd29+53v/M6e73znnF2Cydj4Tntldzi6qrN/qKqzf2jy6b7BnL4B1dI7oMp9AyoRAIdVsNMqhlxWMZjtspzyK/Jhr036OMsm//bh2vzPzNSPzBD6xFutd7R0Dq758ky4orkjYuc05RCAkixbeEq2/UCJ1/LczxcX/c5IPfU5DMHmxpbCpu7o1k/b+xc1n43YjJI7EqV+W2RmvuPt0oDjB2vn5bQbITNjAzzdeKK8qTO0bU9T77zucNQUjzofHrvENWWu3aUBZfW6+ZOOZiIrbYXrmUXo9daX3v6i667O/iGRiRLpwqtIvKDc+0efJ3hb/UIaSkdGWgZ4sqGt9r2m3lc/P9HvSWe80ZiRp3TPL/UsX1+bvyvVsSkb4NE3WjbuPNj5SM8Fcvdk4bAKrqvwv7DxhuCPUxmXNIn6XSy3nWr6R8OhrqrU1btwqJ3m/bgwu/SqZJdEUgbYsuuka09b9/4Pm3tLMlPvwuAbpe6m+RcplfdcURBKdG9CA2zZddLV2Nx1+JO2vlxj1LswqCpynlxc6SxLZIS40bueWfy9vXvv/xt5APhXa1/u7v+EPqvfxXK8++IaoO2Vpn9+cLS33FjVLhw+bOotOX7q6N/i3T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d4rqgnGrUtjCmmSYuOqwB0GcwjbWh9xviurpNnxnDA1IspMPe6bOL755MHJvhKjIgOA7jbJD4pw22Thj+kSIW47h2KRaydVezeP57sCdspRPQqgGeNJJIuBAE+ReJUiOv32mXaXjPZs21C2QnmXgdghyEsMoRfkVMiDgCywF/by9z3xJMb1wCxeHAPgDczZpAh/Iq+HSYmDjCsstgThmf5t4ii8eQm7CgS0SCA5QBezoRApnBaBSyCEhIHCLJEb4ZUd+2SqZSwzE+qpUpEQ9CC4qb01M8cRIQsh8zxiKsMtsn08nvlnrpkyAPj5AGJwMw3AtgGwJ/q2ExxvHsQB74KxfKBMblAyGmTHq4pc4/5GjQeUm6qE9FrAK4E8H6ie41GlkN/jTk6F5Ak2ueUpNmpkgfSMAAAENERAAsB3AHgZDoy0oFdFnBYpXPEBfU4beLRD6Z4qmumug+kIzPjaoeZfQDWAHgAQFam8hLh4MkwWjsHemyS2OF08IYrCjynzZ4zKTCzi5nXMvOnzBw16bevIxR95JOj7DNKb1PqXWa+HMDtAGoBXII0lxq0N2OfAmgA8Hsi2muMhudgesHPzNkA5gKoADADwFRoS8UHQO+x9wLoBNAB4AsAnwM4AOADIjLVxf8L9kdXUOE0IskAAAAASUVORK5CYII=)](https://codeberg.org/Ven/cord) [![Codeberg Mirror](https://img.shields.io/static/v1?style=for-the-badge&label=Codeberg%20Mirror&message=codeberg.org/Vee/cord&color=2185D0&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABmJLR0QA/wD/AP+gvaeTAAAKbUlEQVR4nNVae3AV5RX/nW/3Pva+b24e5HHzIICQKGoiYiW8NFBFgohaa6ctglpbFSujSGurzUinohWsOij/gGX6R2fqOK0d1FYTEZXaTrWCBbEikJCEyCvkeXNvkrunf+zdkJDkPnex/c3cmd29+53v/M6e73znnF2Cydj4Tntldzi6qrN/qKqzf2jy6b7BnL4B1dI7oMp9AyoRAIdVsNMqhlxWMZjtspzyK/Jhr036OMsm//bh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AGoBXII0lxq0N2OfAmgA8Hsi2muMhudgesHPzNkA5gKoADADwFRoS8UHQO+x9wLoBNAB4AsAnwM4AOADIjLVxf8L9kdXUOE0IskAAAAASUVORK5CYII=)](https://codeberg.org/Vee/cord)
The cutest Discord client mod The cutest Discord client mod

View file

@ -6,21 +6,17 @@
import "./ui/styles.css"; import "./ui/styles.css";
import { definePluginSettings } from "@api/Settings";
import ErrorBoundary from "@components/ErrorBoundary"; import ErrorBoundary from "@components/ErrorBoundary";
import { Link } from "@components/Link";
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import { Margins } from "@utils/margins"; import definePlugin from "@utils/types";
import { classes } from "@utils/misc";
import { closeAllModals } from "@utils/modal";
import definePlugin, { OptionType } from "@utils/types";
import { findByPropsLazy } from "@webpack"; import { findByPropsLazy } from "@webpack";
import { FluxDispatcher, Forms, UserStore } from "@webpack/common"; import { UserStore } from "@webpack/common";
import { CDN_URL, RAW_SKU_ID, SKU_ID } from "./lib/constants"; import { CDN_URL, RAW_SKU_ID, SKU_ID } from "./lib/constants";
import { useAuthorizationStore } from "./lib/stores/AuthorizationStore"; import { useAuthorizationStore } from "./lib/stores/AuthorizationStore";
import { useCurrentUserDecorationsStore } from "./lib/stores/CurrentUserDecorationsStore"; import { useCurrentUserDecorationsStore } from "./lib/stores/CurrentUserDecorationsStore";
import { useUserDecorAvatarDecoration, useUsersDecorationsStore } from "./lib/stores/UsersDecorationsStore"; import { useUserDecorAvatarDecoration, useUsersDecorationsStore } from "./lib/stores/UsersDecorationsStore";
import { settings } from "./settings";
import { setDecorationGridDecoration, setDecorationGridItem } from "./ui/components"; import { setDecorationGridDecoration, setDecorationGridItem } from "./ui/components";
import DecorSection from "./ui/components/DecorSection"; import DecorSection from "./ui/components/DecorSection";
@ -30,27 +26,6 @@ export interface AvatarDecoration {
skuId: string; skuId: string;
} }
const settings = definePluginSettings({
changeDecoration: {
type: OptionType.COMPONENT,
description: "Change your avatar decoration",
component() {
return <div>
<DecorSection hideTitle hideDivider noMargin />
<Forms.FormText type="description" className={classes(Margins.top8, Margins.bottom8)}>
You can also access Decor decorations from the <Link
href="/settings/profile-customization"
onClick={e => {
e.preventDefault();
closeAllModals();
FluxDispatcher.dispatch({ type: "USER_SETTINGS_MODAL_SET_SECTION", section: "Profile Customization" });
}}
>Profiles</Link> page.
</Forms.FormText>
</div>;
}
}
});
export default definePlugin({ export default definePlugin({
name: "Decor", name: "Decor",
description: "Create and use your own custom avatar decorations, or pick your favorite from the presets.", description: "Create and use your own custom avatar decorations, or pick your favorite from the presets.",

View file

@ -0,0 +1,47 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2023 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { definePluginSettings } from "@api/Settings";
import { Link } from "@components/Link";
import { Margins } from "@utils/margins";
import { classes } from "@utils/misc";
import { closeAllModals } from "@utils/modal";
import { OptionType } from "@utils/types";
import { FluxDispatcher, Forms } from "@webpack/common";
import DecorSection from "./ui/components/DecorSection";
export const settings = definePluginSettings({
changeDecoration: {
type: OptionType.COMPONENT,
description: "Change your avatar decoration",
component() {
if (!Vencord.Plugins.plugins.Decor.started) return <Forms.FormText>
Enable Decor and restart your client to change your avatar decoration.
</Forms.FormText>;
return <div>
<DecorSection hideTitle hideDivider noMargin />
<Forms.FormText type="description" className={classes(Margins.top8, Margins.bottom8)}>
You can also access Decor decorations from the <Link
href="/settings/profile-customization"
onClick={e => {
e.preventDefault();
closeAllModals();
FluxDispatcher.dispatch({ type: "USER_SETTINGS_MODAL_SET_SECTION", section: "Profile Customization" });
}}
>Profiles</Link> page.
</Forms.FormText>
</div>;
}
},
agreedToGuidelines: {
type: OptionType.BOOLEAN,
description: "Agreed to guidelines",
hidden: true,
default: false
}
});

View file

@ -19,7 +19,7 @@ export let DecorationGridItem: DecorationGridItemComponent;
export const setDecorationGridItem = v => DecorationGridItem = v; export const setDecorationGridItem = v => DecorationGridItem = v;
export const AvatarDecorationModalPreview = LazyComponentWebpack(() => { export const AvatarDecorationModalPreview = LazyComponentWebpack(() => {
const component = findComponentByCode("AvatarDecorationModalPreview"); const component = findComponentByCode(".shopPreviewBanner");
return React.memo(component); return React.memo(component);
}); });

View file

@ -5,9 +5,10 @@
*/ */
import { classNameFactory } from "@api/Styles"; import { classNameFactory } from "@api/Styles";
import { extractAndLoadChunksLazy } from "@webpack"; import { extractAndLoadChunksLazy, findByPropsLazy } from "@webpack";
export const cl = classNameFactory("vc-decor-"); export const cl = classNameFactory("vc-decor-");
export const DecorationModalStyles = findByPropsLazy("modalFooterShopButton");
export const requireAvatarDecorationModal = extractAndLoadChunksLazy(["openAvatarDecorationModal:"]); export const requireAvatarDecorationModal = extractAndLoadChunksLazy(["openAvatarDecorationModal:"]);
export const requireCreateStickerModal = extractAndLoadChunksLazy(["stickerInspected]:"]); export const requireCreateStickerModal = extractAndLoadChunksLazy(["stickerInspected]:"]);

View file

@ -4,12 +4,13 @@
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
*/ */
import ErrorBoundary from "@components/ErrorBoundary";
import { Flex } from "@components/Flex"; import { Flex } from "@components/Flex";
import { openInviteModal } from "@utils/discord"; import { openInviteModal } from "@utils/discord";
import { Margins } from "@utils/margins"; import { Margins } from "@utils/margins";
import { classes } from "@utils/misc"; import { classes } from "@utils/misc";
import { closeAllModals, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalRoot, ModalSize, openModal } from "@utils/modal"; import { closeAllModals, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal";
import { findByPropsLazy, findComponentByCodeLazy } from "@webpack"; import { findComponentByCodeLazy } from "@webpack";
import { Alerts, Button, FluxDispatcher, Forms, GuildStore, NavigationRouter, Parser, Text, Tooltip, useEffect, UserStore, UserUtils, useState } from "@webpack/common"; import { Alerts, Button, FluxDispatcher, Forms, GuildStore, NavigationRouter, Parser, Text, Tooltip, useEffect, UserStore, UserUtils, useState } from "@webpack/common";
import { User } from "discord-types/general"; import { User } from "discord-types/general";
@ -18,16 +19,17 @@ import { GUILD_ID, INVITE_KEY } from "../../lib/constants";
import { useAuthorizationStore } from "../../lib/stores/AuthorizationStore"; import { useAuthorizationStore } from "../../lib/stores/AuthorizationStore";
import { useCurrentUserDecorationsStore } from "../../lib/stores/CurrentUserDecorationsStore"; import { useCurrentUserDecorationsStore } from "../../lib/stores/CurrentUserDecorationsStore";
import { decorationToAvatarDecoration } from "../../lib/utils/decoration"; import { decorationToAvatarDecoration } from "../../lib/utils/decoration";
import { cl, requireAvatarDecorationModal } from "../"; import { settings } from "../../settings";
import { cl, DecorationModalStyles, requireAvatarDecorationModal } from "../";
import { AvatarDecorationModalPreview } from "../components"; import { AvatarDecorationModalPreview } from "../components";
import DecorationGridCreate from "../components/DecorationGridCreate"; import DecorationGridCreate from "../components/DecorationGridCreate";
import DecorationGridNone from "../components/DecorationGridNone"; import DecorationGridNone from "../components/DecorationGridNone";
import DecorDecorationGridDecoration from "../components/DecorDecorationGridDecoration"; import DecorDecorationGridDecoration from "../components/DecorDecorationGridDecoration";
import SectionedGridList from "../components/SectionedGridList"; import SectionedGridList from "../components/SectionedGridList";
import { openCreateDecorationModal } from "./CreateDecorationModal"; import { openCreateDecorationModal } from "./CreateDecorationModal";
import { openGuidelinesModal } from "./GuidelinesModal";
const UserSummaryItem = findComponentByCodeLazy("defaultRenderUser", "showDefaultAvatarsForNullUsers"); const UserSummaryItem = findComponentByCodeLazy("defaultRenderUser", "showDefaultAvatarsForNullUsers");
const DecorationModalStyles = findByPropsLazy("modalFooterShopButton");
function usePresets() { function usePresets() {
const [presets, setPresets] = useState<Preset[]>([]); const [presets, setPresets] = useState<Preset[]>([]);
@ -83,7 +85,7 @@ function SectionHeader({ section }: { section: Section; }) {
</div>; </div>;
} }
export default function ChangeDecorationModal(props: any) { function ChangeDecorationModal(props: ModalProps) {
// undefined = not trying, null = none, Decoration = selected // undefined = not trying, null = none, Decoration = selected
const [tryingDecoration, setTryingDecoration] = useState<Decoration | null | undefined>(undefined); const [tryingDecoration, setTryingDecoration] = useState<Decoration | null | undefined>(undefined);
const isTryingDecoration = typeof tryingDecoration !== "undefined"; const isTryingDecoration = typeof tryingDecoration !== "undefined";
@ -116,6 +118,7 @@ export default function ChangeDecorationModal(props: any) {
const data = [ const data = [
{ {
title: "Your Decorations", title: "Your Decorations",
subtitle: "You can delete your own decorations by right clicking on them.",
sectionKey: "ownDecorations", sectionKey: "ownDecorations",
items: ["none", ...ownDecorations, "create"] items: ["none", ...ownDecorations, "create"]
}, },
@ -148,60 +151,62 @@ export default function ChangeDecorationModal(props: any) {
className={cl("change-decoration-modal-content")} className={cl("change-decoration-modal-content")}
scrollbarType="none" scrollbarType="none"
> >
<SectionedGridList <ErrorBoundary>
renderItem={item => { <SectionedGridList
if (typeof item === "string") { renderItem={item => {
switch (item) { if (typeof item === "string") {
case "none": switch (item) {
return <DecorationGridNone case "none":
className={cl("change-decoration-modal-decoration")} return <DecorationGridNone
isSelected={activeSelectedDecoration === null}
onSelect={() => setTryingDecoration(null)}
/>;
case "create":
return <Tooltip text="You already have a decoration pending review" shouldShow={hasDecorationPendingReview}>
{tooltipProps => <DecorationGridCreate
className={cl("change-decoration-modal-decoration")} className={cl("change-decoration-modal-decoration")}
isSelected={activeSelectedDecoration === null}
onSelect={() => setTryingDecoration(null)}
/>;
case "create":
return <Tooltip text="You already have a decoration pending review" shouldShow={hasDecorationPendingReview}>
{tooltipProps => <DecorationGridCreate
className={cl("change-decoration-modal-decoration")}
{...tooltipProps}
onSelect={!hasDecorationPendingReview ? (settings.store.agreedToGuidelines ? openCreateDecorationModal : openGuidelinesModal) : () => { }}
/>}
</Tooltip>;
}
} else {
return <Tooltip text={"Pending review"} shouldShow={item.reviewed === false}>
{tooltipProps => (
<DecorDecorationGridDecoration
{...tooltipProps} {...tooltipProps}
onSelect={!hasDecorationPendingReview ? openCreateDecorationModal : () => { }} className={cl("change-decoration-modal-decoration")}
/>} onSelect={item.reviewed !== false ? () => setTryingDecoration(item) : () => { }}
</Tooltip>; isSelected={activeSelectedDecoration?.hash === item.hash}
decoration={item}
/>
)}
</Tooltip>;
} }
} else { }}
return <Tooltip text={"Pending review"} shouldShow={item.reviewed === false}> getItemKey={item => typeof item === "string" ? item : item.hash}
{tooltipProps => ( getSectionKey={section => section.sectionKey}
<DecorDecorationGridDecoration renderSectionHeader={section => <SectionHeader section={section} />}
{...tooltipProps} sections={data}
className={cl("change-decoration-modal-decoration")}
onSelect={item.reviewed !== false ? () => setTryingDecoration(item) : () => { }}
isSelected={activeSelectedDecoration?.hash === item.hash}
decoration={item}
/>
)}
</Tooltip>;
}
}}
getItemKey={item => typeof item === "string" ? item : item.hash}
getSectionKey={section => section.sectionKey}
renderSectionHeader={section => <SectionHeader section={section} />}
sections={data}
/>
<div className={cl("change-decoration-modal-preview")}>
<AvatarDecorationModalPreview
avatarDecorationOverride={avatarDecorationOverride}
user={UserStore.getCurrentUser()}
/> />
{isActiveDecorationPreset && <Forms.FormTitle className="">Part of the {activeDecorationPreset.name} Preset</Forms.FormTitle>} <div className={cl("change-decoration-modal-preview")}>
{typeof activeSelectedDecoration === "object" && <AvatarDecorationModalPreview
<Text avatarDecorationOverride={avatarDecorationOverride}
variant="text-sm/semibold" user={UserStore.getCurrentUser()}
color="header-primary" />
> {isActiveDecorationPreset && <Forms.FormTitle className="">Part of the {activeDecorationPreset.name} Preset</Forms.FormTitle>}
{activeSelectedDecoration?.alt} {typeof activeSelectedDecoration === "object" &&
</Text> <Text
} variant="text-sm/semibold"
{activeDecorationHasAuthor && <Text key={`createdBy-${activeSelectedDecoration.authorId}`}>Created by {Parser.parse(`<@${activeSelectedDecoration.authorId}>`)}</Text>} color="header-primary"
</div> >
{activeSelectedDecoration?.alt}
</Text>
}
{activeDecorationHasAuthor && <Text key={`createdBy-${activeSelectedDecoration.authorId}`}>Created by {Parser.parse(`<@${activeSelectedDecoration.authorId}>`)}</Text>}
</div>
</ErrorBoundary>
</ModalContent> </ModalContent>
<ModalFooter className={classes(cl("change-decoration-modal-footer", cl("modal-footer")))}> <ModalFooter className={classes(cl("change-decoration-modal-footer", cl("modal-footer")))}>
<div className={cl("change-decoration-modal-footer-btn-container")}> <div className={cl("change-decoration-modal-footer-btn-container")}>

View file

@ -4,23 +4,23 @@
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
*/ */
import ErrorBoundary from "@components/ErrorBoundary";
import { Link } from "@components/Link"; import { Link } from "@components/Link";
import { openInviteModal } from "@utils/discord"; import { openInviteModal } from "@utils/discord";
import { Margins } from "@utils/margins"; import { Margins } from "@utils/margins";
import { closeAllModals, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalRoot, ModalSize, openModal } from "@utils/modal"; import { closeAllModals, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal";
import { findByPropsLazy, findComponentByCodeLazy } from "@webpack"; import { findByPropsLazy, findComponentByCodeLazy } from "@webpack";
import { Button, FluxDispatcher, Forms, GuildStore, NavigationRouter, Text, TextInput, useEffect, useMemo, UserStore, useState } from "@webpack/common"; import { Button, FluxDispatcher, Forms, GuildStore, NavigationRouter, Text, TextInput, useEffect, useMemo, UserStore, useState } from "@webpack/common";
import { GUILD_ID, INVITE_KEY, RAW_SKU_ID } from "../../lib/constants"; import { GUILD_ID, INVITE_KEY, RAW_SKU_ID } from "../../lib/constants";
import { useCurrentUserDecorationsStore } from "../../lib/stores/CurrentUserDecorationsStore"; import { useCurrentUserDecorationsStore } from "../../lib/stores/CurrentUserDecorationsStore";
import { cl, requireAvatarDecorationModal, requireCreateStickerModal } from "../"; import { cl, DecorationModalStyles, requireAvatarDecorationModal, requireCreateStickerModal } from "../";
import { AvatarDecorationModalPreview } from "../components"; import { AvatarDecorationModalPreview } from "../components";
const DecorationModalStyles = findByPropsLazy("modalFooterShopButton");
const FileUpload = findComponentByCodeLazy("fileUploadInput,"); const FileUpload = findComponentByCodeLazy("fileUploadInput,");
const { default: HelpMessage, HelpMessageTypes } = findByPropsLazy("HelpMessageTypes");
function useObjectURL(object: Blob | MediaSource | null) { function useObjectURL(object: Blob | MediaSource | null) {
const [url, setUrl] = useState<string | null>(null); const [url, setUrl] = useState<string | null>(null);
@ -39,7 +39,7 @@ function useObjectURL(object: Blob | MediaSource | null) {
return url; return url;
} }
export default function CreateDecorationModal(props) { function CreateDecorationModal(props: ModalProps) {
const [name, setName] = useState(""); const [name, setName] = useState("");
const [file, setFile] = useState<File | null>(null); const [file, setFile] = useState<File | null>(null);
const [submitting, setSubmitting] = useState(false); const [submitting, setSubmitting] = useState(false);
@ -75,65 +75,69 @@ export default function CreateDecorationModal(props) {
className={cl("create-decoration-modal-content")} className={cl("create-decoration-modal-content")}
scrollbarType="none" scrollbarType="none"
> >
<div className={cl("create-decoration-modal-form-preview-container")}> <ErrorBoundary>
<div className={cl("create-decoration-modal-form")}> <HelpMessage messageType={HelpMessageTypes.WARNING}>
{error !== null && <Text color="text-danger" variant="text-xs/normal">{error.message}</Text>} Make sure your decoration does not violate <Link
<Forms.FormSection title="File"> href="https://github.com/decor-discord/.github/blob/main/GUIDELINES.md"
<FileUpload >
filename={file?.name} the guidelines
placeholder="Choose a file" </Link> before submitting it.
buttonText="Browse" </HelpMessage>
filters={[{ name: "Decoration file", extensions: ["png", "apng"] }]} <div className={cl("create-decoration-modal-form-preview-container")}>
onFileSelect={setFile} <div className={cl("create-decoration-modal-form")}>
{error !== null && <Text color="text-danger" variant="text-xs/normal">{error.message}</Text>}
<Forms.FormSection title="File">
<FileUpload
filename={file?.name}
placeholder="Choose a file"
buttonText="Browse"
filters={[{ name: "Decoration file", extensions: ["png", "apng"] }]}
onFileSelect={setFile}
/>
<Forms.FormText type="description" className={Margins.top8}>
File should be APNG or PNG.
</Forms.FormText>
</Forms.FormSection>
<Forms.FormSection title="Name">
<TextInput
placeholder="Companion Cube"
value={name}
onChange={setName}
/>
<Forms.FormText type="description" className={Margins.top8}>
This name will be used when referring to this decoration.
</Forms.FormText>
</Forms.FormSection>
</div>
<div>
<AvatarDecorationModalPreview
avatarDecorationOverride={decoration}
user={UserStore.getCurrentUser()}
/> />
<Forms.FormText type="description" className={Margins.top8}> </div>
File should be APNG or PNG.
</Forms.FormText>
</Forms.FormSection>
<Forms.FormSection title="Name">
<TextInput
placeholder="Companion Cube"
value={name}
onChange={setName}
/>
<Forms.FormText type="description" className={Margins.top8}>
This name will be used when referring to this decoration.
</Forms.FormText>
</Forms.FormSection>
</div> </div>
<div> <Forms.FormText type="description" className={Margins.bottom16}>
<AvatarDecorationModalPreview <br />You can receive updates on your decoration's review by joining <Link
avatarDecorationOverride={decoration} href={`https://discord.gg/${INVITE_KEY}`}
user={UserStore.getCurrentUser()} onClick={async e => {
/> e.preventDefault();
</div> if (!GuildStore.getGuild(GUILD_ID)) {
</div> const inviteAccepted = await openInviteModal(INVITE_KEY);
<Forms.FormText type="description" className={Margins.bottom16}> if (inviteAccepted) {
Make sure your decoration does not violate <Link closeAllModals();
href="https://github.com/decor-discord/.github/blob/main/GUIDELINES.md" FluxDispatcher.dispatch({ type: "LAYER_POP_ALL" });
> }
the guidelines } else {
</Link> before creating your decoration.
<br />You can receive updates on your decoration's review by joining <Link
href={`https://discord.gg/${INVITE_KEY}`}
onClick={async e => {
e.preventDefault();
if (!GuildStore.getGuild(GUILD_ID)) {
const inviteAccepted = await openInviteModal(INVITE_KEY);
if (inviteAccepted) {
closeAllModals(); closeAllModals();
FluxDispatcher.dispatch({ type: "LAYER_POP_ALL" }); FluxDispatcher.dispatch({ type: "LAYER_POP_ALL" });
NavigationRouter.transitionToGuild(GUILD_ID);
} }
} else { }}
closeAllModals(); >
FluxDispatcher.dispatch({ type: "LAYER_POP_ALL" }); Decor's Discord server
NavigationRouter.transitionToGuild(GUILD_ID); </Link>.
} </Forms.FormText>
}} </ErrorBoundary>
>
Decor's Discord server
</Link>.
</Forms.FormText>
</ModalContent> </ModalContent>
<ModalFooter className={cl("modal-footer")}> <ModalFooter className={cl("modal-footer")}>
<Button <Button
@ -145,7 +149,7 @@ export default function CreateDecorationModal(props) {
disabled={!file || !name} disabled={!file || !name}
submitting={submitting} submitting={submitting}
> >
Create Submit for Review
</Button> </Button>
<Button <Button
onClick={props.onClose} onClick={props.onClose}

View file

@ -0,0 +1,65 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2023 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { Link } from "@components/Link";
import { ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal";
import { Button, Forms, Text } from "@webpack/common";
import { settings } from "../../settings";
import { cl, DecorationModalStyles, requireAvatarDecorationModal } from "../";
import { openCreateDecorationModal } from "./CreateDecorationModal";
function GuidelinesModal(props: ModalProps) {
return <ModalRoot
{...props}
size={ModalSize.SMALL}
className={DecorationModalStyles.modal}
>
<ModalHeader separator={false} className={cl("modal-header")}>
<Text
color="header-primary"
variant="heading-lg/semibold"
tag="h1"
style={{ flexGrow: 1 }}
>
Hold on
</Text>
<ModalCloseButton onClick={props.onClose} />
</ModalHeader>
<ModalContent
scrollbarType="none"
>
<Forms.FormText>
By submitting a decoration, you agree to <Link
href="https://github.com/decor-discord/.github/blob/main/GUIDELINES.md"
>
the guidelines
</Link>. Not reading these guidelines may get your account suspended from creating more decorations in the future.
</Forms.FormText>
</ModalContent>
<ModalFooter className={cl("modal-footer")}>
<Button
onClick={() => {
settings.store.agreedToGuidelines = true;
props.onClose();
openCreateDecorationModal();
}}
>
Continue
</Button>
<Button
onClick={props.onClose}
color={Button.Colors.PRIMARY}
look={Button.Looks.LINK}
>
Go Back
</Button>
</ModalFooter>
</ModalRoot>;
}
export const openGuidelinesModal = () =>
requireAvatarDecorationModal().then(() => openModal(props => <GuidelinesModal {...props} />));

View file

@ -8,7 +8,7 @@
display: flex; display: flex;
border-radius: 5px 5px 0 0; border-radius: 5px 5px 0 0;
padding: 0 16px; padding: 0 16px;
gap: 4px gap: 4px;
} }
.vc-decor-change-decoration-modal-preview { .vc-decor-change-decoration-modal-preview {
@ -72,7 +72,7 @@
.vc-decor-sectioned-grid-list-grid { .vc-decor-sectioned-grid-list-grid {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
gap: 8px gap: 8px;
} }
.vc-decor-section-remove-margin { .vc-decor-section-remove-margin {

View file

@ -0,0 +1,13 @@
# Urban Dictionary
Use /urban slash command to search for a definition for a word on [Urban Dictionary](https://www.urbandictionary.com/).
## Preview
![preview](https://i.imgur.com/1zwzj38.png)
## Usage
- Enable this plugin
- Set plugin settings as desired
- Type /urban and start getting definitions right into your Discord client.

View file

@ -18,14 +18,24 @@
import { ApplicationCommandOptionType, sendBotMessage } from "@api/Commands"; import { ApplicationCommandOptionType, sendBotMessage } from "@api/Commands";
import { ApplicationCommandInputType } from "@api/Commands/types"; import { ApplicationCommandInputType } from "@api/Commands/types";
import { definePluginSettings } from "@api/Settings";
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import definePlugin from "@utils/types"; import definePlugin, { OptionType } from "@utils/types";
const settings = definePluginSettings({
resultsAmount: {
type: OptionType.NUMBER,
description: "The amount of results you want to get (more gives better results, but is slower)",
default: 10
}
});
export default definePlugin({ export default definePlugin({
name: "UrbanDictionary", name: "UrbanDictionary",
description: "Search for a word on Urban Dictionary via /urban slash command", description: "Search for a word on Urban Dictionary via /urban slash command",
authors: [Devs.jewdev], authors: [Devs.jewdev],
dependencies: ["CommandsAPI"], dependencies: ["CommandsAPI"],
settings,
commands: [ commands: [
{ {
name: "urban", name: "urban",
@ -41,12 +51,16 @@ export default definePlugin({
], ],
execute: async (args, ctx) => { execute: async (args, ctx) => {
try { try {
const query = encodeURIComponent(args[0].value); const query: string = encodeURIComponent(args[0].value);
const { list: [definition] } = await (await fetch(`https://api.urbandictionary.com/v0/define?term=${query}`)).json(); const { list } = await fetch(`https://api.urbandictionary.com/v0/define?term=${query}&per_page=${settings.store.resultsAmount}`).then(response => response.json());
if (!definition) if (!list.length)
return void sendBotMessage(ctx.channel.id, { content: "No results found." }); return void sendBotMessage(ctx.channel.id, { content: "No results found." });
const definition = list.reduce((prev, curr) => {
return prev.thumbs_up > curr.thumbs_up ? prev : curr;
});
const linkify = (text: string) => text const linkify = (text: string) => text
.replaceAll("\r\n", "\n") .replaceAll("\r\n", "\n")
.replace(/([*>_`~\\])/gsi, "\\$1") .replace(/([*>_`~\\])/gsi, "\\$1")