mirror of
https://github.com/Vendicated/Vencord.git
synced 2024-09-20 06:30:35 +00:00
feat(serverProfilesToolbox): add new plugin
This commit is contained in:
parent
7b96071643
commit
7cdfb07ccc
3 changed files with 72 additions and 0 deletions
5
src/plugins/serverProfilesToolbox/README.md
Normal file
5
src/plugins/serverProfilesToolbox/README.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
# ServerProfilesToolbox
|
||||
|
||||
Adds a copy/paste/reset button to the server profiles editor
|
||||
|
||||
![Screenshot](./screenshot.png)
|
67
src/plugins/serverProfilesToolbox/index.tsx
Normal file
67
src/plugins/serverProfilesToolbox/index.tsx
Normal file
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2024 Vendicated and contributors
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
import { findByPropsLazy, findComponentByCodeLazy } from "@webpack";
|
||||
import { Button, GuildMemberStore, UserProfileStore, UserStore } from "@webpack/common";
|
||||
|
||||
const SummaryItem = findComponentByCodeLazy("borderType", "showBorder", "hideDivider");
|
||||
|
||||
let savedNick = "";
|
||||
let savedPronouns = "";
|
||||
|
||||
const { setPendingNickname, setPendingPronouns }: {
|
||||
setPendingNickname: (a: string | null) => void;
|
||||
setPendingPronouns: (a: string) => void;
|
||||
} = findByPropsLazy("setPendingNickname");
|
||||
|
||||
export default definePlugin({
|
||||
name: "ServerProfilesToolbox",
|
||||
authors: [Devs.D3SOX],
|
||||
description: "Adds a copy/paste/reset button to the server profiles editor",
|
||||
|
||||
patchServerProfiles(args: { guildId: string }) {
|
||||
return <SummaryItem title="Server Profiles Toolbox" hideDivider={false} forcedDivider>
|
||||
<div style={{ display: "flex", gap: "5px" }}>
|
||||
<Button onClick={() => {
|
||||
const currentUser = UserStore.getCurrentUser();
|
||||
const profile = UserProfileStore.getGuildMemberProfile(currentUser.id, args.guildId);
|
||||
const nick = GuildMemberStore.getNick(args.guildId, currentUser.id);
|
||||
savedNick = nick ?? "";
|
||||
savedPronouns = profile.pronouns;
|
||||
}}>
|
||||
Copy profile
|
||||
</Button>
|
||||
<Button onClick={() => {
|
||||
// set pending
|
||||
setPendingNickname(savedNick);
|
||||
setPendingPronouns(savedPronouns);
|
||||
}}>
|
||||
Paste profile
|
||||
</Button>
|
||||
<Button onClick={() => {
|
||||
// reset
|
||||
setPendingNickname("");
|
||||
setPendingPronouns("");
|
||||
}}>
|
||||
Reset profile
|
||||
</Button>
|
||||
</div>
|
||||
</SummaryItem>;
|
||||
},
|
||||
|
||||
patches: [
|
||||
{
|
||||
find: ".PROFILE_CUSTOMIZATION_GUILD_SELECT_TITLE",
|
||||
replacement: {
|
||||
match: /return\(0(.{10,350})\}\)\}\)\}/,
|
||||
replace: "return [(0$1})}),$self.patchServerProfiles(e)]}"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
});
|
BIN
src/plugins/serverProfilesToolbox/screenshot.png
Normal file
BIN
src/plugins/serverProfilesToolbox/screenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 33 KiB |
Loading…
Reference in a new issue