Compare commits
38 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
d589d22a0b | ||
|
4c13521a30 | ||
|
043381963b | ||
|
5b485806ea | ||
|
29c994648b | ||
|
a35b417194 | ||
|
070aa343ef | ||
|
b95c5c6619 | ||
|
bf795c49df | ||
|
a2e03084b0 | ||
|
ec72b4c91d | ||
|
d70d7c7b49 | ||
|
e7d0fc258d | ||
|
7b13b9a53e | ||
|
1b2cb52dac | ||
|
0fe0fecba2 | ||
|
c1fca76f94 | ||
|
0cc3901e4e | ||
|
f8ace5b53a | ||
|
c0954a1844 | ||
|
6548163d3e | ||
|
24f161d6e9 | ||
|
7d00b6a842 | ||
|
5f5d4b8961 | ||
|
5be86f9bd1 | ||
|
dfc3f05834 | ||
|
63fc354d48 | ||
|
c6f0c84935 | ||
|
a8d017811d | ||
|
8dd70f5d1a | ||
|
8be6c6e3ce | ||
|
7e96b5dcfb | ||
|
99a7d78e9b | ||
|
e70d00d008 | ||
|
c0ac6a4b86 | ||
|
29749e93c7 | ||
|
993c6be219 | ||
|
e2e1cf2bfd |
43
README.md
43
README.md
@ -2,10 +2,14 @@
|
||||
|
||||
The cutest Discord client mod
|
||||
|
||||
|
||||
![](https://user-images.githubusercontent.com/45497981/235015332-0453d3eb-1da6-4601-963e-ef5e454123a1.png)
|
||||
*A screenshot of Vencord featuring the [ClearVision-v6 theme](https://github.com/ClearVision/ClearVision-v6) (Vencord does not come with it pre-installed, it is only an example)*
|
||||
|
||||
## Features
|
||||
|
||||
- Super easy to install (Download Installer, open, click install button, done)
|
||||
- 100+ plugins built in: [See a list](https://gist.github.com/Vendicated/8696cde7b92548064a3ae92ead84d033)
|
||||
- 100+ plugins built in: [See a list](https://vencord.dev/plugins)
|
||||
- Some highlights: SpotifyControls, GameActivityToggle, Experiments, NoTrack, MessageLogger, QuickReply, Free Emotes/Stickers, CustomCommands, ShowHiddenChannels, PronounDB
|
||||
- Fairly lightweight despite the many inbuilt plugins
|
||||
- Excellent Browser Support: Run Vencord in your Browser via extension or UserScript
|
||||
@ -13,10 +17,14 @@ The cutest Discord client mod
|
||||
- Custom CSS and Themes: Inbuilt css editor with support to import any css files (including BetterDiscord themes)
|
||||
- Privacy friendly, blocks Discord analytics & crash reporting out of the box and has no telemetry
|
||||
- Maintained very actively, broken plugins are usually fixed within 12 hours
|
||||
- Settings sync: Keep your plugins and their settings synchronised between devices / apps (optional)
|
||||
|
||||
|
||||
## Installing / Uninstalling
|
||||
|
||||
[![Download and run the Installer ](https://img.shields.io/github/v/release/Vencord/Installer?label=Download%20Vencord%20Installer&style=for-the-badge)](https://github.com/Vencord/Installer#usage)
|
||||
Click the below button to install Vencord to the Discord Desktop app
|
||||
|
||||
[![Download and run the Installer](https://img.shields.io/github/v/release/Vencord/Installer?label=Download%20Vencord%20Installer&style=for-the-badge)](https://github.com/Vencord/Installer#vencord-installer)
|
||||
|
||||
## Installing on Browser
|
||||
|
||||
@ -24,25 +32,30 @@ The cutest Discord client mod
|
||||
|
||||
Or use the [UserScript](https://raw.githubusercontent.com/Vencord/builds/main/Vencord.user.js) - Please note that the CSS Editor, Themes loaded from remote sources and co. will not work in the UserScript. Use the extension if you need any of those
|
||||
|
||||
## Building from Source
|
||||
## Installing our Desktop App
|
||||
|
||||
See the docs folder
|
||||
As an alternative to the Discord Desktop app, Vencord also has its own standalone Desktop app that is snappier and lighter than Discord's official Desktop app. It is currently in beta and we have yet to implement some features like screensharing, but you can try the beta nonetheless
|
||||
|
||||
## Contributing
|
||||
[![Download Vencord Desktop](https://img.shields.io/github/v/release/Vencord/Desktop?label=Download%20Vencord%20Desktop&style=for-the-badge)](https://github.com/Vencord/Desktop#vencord-desktop)
|
||||
|
||||
See [CONTRIBUTING.md](CONTRIBUTING.md) and [Megu's Plugin Guide!](docs/2_PLUGINS.md)
|
||||
## Join our Support/Community Server
|
||||
|
||||
[contribute]: CONTRIBUTING.md
|
||||
|
||||
[contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute]
|
||||
|
||||
## Join
|
||||
|
||||
[join]: https://discord.gg/D9uwnFnqmd
|
||||
|
||||
[join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join]
|
||||
[![Vencord Discord Server](https://invidget.switchblade.xyz/D9uwnFnqmd?theme=dark)](https://discord.gg/D9uwnFnqmd)
|
||||
|
||||
## Disclaimer
|
||||
|
||||
Discord is trademark of Discord Inc. and solely mentioned for the sake of descriptivity.
|
||||
Mention of it does not imply any affiliation with or endorsement by Discord Inc.
|
||||
|
||||
<details>
|
||||
<summary>Using Vencord violates Discord's terms of service</summary>
|
||||
|
||||
Client modifications are against Discord’s Terms of Service.
|
||||
|
||||
However, Discord is pretty indifferent about them and there are no known cases of users getting banned for using client mods! So you should generally be fine as long as you don’t use any plugins that implement abusive behaviour. But no worries, all inbuilt plugins are safe to use!
|
||||
|
||||
Regardless, if your account is very important to you and it getting disabled would be a disaster for you, you should probably not use any client mods (not exclusive to Vencord), just to be safe
|
||||
|
||||
Additionally, make sure not to post screenshots with Vencord in a server where you might get banned for it
|
||||
|
||||
</details>
|
||||
|
@ -59,7 +59,9 @@ async function checkCors(url, method) {
|
||||
const origin = headers["access-control-allow-origin"];
|
||||
if (origin !== "*" && origin !== window.location.origin) return false;
|
||||
|
||||
const methods = headers["access-control-allow-methods"]?.toLowerCase().split(/,\s/g);
|
||||
const methods = headers["access-control-allow-methods"]?.toLowerCase()
|
||||
.split(",")
|
||||
.map(s => s.trim());
|
||||
if (methods && !methods.includes(method.toLowerCase())) return false;
|
||||
|
||||
return true;
|
||||
|
@ -16,7 +16,7 @@ chrome.webRequest.onHeadersReceived.addListener(
|
||||
// In main frame requests, the CSP needs to be removed to enable fetching of custom css
|
||||
// as desired by the user
|
||||
removeFirst(responseHeaders, h => h.name.toLowerCase() === "content-security-policy");
|
||||
} else if (type === "stylesheet" && url.startsWith("https://raw.githubusercontent.com")) {
|
||||
} else if (type === "stylesheet" && url.startsWith("https://raw.githubusercontent.com/")) {
|
||||
// Most users will load css from GitHub, but GitHub doesn't set the correct content type,
|
||||
// so we fix it here
|
||||
removeFirst(responseHeaders, h => h.name.toLowerCase() === "content-type");
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "vencord",
|
||||
"private": "true",
|
||||
"version": "1.1.9",
|
||||
"version": "1.2.0",
|
||||
"description": "The cutest Discord client mod",
|
||||
"homepage": "https://github.com/Vendicated/Vencord#readme",
|
||||
"bugs": {
|
||||
|
@ -186,7 +186,16 @@ page.on("console", async e => {
|
||||
} else if (isDebug) {
|
||||
console.error(e.text());
|
||||
} else if (level === "error") {
|
||||
const text = e.text();
|
||||
const text = await Promise.all(
|
||||
e.args().map(async a => {
|
||||
try {
|
||||
return await maybeGetError(a) || await a.jsonValue();
|
||||
} catch (e) {
|
||||
return a.toString();
|
||||
}
|
||||
})
|
||||
).then(a => a.join(" "));
|
||||
|
||||
if (!text.startsWith("Failed to load resource: the server responded with a status of")) {
|
||||
console.error("Got unexpected error", text);
|
||||
report.otherErrors.push(text);
|
||||
@ -258,7 +267,7 @@ function runTime(token: string) {
|
||||
if (!isWasm)
|
||||
await wreq.e(id as any);
|
||||
|
||||
await new Promise(r => setTimeout(r, 100));
|
||||
await new Promise(r => setTimeout(r, 150));
|
||||
}
|
||||
console.error("[PUP_DEBUG]", "Finished loading chunks!");
|
||||
|
||||
|
@ -79,8 +79,8 @@ export function _getBadges(args: BadgeUserArgs) {
|
||||
: badges.push({ ...badge, ...args });
|
||||
}
|
||||
}
|
||||
const donorBadge = (Plugins.BadgeAPI as any).getDonorBadge(args.user.id);
|
||||
if (donorBadge) badges.unshift(donorBadge);
|
||||
const donorBadges = (Plugins.BadgeAPI as unknown as typeof import("../plugins/apiBadges").default).getDonorBadges(args.user.id);
|
||||
if (donorBadges) badges.unshift(...donorBadges);
|
||||
|
||||
return badges;
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ export default function PluginModal({ plugin, onRestartNeeded, onClose, transiti
|
||||
);
|
||||
});
|
||||
|
||||
return <Flex flexDirection="column" style={{ gap: 12 }}>{options}</Flex>;
|
||||
return <Flex flexDirection="column" style={{ gap: 12, marginBottom: 16 }}>{options}</Flex>;
|
||||
}
|
||||
}
|
||||
|
||||
@ -180,7 +180,7 @@ export default function PluginModal({ plugin, onRestartNeeded, onClose, transiti
|
||||
<Text variant="heading-lg/semibold" style={{ flexGrow: 1 }}>{plugin.name}</Text>
|
||||
<ModalCloseButton onClick={onClose} />
|
||||
</ModalHeader>
|
||||
<ModalContent style={{ marginBottom: 8, marginTop: 8 }}>
|
||||
<ModalContent>
|
||||
<Forms.FormSection>
|
||||
<Forms.FormTitle tag="h3">About {plugin.name}</Forms.FormTitle>
|
||||
<Forms.FormText>{plugin.description}</Forms.FormText>
|
||||
|
@ -1,52 +1,66 @@
|
||||
<!doctype html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Vencord QuickCSS Editor</title>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.37.1/min/vs/editor/editor.main.min.css"
|
||||
integrity="sha512-wB3xfL98hWg1bpkVYSyL0js/Jx9s7FsDg9aYO6nOMSJTgPuk/PFqxXQJKKSUjteZjeYrfgo9NFBOA1r9HwDuZw=="
|
||||
crossorigin="anonymous"
|
||||
referrerpolicy="no-referrer"
|
||||
/>
|
||||
<style>
|
||||
html,
|
||||
body,
|
||||
#container {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Vencord QuickCSS Editor</title>
|
||||
<link rel="stylesheet" data-name="vs/editor/editor.main"
|
||||
href="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.34.0/min/vs/editor/editor.main.min.css">
|
||||
<style>
|
||||
html,
|
||||
body,
|
||||
#container {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="container"></div>
|
||||
<script
|
||||
src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.37.1/min/vs/loader.min.js"
|
||||
integrity="sha512-A+6SvPGkIN9Rf0mUXmW4xh7rDvALXf/f0VtOUiHlDUSPknu2kcfz1KzLpOJyL2pO+nZS13hhIjLqVgiQExLJrw=="
|
||||
crossorigin="anonymous"
|
||||
referrerpolicy="no-referrer"
|
||||
></script>
|
||||
|
||||
<body>
|
||||
<div id="container"></div>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.34.0/min/vs/loader.min.js"></script>
|
||||
<script>
|
||||
require.config({
|
||||
paths: {
|
||||
vs: "https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.37.1/min/vs",
|
||||
},
|
||||
});
|
||||
|
||||
<script>
|
||||
require.config({ paths: { 'vs': 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.34.0/min/vs' } });
|
||||
require(["vs/editor/editor.main"], () => {
|
||||
getCurrentCss().then(css => {
|
||||
var editor = monaco.editor.create(document.getElementById('container'), {
|
||||
value: css,
|
||||
language: 'css',
|
||||
theme: getTheme(),
|
||||
});
|
||||
editor.onDidChangeModelContent(() =>
|
||||
setCss(editor.getValue())
|
||||
);
|
||||
window.addEventListener("resize", () => {
|
||||
// make monaco re-layout
|
||||
editor.layout();
|
||||
require(["vs/editor/editor.main"], () => {
|
||||
getCurrentCss().then((css) => {
|
||||
var editor = monaco.editor.create(
|
||||
document.getElementById("container"),
|
||||
{
|
||||
value: css,
|
||||
language: "css",
|
||||
theme: getTheme(),
|
||||
}
|
||||
);
|
||||
editor.onDidChangeModelContent(() =>
|
||||
setCss(editor.getValue())
|
||||
);
|
||||
window.addEventListener("resize", () => {
|
||||
// make monaco re-layout
|
||||
editor.layout();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -48,7 +48,7 @@ const ContributorBadge: ProfileBadge = {
|
||||
link: "https://github.com/Vendicated/Vencord"
|
||||
};
|
||||
|
||||
const DonorBadges = {} as Record<string, Pick<ProfileBadge, "image" | "description">>;
|
||||
const DonorBadges = {} as Record<string, Pick<ProfileBadge, "image" | "description">[]>;
|
||||
|
||||
export default definePlugin({
|
||||
name: "BadgeAPI",
|
||||
@ -56,21 +56,17 @@ export default definePlugin({
|
||||
authors: [Devs.Megu, Devs.Ven, Devs.TheSun],
|
||||
required: true,
|
||||
patches: [
|
||||
/* Patch the badges array */
|
||||
{
|
||||
find: "Messages.ACTIVE_DEVELOPER_BADGE_TOOLTIP",
|
||||
replacement: {
|
||||
match: /(?<=void 0:)\i.getBadges\(\)/,
|
||||
replace: "Vencord.Api.Badges._getBadges(arguments[0]).concat($&??[])",
|
||||
}
|
||||
},
|
||||
/* Patch the badge list component on user profiles */
|
||||
{
|
||||
find: "Messages.PROFILE_USER_BADGES,role:",
|
||||
replacement: [
|
||||
{
|
||||
match: /null==\i\?void 0:(\i)\.getBadges\(\)/,
|
||||
replace: (_, badgesMod) => `Vencord.Api.Badges._getBadges(arguments[0]).concat(${badgesMod}?.getBadges()??[])`,
|
||||
},
|
||||
{
|
||||
// alt: "", aria-hidden: false, src: originalSrc
|
||||
match: /alt:" ","aria-hidden":!0,src:(?=.{0,10}\b(\i)\.(?:icon|key))/g,
|
||||
match: /alt:" ","aria-hidden":!0,src:(?=(\i)\.src)/g,
|
||||
// ...badge.props, ..., src: badge.image ?? ...
|
||||
replace: "...$1.props,$& $1.image??"
|
||||
},
|
||||
@ -101,78 +97,75 @@ export default definePlugin({
|
||||
}
|
||||
for (const line of lines) {
|
||||
const [id, description, image] = line.split(",");
|
||||
DonorBadges[id] = { image, description };
|
||||
(DonorBadges[id] ??= []).push({ image, description });
|
||||
}
|
||||
},
|
||||
|
||||
getDonorBadge(userId: string) {
|
||||
const badge = DonorBadges[userId];
|
||||
if (badge) {
|
||||
return {
|
||||
...badge,
|
||||
position: BadgePosition.START,
|
||||
props: {
|
||||
style: {
|
||||
borderRadius: "50%",
|
||||
transform: "scale(0.9)" // The image is a bit too big compared to default badges
|
||||
}
|
||||
},
|
||||
onClick() {
|
||||
const modalKey = openModal(props => (
|
||||
<ErrorBoundary noop onError={() => {
|
||||
closeModal(modalKey);
|
||||
VencordNative.ipc.invoke(IpcEvents.OPEN_EXTERNAL, "https://github.com/sponsors/Vendicated");
|
||||
}}>
|
||||
<Modals.ModalRoot {...props}>
|
||||
<Modals.ModalHeader>
|
||||
<Flex style={{ width: "100%", justifyContent: "center" }}>
|
||||
<Forms.FormTitle
|
||||
tag="h2"
|
||||
style={{
|
||||
width: "100%",
|
||||
textAlign: "center",
|
||||
margin: 0
|
||||
}}
|
||||
>
|
||||
<Heart />
|
||||
Vencord Donor
|
||||
</Forms.FormTitle>
|
||||
</Flex>
|
||||
</Modals.ModalHeader>
|
||||
<Modals.ModalContent>
|
||||
<Flex>
|
||||
<img
|
||||
role="presentation"
|
||||
src="https://cdn.discordapp.com/emojis/1026533070955872337.png"
|
||||
alt=""
|
||||
style={{ margin: "auto" }}
|
||||
/>
|
||||
<img
|
||||
role="presentation"
|
||||
src="https://cdn.discordapp.com/emojis/1026533090627174460.png"
|
||||
alt=""
|
||||
style={{ margin: "auto" }}
|
||||
/>
|
||||
</Flex>
|
||||
<div style={{ padding: "1em" }}>
|
||||
<Forms.FormText>
|
||||
This Badge is a special perk for Vencord Donors
|
||||
</Forms.FormText>
|
||||
<Forms.FormText className={Margins.top20}>
|
||||
Please consider supporting the development of Vencord by becoming a donor. It would mean a lot!!
|
||||
</Forms.FormText>
|
||||
</div>
|
||||
</Modals.ModalContent>
|
||||
<Modals.ModalFooter>
|
||||
<Flex style={{ width: "100%", justifyContent: "center" }}>
|
||||
<DonateButton />
|
||||
</Flex>
|
||||
</Modals.ModalFooter>
|
||||
</Modals.ModalRoot>
|
||||
</ErrorBoundary>
|
||||
));
|
||||
},
|
||||
};
|
||||
}
|
||||
getDonorBadges(userId: string) {
|
||||
return DonorBadges[userId]?.map(badge => ({
|
||||
...badge,
|
||||
position: BadgePosition.START,
|
||||
props: {
|
||||
style: {
|
||||
borderRadius: "50%",
|
||||
transform: "scale(0.9)" // The image is a bit too big compared to default badges
|
||||
}
|
||||
},
|
||||
onClick() {
|
||||
const modalKey = openModal(props => (
|
||||
<ErrorBoundary noop onError={() => {
|
||||
closeModal(modalKey);
|
||||
VencordNative.ipc.invoke(IpcEvents.OPEN_EXTERNAL, "https://github.com/sponsors/Vendicated");
|
||||
}}>
|
||||
<Modals.ModalRoot {...props}>
|
||||
<Modals.ModalHeader>
|
||||
<Flex style={{ width: "100%", justifyContent: "center" }}>
|
||||
<Forms.FormTitle
|
||||
tag="h2"
|
||||
style={{
|
||||
width: "100%",
|
||||
textAlign: "center",
|
||||
margin: 0
|
||||
}}
|
||||
>
|
||||
<Heart />
|
||||
Vencord Donor
|
||||
</Forms.FormTitle>
|
||||
</Flex>
|
||||
</Modals.ModalHeader>
|
||||
<Modals.ModalContent>
|
||||
<Flex>
|
||||
<img
|
||||
role="presentation"
|
||||
src="https://cdn.discordapp.com/emojis/1026533070955872337.png"
|
||||
alt=""
|
||||
style={{ margin: "auto" }}
|
||||
/>
|
||||
<img
|
||||
role="presentation"
|
||||
src="https://cdn.discordapp.com/emojis/1026533090627174460.png"
|
||||
alt=""
|
||||
style={{ margin: "auto" }}
|
||||
/>
|
||||
</Flex>
|
||||
<div style={{ padding: "1em" }}>
|
||||
<Forms.FormText>
|
||||
This Badge is a special perk for Vencord Donors
|
||||
</Forms.FormText>
|
||||
<Forms.FormText className={Margins.top20}>
|
||||
Please consider supporting the development of Vencord by becoming a donor. It would mean a lot!!
|
||||
</Forms.FormText>
|
||||
</div>
|
||||
</Modals.ModalContent>
|
||||
<Modals.ModalFooter>
|
||||
<Flex style={{ width: "100%", justifyContent: "center" }}>
|
||||
<DonateButton />
|
||||
</Flex>
|
||||
</Modals.ModalFooter>
|
||||
</Modals.ModalRoot>
|
||||
</ErrorBoundary>
|
||||
));
|
||||
},
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
@ -16,12 +16,11 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { migratePluginSettings, Settings } from "@api/settings";
|
||||
import { Settings } from "@api/settings";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { Clipboard, Toasts } from "@webpack/common";
|
||||
|
||||
migratePluginSettings("BetterRoleDot", "ClickableRoleDot");
|
||||
export default definePlugin({
|
||||
name: "BetterRoleDot",
|
||||
authors: [Devs.Ven],
|
||||
@ -30,10 +29,10 @@ export default definePlugin({
|
||||
|
||||
patches: [
|
||||
{
|
||||
find: "M0 4C0 1.79086 1.79086 0 4 0H16C18.2091 0 20 1.79086 20 4V16C20 18.2091 18.2091 20 16 20H4C1.79086 20 0 18.2091 0 16V4Z",
|
||||
find: ".dotBorderBase",
|
||||
replacement: {
|
||||
match: /viewBox:"0 0 20 20"/,
|
||||
replace: "$&,onClick:()=>$self.copyToClipBoard(e.color),style:{cursor:'pointer'}",
|
||||
match: /,viewBox:"0 0 20 20"/,
|
||||
replace: "$&,onClick:()=>$self.copyToClipBoard(arguments[0].color),style:{cursor:'pointer'}",
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -23,7 +23,6 @@ import {
|
||||
removePreEditListener,
|
||||
removePreSendListener
|
||||
} from "@api/MessageEvents";
|
||||
import { migratePluginSettings } from "@api/settings";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
|
||||
@ -33,7 +32,6 @@ import { defaultRules } from "./defaultRules";
|
||||
const reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
||||
const reHasRegExpChar = RegExp(reRegExpChar.source);
|
||||
|
||||
migratePluginSettings("ClearURLs", "clearURLs");
|
||||
export default definePlugin({
|
||||
name: "ClearURLs",
|
||||
description: "Removes tracking garbage from URLs",
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
import { addPreEditListener, addPreSendListener, removePreEditListener, removePreSendListener } from "@api/MessageEvents";
|
||||
import { definePluginSettings, migratePluginSettings, Settings } from "@api/settings";
|
||||
import { definePluginSettings, Settings } from "@api/settings";
|
||||
import { Devs } from "@utils/constants";
|
||||
import { ApngBlendOp, ApngDisposeOp, getGifEncoder, importApngJs } from "@utils/dependencies";
|
||||
import { getCurrentGuild } from "@utils/discord";
|
||||
@ -149,8 +149,6 @@ const settings = definePluginSettings({
|
||||
}
|
||||
});
|
||||
|
||||
migratePluginSettings("FakeNitro", "NitroBypass");
|
||||
|
||||
export default definePlugin({
|
||||
name: "FakeNitro",
|
||||
authors: [Devs.Arjix, Devs.D3SOX, Devs.Ven, Devs.obscurity, Devs.captain, Devs.Nuckyz, Devs.AutumnVN],
|
||||
|
@ -17,9 +17,9 @@
|
||||
*/
|
||||
|
||||
import { Devs } from "@utils/constants";
|
||||
import { insertTextIntoChatInputBox } from "@utils/discord";
|
||||
import definePlugin from "@utils/types";
|
||||
import { filters, mapMangledModuleLazy } from "@webpack";
|
||||
import { ComponentDispatch } from "@webpack/common";
|
||||
|
||||
const ExpressionPickerState = mapMangledModuleLazy('name:"expression-picker-last-active-view"', {
|
||||
close: filters.byCode("activeView:null", "setState")
|
||||
@ -40,7 +40,7 @@ export default definePlugin({
|
||||
|
||||
handleSelect(gif?: { url: string; }) {
|
||||
if (gif) {
|
||||
ComponentDispatch.dispatchToLastSubscribed("INSERT_TEXT", { rawText: gif.url + " " });
|
||||
insertTextIntoChatInputBox(gif.url + " ");
|
||||
ExpressionPickerState.close();
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,8 @@ import { registerCommand, unregisterCommand } from "@api/Commands";
|
||||
import { Settings } from "@api/settings";
|
||||
import Logger from "@utils/Logger";
|
||||
import { Patch, Plugin } from "@utils/types";
|
||||
import { FluxDispatcher } from "@webpack/common";
|
||||
import { FluxEvents } from "@webpack/types";
|
||||
|
||||
import Plugins from "~plugins";
|
||||
|
||||
@ -111,56 +113,64 @@ export function startDependenciesRecursive(p: Plugin) {
|
||||
}
|
||||
|
||||
export const startPlugin = traceFunction("startPlugin", function startPlugin(p: Plugin) {
|
||||
const { name, commands, flux } = p;
|
||||
|
||||
if (p.start) {
|
||||
logger.info("Starting plugin", p.name);
|
||||
logger.info("Starting plugin", name);
|
||||
if (p.started) {
|
||||
logger.warn(`${p.name} already started`);
|
||||
logger.warn(`${name} already started`);
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
p.start();
|
||||
p.started = true;
|
||||
} catch (e) {
|
||||
logger.error(`Failed to start ${p.name}\n`, e);
|
||||
logger.error(`Failed to start ${name}\n`, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (p.commands?.length) {
|
||||
logger.info("Registering commands of plugin", p.name);
|
||||
for (const cmd of p.commands) {
|
||||
if (commands?.length) {
|
||||
logger.info("Registering commands of plugin", name);
|
||||
for (const cmd of commands) {
|
||||
try {
|
||||
registerCommand(cmd, p.name);
|
||||
registerCommand(cmd, name);
|
||||
} catch (e) {
|
||||
logger.error(`Failed to register command ${cmd.name}\n`, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flux) {
|
||||
for (const event in flux) {
|
||||
FluxDispatcher.subscribe(event as FluxEvents, flux[event]);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}, p => `startPlugin ${p.name}`);
|
||||
|
||||
export const stopPlugin = traceFunction("stopPlugin", function stopPlugin(p: Plugin) {
|
||||
const { name, commands, flux } = p;
|
||||
if (p.stop) {
|
||||
logger.info("Stopping plugin", p.name);
|
||||
logger.info("Stopping plugin", name);
|
||||
if (!p.started) {
|
||||
logger.warn(`${p.name} already stopped`);
|
||||
logger.warn(`${name} already stopped`);
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
p.stop();
|
||||
p.started = false;
|
||||
} catch (e) {
|
||||
logger.error(`Failed to stop ${p.name}\n`, e);
|
||||
logger.error(`Failed to stop ${name}\n`, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (p.commands?.length) {
|
||||
logger.info("Unregistering commands of plugin", p.name);
|
||||
for (const cmd of p.commands) {
|
||||
if (commands?.length) {
|
||||
logger.info("Unregistering commands of plugin", name);
|
||||
for (const cmd of commands) {
|
||||
try {
|
||||
unregisterCommand(cmd.name);
|
||||
} catch (e) {
|
||||
@ -170,5 +180,11 @@ export const stopPlugin = traceFunction("stopPlugin", function stopPlugin(p: Plu
|
||||
}
|
||||
}
|
||||
|
||||
if (flux) {
|
||||
for (const event in flux) {
|
||||
FluxDispatcher.unsubscribe(event as FluxEvents, flux[event]);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}, p => `stopPlugin ${p.name}`);
|
||||
|
@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { insertTextIntoChatInputBox } from "@utils/discord";
|
||||
import {
|
||||
ModalContent,
|
||||
ModalFooter,
|
||||
@ -24,7 +25,7 @@ import {
|
||||
ModalRoot,
|
||||
openModal,
|
||||
} from "@utils/modal";
|
||||
import { Button, ComponentDispatch, Forms, React, Switch, TextInput } from "@webpack/common";
|
||||
import { Button, Forms, React, Switch, TextInput } from "@webpack/common";
|
||||
|
||||
import { encrypt } from "../index";
|
||||
|
||||
@ -84,9 +85,7 @@ function EncModal(props: ModalProps) {
|
||||
const toSend = noCover ? encrypted.replaceAll("d", "") : encrypted;
|
||||
if (!toSend) return;
|
||||
|
||||
ComponentDispatch.dispatchToLastSubscribed("INSERT_TEXT", {
|
||||
rawText: `${toSend}`
|
||||
});
|
||||
insertTextIntoChatInputBox(toSend);
|
||||
|
||||
props.onClose();
|
||||
}}
|
||||
|
@ -19,7 +19,7 @@
|
||||
import * as DataStore from "@api/DataStore";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
import { ChannelStore, FluxDispatcher, NavigationRouter, SelectedChannelStore, SelectedGuildStore } from "@webpack/common";
|
||||
import { ChannelStore, NavigationRouter, SelectedChannelStore, SelectedGuildStore } from "@webpack/common";
|
||||
|
||||
export interface LogoutEvent {
|
||||
type: "LOGOUT";
|
||||
@ -37,63 +37,54 @@ interface PreviousChannel {
|
||||
channelId: string | null;
|
||||
}
|
||||
|
||||
let isSwitchingAccount = false;
|
||||
let previousCache: PreviousChannel | undefined;
|
||||
|
||||
function attemptToNavigateToChannel(guildId: string | null, channelId: string) {
|
||||
if (!ChannelStore.hasChannel(channelId)) return;
|
||||
NavigationRouter.transitionTo(`/channels/${guildId ?? "@me"}/${channelId}`);
|
||||
}
|
||||
|
||||
export default definePlugin({
|
||||
name: "KeepCurrentChannel",
|
||||
description: "Attempt to navigate to the channel you were in before switching accounts or loading Discord.",
|
||||
authors: [Devs.Nuckyz],
|
||||
|
||||
isSwitchingAccount: false,
|
||||
previousCache: {} as PreviousChannel,
|
||||
flux: {
|
||||
LOGOUT(e: LogoutEvent) {
|
||||
({ isSwitchingAccount } = e);
|
||||
},
|
||||
|
||||
attemptToNavigateToChannel(guildId: string | null, channelId: string) {
|
||||
if (!ChannelStore.hasChannel(channelId)) return;
|
||||
NavigationRouter.transitionTo(`/channels/${guildId ?? "@me"}/${channelId}`);
|
||||
},
|
||||
CONNECTION_OPEN() {
|
||||
if (!isSwitchingAccount) return;
|
||||
isSwitchingAccount = false;
|
||||
|
||||
onLogout(e: LogoutEvent) {
|
||||
this.isSwitchingAccount = e.isSwitchingAccount;
|
||||
},
|
||||
if (previousCache?.channelId)
|
||||
attemptToNavigateToChannel(previousCache.guildId, previousCache.channelId);
|
||||
},
|
||||
|
||||
onConnectionOpen() {
|
||||
if (!this.isSwitchingAccount) return;
|
||||
this.isSwitchingAccount = false;
|
||||
async CHANNEL_SELECT({ guildId, channelId }: ChannelSelectEvent) {
|
||||
if (isSwitchingAccount) return;
|
||||
|
||||
if (this.previousCache.channelId) this.attemptToNavigateToChannel(this.previousCache.guildId, this.previousCache.channelId);
|
||||
},
|
||||
|
||||
async onChannelSelect({ guildId, channelId }: ChannelSelectEvent) {
|
||||
if (this.isSwitchingAccount) return;
|
||||
|
||||
this.previousCache = {
|
||||
guildId,
|
||||
channelId
|
||||
};
|
||||
await DataStore.set("KeepCurrentChannel_previousData", this.previousCache);
|
||||
previousCache = {
|
||||
guildId,
|
||||
channelId
|
||||
};
|
||||
await DataStore.set("KeepCurrentChannel_previousData", previousCache);
|
||||
}
|
||||
},
|
||||
|
||||
async start() {
|
||||
const previousData = await DataStore.get<PreviousChannel>("KeepCurrentChannel_previousData");
|
||||
if (previousData) {
|
||||
this.previousCache = previousData;
|
||||
|
||||
if (this.previousCache.channelId) this.attemptToNavigateToChannel(this.previousCache.guildId, this.previousCache.channelId);
|
||||
} else {
|
||||
this.previousCache = {
|
||||
previousCache = await DataStore.get<PreviousChannel>("KeepCurrentChannel_previousData");
|
||||
if (!previousCache) {
|
||||
previousCache = {
|
||||
guildId: SelectedGuildStore.getGuildId(),
|
||||
channelId: SelectedChannelStore.getChannelId() ?? null
|
||||
};
|
||||
await DataStore.set("KeepCurrentChannel_previousData", this.previousCache);
|
||||
|
||||
await DataStore.set("KeepCurrentChannel_previousData", previousCache);
|
||||
} else if (previousCache.channelId) {
|
||||
attemptToNavigateToChannel(previousCache.guildId, previousCache.channelId);
|
||||
}
|
||||
|
||||
FluxDispatcher.subscribe("LOGOUT", this.onLogout.bind(this));
|
||||
FluxDispatcher.subscribe("CONNECTION_OPEN", this.onConnectionOpen.bind(this));
|
||||
FluxDispatcher.subscribe("CHANNEL_SELECT", this.onChannelSelect.bind(this));
|
||||
},
|
||||
|
||||
stop() {
|
||||
FluxDispatcher.unsubscribe("LOGOUT", this.onLogout);
|
||||
FluxDispatcher.unsubscribe("CONNECTION_OPEN", this.onConnectionOpen);
|
||||
FluxDispatcher.unsubscribe("CHANNEL_SELECT", this.onChannelSelect);
|
||||
}
|
||||
});
|
||||
|
@ -23,7 +23,7 @@ import { getCurrentChannel } from "@utils/discord";
|
||||
import { useForceUpdater } from "@utils/misc";
|
||||
import definePlugin from "@utils/types";
|
||||
import { findStoreLazy } from "@webpack";
|
||||
import { FluxDispatcher, Tooltip } from "@webpack/common";
|
||||
import { Tooltip } from "@webpack/common";
|
||||
|
||||
const counts = {} as Record<string, [number, number]>;
|
||||
let forceUpdate: () => void;
|
||||
@ -107,27 +107,21 @@ export default definePlugin({
|
||||
}
|
||||
}],
|
||||
|
||||
onGuildMemberListUpdate({ guildId, groups, memberCount, id }) {
|
||||
// eeeeeh - sometimes it has really wrong counts??? like 10 times less than actual
|
||||
// but if we only listen to everyone updates, sometimes we never get the count?
|
||||
// this seems to work but isn't optional
|
||||
if (id !== "everyone" && counts[guildId]) return;
|
||||
flux: {
|
||||
GUILD_MEMBER_LIST_UPDATE({ guildId, groups, memberCount, id }) {
|
||||
// eeeeeh - sometimes it has really wrong counts??? like 10 times less than actual
|
||||
// but if we only listen to everyone updates, sometimes we never get the count?
|
||||
// this seems to work but isn't optional
|
||||
if (id !== "everyone" && counts[guildId]) return;
|
||||
|
||||
let count = 0;
|
||||
for (const group of groups) {
|
||||
if (group.id !== "offline")
|
||||
count += group.count;
|
||||
let count = 0;
|
||||
for (const group of groups) {
|
||||
if (group.id !== "offline")
|
||||
count += group.count;
|
||||
}
|
||||
counts[guildId] = [memberCount, count];
|
||||
forceUpdate?.();
|
||||
}
|
||||
counts[guildId] = [memberCount, count];
|
||||
forceUpdate?.();
|
||||
},
|
||||
|
||||
start() {
|
||||
FluxDispatcher.subscribe("GUILD_MEMBER_LIST_UPDATE", this.onGuildMemberListUpdate);
|
||||
},
|
||||
|
||||
stop() {
|
||||
FluxDispatcher.unsubscribe("GUILD_MEMBER_LIST_UPDATE", this.onGuildMemberListUpdate);
|
||||
},
|
||||
|
||||
render: () => (
|
||||
|
@ -17,7 +17,6 @@
|
||||
*/
|
||||
|
||||
import { addClickListener, removeClickListener } from "@api/MessageEvents";
|
||||
import { migratePluginSettings } from "@api/settings";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { findByPropsLazy } from "@webpack";
|
||||
@ -29,8 +28,6 @@ const keyup = (e: KeyboardEvent) => e.key === "Backspace" && (isDeletePressed =
|
||||
|
||||
const MANAGE_CHANNELS = 1n << 4n;
|
||||
|
||||
migratePluginSettings("MessageClickActions", "MessageQuickActions");
|
||||
|
||||
export default definePlugin({
|
||||
name: "MessageClickActions",
|
||||
description: "Hold Backspace and click to delete, double click to edit",
|
||||
|
@ -51,7 +51,7 @@ const SearchResultClasses = findByPropsLazy("message", "searchResult");
|
||||
let AutoModEmbed: React.ComponentType<any> = () => null;
|
||||
|
||||
const messageLinkRegex = /(?<!<)https?:\/\/(?:\w+\.)?discord(?:app)?\.com\/channels\/(\d{17,20}|@me)\/(\d{17,20})\/(\d{17,20})/g;
|
||||
const tenorRegex = /https:\/\/(?:www.)?tenor\.com/;
|
||||
const tenorRegex = /^https:\/\/(?:www\.)?tenor\.com\//;
|
||||
|
||||
interface Attachment {
|
||||
height: number;
|
||||
|
@ -51,11 +51,28 @@ const patchMessageContextMenu: NavContextMenuPatchCallback = (children, props) =
|
||||
|
||||
if (!deleted && !editHistory?.length) return;
|
||||
|
||||
toggle: {
|
||||
if (!deleted) break toggle;
|
||||
|
||||
const domElement = document.getElementById(`chat-messages-${channel_id}-${id}`);
|
||||
if (!domElement) break toggle;
|
||||
|
||||
children.push((
|
||||
<Menu.MenuItem
|
||||
id={TOGGLE_DELETE_STYLE_ID}
|
||||
key={TOGGLE_DELETE_STYLE_ID}
|
||||
label="Toggle Deleted Highlight"
|
||||
action={() => domElement.classList.toggle("messagelogger-deleted")}
|
||||
/>
|
||||
));
|
||||
}
|
||||
|
||||
children.push((
|
||||
<Menu.MenuItem
|
||||
id={REMOVE_HISTORY_ID}
|
||||
key={REMOVE_HISTORY_ID}
|
||||
label="Remove Message History"
|
||||
color="danger"
|
||||
action={() => {
|
||||
if (deleted) {
|
||||
FluxDispatcher.dispatch({
|
||||
@ -70,20 +87,6 @@ const patchMessageContextMenu: NavContextMenuPatchCallback = (children, props) =
|
||||
}}
|
||||
/>
|
||||
));
|
||||
|
||||
if (!deleted) return;
|
||||
|
||||
const domElement = document.getElementById(`chat-messages-${channel_id}-${id}`);
|
||||
if (!domElement) return;
|
||||
|
||||
children.push((
|
||||
<Menu.MenuItem
|
||||
id={TOGGLE_DELETE_STYLE_ID}
|
||||
key={TOGGLE_DELETE_STYLE_ID}
|
||||
label="Toggle Deleted Highlight"
|
||||
action={() => domElement.classList.toggle("messagelogger-deleted")}
|
||||
/>
|
||||
));
|
||||
};
|
||||
|
||||
export default definePlugin({
|
||||
|
@ -17,11 +17,9 @@
|
||||
*/
|
||||
|
||||
import { findOption, OptionalMessageOption } from "@api/Commands";
|
||||
import { migratePluginSettings } from "@api/settings";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
|
||||
migratePluginSettings("MoreKaomoji", "moarKaomojis");
|
||||
export default definePlugin({
|
||||
name: "MoreKaomoji",
|
||||
description: "Adds more Kaomoji to discord. ヽ(´▽`)/",
|
||||
|
@ -21,7 +21,7 @@ import { makeRange } from "@components/PluginSettings/components/SettingSliderCo
|
||||
import { Devs } from "@utils/constants";
|
||||
import { sleep } from "@utils/misc";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { FluxDispatcher, SelectedChannelStore, UserStore } from "@webpack/common";
|
||||
import { SelectedChannelStore, UserStore } from "@webpack/common";
|
||||
import { Message, ReactionEmoji } from "discord-types/general";
|
||||
|
||||
interface IMessageCreate {
|
||||
@ -80,50 +80,40 @@ export default definePlugin({
|
||||
description: "🗿🗿🗿🗿🗿🗿🗿🗿",
|
||||
settings,
|
||||
|
||||
async onMessage(e: IMessageCreate) {
|
||||
if (e.optimistic || e.type !== "MESSAGE_CREATE") return;
|
||||
if (e.message.state === "SENDING") return;
|
||||
if (settings.store.ignoreBots && e.message.author?.bot) return;
|
||||
if (!e.message.content) return;
|
||||
if (e.channelId !== SelectedChannelStore.getChannelId()) return;
|
||||
flux: {
|
||||
async MESSAGE_CREATE({ optimistic, type, message, channelId }: IMessageCreate) {
|
||||
if (optimistic || type !== "MESSAGE_CREATE") return;
|
||||
if (message.state === "SENDING") return;
|
||||
if (settings.store.ignoreBots && message.author?.bot) return;
|
||||
if (!message.content) return;
|
||||
if (channelId !== SelectedChannelStore.getChannelId()) return;
|
||||
|
||||
const moyaiCount = getMoyaiCount(e.message.content);
|
||||
const moyaiCount = getMoyaiCount(message.content);
|
||||
|
||||
for (let i = 0; i < moyaiCount; i++) {
|
||||
boom();
|
||||
await sleep(300);
|
||||
}
|
||||
},
|
||||
|
||||
MESSAGE_REACTION_ADD({ optimistic, type, channelId, userId, emoji }: IReactionAdd) {
|
||||
if (optimistic || type !== "MESSAGE_REACTION_ADD") return;
|
||||
if (settings.store.ignoreBots && UserStore.getUser(userId)?.bot) return;
|
||||
if (channelId !== SelectedChannelStore.getChannelId()) return;
|
||||
|
||||
const name = emoji.name.toLowerCase();
|
||||
if (name !== MOYAI && !name.includes("moyai") && !name.includes("moai")) return;
|
||||
|
||||
boom();
|
||||
},
|
||||
|
||||
VOICE_CHANNEL_EFFECT_SEND({ emoji }: IVoiceChannelEffectSendEvent) {
|
||||
if (!emoji?.name) return;
|
||||
const name = emoji.name.toLowerCase();
|
||||
if (name !== MOYAI && !name.includes("moyai") && !name.includes("moai")) return;
|
||||
|
||||
for (let i = 0; i < moyaiCount; i++) {
|
||||
boom();
|
||||
await sleep(300);
|
||||
}
|
||||
},
|
||||
|
||||
onReaction(e: IReactionAdd) {
|
||||
if (e.optimistic || e.type !== "MESSAGE_REACTION_ADD") return;
|
||||
if (settings.store.ignoreBots && UserStore.getUser(e.userId)?.bot) return;
|
||||
if (e.channelId !== SelectedChannelStore.getChannelId()) return;
|
||||
|
||||
const name = e.emoji.name.toLowerCase();
|
||||
if (name !== MOYAI && !name.includes("moyai") && !name.includes("moai")) return;
|
||||
|
||||
boom();
|
||||
},
|
||||
|
||||
onVoiceChannelEffect(e: IVoiceChannelEffectSendEvent) {
|
||||
if (!e.emoji?.name) return;
|
||||
const name = e.emoji.name.toLowerCase();
|
||||
if (name !== MOYAI && !name.includes("moyai") && !name.includes("moai")) return;
|
||||
|
||||
boom();
|
||||
},
|
||||
|
||||
start() {
|
||||
FluxDispatcher.subscribe("MESSAGE_CREATE", this.onMessage);
|
||||
FluxDispatcher.subscribe("MESSAGE_REACTION_ADD", this.onReaction);
|
||||
FluxDispatcher.subscribe("VOICE_CHANNEL_EFFECT_SEND", this.onVoiceChannelEffect);
|
||||
},
|
||||
|
||||
stop() {
|
||||
FluxDispatcher.unsubscribe("MESSAGE_CREATE", this.onMessage);
|
||||
FluxDispatcher.unsubscribe("MESSAGE_REACTION_ADD", this.onReaction);
|
||||
FluxDispatcher.unsubscribe("VOICE_CHANNEL_EFFECT_SEND", this.onVoiceChannelEffect);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -16,9 +16,10 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { definePluginSettings } from "@api/settings";
|
||||
import { Devs } from "@utils/constants";
|
||||
import { ModalContent, ModalFooter, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal";
|
||||
import definePlugin from "@utils/types";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { findByProps, findStoreLazy } from "@webpack";
|
||||
import { Button, Text } from "@webpack/common";
|
||||
|
||||
@ -49,10 +50,28 @@ function NoDMNotificationsModal({ modalProps }: { modalProps: ModalProps; }) {
|
||||
);
|
||||
}
|
||||
|
||||
const settings = definePluginSettings({
|
||||
guild: {
|
||||
description: "Mute Guild",
|
||||
type: OptionType.BOOLEAN,
|
||||
default: true
|
||||
},
|
||||
everyone: {
|
||||
description: "Suppress @everyone and @here",
|
||||
type: OptionType.BOOLEAN,
|
||||
default: true
|
||||
},
|
||||
role: {
|
||||
description: "Suppress All Role @mentions",
|
||||
type: OptionType.BOOLEAN,
|
||||
default: true
|
||||
},
|
||||
});
|
||||
|
||||
export default definePlugin({
|
||||
name: "MuteNewGuild",
|
||||
description: "Mutes newly joined guilds",
|
||||
authors: [Devs.Glitch, Devs.Nuckyz],
|
||||
authors: [Devs.Glitch, Devs.Nuckyz, Devs.carince],
|
||||
patches: [
|
||||
{
|
||||
find: ",acceptInvite:function",
|
||||
@ -62,10 +81,17 @@ export default definePlugin({
|
||||
}
|
||||
}
|
||||
],
|
||||
settings,
|
||||
|
||||
handleMute(guildId: string | null) {
|
||||
if (guildId === "@me" || guildId === "null" || guildId == null) return;
|
||||
findByProps("updateGuildNotificationSettings").updateGuildNotificationSettings(guildId, { muted: true, suppress_everyone: true, suppress_roles: true });
|
||||
findByProps("updateGuildNotificationSettings").updateGuildNotificationSettings(guildId,
|
||||
{
|
||||
muted: settings.store.guild,
|
||||
suppress_everyone: settings.store.everyone,
|
||||
suppress_roles: settings.store.role
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
start() {
|
||||
|
@ -16,12 +16,9 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { migratePluginSettings } from "@api/settings";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
|
||||
migratePluginSettings("NoDevtoolsWarning", "STFU");
|
||||
|
||||
export default definePlugin({
|
||||
name: "NoDevtoolsWarning",
|
||||
description: "Disables the 'HOLD UP' banner in the console. As a side effect, also prevents Discord from hiding your token, which prevents random logouts.",
|
||||
|
@ -16,11 +16,9 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { migratePluginSettings } from "@api/settings";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
|
||||
migratePluginSettings("NoF1", "No F1");
|
||||
export default definePlugin({
|
||||
name: "NoF1",
|
||||
description: "Disables F1 help bind.",
|
||||
|
@ -16,11 +16,9 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { migratePluginSettings } from "@api/settings";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
|
||||
migratePluginSettings("NoRPC", "No RPC");
|
||||
export default definePlugin({
|
||||
name: "NoRPC",
|
||||
description: "Disables Discord's RPC server.",
|
||||
|
@ -21,7 +21,7 @@ import definePlugin from "@utils/types";
|
||||
import { Channel } from "discord-types/general";
|
||||
|
||||
import { addContextMenus, removeContextMenus } from "./contextMenus";
|
||||
import { getPinAt, isPinned, settings, snapshotArray, usePinnedDms } from "./settings";
|
||||
import { getPinAt, isPinned, settings, snapshotArray, sortedSnapshot, usePinnedDms } from "./settings";
|
||||
|
||||
export default definePlugin({
|
||||
name: "PinDMs",
|
||||
@ -44,7 +44,7 @@ export default definePlugin({
|
||||
},
|
||||
|
||||
isPinned,
|
||||
getSnapshot: () => snapshotArray,
|
||||
getSnapshot: sortedSnapshot,
|
||||
|
||||
getScrollOffset(channelId: string, rowHeight: number, padding: number, preRenderedChildren: number, originalOffset: number) {
|
||||
if (!isPinned(channelId))
|
||||
|
@ -71,7 +71,7 @@ export function togglePin(id: string) {
|
||||
save([...snapshot]);
|
||||
}
|
||||
|
||||
function sortedSnapshot() {
|
||||
export function sortedSnapshot() {
|
||||
requireSnapshot();
|
||||
if (settings.store.pinOrder === PinOrder.LastMessage)
|
||||
return PrivateChannelSortStore.getPrivateChannelIds().filter(isPinned);
|
||||
|
@ -112,7 +112,7 @@ const PlatformIndicator = ({ user, inline = false, marginLeft = "4px" }: { user:
|
||||
gap: "4px",
|
||||
display: inline ? "inline-flex" : "flex",
|
||||
alignItems: "center",
|
||||
transform: inline ? "translateY(4px)" : undefined
|
||||
translate: inline ? "0 3px 0" : undefined
|
||||
}}
|
||||
>
|
||||
{icons}
|
||||
|
@ -16,66 +16,59 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Settings } from "@api/settings";
|
||||
import { classes } from "@utils/misc";
|
||||
import { findByPropsLazy } from "@webpack";
|
||||
import { UserStore } from "@webpack/common";
|
||||
import { Message } from "discord-types/general";
|
||||
|
||||
import { awaitAndFormatPronouns } from "../pronoundbUtils";
|
||||
import { useFormattedPronouns } from "../pronoundbUtils";
|
||||
import { settings } from "../settings";
|
||||
|
||||
const styles: Record<string, string> = findByPropsLazy("timestampInline");
|
||||
|
||||
function shouldShow(message: Message): boolean {
|
||||
// Respect showInMessages
|
||||
if (!Settings.plugins.PronounDB.showInMessages)
|
||||
if (!settings.store.showInMessages)
|
||||
return false;
|
||||
// Don't bother fetching bot or system users
|
||||
if (message.author.bot || message.author.system)
|
||||
return false;
|
||||
// Respect showSelf options
|
||||
if (!Settings.plugins.PronounDB.showSelf && message.author.id === UserStore.getCurrentUser().id)
|
||||
if (!settings.store.showSelf && message.author.id === UserStore.getCurrentUser().id)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
export function PronounsChatComponentWrapper({ message }: { message: Message; }) {
|
||||
if (!shouldShow(message))
|
||||
return null;
|
||||
|
||||
return <PronounsChatComponent message={message} />;
|
||||
return shouldShow(message)
|
||||
? <PronounsChatComponent message={message} />
|
||||
: null;
|
||||
}
|
||||
|
||||
export function CompactPronounsChatComponentWrapper({ message }: { message: Message; }) {
|
||||
if (!shouldShow(message))
|
||||
return null;
|
||||
|
||||
return <CompactPronounsChatComponent message={message} />;
|
||||
return shouldShow(message)
|
||||
? <CompactPronounsChatComponent message={message} />
|
||||
: null;
|
||||
}
|
||||
|
||||
function PronounsChatComponent({ message }: { message: Message; }) {
|
||||
const result = awaitAndFormatPronouns(message.author.id);
|
||||
if (result != null) {
|
||||
return (
|
||||
const result = useFormattedPronouns(message.author.id);
|
||||
|
||||
return result
|
||||
? (
|
||||
<span
|
||||
className={classes(styles.timestampInline, styles.timestamp)}
|
||||
>• {result}</span>
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
)
|
||||
: null;
|
||||
}
|
||||
|
||||
export function CompactPronounsChatComponent({ message }: { message: Message; }) {
|
||||
const result = awaitAndFormatPronouns(message.author.id);
|
||||
if (result != null) {
|
||||
return (
|
||||
const result = useFormattedPronouns(message.author.id);
|
||||
|
||||
return result
|
||||
? (
|
||||
<span
|
||||
className={classes(styles.timestampInline, styles.timestamp, "vc-pronoundb-compact")}
|
||||
>• {result}</span>
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
)
|
||||
: null;
|
||||
}
|
||||
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Vencord, a modification for Discord's desktop app
|
||||
* Copyright (c) 2022 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Settings } from "@api/settings";
|
||||
import { UserStore } from "@webpack/common";
|
||||
|
||||
import { awaitAndFormatPronouns } from "../pronoundbUtils";
|
||||
import { UserProfilePronounsProps, UserProfileProps } from "../types";
|
||||
|
||||
export default function PronounsProfileWrapper(PronounsComponent: React.ElementType<UserProfilePronounsProps>, props: UserProfilePronounsProps, profileProps: UserProfileProps) {
|
||||
const user = UserStore.getUser(profileProps.userId) ?? {};
|
||||
// Respect showInProfile
|
||||
if (!Settings.plugins.PronounDB.showInProfile)
|
||||
return null;
|
||||
// Don't bother fetching bot or system users
|
||||
if (user.bot || user.system)
|
||||
return null;
|
||||
// Respect showSelf options
|
||||
if (!Settings.plugins.PronounDB.showSelf && user.id === UserStore.getCurrentUser().id)
|
||||
return null;
|
||||
|
||||
return <ProfilePronouns
|
||||
userId={profileProps.userId}
|
||||
Component={PronounsComponent}
|
||||
leProps={props}
|
||||
/>;
|
||||
}
|
||||
|
||||
function ProfilePronouns(
|
||||
{ userId, Component, leProps }: {
|
||||
userId: string;
|
||||
Component: React.ElementType<UserProfilePronounsProps>;
|
||||
leProps: UserProfilePronounsProps;
|
||||
}
|
||||
) {
|
||||
const result = awaitAndFormatPronouns(userId);
|
||||
|
||||
// If the promise completed, the result was not "unspecified", and there is a mapping for the code, then render
|
||||
if (result != null) {
|
||||
// First child is the header, second is a div with the actual text
|
||||
leProps.currentPronouns ||= result;
|
||||
return <Component {...leProps} />;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
@ -19,20 +19,16 @@
|
||||
import "./styles.css";
|
||||
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import definePlugin from "@utils/types";
|
||||
|
||||
import PronounsAboutComponent from "./components/PronounsAboutComponent";
|
||||
import { CompactPronounsChatComponentWrapper, PronounsChatComponentWrapper } from "./components/PronounsChatComponent";
|
||||
import PronounsProfileWrapper from "./components/PronounsProfileWrapper";
|
||||
|
||||
export enum PronounsFormat {
|
||||
Lowercase = "LOWERCASE",
|
||||
Capitalized = "CAPITALIZED"
|
||||
}
|
||||
import { useProfilePronouns } from "./pronoundbUtils";
|
||||
import { settings } from "./settings";
|
||||
|
||||
export default definePlugin({
|
||||
name: "PronounDB",
|
||||
authors: [Devs.Tyman, Devs.TheKodeToad],
|
||||
authors: [Devs.Tyman, Devs.TheKodeToad, Devs.Ven],
|
||||
description: "Adds pronouns to user messages using pronoundb",
|
||||
patches: [
|
||||
// Add next to username (compact mode)
|
||||
@ -51,59 +47,30 @@ export default definePlugin({
|
||||
replace: "[$1, $self.PronounsChatComponentWrapper(e)]"
|
||||
}
|
||||
},
|
||||
// Hijack the discord pronouns section and add a wrapper around the text section
|
||||
// Patch the profile popout username header to use our pronoun hook instead of Discord's pronouns
|
||||
{
|
||||
find: ".Messages.BOT_PROFILE_SLASH_COMMANDS",
|
||||
find: ".userTagNoNickname",
|
||||
replacement: {
|
||||
match: /\(0,.\.jsx\)\((?<PronounComponent>\i\..),(?<pronounProps>{currentPronouns.+?:(?<fullProps>\i)\.pronouns.+?})\)/,
|
||||
replace: "$<fullProps>&&$self.PronounsProfileWrapper($<PronounComponent>,$<pronounProps>,$<fullProps>)"
|
||||
match: /=(\i)\.pronouns/,
|
||||
replace: "=$self.useProfilePronouns($1.user.id)"
|
||||
}
|
||||
},
|
||||
// Force enable pronouns component ignoring the experiment value
|
||||
// Patch the profile modal username header to use our pronoun hook instead of Discord's pronouns
|
||||
{
|
||||
find: ".Messages.USER_POPOUT_PRONOUNS",
|
||||
find: ".USER_PROFILE_ACTIVITY",
|
||||
replacement: {
|
||||
match: /\.showPronouns/,
|
||||
replace: ".showPronouns||true"
|
||||
match: /\).showPronouns/,
|
||||
replace: ").showPronouns||true;const vcPronounce=$self.useProfilePronouns(arguments[0].user.id);if(arguments[0].displayProfile)arguments[0].displayProfile.pronouns=vcPronounce"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
options: {
|
||||
pronounsFormat: {
|
||||
type: OptionType.SELECT,
|
||||
description: "The format for pronouns to appear in chat",
|
||||
options: [
|
||||
{
|
||||
label: "Lowercase",
|
||||
value: PronounsFormat.Lowercase,
|
||||
default: true
|
||||
},
|
||||
{
|
||||
label: "Capitalized",
|
||||
value: PronounsFormat.Capitalized
|
||||
}
|
||||
]
|
||||
},
|
||||
showSelf: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Enable or disable showing pronouns for the current user",
|
||||
default: true
|
||||
},
|
||||
showInMessages: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Show in messages",
|
||||
default: true
|
||||
},
|
||||
showInProfile: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Show in profile",
|
||||
default: true
|
||||
}
|
||||
},
|
||||
settings,
|
||||
|
||||
settingsAboutComponent: PronounsAboutComponent,
|
||||
|
||||
// Re-export the components on the plugin object so it is easily accessible in patches
|
||||
PronounsChatComponentWrapper,
|
||||
CompactPronounsChatComponentWrapper,
|
||||
PronounsProfileWrapper
|
||||
useProfilePronouns
|
||||
});
|
||||
|
@ -20,10 +20,16 @@ import { Settings } from "@api/settings";
|
||||
import { VENCORD_USER_AGENT } from "@utils/constants";
|
||||
import { debounce } from "@utils/debounce";
|
||||
import { useAwaiter } from "@utils/misc";
|
||||
import { UserStore } from "@webpack/common";
|
||||
|
||||
import { PronounsFormat } from ".";
|
||||
import { settings } from "./settings";
|
||||
import { PronounCode, PronounMapping, PronounsResponse } from "./types";
|
||||
|
||||
export const enum PronounsFormat {
|
||||
Lowercase = "LOWERCASE",
|
||||
Capitalized = "CAPITALIZED"
|
||||
}
|
||||
|
||||
// A map of cached pronouns so the same request isn't sent twice
|
||||
const cache: Record<string, PronounCode> = {};
|
||||
// A map of ids and callbacks that should be triggered on fetch
|
||||
@ -40,8 +46,8 @@ const bulkFetch = debounce(async () => {
|
||||
}
|
||||
});
|
||||
|
||||
export function awaitAndFormatPronouns(id: string): string | null {
|
||||
const [result, , isPending] = useAwaiter(() => fetchPronouns(id), {
|
||||
export function useFormattedPronouns(id: string): string | null {
|
||||
const [result] = useAwaiter(() => fetchPronouns(id), {
|
||||
fallbackValue: getCachedPronouns(id),
|
||||
onError: e => console.error("Fetching pronouns failed: ", e)
|
||||
});
|
||||
@ -53,6 +59,16 @@ export function awaitAndFormatPronouns(id: string): string | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
export function useProfilePronouns(id: string) {
|
||||
const pronouns = useFormattedPronouns(id);
|
||||
|
||||
if (!settings.store.showInProfile) return null;
|
||||
if (!settings.store.showSelf && id === UserStore.getCurrentUser().id) return null;
|
||||
|
||||
return pronouns;
|
||||
}
|
||||
|
||||
|
||||
// Gets the cached pronouns, if you're too impatient for a promise!
|
||||
export function getCachedPronouns(id: string): PronounCode | null {
|
||||
return cache[id] ?? null;
|
||||
|
55
src/plugins/pronoundb/settings.ts
Normal file
55
src/plugins/pronoundb/settings.ts
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { definePluginSettings } from "@api/settings";
|
||||
import { OptionType } from "@utils/types";
|
||||
|
||||
import { PronounsFormat } from "./pronoundbUtils";
|
||||
|
||||
export const settings = definePluginSettings({
|
||||
pronounsFormat: {
|
||||
type: OptionType.SELECT,
|
||||
description: "The format for pronouns to appear in chat",
|
||||
options: [
|
||||
{
|
||||
label: "Lowercase",
|
||||
value: PronounsFormat.Lowercase,
|
||||
default: true
|
||||
},
|
||||
{
|
||||
label: "Capitalized",
|
||||
value: PronounsFormat.Capitalized
|
||||
}
|
||||
]
|
||||
},
|
||||
showSelf: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Enable or disable showing pronouns for the current user",
|
||||
default: true
|
||||
},
|
||||
showInMessages: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Show in messages",
|
||||
default: true
|
||||
},
|
||||
showInProfile: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Show in profile",
|
||||
default: true
|
||||
}
|
||||
});
|
@ -18,8 +18,9 @@
|
||||
|
||||
import { addButton, removeButton } from "@api/MessagePopover";
|
||||
import { Devs } from "@utils/constants";
|
||||
import { insertTextIntoChatInputBox } from "@utils/discord";
|
||||
import definePlugin from "@utils/types";
|
||||
import { ChannelStore, ComponentDispatch } from "@webpack/common";
|
||||
import { ChannelStore } from "@webpack/common";
|
||||
|
||||
export default definePlugin({
|
||||
name: "QuickMention",
|
||||
@ -34,7 +35,7 @@ export default definePlugin({
|
||||
icon: this.Icon,
|
||||
message: msg,
|
||||
channel: ChannelStore.getChannel(msg.channel_id),
|
||||
onClick: () => ComponentDispatch.dispatchToLastSubscribed("INSERT_TEXT", { rawText: `<@${msg.author.id}> ` })
|
||||
onClick: () => insertTextIntoChatInputBox(`<@${msg.author.id}> `)
|
||||
};
|
||||
});
|
||||
},
|
||||
|
@ -16,7 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { definePluginSettings, migratePluginSettings, Settings } from "@api/settings";
|
||||
import { definePluginSettings, Settings } from "@api/settings";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { findByPropsLazy } from "@webpack";
|
||||
@ -29,7 +29,6 @@ const isMac = navigator.platform.includes("Mac"); // bruh
|
||||
let replyIdx = -1;
|
||||
let editIdx = -1;
|
||||
|
||||
migratePluginSettings("QuickReply", "InteractionKeybinds");
|
||||
|
||||
const enum MentionOptions {
|
||||
DISABLED,
|
||||
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { FluxEvents } from "@webpack/types";
|
||||
|
||||
import { onChannelDelete, onGuildDelete, onRelationshipRemove } from "./functions";
|
||||
import { syncFriends, syncGroups, syncGuilds } from "./utils";
|
||||
|
||||
export const FluxHandlers: Partial<Record<FluxEvents, Array<(data: any) => void>>> = {
|
||||
GUILD_CREATE: [syncGuilds],
|
||||
GUILD_DELETE: [onGuildDelete],
|
||||
CHANNEL_CREATE: [syncGroups],
|
||||
CHANNEL_DELETE: [onChannelDelete],
|
||||
RELATIONSHIP_ADD: [syncFriends],
|
||||
RELATIONSHIP_UPDATE: [syncFriends],
|
||||
RELATIONSHIP_REMOVE: [syncFriends, onRelationshipRemove]
|
||||
};
|
||||
|
||||
export function forEachEvent(fn: (event: FluxEvents, handler: (data: any) => void) => void) {
|
||||
for (const event in FluxHandlers) {
|
||||
for (const cb of FluxHandlers[event]) {
|
||||
fn(event as FluxEvents, cb);
|
||||
}
|
||||
}
|
||||
}
|
@ -18,12 +18,10 @@
|
||||
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
import { FluxDispatcher } from "@webpack/common";
|
||||
|
||||
import { forEachEvent } from "./events";
|
||||
import { removeFriend, removeGroup, removeGuild } from "./functions";
|
||||
import { onChannelDelete, onGuildDelete, onRelationshipRemove, removeFriend, removeGroup, removeGuild } from "./functions";
|
||||
import settings from "./settings";
|
||||
import { syncAndRunChecks } from "./utils";
|
||||
import { syncAndRunChecks, syncFriends, syncGroups, syncGuilds } from "./utils";
|
||||
|
||||
export default definePlugin({
|
||||
name: "RelationshipNotifier",
|
||||
@ -55,15 +53,24 @@ export default definePlugin({
|
||||
}
|
||||
],
|
||||
|
||||
flux: {
|
||||
GUILD_CREATE: syncGuilds,
|
||||
GUILD_DELETE: onGuildDelete,
|
||||
CHANNEL_CREATE: syncGroups,
|
||||
CHANNEL_DELETE: onChannelDelete,
|
||||
RELATIONSHIP_ADD: syncFriends,
|
||||
RELATIONSHIP_UPDATE: syncFriends,
|
||||
RELATIONSHIP_REMOVE(e) {
|
||||
onRelationshipRemove(e);
|
||||
syncFriends();
|
||||
},
|
||||
CONNECTION_OPEN: syncAndRunChecks
|
||||
},
|
||||
|
||||
async start() {
|
||||
setTimeout(() => {
|
||||
syncAndRunChecks();
|
||||
}, 5000);
|
||||
forEachEvent((ev, cb) => FluxDispatcher.subscribe(ev, cb));
|
||||
},
|
||||
|
||||
stop() {
|
||||
forEachEvent((ev, cb) => FluxDispatcher.unsubscribe(ev, cb));
|
||||
},
|
||||
|
||||
removeFriend,
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
import { DataStore, Notices } from "@api/index";
|
||||
import { showNotification } from "@api/Notifications";
|
||||
import { ChannelStore, GuildStore, RelationshipStore, UserUtils } from "@webpack/common";
|
||||
import { ChannelStore, GuildStore, RelationshipStore, UserStore, UserUtils } from "@webpack/common";
|
||||
|
||||
import settings from "./settings";
|
||||
import { ChannelType, RelationshipType, SimpleGroupChannel, SimpleGuild } from "./types";
|
||||
@ -30,11 +30,20 @@ const friends = {
|
||||
requests: [] as string[]
|
||||
};
|
||||
|
||||
const guildsKey = () => `relationship-notifier-guilds-${UserStore.getCurrentUser().id}`;
|
||||
const groupsKey = () => `relationship-notifier-groups-${UserStore.getCurrentUser().id}`;
|
||||
const friendsKey = () => `relationship-notifier-friends-${UserStore.getCurrentUser().id}`;
|
||||
|
||||
async function runMigrations() {
|
||||
DataStore.delMany(["relationship-notifier-guilds", "relationship-notifier-groups", "relationship-notifier-friends"]);
|
||||
}
|
||||
|
||||
export async function syncAndRunChecks() {
|
||||
await runMigrations();
|
||||
const [oldGuilds, oldGroups, oldFriends] = await DataStore.getMany([
|
||||
"relationship-notifier-guilds",
|
||||
"relationship-notifier-groups",
|
||||
"relationship-notifier-friends"
|
||||
guildsKey(),
|
||||
groupsKey(),
|
||||
friendsKey()
|
||||
]) as [Map<string, SimpleGuild> | undefined, Map<string, SimpleGroupChannel> | undefined, Record<"friends" | "requests", string[]> | undefined];
|
||||
|
||||
await Promise.all([syncGuilds(), syncGroups(), syncFriends()]);
|
||||
@ -104,7 +113,7 @@ export async function syncGuilds() {
|
||||
iconURL: icon && `https://cdn.discordapp.com/icons/${id}/${icon}.png`
|
||||
});
|
||||
}
|
||||
await DataStore.set("relationship-notifier-guilds", guilds);
|
||||
await DataStore.set(guildsKey(), guilds);
|
||||
}
|
||||
|
||||
export function getGroup(id: string) {
|
||||
@ -126,7 +135,7 @@ export async function syncGroups() {
|
||||
});
|
||||
}
|
||||
|
||||
await DataStore.set("relationship-notifier-groups", groups);
|
||||
await DataStore.set(groupsKey(), groups);
|
||||
}
|
||||
|
||||
export async function syncFriends() {
|
||||
@ -145,5 +154,5 @@ export async function syncFriends() {
|
||||
}
|
||||
}
|
||||
|
||||
await DataStore.set("relationship-notifier-friends", friends);
|
||||
await DataStore.set(friendsKey(), friends);
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
import { Settings } from "@api/settings";
|
||||
|
||||
import { Review } from "../entities/Review";
|
||||
import { ReviewDBUser } from "../entities/User";
|
||||
import { authorize, showToast } from "./Utils";
|
||||
|
||||
const API_URL = "https://manti.vendicated.dev";
|
||||
@ -32,8 +33,12 @@ interface Response {
|
||||
updated: boolean;
|
||||
}
|
||||
|
||||
const WarningFlag = 0b00000010;
|
||||
|
||||
export async function getReviews(id: string): Promise<Review[]> {
|
||||
const req = await fetch(API_URL + `/api/reviewdb/users/${id}/reviews`);
|
||||
var flags = 0;
|
||||
if (!Settings.plugins.ReviewDB.showWarning) flags |= WarningFlag;
|
||||
const req = await fetch(API_URL + `/api/reviewdb/users/${id}/reviews?flags=${flags}`);
|
||||
|
||||
const res = (req.status === 200) ? await req.json() as Response : { success: false, message: "An Error occured while fetching reviews. Please try again later.", reviews: [], updated: false };
|
||||
if (!res.success) {
|
||||
@ -43,6 +48,7 @@ export async function getReviews(id: string): Promise<Review[]> {
|
||||
id: 0,
|
||||
comment: "An Error occured while fetching reviews. Please try again later.",
|
||||
star: 0,
|
||||
timestamp: 0,
|
||||
sender: {
|
||||
id: 0,
|
||||
username: "Error",
|
||||
@ -108,8 +114,10 @@ export async function reportReview(id: number) {
|
||||
showToast(await res.message);
|
||||
}
|
||||
|
||||
export function getLastReviewID(id: string): Promise<number> {
|
||||
return fetch(API_URL + "/getLastReviewID?discordid=" + id)
|
||||
.then(r => r.text())
|
||||
.then(Number);
|
||||
export function getCurrentUserInfo(token: string): Promise<ReviewDBUser> {
|
||||
return fetch(API_URL + "/api/reviewdb/users", {
|
||||
body: JSON.stringify({ token }),
|
||||
method: "POST",
|
||||
})
|
||||
.then(r => r.json());
|
||||
}
|
||||
|
@ -17,13 +17,13 @@
|
||||
*/
|
||||
|
||||
import { Settings } from "@api/settings";
|
||||
import { Devs } from "@utils/constants";
|
||||
import Logger from "@utils/Logger";
|
||||
import { openModal } from "@utils/modal";
|
||||
import { findByProps } from "@webpack";
|
||||
import { FluxDispatcher, React, SelectedChannelStore, Toasts, UserUtils } from "@webpack/common";
|
||||
|
||||
import { Review } from "../entities/Review";
|
||||
import { UserType } from "../entities/User";
|
||||
|
||||
export async function openUserProfileModal(userId: string) {
|
||||
await UserUtils.fetchUser(userId);
|
||||
@ -86,10 +86,5 @@ export function showToast(text: string) {
|
||||
export const sleep = (ms: number) => new Promise(r => setTimeout(r, ms));
|
||||
|
||||
export function canDeleteReview(review: Review, userId: string) {
|
||||
if (review.sender.discordID === userId) return true;
|
||||
|
||||
const myId = BigInt(userId);
|
||||
return myId === Devs.mantikafasi.id ||
|
||||
myId === Devs.Ven.id ||
|
||||
myId === Devs.rushii.id;
|
||||
if (review.sender.discordID === userId || Settings.plugins.ReviewDB.userType === UserType.Admin) return true;
|
||||
}
|
||||
|
@ -16,9 +16,10 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Settings } from "@api/settings";
|
||||
import { classes, LazyComponent } from "@utils/misc";
|
||||
import { filters, findBulk } from "@webpack";
|
||||
import { Alerts, UserStore } from "@webpack/common";
|
||||
import { Alerts, moment, Timestamp, UserStore } from "@webpack/common";
|
||||
|
||||
import { Review } from "../entities/Review";
|
||||
import { deleteReview, reportReview } from "../Utils/ReviewDBAPI";
|
||||
@ -32,7 +33,7 @@ export default LazyComponent(() => {
|
||||
const [
|
||||
{ cozyMessage, buttons, message, groupStart },
|
||||
{ container, isHeader },
|
||||
{ avatar, clickable, username, messageContent, wrapper, cozy },
|
||||
{ avatar, clickable, username, messageContent, wrapper, cozy, timestampInline, timestamp },
|
||||
{ contents },
|
||||
buttonClasses,
|
||||
{ defaultColor }
|
||||
@ -102,6 +103,16 @@ export default LazyComponent(() => {
|
||||
{review.sender.username}
|
||||
</span>
|
||||
{review.sender.badges.map(badge => <ReviewBadge {...badge} />)}
|
||||
|
||||
{
|
||||
!Settings.plugins.ReviewDB.hideTimestamps && (
|
||||
<Timestamp
|
||||
timestamp={moment(review.timestamp * 1000)}
|
||||
compact={true}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
<p
|
||||
className={classes(messageContent, defaultColor)}
|
||||
style={{ fontSize: 15, marginTop: 4 }}
|
||||
|
@ -16,18 +16,20 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Settings } from "@api/settings";
|
||||
import { classes, useAwaiter } from "@utils/misc";
|
||||
import { findLazy } from "@webpack";
|
||||
import { Forms, React, Text, UserStore } from "@webpack/common";
|
||||
import type { KeyboardEvent } from "react";
|
||||
|
||||
import { addReview, getReviews } from "../Utils/ReviewDBAPI";
|
||||
import { showToast } from "../Utils/Utils";
|
||||
import { authorize, showToast } from "../Utils/Utils";
|
||||
import ReviewComponent from "./ReviewComponent";
|
||||
|
||||
const Classes = findLazy(m => typeof m.textarea === "string");
|
||||
|
||||
export default function ReviewsView({ userId }: { userId: string; }) {
|
||||
const { token } = Settings.plugins.ReviewDB;
|
||||
const [refetchCount, setRefetchCount] = React.useState(0);
|
||||
const [reviews, _, isLoading] = useAwaiter(() => getReviews(userId), {
|
||||
fallbackValue: [],
|
||||
@ -57,7 +59,7 @@ export default function ReviewsView({ userId }: { userId: string; }) {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="ReviewDB">
|
||||
<div className="vc-reviewdb-view">
|
||||
<Text
|
||||
tag="h2"
|
||||
variant="eyebrow"
|
||||
@ -83,8 +85,21 @@ export default function ReviewsView({ userId }: { userId: string; }) {
|
||||
<textarea
|
||||
className={classes(Classes.textarea.replace("textarea", ""), "enter-comment")}
|
||||
// this produces something like '-_59yqs ...' but since no class exists with that name its fine
|
||||
placeholder={reviews?.some(r => r.sender.discordID === UserStore.getCurrentUser().id) ? `Update review for @${username}` : `Review @${username}`}
|
||||
placeholder={
|
||||
token
|
||||
? (reviews?.some(r => r.sender.discordID === UserStore.getCurrentUser().id)
|
||||
? `Update review for @${username}`
|
||||
: `Review @${username}`)
|
||||
: "You need to authorize to review users!"
|
||||
}
|
||||
onKeyDown={onKeyPress}
|
||||
onClick={() => {
|
||||
if (!token) {
|
||||
showToast("Opening authorization window...");
|
||||
authorize();
|
||||
}
|
||||
}}
|
||||
|
||||
style={{
|
||||
marginTop: "6px",
|
||||
resize: "none",
|
||||
|
@ -31,4 +31,5 @@ export interface Review {
|
||||
id: number,
|
||||
star: number,
|
||||
sender: Sender,
|
||||
timestamp: number
|
||||
}
|
||||
|
28
src/plugins/reviewDB/entities/User.ts
Normal file
28
src/plugins/reviewDB/entities/User.ts
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
export const enum UserType {
|
||||
Banned = -1,
|
||||
Normal = 0,
|
||||
Admin = 1
|
||||
}
|
||||
|
||||
export interface ReviewDBUser {
|
||||
lastReviewID: number,
|
||||
type: UserType;
|
||||
}
|
@ -16,15 +16,17 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import "./style.css";
|
||||
|
||||
import { Settings } from "@api/settings";
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { Button, UserStore } from "@webpack/common";
|
||||
import { Button } from "@webpack/common";
|
||||
import { User } from "discord-types/general";
|
||||
|
||||
import ReviewsView from "./components/ReviewsView";
|
||||
import { getLastReviewID } from "./Utils/ReviewDBAPI";
|
||||
import { getCurrentUserInfo } from "./Utils/ReviewDBAPI";
|
||||
import { authorize, showToast } from "./Utils/Utils";
|
||||
|
||||
export default definePlugin({
|
||||
@ -38,7 +40,7 @@ export default definePlugin({
|
||||
replacement: {
|
||||
match: /\(.{0,10}\{user:(.),setNote:.,canDM:.,.+?\}\)/,
|
||||
replace: "$&,$self.getReviewsComponent($1)"
|
||||
},
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
@ -56,19 +58,31 @@ export default definePlugin({
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Notify about new reviews on startup",
|
||||
default: true,
|
||||
},
|
||||
showWarning: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Display warning to be respectful at the top of the reviews list",
|
||||
default: true,
|
||||
},
|
||||
hideTimestamps: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Hide timestamps on reviews",
|
||||
default: false,
|
||||
}
|
||||
},
|
||||
|
||||
async start() {
|
||||
const settings = Settings.plugins.ReviewDB;
|
||||
if (!settings.lastReviewId || !settings.notifyReviews) return;
|
||||
if (!settings.notifyReviews || !settings.token) return;
|
||||
|
||||
setTimeout(async () => {
|
||||
const id = await getLastReviewID(UserStore.getCurrentUser().id);
|
||||
if (settings.lastReviewId < id) {
|
||||
showToast("You have new reviews on your profile!");
|
||||
settings.lastReviewId = id;
|
||||
const user = await getCurrentUserInfo(settings.token);
|
||||
if (settings.lastReviewId < user.lastReviewID) {
|
||||
settings.lastReviewId = user.lastReviewID;
|
||||
if (user.lastReviewID !== 0)
|
||||
showToast("You have new reviews on your profile!");
|
||||
}
|
||||
settings.userType = user.type;
|
||||
}, 4000);
|
||||
},
|
||||
|
||||
|
3
src/plugins/reviewDB/style.css
Normal file
3
src/plugins/reviewDB/style.css
Normal file
@ -0,0 +1,3 @@
|
||||
[class|="section"]:not([class|="lastSection"]) + .vc-reviewdb-view {
|
||||
margin-top: 12px;
|
||||
}
|
@ -53,7 +53,7 @@ export default definePlugin({
|
||||
replacement: [
|
||||
{
|
||||
match: /user:(\i),channel:(\i).{0,300}?"@"\.concat\(.+?\)/,
|
||||
replace: "$&,color:$self.getUserColor($1.id,{channelId:$2?.id})"
|
||||
replace: "$&,color:$self.getUserColor($1?.id,{channelId:$2?.id})"
|
||||
}
|
||||
],
|
||||
predicate: () => settings.store.chatMentions,
|
||||
@ -99,10 +99,12 @@ export default definePlugin({
|
||||
if (!(guildId ??= ChannelStore.getChannel(channelId!)?.guild_id)) return null;
|
||||
return GuildMemberStore.getMember(guildId, userId)?.colorString ?? null;
|
||||
},
|
||||
|
||||
getUserColor(userId: string, ids: { channelId?: string; guildId?: string; }) {
|
||||
const colorString = this.getColor(userId, ids);
|
||||
return colorString && parseInt(colorString.slice(1), 16);
|
||||
},
|
||||
|
||||
roleGroupColor({ id, count, title, guildId }: { id: string; count: number; title: string; guildId: string; }) {
|
||||
const guild = GuildStore.getGuild(guildId);
|
||||
const role = guild?.roles[id];
|
||||
@ -113,6 +115,7 @@ export default definePlugin({
|
||||
letterSpacing: ".05em"
|
||||
}}>{title} — {count}</span>;
|
||||
},
|
||||
|
||||
getVoiceProps({ user: { id: userId }, guildId }: { user: { id: string; }; guildId: string; }) {
|
||||
return {
|
||||
style: {
|
||||
|
@ -21,11 +21,11 @@ import "./styles.css";
|
||||
import { addPreSendListener, removePreSendListener } from "@api/MessageEvents";
|
||||
import { classNameFactory } from "@api/Styles";
|
||||
import { Devs } from "@utils/constants";
|
||||
import { getTheme, Theme } from "@utils/discord";
|
||||
import { getTheme, insertTextIntoChatInputBox, Theme } from "@utils/discord";
|
||||
import { Margins } from "@utils/margins";
|
||||
import { closeModal, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, openModal } from "@utils/modal";
|
||||
import definePlugin from "@utils/types";
|
||||
import { Button, ButtonLooks, ButtonWrapperClasses, ComponentDispatch, Forms, Parser, Select, Tooltip, useMemo, useState } from "@webpack/common";
|
||||
import { Button, ButtonLooks, ButtonWrapperClasses, Forms, Parser, Select, Tooltip, useMemo, useState } from "@webpack/common";
|
||||
|
||||
function parseTime(time: string) {
|
||||
const cleanTime = time.slice(1, -1).replace(/(\d)(AM|PM)$/i, "$1 $2");
|
||||
@ -104,7 +104,7 @@ function PickerModal({ rootProps, close }: { rootProps: ModalProps, close(): voi
|
||||
<ModalFooter>
|
||||
<Button
|
||||
onClick={() => {
|
||||
ComponentDispatch.dispatchToLastSubscribed("INSERT_TEXT", { rawText: formatted });
|
||||
insertTextIntoChatInputBox(formatted + " ");
|
||||
close();
|
||||
}}
|
||||
>Insert</Button>
|
||||
|
@ -22,7 +22,7 @@ import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { Devs } from "@utils/constants";
|
||||
import { useForceUpdater } from "@utils/misc";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { FluxDispatcher, GuildStore,PresenceStore, RelationshipStore } from "@webpack/common";
|
||||
import { GuildStore, PresenceStore, RelationshipStore } from "@webpack/common";
|
||||
|
||||
enum IndicatorType {
|
||||
SERVER = 1 << 0,
|
||||
@ -71,6 +71,24 @@ function ServersIndicator() {
|
||||
);
|
||||
}
|
||||
|
||||
function handlePresenceUpdate() {
|
||||
onlineFriends = 0;
|
||||
const relations = RelationshipStore.getRelationships();
|
||||
for (const id of Object.keys(relations)) {
|
||||
const type = relations[id];
|
||||
// FRIEND relationship type
|
||||
if (type === 1 && PresenceStore.getStatus(id) !== "offline") {
|
||||
onlineFriends += 1;
|
||||
}
|
||||
}
|
||||
forceUpdateFriendCount?.();
|
||||
}
|
||||
|
||||
function handleGuildUpdate() {
|
||||
guildCount = GuildStore.getGuildCount();
|
||||
forceUpdateGuildCount?.();
|
||||
}
|
||||
|
||||
export default definePlugin({
|
||||
name: "ServerListIndicators",
|
||||
description: "Add online friend count or server count in the server list",
|
||||
@ -99,37 +117,21 @@ export default definePlugin({
|
||||
</ErrorBoundary>;
|
||||
},
|
||||
|
||||
handlePresenceUpdate() {
|
||||
onlineFriends = 0;
|
||||
const relations = RelationshipStore.getRelationships();
|
||||
for (const id of Object.keys(relations)) {
|
||||
const type = relations[id];
|
||||
// FRIEND relationship type
|
||||
if (type === 1 && PresenceStore.getStatus(id) !== "offline") {
|
||||
onlineFriends += 1;
|
||||
}
|
||||
}
|
||||
forceUpdateFriendCount?.();
|
||||
flux: {
|
||||
PRESENCE_UPDATES: handlePresenceUpdate,
|
||||
GUILD_CREATE: handleGuildUpdate,
|
||||
GUILD_DELETE: handleGuildUpdate,
|
||||
},
|
||||
|
||||
handleGuildUpdate() {
|
||||
guildCount = GuildStore.getGuildCount();
|
||||
forceUpdateGuildCount?.();
|
||||
},
|
||||
|
||||
start() {
|
||||
this.handlePresenceUpdate();
|
||||
this.handleGuildUpdate();
|
||||
addServerListElement(ServerListRenderPosition.Above, this.renderIndicator);
|
||||
FluxDispatcher.subscribe("PRESENCE_UPDATES", this.handlePresenceUpdate);
|
||||
FluxDispatcher.subscribe("GUILD_CREATE", this.handleGuildUpdate);
|
||||
FluxDispatcher.subscribe("GUILD_DELETE", this.handleGuildUpdate);
|
||||
|
||||
handlePresenceUpdate();
|
||||
handleGuildUpdate();
|
||||
},
|
||||
|
||||
stop() {
|
||||
removeServerListElement(ServerListRenderPosition.Above, this.renderIndicator);
|
||||
FluxDispatcher.unsubscribe("PRESENCE_UPDATES", this.handlePresenceUpdate);
|
||||
FluxDispatcher.unsubscribe("GUILD_CREATE", this.handleGuildUpdate);
|
||||
FluxDispatcher.unsubscribe("GUILD_DELETE", this.handleGuildUpdate);
|
||||
}
|
||||
});
|
||||
|
173
src/plugins/showConnections/index.tsx
Normal file
173
src/plugins/showConnections/index.tsx
Normal file
@ -0,0 +1,173 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import "./styles.css";
|
||||
|
||||
import { definePluginSettings } from "@api/settings";
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { Devs } from "@utils/constants";
|
||||
import { copyWithToast, LazyComponent } from "@utils/misc";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { findByCode, findByCodeLazy, findByPropsLazy, findStoreLazy } from "@webpack";
|
||||
import { Text, Tooltip } from "@webpack/common";
|
||||
import { User } from "discord-types/general";
|
||||
|
||||
const Section = LazyComponent(() => findByCode("().lastSection"));
|
||||
const UserProfileStore = findStoreLazy("UserProfileStore");
|
||||
const ThemeStore = findStoreLazy("ThemeStore");
|
||||
const platforms: { get(type: string): ConnectionPlatform; } = findByPropsLazy("isSupported", "getByUrl");
|
||||
const getTheme: (user: User, displayProfile: any) => any = findByCodeLazy(',"--profile-gradient-primary-color"');
|
||||
|
||||
const enum Spacing {
|
||||
COMPACT,
|
||||
COZY,
|
||||
ROOMY
|
||||
}
|
||||
const getSpacingPx = (spacing: Spacing | undefined) => (spacing ?? Spacing.COMPACT) * 2 + 4;
|
||||
|
||||
const settings = definePluginSettings({
|
||||
iconSize: {
|
||||
type: OptionType.NUMBER,
|
||||
description: "Icon size (px)",
|
||||
default: 32
|
||||
},
|
||||
iconSpacing: {
|
||||
type: OptionType.SELECT,
|
||||
description: "Icon margin",
|
||||
default: Spacing.COZY,
|
||||
options: [
|
||||
{ label: "Compact", value: Spacing.COMPACT },
|
||||
{ label: "Cozy", value: Spacing.COZY }, // US Spelling :/
|
||||
{ label: "Roomy", value: Spacing.ROOMY }
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
interface Connection {
|
||||
type: string;
|
||||
id: string;
|
||||
name: string;
|
||||
verified: boolean;
|
||||
}
|
||||
|
||||
interface ConnectionPlatform {
|
||||
getPlatformUserUrl(connection: Connection): string;
|
||||
icon: { lightSVG: string, darkSVG: string; };
|
||||
}
|
||||
|
||||
const profilePopoutComponent = ErrorBoundary.wrap(e =>
|
||||
<ConnectionsComponent id={e.user.id} theme={getTheme(e.user, e.displayProfile).profileTheme} />
|
||||
);
|
||||
|
||||
const profilePanelComponent = ErrorBoundary.wrap(e =>
|
||||
<ConnectionsComponent id={e.channel.recipients[0]} theme={ThemeStore.theme} />
|
||||
);
|
||||
|
||||
function ConnectionsComponent({ id, theme }: { id: string, theme: string; }) {
|
||||
const profile = UserProfileStore.getUserProfile(id);
|
||||
if (!profile)
|
||||
return null;
|
||||
|
||||
const connections: Connection[] = profile.connectedAccounts;
|
||||
if (!connections?.length)
|
||||
return null;
|
||||
|
||||
return (
|
||||
<Section>
|
||||
<Text
|
||||
tag="h2"
|
||||
variant="eyebrow"
|
||||
style={{ color: "var(--header-primary)" }}
|
||||
>
|
||||
Connections
|
||||
</Text>
|
||||
{connections.map(connection => <CompactConnectionComponent connection={connection} theme={theme} />)}
|
||||
</Section>
|
||||
);
|
||||
}
|
||||
|
||||
function CompactConnectionComponent({ connection, theme }: { connection: Connection, theme: string; }) {
|
||||
const platform = platforms.get(connection.type);
|
||||
const url = platform.getPlatformUserUrl?.(connection);
|
||||
|
||||
const img = (
|
||||
<img
|
||||
aria-label={connection.name}
|
||||
src={theme === "light" ? platform.icon.lightSVG : platform.icon.darkSVG}
|
||||
style={{
|
||||
marginTop: getSpacingPx(settings.store.iconSpacing),
|
||||
marginRight: getSpacingPx(settings.store.iconSpacing),
|
||||
width: settings.store.iconSize,
|
||||
height: settings.store.iconSize
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
<Tooltip
|
||||
text={`${connection.name}${!connection.verified ? " (unverified)" : ""} (click to ${url ? "open" : "copy"})`}
|
||||
key={connection.id}
|
||||
>
|
||||
{tooltipProps =>
|
||||
url
|
||||
? <a
|
||||
{...tooltipProps}
|
||||
className="vc-user-connection"
|
||||
href={url}
|
||||
target="_blank"
|
||||
>
|
||||
{img}
|
||||
</a>
|
||||
: <button
|
||||
{...tooltipProps}
|
||||
className="vc-user-connection"
|
||||
onClick={() => copyWithToast(connection.name)}
|
||||
>
|
||||
{img}
|
||||
</button>
|
||||
|
||||
}
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
|
||||
export default definePlugin({
|
||||
name: "ShowConnections",
|
||||
description: "Show connected accounts in user popouts",
|
||||
authors: [Devs.TheKodeToad],
|
||||
patches: [
|
||||
{
|
||||
find: ".Messages.BOT_PROFILE_SLASH_COMMANDS",
|
||||
replacement: {
|
||||
match: /,theme:\i\}\)(?=,.{0,100}setNote:)/,
|
||||
replace: "$&,$self.profilePopoutComponent(arguments[0])"
|
||||
}
|
||||
},
|
||||
{
|
||||
find: "\"Profile Panel: user cannot be undefined\"",
|
||||
replacement: {
|
||||
// createElement(Divider, {}), createElement(NoteComponent)
|
||||
match: /\(0,\i\.jsx\)\(\i\.\i,\{\}\).{0,100}setNote:/,
|
||||
replace: "$self.profilePanelComponent(arguments[0]),$&"
|
||||
}
|
||||
}
|
||||
],
|
||||
settings,
|
||||
profilePopoutComponent,
|
||||
profilePanelComponent
|
||||
});
|
5
src/plugins/showConnections/styles.css
Normal file
5
src/plugins/showConnections/styles.css
Normal file
@ -0,0 +1,5 @@
|
||||
.vc-user-connection {
|
||||
all: unset;
|
||||
display: inline-block;
|
||||
cursor: pointer;
|
||||
}
|
@ -17,22 +17,41 @@
|
||||
*/
|
||||
|
||||
import { addPreSendListener, removePreSendListener, SendListener } from "@api/MessageEvents";
|
||||
import { definePluginSettings } from "@api/settings";
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { Button, ButtonLooks, ButtonWrapperClasses, React, Tooltip } from "@webpack/common";
|
||||
|
||||
let lastState = false;
|
||||
|
||||
const settings = definePluginSettings({
|
||||
persistState: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Whether to persist the state of the silent message toggle when changing channels",
|
||||
default: false,
|
||||
onChange(newValue: boolean) {
|
||||
if (newValue === false) lastState = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function SilentMessageToggle(chatBoxProps: {
|
||||
type: {
|
||||
analyticsName: string;
|
||||
};
|
||||
}) {
|
||||
const [enabled, setEnabled] = React.useState(false);
|
||||
const [enabled, setEnabled] = React.useState(lastState);
|
||||
|
||||
function setEnabledValue(value: boolean) {
|
||||
if (settings.store.persistState) lastState = value;
|
||||
setEnabled(value);
|
||||
}
|
||||
|
||||
React.useEffect(() => {
|
||||
const listener: SendListener = (_, message) => {
|
||||
if (enabled) {
|
||||
setEnabled(false);
|
||||
setEnabledValue(false);
|
||||
if (!message.content.startsWith("@silent ")) message.content = "@silent " + message.content;
|
||||
}
|
||||
};
|
||||
@ -49,7 +68,7 @@ function SilentMessageToggle(chatBoxProps: {
|
||||
<div style={{ display: "flex" }}>
|
||||
<Button
|
||||
{...tooltipProps}
|
||||
onClick={() => setEnabled(prev => !prev)}
|
||||
onClick={() => setEnabledValue(!enabled)}
|
||||
size=""
|
||||
look={ButtonLooks.BLANK}
|
||||
innerClassName={ButtonWrapperClasses.button}
|
||||
@ -79,6 +98,9 @@ export default definePlugin({
|
||||
name: "SilentMessageToggle",
|
||||
authors: [Devs.Nuckyz],
|
||||
description: "Adds a button to the chat bar to toggle sending a silent message.",
|
||||
dependencies: ["MessageEventsAPI"],
|
||||
|
||||
settings,
|
||||
patches: [
|
||||
{
|
||||
find: ".activeCommandOption",
|
||||
|
@ -16,7 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { definePluginSettings, migratePluginSettings } from "@api/settings";
|
||||
import { definePluginSettings } from "@api/settings";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
|
||||
@ -35,7 +35,6 @@ const settings = definePluginSettings({
|
||||
}
|
||||
});
|
||||
|
||||
migratePluginSettings("SpotifyCrack", "Ify");
|
||||
export default definePlugin({
|
||||
name: "SpotifyCrack",
|
||||
description: "Free listen along, no auto-pausing in voice chat, and allows activity to continue playing when idling",
|
||||
|
@ -17,7 +17,6 @@
|
||||
*/
|
||||
|
||||
import { ApplicationCommandInputType, sendBotMessage } from "@api/Commands";
|
||||
import { migratePluginSettings } from "@api/settings";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
import { findByPropsLazy } from "@webpack";
|
||||
@ -74,7 +73,6 @@ function sendMessage(channelId, message) {
|
||||
});
|
||||
}
|
||||
|
||||
migratePluginSettings("SpotifyShareCommands", "Sendify");
|
||||
export default definePlugin({
|
||||
name: "SpotifyShareCommands",
|
||||
description: "Share your current Spotify track, album or artist via slash command (/track, /album, /artist)",
|
||||
|
@ -21,7 +21,7 @@ import { Devs, SUPPORT_CHANNEL_ID } from "@utils/constants";
|
||||
import { makeCodeblock } from "@utils/misc";
|
||||
import definePlugin from "@utils/types";
|
||||
import { isOutdated } from "@utils/updater";
|
||||
import { Alerts, FluxDispatcher, Forms, UserStore } from "@webpack/common";
|
||||
import { Alerts, Forms, UserStore } from "@webpack/common";
|
||||
|
||||
import gitHash from "~git-hash";
|
||||
import plugins from "~plugins";
|
||||
@ -69,18 +69,16 @@ ${makeCodeblock(Object.keys(plugins).filter(Vencord.Plugins.isPluginEnabled).joi
|
||||
}
|
||||
}],
|
||||
|
||||
rememberDismiss() {
|
||||
DataStore.set(REMEMBER_DISMISS_KEY, gitHash);
|
||||
},
|
||||
|
||||
start() {
|
||||
FluxDispatcher.subscribe("CHANNEL_SELECT", async ({ channelId }) => {
|
||||
flux: {
|
||||
async CHANNEL_SELECT({ channelId }) {
|
||||
if (channelId !== SUPPORT_CHANNEL_ID) return;
|
||||
|
||||
const myId = BigInt(UserStore.getCurrentUser().id);
|
||||
if (Object.values(Devs).some(d => d.id === myId)) return;
|
||||
|
||||
if (isOutdated && gitHash !== await DataStore.get(REMEMBER_DISMISS_KEY)) {
|
||||
const rememberDismiss = () => DataStore.set(REMEMBER_DISMISS_KEY, gitHash);
|
||||
|
||||
Alerts.show({
|
||||
title: "Hold on!",
|
||||
body: <div>
|
||||
@ -90,10 +88,10 @@ ${makeCodeblock(Object.keys(plugins).filter(Vencord.Plugins.isPluginEnabled).joi
|
||||
to do so, in case you can't access the Updater page.
|
||||
</Forms.FormText>
|
||||
</div>,
|
||||
onCancel: this.rememberDismiss,
|
||||
onConfirm: this.rememberDismiss
|
||||
onCancel: rememberDismiss,
|
||||
onConfirm: rememberDismiss
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -24,7 +24,7 @@ import { findByCodeLazy } from "@webpack";
|
||||
import { GuildMemberStore, React, RelationshipStore, SelectedChannelStore } from "@webpack/common";
|
||||
import { User } from "discord-types/general";
|
||||
|
||||
const Avatar = findByCodeLazy('"top",spacing:');
|
||||
const Avatar = findByCodeLazy(".typingIndicatorRef", "svg");
|
||||
const openProfile = findByCodeLazy("friendToken", "USER_PROFILE_MODAL_OPEN");
|
||||
|
||||
const settings = definePluginSettings({
|
||||
|
10
src/plugins/usrbg/index.css
Normal file
10
src/plugins/usrbg/index.css
Normal file
@ -0,0 +1,10 @@
|
||||
:is([class*="userProfile"], [class*="userPopout"]) [class*="bannerPremium"] {
|
||||
background: center / cover no-repeat;
|
||||
position: relative;
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
[class*="NonPremium"]:has([class*="bannerPremium"]) [class*="avatarPositionNormal"],
|
||||
[class*="PremiumWithoutBanner"]:has([class*="bannerPremium"]) [class*="avatarPositionPremiumNoBanner"] {
|
||||
top: 76px;
|
||||
}
|
85
src/plugins/usrbg/index.tsx
Normal file
85
src/plugins/usrbg/index.tsx
Normal file
@ -0,0 +1,85 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { definePluginSettings } from "@api/settings";
|
||||
import { enableStyle } from "@api/Styles";
|
||||
import { Link } from "@components/Link";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
|
||||
import style from "./index.css?managed";
|
||||
|
||||
const BASE_URL = "https://raw.githubusercontent.com/AutumnVN/usrbg/main/usrbg.json";
|
||||
|
||||
let data = {} as Record<string, string>;
|
||||
|
||||
const settings = definePluginSettings({
|
||||
nitroFirst: {
|
||||
description: "Banner to use if both Nitro and USRBG banners are present",
|
||||
type: OptionType.SELECT,
|
||||
options: [
|
||||
{ label: "Nitro banner", value: true, default: true },
|
||||
{ label: "USRBG banner", value: false },
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
export default definePlugin({
|
||||
name: "USRBG",
|
||||
description: "USRBG is a community maintained database of Discord banners, allowing anyone to get a banner without requiring Nitro",
|
||||
authors: [Devs.AutumnVN, Devs.pylix],
|
||||
settings,
|
||||
patches: [
|
||||
{
|
||||
find: ".NITRO_BANNER,",
|
||||
replacement: [
|
||||
{
|
||||
match: /(\i)\.premiumType/,
|
||||
replace: "$self.premiumHook($1)||$&"
|
||||
},
|
||||
{
|
||||
match: /(\i)\.bannerSrc,/,
|
||||
replace: "$self.useBannerHook($1),"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
settingsAboutComponent: () => {
|
||||
return (
|
||||
<Link href="https://github.com/AutumnVN/usrbg#how-to-request-your-own-usrbg-banner">CLICK HERE TO GET YOUR OWN BANNER</Link>
|
||||
);
|
||||
},
|
||||
|
||||
useBannerHook({ displayProfile, user }: any) {
|
||||
if (displayProfile?.banner && settings.store.nitroFirst) return;
|
||||
if (data[user.id]) return data[user.id];
|
||||
},
|
||||
|
||||
premiumHook({ userId }: any) {
|
||||
if (data[userId]) return 2;
|
||||
},
|
||||
|
||||
async start() {
|
||||
enableStyle(style);
|
||||
|
||||
const res = await fetch(BASE_URL);
|
||||
if (res.ok)
|
||||
data = await res.json();
|
||||
}
|
||||
});
|
@ -16,7 +16,6 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { migratePluginSettings } from "@api/settings";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
import { ChannelStore, SelectedChannelStore } from "@webpack/common";
|
||||
@ -26,7 +25,6 @@ const timers = {} as Record<string, {
|
||||
i: number;
|
||||
}>;
|
||||
|
||||
migratePluginSettings("VoiceChatDoubleClick", "vcDoubleClick");
|
||||
export default definePlugin({
|
||||
name: "VoiceChatDoubleClick",
|
||||
description: "Join voice chats via double click instead of single click",
|
||||
|
@ -24,7 +24,7 @@ import { Margins } from "@utils/margins";
|
||||
import { wordsToTitle } from "@utils/text";
|
||||
import definePlugin, { OptionType, PluginOptionsItem } from "@utils/types";
|
||||
import { findByPropsLazy } from "@webpack";
|
||||
import { Button, ChannelStore, FluxDispatcher, Forms, SelectedChannelStore, useMemo, UserStore } from "@webpack/common";
|
||||
import { Button, ChannelStore, Forms, SelectedChannelStore, useMemo, UserStore } from "@webpack/common";
|
||||
|
||||
interface VoiceState {
|
||||
userId: string;
|
||||
@ -137,49 +137,6 @@ function updateStatuses(type: string, { deaf, mute, selfDeaf, selfMute, userId,
|
||||
}
|
||||
*/
|
||||
|
||||
function handleVoiceStates({ voiceStates }: { voiceStates: VoiceState[]; }) {
|
||||
const myChanId = SelectedChannelStore.getVoiceChannelId();
|
||||
const myId = UserStore.getCurrentUser().id;
|
||||
|
||||
for (const state of voiceStates) {
|
||||
const { userId, channelId, oldChannelId } = state;
|
||||
const isMe = userId === myId;
|
||||
if (!isMe) {
|
||||
if (!myChanId) continue;
|
||||
if (channelId !== myChanId && oldChannelId !== myChanId) continue;
|
||||
}
|
||||
|
||||
const [type, id] = getTypeAndChannelId(state, isMe);
|
||||
if (!type) continue;
|
||||
|
||||
const template = Settings.plugins.VcNarrator[type + "Message"];
|
||||
const user = isMe ? "" : UserStore.getUser(userId).username;
|
||||
const channel = ChannelStore.getChannel(id).name;
|
||||
|
||||
speak(formatText(template, user, channel));
|
||||
|
||||
// updateStatuses(type, state, isMe);
|
||||
}
|
||||
}
|
||||
|
||||
function handleToggleSelfMute() {
|
||||
const chanId = SelectedChannelStore.getVoiceChannelId()!;
|
||||
const s = VoiceStateStore.getVoiceStateForChannel(chanId) as VoiceState;
|
||||
if (!s) return;
|
||||
|
||||
const event = s.mute || s.selfMute ? "unmute" : "mute";
|
||||
speak(formatText(Settings.plugins.VcNarrator[event + "Message"], "", ChannelStore.getChannel(chanId).name));
|
||||
}
|
||||
|
||||
function handleToggleSelfDeafen() {
|
||||
const chanId = SelectedChannelStore.getVoiceChannelId()!;
|
||||
const s = VoiceStateStore.getVoiceStateForChannel(chanId) as VoiceState;
|
||||
if (!s) return;
|
||||
|
||||
const event = s.deaf || s.selfDeaf ? "undeafen" : "deafen";
|
||||
speak(formatText(Settings.plugins.VcNarrator[event + "Message"], "", ChannelStore.getChannel(chanId).name));
|
||||
}
|
||||
|
||||
function playSample(tempSettings: any, type: string) {
|
||||
const settings = Object.assign({}, Settings.plugins.VcNarrator, tempSettings);
|
||||
|
||||
@ -191,6 +148,51 @@ export default definePlugin({
|
||||
description: "Announces when users join, leave, or move voice channels via narrator",
|
||||
authors: [Devs.Ven],
|
||||
|
||||
flux: {
|
||||
VOICE_STATE_UPDATES({ voiceStates }: { voiceStates: VoiceState[]; }) {
|
||||
const myChanId = SelectedChannelStore.getVoiceChannelId();
|
||||
const myId = UserStore.getCurrentUser().id;
|
||||
|
||||
for (const state of voiceStates) {
|
||||
const { userId, channelId, oldChannelId } = state;
|
||||
const isMe = userId === myId;
|
||||
if (!isMe) {
|
||||
if (!myChanId) continue;
|
||||
if (channelId !== myChanId && oldChannelId !== myChanId) continue;
|
||||
}
|
||||
|
||||
const [type, id] = getTypeAndChannelId(state, isMe);
|
||||
if (!type) continue;
|
||||
|
||||
const template = Settings.plugins.VcNarrator[type + "Message"];
|
||||
const user = isMe ? "" : UserStore.getUser(userId).username;
|
||||
const channel = ChannelStore.getChannel(id).name;
|
||||
|
||||
speak(formatText(template, user, channel));
|
||||
|
||||
// updateStatuses(type, state, isMe);
|
||||
}
|
||||
},
|
||||
|
||||
AUDIO_TOGGLE_SELF_MUTE() {
|
||||
const chanId = SelectedChannelStore.getVoiceChannelId()!;
|
||||
const s = VoiceStateStore.getVoiceStateForChannel(chanId) as VoiceState;
|
||||
if (!s) return;
|
||||
|
||||
const event = s.mute || s.selfMute ? "unmute" : "mute";
|
||||
speak(formatText(Settings.plugins.VcNarrator[event + "Message"], "", ChannelStore.getChannel(chanId).name));
|
||||
},
|
||||
|
||||
AUDIO_TOGGLE_SELF_DEAF() {
|
||||
const chanId = SelectedChannelStore.getVoiceChannelId()!;
|
||||
const s = VoiceStateStore.getVoiceStateForChannel(chanId) as VoiceState;
|
||||
if (!s) return;
|
||||
|
||||
const event = s.deaf || s.selfDeaf ? "undeafen" : "deafen";
|
||||
speak(formatText(Settings.plugins.VcNarrator[event + "Message"], "", ChannelStore.getChannel(chanId).name));
|
||||
}
|
||||
},
|
||||
|
||||
start() {
|
||||
if (typeof speechSynthesis === "undefined" || speechSynthesis.getVoices().length === 0) {
|
||||
new Logger("VcNarrator").warn(
|
||||
@ -199,15 +201,6 @@ export default definePlugin({
|
||||
return;
|
||||
}
|
||||
|
||||
FluxDispatcher.subscribe("VOICE_STATE_UPDATES", handleVoiceStates);
|
||||
FluxDispatcher.subscribe("AUDIO_TOGGLE_SELF_MUTE", handleToggleSelfMute);
|
||||
FluxDispatcher.subscribe("AUDIO_TOGGLE_SELF_DEAF", handleToggleSelfDeafen);
|
||||
},
|
||||
|
||||
stop() {
|
||||
FluxDispatcher.unsubscribe("VOICE_STATE_UPDATES", handleVoiceStates);
|
||||
FluxDispatcher.subscribe("AUDIO_TOGGLE_SELF_MUTE", handleToggleSelfMute);
|
||||
FluxDispatcher.subscribe("AUDIO_TOGGLE_SELF_DEAF", handleToggleSelfDeafen);
|
||||
},
|
||||
|
||||
optionsCache: null as Record<string, PluginOptionsItem> | null,
|
||||
|
@ -167,26 +167,30 @@ export default definePlugin({
|
||||
},
|
||||
|
||||
patches: [
|
||||
// Make pfps clickable
|
||||
{
|
||||
find: "onAddFriend:",
|
||||
replacement: {
|
||||
// global because Discord has two components that are 99% identical with one small change ._.
|
||||
match: /\{src:(\i),avatarDecoration/g,
|
||||
replace: "{src:$1,onClick:()=>$self.openImage($1),avatarDecoration"
|
||||
match: /\{src:(\i)(?=,avatarDecoration)/,
|
||||
replace: "{src:$1,onClick:()=>$self.openImage($1)"
|
||||
}
|
||||
}, {
|
||||
find: ".popoutNoBannerPremium",
|
||||
},
|
||||
// Make banners clickable
|
||||
{
|
||||
find: ".NITRO_BANNER,",
|
||||
replacement: {
|
||||
match: /style:.{0,10}\{\},(\i)\)/,
|
||||
// style: { backgroundImage: shouldShowBanner ? "url(".concat(bannerUrl,
|
||||
match: /style:\{(?=backgroundImage:(\i&&\i)\?"url\("\.concat\((\i),)/,
|
||||
replace:
|
||||
"onClick:$1.backgroundImage&&($1.cursor=\"pointer\"," +
|
||||
"()=>$self.openImage($1.backgroundImage.replace(\"url(\", \"\"))),$&"
|
||||
// onClick: () => shouldShowBanner && openImage(bannerUrl), style: { cursor: shouldShowBanner ? "pointer" : void 0,
|
||||
'onClick:()=>$1&&$self.openImage($2),style:{cursor:$1?"pointer":void 0,'
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
find: "().avatarWrapperNonUserBot",
|
||||
replacement: {
|
||||
match: /(avatarPositionPanel.+?)onClick:(\i\|\|\i)\?void 0(?<=,(\i)=\i\.avatarSrc.+?)/,
|
||||
replace: "$1style:($2)?{cursor:\"pointer\"}:{},onClick:$2?()=>{$self.openImage($3)}"
|
||||
match: /(?<=avatarPositionPanel.+?)onClick:(\i\|\|\i)\?void 0(?<=,(\i)=\i\.avatarSrc.+?)/,
|
||||
replace: "style:($1)?{cursor:\"pointer\"}:{},onClick:$1?()=>{$self.openImage($2)}"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -121,7 +121,7 @@ export default definePlugin({
|
||||
predicate: () => settings.store.addBack,
|
||||
replacement: {
|
||||
// return IS_DESKTOP ? React.createElement(Menu, ...)
|
||||
match: /return \i\.\i\?(?=\(0,\i\.jsxs?\)\(\i\.Menu)/,
|
||||
match: /return \i\.\i\?/,
|
||||
replace: "return true?"
|
||||
}
|
||||
},
|
||||
@ -146,7 +146,7 @@ export default definePlugin({
|
||||
}
|
||||
},
|
||||
{
|
||||
find: 'navId:"textarea-context"',
|
||||
find: ':"command-suggestions"',
|
||||
predicate: () => settings.store.addBack,
|
||||
replacement: [
|
||||
{
|
||||
|
@ -85,10 +85,14 @@ function makeRenderMoreUsers(users: User[]) {
|
||||
};
|
||||
}
|
||||
|
||||
function handleClickAvatar(event: React.MouseEvent<HTMLElement, MouseEvent>) {
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
export default definePlugin({
|
||||
name: "WhoReacted",
|
||||
description: "Renders the Avatars of reactors",
|
||||
authors: [Devs.Ven],
|
||||
authors: [Devs.Ven, Devs.KannaDev],
|
||||
|
||||
patches: [{
|
||||
find: ",reactionRef:",
|
||||
@ -132,15 +136,17 @@ export default definePlugin({
|
||||
<div
|
||||
style={{ marginLeft: "0.5em", transform: "scale(0.9)" }}
|
||||
>
|
||||
<UserSummaryItem
|
||||
users={users}
|
||||
guildId={ChannelStore.getChannel(message.channel_id)?.guild_id}
|
||||
renderIcon={false}
|
||||
max={5}
|
||||
showDefaultAvatarsForNullUsers
|
||||
showUserPopout
|
||||
renderMoreUsers={makeRenderMoreUsers(users)}
|
||||
/>
|
||||
<div onClick={handleClickAvatar}>
|
||||
<UserSummaryItem
|
||||
users={users}
|
||||
guildId={ChannelStore.getChannel(message.channel_id)?.guild_id}
|
||||
renderIcon={false}
|
||||
max={5}
|
||||
showDefaultAvatarsForNullUsers
|
||||
showUserPopout
|
||||
renderMoreUsers={makeRenderMoreUsers(users)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -273,5 +273,13 @@ export const Devs = /* #__PURE__*/ Object.freeze({
|
||||
FieryFlames: {
|
||||
name: "Fiery",
|
||||
id: 890228870559698955n
|
||||
},
|
||||
KannaDev: {
|
||||
name: "Kanna",
|
||||
id: 317728561106518019n
|
||||
},
|
||||
carince: {
|
||||
name: "carince",
|
||||
id: 818323528755314698n
|
||||
}
|
||||
});
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
import { findLazy } from "@webpack";
|
||||
import { ChannelStore, GuildStore, PrivateChannelsStore, SelectedChannelStore } from "@webpack/common";
|
||||
import { ChannelStore, ComponentDispatch, GuildStore, PrivateChannelsStore, SelectedChannelStore } from "@webpack/common";
|
||||
import { Guild } from "discord-types/general";
|
||||
|
||||
const PreloadedUserSettings = findLazy(m => m.ProtoClass?.typeName.endsWith("PreloadedUserSettings"));
|
||||
@ -42,3 +42,10 @@ export const enum Theme {
|
||||
export function getTheme(): Theme {
|
||||
return PreloadedUserSettings.getCurrentValue()?.appearance?.theme;
|
||||
}
|
||||
|
||||
export function insertTextIntoChatInputBox(text: string) {
|
||||
ComponentDispatch.dispatchToLastSubscribed("INSERT_TEXT", {
|
||||
rawText: text,
|
||||
plainText: text
|
||||
});
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
import { Command } from "@api/Commands";
|
||||
import { FluxEvents } from "@webpack/types";
|
||||
import { Promisable } from "type-fest";
|
||||
|
||||
// exists to export default definePlugin({...})
|
||||
@ -101,6 +102,14 @@ export interface PluginDef {
|
||||
settingsAboutComponent?: React.ComponentType<{
|
||||
tempSettings?: Record<string, any>;
|
||||
}>;
|
||||
/**
|
||||
* Allows you to subscribe to Flux events
|
||||
*/
|
||||
flux?: {
|
||||
[E in FluxEvents]?: (event: any) => void;
|
||||
};
|
||||
|
||||
tags?: string[];
|
||||
}
|
||||
|
||||
export enum OptionType {
|
||||
@ -126,6 +135,7 @@ export type PluginSettingDef = (
|
||||
| PluginSettingSelectDef
|
||||
| PluginSettingSliderDef
|
||||
| PluginSettingComponentDef
|
||||
| PluginSettingBigIntDef
|
||||
) & PluginSettingCommon;
|
||||
|
||||
export interface PluginSettingCommon {
|
||||
|
1
src/webpack/common/types/menu.d.ts
vendored
1
src/webpack/common/types/menu.d.ts
vendored
@ -38,6 +38,7 @@ export interface Menu {
|
||||
label: string;
|
||||
action?(e: MouseEvent): void;
|
||||
|
||||
color?: string;
|
||||
render?: ComponentType;
|
||||
onChildrenScroll?: Function;
|
||||
childRowHeight?: number;
|
||||
|
Reference in New Issue
Block a user