Compare commits
76 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
a8b6aea26f | ||
|
e50c2fafa5 | ||
|
6e3cafce42 | ||
|
4d0a064425 | ||
|
d1ad6c47a7 | ||
|
d5c35055f3 | ||
|
cb385d1b28 | ||
|
195f1a032f | ||
|
dfda9e7f84 | ||
|
0d5e2d0696 | ||
|
2834bed518 | ||
|
0b2c3c834a | ||
|
3a54a24c70 | ||
|
244d10dc9e | ||
|
c25bc0ff4b | ||
|
22334663cf | ||
|
8813f81bde | ||
|
84371ed456 | ||
|
8f61119b99 | ||
|
0a89d09727 | ||
|
474932161f | ||
|
bd95a25f4c | ||
|
6a57ecc22b | ||
|
0d665b7e0b | ||
|
d94b28fb8e | ||
|
bc1d8694d4 | ||
|
7bc1362cbd | ||
|
4dce836ff7 | ||
|
9f534c0685 | ||
|
c62d05e1b3 | ||
|
6a1cb133cd | ||
|
c6196dff81 | ||
|
acdb390302 | ||
|
08d88b326d | ||
|
a73858d131 | ||
|
b0caa6f4db | ||
|
168d4b4cd9 | ||
|
06cee75a56 | ||
|
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 |
@ -62,7 +62,7 @@
|
|||||||
"indent": ["error", 4, { "SwitchCase": 1 }],
|
"indent": ["error", 4, { "SwitchCase": 1 }],
|
||||||
"arrow-parens": ["error", "as-needed"],
|
"arrow-parens": ["error", "as-needed"],
|
||||||
"eol-last": ["error", "always"],
|
"eol-last": ["error", "always"],
|
||||||
"func-call-spacing": ["error", "never"],
|
"@typescript-eslint/func-call-spacing": ["error", "never"],
|
||||||
"no-multi-spaces": "error",
|
"no-multi-spaces": "error",
|
||||||
"no-trailing-spaces": "error",
|
"no-trailing-spaces": "error",
|
||||||
"no-whitespace-before-property": "error",
|
"no-whitespace-before-property": "error",
|
||||||
|
43
README.md
43
README.md
@ -2,10 +2,14 @@
|
|||||||
|
|
||||||
The cutest Discord client mod
|
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
|
## Features
|
||||||
|
|
||||||
- Super easy to install (Download Installer, open, click install button, done)
|
- 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
|
- Some highlights: SpotifyControls, GameActivityToggle, Experiments, NoTrack, MessageLogger, QuickReply, Free Emotes/Stickers, CustomCommands, ShowHiddenChannels, PronounDB
|
||||||
- Fairly lightweight despite the many inbuilt plugins
|
- Fairly lightweight despite the many inbuilt plugins
|
||||||
- Excellent Browser Support: Run Vencord in your Browser via extension or UserScript
|
- 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)
|
- 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
|
- 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
|
- 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
|
## 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
|
## 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
|
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
|
[![Vencord Discord Server](https://invidget.switchblade.xyz/D9uwnFnqmd?theme=dark)](https://discord.gg/D9uwnFnqmd)
|
||||||
|
|
||||||
[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]
|
|
||||||
|
|
||||||
## Disclaimer
|
## Disclaimer
|
||||||
|
|
||||||
Discord is trademark of Discord Inc. and solely mentioned for the sake of descriptivity.
|
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.
|
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"];
|
const origin = headers["access-control-allow-origin"];
|
||||||
if (origin !== "*" && origin !== window.location.origin) return false;
|
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;
|
if (methods && !methods.includes(method.toLowerCase())) return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -16,51 +16,70 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/// <reference path="../src/modules.d.ts" />
|
||||||
|
/// <reference path="../src/globals.d.ts" />
|
||||||
|
|
||||||
|
import monacoHtml from "~fileContent/../src/components/monacoWin.html";
|
||||||
import * as DataStore from "../src/api/DataStore";
|
import * as DataStore from "../src/api/DataStore";
|
||||||
import IpcEvents from "../src/utils/IpcEvents";
|
import { debounce } from "../src/utils";
|
||||||
|
import { getTheme, Theme } from "../src/utils/discord";
|
||||||
|
|
||||||
// Discord deletes this so need to store in variable
|
// Discord deletes this so need to store in variable
|
||||||
const { localStorage } = window;
|
const { localStorage } = window;
|
||||||
|
|
||||||
// listeners for ipc.on
|
// listeners for ipc.on
|
||||||
const listeners = {} as Record<string, Set<Function>>;
|
const cssListeners = new Set<(css: string) => void>();
|
||||||
|
const NOOP = () => { };
|
||||||
|
const NOOP_ASYNC = async () => { };
|
||||||
|
|
||||||
const handlers = {
|
const setCssDebounced = debounce((css: string) => VencordNative.quickCss.set(css));
|
||||||
[IpcEvents.GET_REPO]: () => "https://github.com/Vendicated/Vencord", // shrug
|
|
||||||
[IpcEvents.GET_SETTINGS_DIR]: () => "LocalStorage",
|
|
||||||
|
|
||||||
[IpcEvents.GET_QUICK_CSS]: () => DataStore.get("VencordQuickCss").then(s => s ?? ""),
|
|
||||||
[IpcEvents.SET_QUICK_CSS]: (css: string) => {
|
|
||||||
DataStore.set("VencordQuickCss", css);
|
|
||||||
listeners[IpcEvents.QUICK_CSS_UPDATE]?.forEach(l => l(null, css));
|
|
||||||
},
|
|
||||||
|
|
||||||
[IpcEvents.GET_SETTINGS]: () => localStorage.getItem("VencordSettings") || "{}",
|
|
||||||
[IpcEvents.SET_SETTINGS]: (s: string) => localStorage.setItem("VencordSettings", s),
|
|
||||||
|
|
||||||
[IpcEvents.GET_UPDATES]: () => ({ ok: true, value: [] }),
|
|
||||||
|
|
||||||
[IpcEvents.OPEN_EXTERNAL]: (url: string) => open(url, "_blank"),
|
|
||||||
};
|
|
||||||
|
|
||||||
function onEvent(event: string, ...args: any[]) {
|
|
||||||
const handler = handlers[event];
|
|
||||||
if (!handler) throw new Error(`Event ${event} not implemented.`);
|
|
||||||
return handler(...args);
|
|
||||||
}
|
|
||||||
|
|
||||||
// probably should make this less cursed at some point
|
// probably should make this less cursed at some point
|
||||||
window.VencordNative = {
|
window.VencordNative = {
|
||||||
|
native: {
|
||||||
getVersions: () => ({}),
|
getVersions: () => ({}),
|
||||||
ipc: {
|
openExternal: async (url) => void open(url, "_blank")
|
||||||
send: (event: string, ...args: any[]) => void onEvent(event, ...args),
|
|
||||||
sendSync: onEvent,
|
|
||||||
on(event: string, listener: () => {}) {
|
|
||||||
(listeners[event] ??= new Set()).add(listener);
|
|
||||||
},
|
},
|
||||||
off(event: string, listener: () => {}) {
|
|
||||||
return listeners[event]?.delete(listener);
|
updater: {
|
||||||
|
getRepo: async () => ({ ok: true, value: "https://github.com/Vendicated/Vencord" }),
|
||||||
|
getUpdates: async () => ({ ok: true, value: [] }),
|
||||||
|
update: async () => ({ ok: true, value: false }),
|
||||||
|
rebuild: async () => ({ ok: true, value: true }),
|
||||||
},
|
},
|
||||||
invoke: (event: string, ...args: any[]) => Promise.resolve(onEvent(event, ...args))
|
|
||||||
|
quickCss: {
|
||||||
|
get: () => DataStore.get("VencordQuickCss").then(s => s ?? ""),
|
||||||
|
set: async (css: string) => {
|
||||||
|
await DataStore.set("VencordQuickCss", css);
|
||||||
|
cssListeners.forEach(l => l(css));
|
||||||
},
|
},
|
||||||
|
addChangeListener(cb) {
|
||||||
|
cssListeners.add(cb);
|
||||||
|
},
|
||||||
|
openFile: NOOP_ASYNC,
|
||||||
|
async openEditor() {
|
||||||
|
const features = `popup,width=${Math.min(window.innerWidth, 1000)},height=${Math.min(window.innerHeight, 1000)}`;
|
||||||
|
const win = open("about:blank", "VencordQuickCss", features);
|
||||||
|
if (!win) {
|
||||||
|
alert("Failed to open QuickCSS popup. Make sure to allow popups!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
win.setCss = setCssDebounced;
|
||||||
|
win.getCurrentCss = () => VencordNative.quickCss.get();
|
||||||
|
win.getTheme = () =>
|
||||||
|
getTheme() === Theme.Light
|
||||||
|
? "vs-light"
|
||||||
|
: "vs-dark";
|
||||||
|
|
||||||
|
win.document.write(monacoHtml);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
settings: {
|
||||||
|
get: () => localStorage.getItem("VencordSettings") || "{}",
|
||||||
|
set: async (s: string) => localStorage.setItem("VencordSettings", s),
|
||||||
|
getSettingsDir: async () => "LocalStorage"
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
@ -16,7 +16,7 @@ chrome.webRequest.onHeadersReceived.addListener(
|
|||||||
// In main frame requests, the CSP needs to be removed to enable fetching of custom css
|
// In main frame requests, the CSP needs to be removed to enable fetching of custom css
|
||||||
// as desired by the user
|
// as desired by the user
|
||||||
removeFirst(responseHeaders, h => h.name.toLowerCase() === "content-security-policy");
|
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,
|
// Most users will load css from GitHub, but GitHub doesn't set the correct content type,
|
||||||
// so we fix it here
|
// so we fix it here
|
||||||
removeFirst(responseHeaders, h => h.name.toLowerCase() === "content-type");
|
removeFirst(responseHeaders, h => h.name.toLowerCase() === "content-type");
|
||||||
|
@ -26,10 +26,6 @@ export default definePlugin({
|
|||||||
name: "Your Name",
|
name: "Your Name",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
// Delete `patches` if you are not using code patches, as it will make
|
|
||||||
// your plugin require restarts, and your stop() method will not be
|
|
||||||
// invoked at all. The presence of the key in the object alone is
|
|
||||||
// enough to trigger this behavior, even if the value is an empty array.
|
|
||||||
patches: [],
|
patches: [],
|
||||||
// Delete these two below if you are only using code patches
|
// Delete these two below if you are only using code patches
|
||||||
start() {},
|
start() {},
|
||||||
|
32
package.json
32
package.json
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "vencord",
|
"name": "vencord",
|
||||||
"private": "true",
|
"private": "true",
|
||||||
"version": "1.1.9",
|
"version": "1.2.1",
|
||||||
"description": "The cutest Discord client mod",
|
"description": "The cutest Discord client mod",
|
||||||
"homepage": "https://github.com/Vendicated/Vencord#readme",
|
"homepage": "https://github.com/Vendicated/Vencord#readme",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
@ -32,20 +32,20 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@vap/core": "0.0.12",
|
"@vap/core": "0.0.12",
|
||||||
"@vap/shiki": "0.10.3",
|
"@vap/shiki": "0.10.5",
|
||||||
"fflate": "^0.7.4",
|
"fflate": "^0.7.4",
|
||||||
"nanoid": "^4.0.2",
|
"nanoid": "^4.0.2",
|
||||||
"virtual-merge": "^1.0.1"
|
"virtual-merge": "^1.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/diff": "^5.0.2",
|
"@types/diff": "^5.0.3",
|
||||||
"@types/lodash": "^4.14.191",
|
"@types/lodash": "^4.14.194",
|
||||||
"@types/node": "^18.11.18",
|
"@types/node": "^18.16.3",
|
||||||
"@types/react": "^18.0.27",
|
"@types/react": "^18.2.0",
|
||||||
"@types/react-dom": "^18.0.10",
|
"@types/react-dom": "^18.2.1",
|
||||||
"@types/yazl": "^2.4.2",
|
"@types/yazl": "^2.4.2",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.49.0",
|
"@typescript-eslint/eslint-plugin": "^5.59.1",
|
||||||
"@typescript-eslint/parser": "^5.49.0",
|
"@typescript-eslint/parser": "^5.59.1",
|
||||||
"diff": "^5.1.0",
|
"diff": "^5.1.0",
|
||||||
"discord-types": "^1.3.26",
|
"discord-types": "^1.3.26",
|
||||||
"esbuild": "^0.15.18",
|
"esbuild": "^0.15.18",
|
||||||
@ -53,17 +53,17 @@
|
|||||||
"eslint-import-resolver-alias": "^1.1.2",
|
"eslint-import-resolver-alias": "^1.1.2",
|
||||||
"eslint-plugin-header": "^3.1.1",
|
"eslint-plugin-header": "^3.1.1",
|
||||||
"eslint-plugin-path-alias": "^1.0.0",
|
"eslint-plugin-path-alias": "^1.0.0",
|
||||||
"eslint-plugin-simple-import-sort": "^8.0.0",
|
"eslint-plugin-simple-import-sort": "^10.0.0",
|
||||||
"eslint-plugin-unused-imports": "^2.0.0",
|
"eslint-plugin-unused-imports": "^2.0.0",
|
||||||
"highlight.js": "10.6.0",
|
"highlight.js": "10.6.0",
|
||||||
"moment": "^2.29.4",
|
"moment": "^2.29.4",
|
||||||
"puppeteer-core": "^19.6.0",
|
"puppeteer-core": "^19.11.1",
|
||||||
"standalone-electron-types": "^1.0.0",
|
"standalone-electron-types": "^1.0.0",
|
||||||
"stylelint": "^14.16.1",
|
"stylelint": "^15.6.0",
|
||||||
"stylelint-config-standard": "^29.0.0",
|
"stylelint-config-standard": "^33.0.0",
|
||||||
"tsx": "^3.12.6",
|
"tsx": "^3.12.7",
|
||||||
"type-fest": "^3.5.3",
|
"type-fest": "^3.9.0",
|
||||||
"typescript": "^4.9.4"
|
"typescript": "^5.0.4"
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@8.1.1",
|
"packageManager": "pnpm@8.1.1",
|
||||||
"pnpm": {
|
"pnpm": {
|
||||||
|
734
pnpm-lock.yaml
generated
734
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -130,7 +130,7 @@ async function printReport() {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Discord Errors",
|
title: "Discord Errors",
|
||||||
description: toCodeBlock(report.otherErrors.join("\n")),
|
description: report.otherErrors.length ? toCodeBlock(report.otherErrors.join("\n")) : "None",
|
||||||
color: report.otherErrors.length ? 0xff0000 : 0x00ff00
|
color: report.otherErrors.length ? 0xff0000 : 0x00ff00
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -186,8 +186,18 @@ page.on("console", async e => {
|
|||||||
} else if (isDebug) {
|
} else if (isDebug) {
|
||||||
console.error(e.text());
|
console.error(e.text());
|
||||||
} else if (level === "error") {
|
} else if (level === "error") {
|
||||||
const text = e.text();
|
const text = await Promise.all(
|
||||||
if (!text.startsWith("Failed to load resource: the server responded with a status of")) {
|
e.args().map(async a => {
|
||||||
|
try {
|
||||||
|
return await maybeGetError(a) || await a.jsonValue();
|
||||||
|
} catch (e) {
|
||||||
|
return a.toString();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
).then(a => a.join(" ").trim());
|
||||||
|
|
||||||
|
|
||||||
|
if (text.length && !text.startsWith("Failed to load resource: the server responded with a status of")) {
|
||||||
console.error("Got unexpected error", text);
|
console.error("Got unexpected error", text);
|
||||||
report.otherErrors.push(text);
|
report.otherErrors.push(text);
|
||||||
}
|
}
|
||||||
@ -224,7 +234,7 @@ function runTime(token: string) {
|
|||||||
// Needs native server to run
|
// Needs native server to run
|
||||||
if (p.name === "WebRichPresence (arRPC)") return;
|
if (p.name === "WebRichPresence (arRPC)") return;
|
||||||
|
|
||||||
p.required = true;
|
Vencord.Settings.plugins[p.name].enabled = true;
|
||||||
p.patches?.forEach(patch => {
|
p.patches?.forEach(patch => {
|
||||||
patch.plugin = p.name;
|
patch.plugin = p.name;
|
||||||
delete patch.predicate;
|
delete patch.predicate;
|
||||||
@ -258,7 +268,7 @@ function runTime(token: string) {
|
|||||||
if (!isWasm)
|
if (!isWasm)
|
||||||
await wreq.e(id as any);
|
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!");
|
console.error("[PUP_DEBUG]", "Finished loading chunks!");
|
||||||
|
|
||||||
|
@ -28,12 +28,12 @@ import "./utils/quickCss";
|
|||||||
import "./webpack/patchWebpack";
|
import "./webpack/patchWebpack";
|
||||||
|
|
||||||
import { showNotification } from "./api/Notifications";
|
import { showNotification } from "./api/Notifications";
|
||||||
import { PlainSettings, Settings } from "./api/settings";
|
import { PlainSettings, Settings } from "./api/Settings";
|
||||||
import { patches, PMLogger, startAllPlugins } from "./plugins";
|
import { patches, PMLogger, startAllPlugins } from "./plugins";
|
||||||
import { localStorage } from "./utils/localStorage";
|
import { localStorage } from "./utils/localStorage";
|
||||||
import { relaunch } from "./utils/native";
|
import { relaunch } from "./utils/native";
|
||||||
import { getCloudSettings, putCloudSettings } from "./utils/settingsSync";
|
import { getCloudSettings, putCloudSettings } from "./utils/settingsSync";
|
||||||
import { checkForUpdates, rebuild, update, UpdateLogger } from "./utils/updater";
|
import { checkForUpdates, update, UpdateLogger } from "./utils/updater";
|
||||||
import { onceReady } from "./webpack";
|
import { onceReady } from "./webpack";
|
||||||
import { SettingsRouter } from "./webpack/common";
|
import { SettingsRouter } from "./webpack/common";
|
||||||
|
|
||||||
@ -76,7 +76,6 @@ async function init() {
|
|||||||
|
|
||||||
if (Settings.autoUpdate) {
|
if (Settings.autoUpdate) {
|
||||||
await update();
|
await update();
|
||||||
await rebuild();
|
|
||||||
if (Settings.autoUpdateNotification)
|
if (Settings.autoUpdateNotification)
|
||||||
setTimeout(() => showNotification({
|
setTimeout(() => showNotification({
|
||||||
title: "Vencord has been updated!",
|
title: "Vencord has been updated!",
|
||||||
|
@ -16,34 +16,46 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import IPC_EVENTS from "@utils/IpcEvents";
|
import { IpcEvents } from "@utils/IpcEvents";
|
||||||
import { IpcRenderer, ipcRenderer } from "electron";
|
import { IpcRes } from "@utils/types";
|
||||||
|
import { ipcRenderer } from "electron";
|
||||||
|
|
||||||
function assertEventAllowed(event: string) {
|
function invoke<T = any>(event: IpcEvents, ...args: any[]) {
|
||||||
if (!(event in IPC_EVENTS)) throw new Error(`Event ${event} not allowed.`);
|
return ipcRenderer.invoke(event, ...args) as Promise<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function sendSync<T = any>(event: IpcEvents, ...args: any[]) {
|
||||||
|
return ipcRenderer.sendSync(event, ...args) as T;
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
getVersions: () => process.versions,
|
updater: {
|
||||||
ipc: {
|
getUpdates: () => invoke<IpcRes<Record<"hash" | "author" | "message", string>[]>>(IpcEvents.GET_UPDATES),
|
||||||
send(event: string, ...args: any[]) {
|
update: () => invoke<IpcRes<boolean>>(IpcEvents.UPDATE),
|
||||||
assertEventAllowed(event);
|
rebuild: () => invoke<IpcRes<boolean>>(IpcEvents.BUILD),
|
||||||
ipcRenderer.send(event, ...args);
|
getRepo: () => invoke<IpcRes<string>>(IpcEvents.GET_REPO),
|
||||||
},
|
},
|
||||||
sendSync<T = any>(event: string, ...args: any[]): T {
|
|
||||||
assertEventAllowed(event);
|
settings: {
|
||||||
return ipcRenderer.sendSync(event, ...args);
|
get: () => sendSync<string>(IpcEvents.GET_SETTINGS),
|
||||||
|
set: (settings: string) => invoke<void>(IpcEvents.SET_SETTINGS, settings),
|
||||||
|
getSettingsDir: () => invoke<string>(IpcEvents.GET_SETTINGS_DIR),
|
||||||
},
|
},
|
||||||
on(event: string, listener: Parameters<IpcRenderer["on"]>[1]) {
|
|
||||||
assertEventAllowed(event);
|
quickCss: {
|
||||||
ipcRenderer.on(event, listener);
|
get: () => invoke<string>(IpcEvents.GET_QUICK_CSS),
|
||||||
|
set: (css: string) => invoke<void>(IpcEvents.SET_QUICK_CSS, css),
|
||||||
|
|
||||||
|
addChangeListener(cb: (newCss: string) => void) {
|
||||||
|
ipcRenderer.on(IpcEvents.QUICK_CSS_UPDATE, (_, css) => cb(css));
|
||||||
},
|
},
|
||||||
off(event: string, listener: Parameters<IpcRenderer["off"]>[1]) {
|
|
||||||
assertEventAllowed(event);
|
openFile: () => invoke<void>(IpcEvents.OPEN_QUICKCSS),
|
||||||
ipcRenderer.off(event, listener);
|
openEditor: () => invoke<void>(IpcEvents.OPEN_MONACO_EDITOR),
|
||||||
|
},
|
||||||
|
|
||||||
|
native: {
|
||||||
|
getVersions: () => process.versions as Partial<NodeJS.ProcessVersions>,
|
||||||
|
openExternal: (url: string) => invoke<void>(IpcEvents.OPEN_EXTERNAL, url)
|
||||||
},
|
},
|
||||||
invoke<T = any>(event: string, ...args: any[]): Promise<T> {
|
|
||||||
assertEventAllowed(event);
|
|
||||||
return ipcRenderer.invoke(event, ...args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
@ -79,8 +79,8 @@ export function _getBadges(args: BadgeUserArgs) {
|
|||||||
: badges.push({ ...badge, ...args });
|
: badges.push({ ...badge, ...args });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const donorBadge = (Plugins.BadgeAPI as any).getDonorBadge(args.user.id);
|
const donorBadges = (Plugins.BadgeAPI as unknown as typeof import("../plugins/apiBadges").default).getDonorBadges(args.user.id);
|
||||||
if (donorBadge) badges.unshift(donorBadge);
|
if (donorBadges) badges.unshift(...donorBadges);
|
||||||
|
|
||||||
return badges;
|
return badges;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { makeCodeblock } from "@utils/misc";
|
import { makeCodeblock } from "@utils/text";
|
||||||
|
|
||||||
import { sendBotMessage } from "./commandHelpers";
|
import { sendBotMessage } from "./commandHelpers";
|
||||||
import { ApplicationCommandInputType, ApplicationCommandOptionType, ApplicationCommandType, Argument, Command, CommandContext, Option } from "./types";
|
import { ApplicationCommandInputType, ApplicationCommandOptionType, ApplicationCommandType, Argument, Command, CommandContext, Option } from "./types";
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Logger from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
import type { ReactElement } from "react";
|
import type { ReactElement } from "react";
|
||||||
|
|
||||||
type ContextMenuPatchCallbackReturn = (() => void) | void;
|
type ContextMenuPatchCallbackReturn = (() => void) | void;
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Logger from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
import { MessageStore } from "@webpack/common";
|
import { MessageStore } from "@webpack/common";
|
||||||
import type { Channel, Message } from "discord-types/general";
|
import type { Channel, Message } from "discord-types/general";
|
||||||
import type { Promisable } from "type-fest";
|
import type { Promisable } from "type-fest";
|
||||||
@ -36,10 +36,50 @@ export interface Emoji {
|
|||||||
export interface MessageObject {
|
export interface MessageObject {
|
||||||
content: string,
|
content: string,
|
||||||
validNonShortcutEmojis: Emoji[];
|
validNonShortcutEmojis: Emoji[];
|
||||||
|
invalidEmojis: any[];
|
||||||
|
tts: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Upload {
|
||||||
|
classification: string;
|
||||||
|
currentSize: number;
|
||||||
|
description: string | null;
|
||||||
|
filename: string;
|
||||||
|
id: string;
|
||||||
|
isImage: boolean;
|
||||||
|
isVideo: boolean;
|
||||||
|
item: {
|
||||||
|
file: File;
|
||||||
|
platform: number;
|
||||||
|
};
|
||||||
|
loaded: number;
|
||||||
|
mimeType: string;
|
||||||
|
preCompressionSize: number;
|
||||||
|
responseUrl: string;
|
||||||
|
sensitive: boolean;
|
||||||
|
showLargeMessageDialog: boolean;
|
||||||
|
spoiler: boolean;
|
||||||
|
status: "NOT_STARTED" | "STARTED" | "UPLOADING" | "ERROR" | "COMPLETED" | "CANCELLED";
|
||||||
|
uniqueId: string;
|
||||||
|
uploadedFilename: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MessageReplyOptions {
|
||||||
|
messageReference: Message["messageReference"];
|
||||||
|
allowedMentions?: {
|
||||||
|
parse: Array<string>;
|
||||||
|
repliedUser: boolean;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MessageExtra {
|
export interface MessageExtra {
|
||||||
stickerIds?: string[];
|
stickers?: string[];
|
||||||
|
uploads?: Upload[];
|
||||||
|
replyOptions: MessageReplyOptions;
|
||||||
|
content: string;
|
||||||
|
channel: Channel;
|
||||||
|
type?: any;
|
||||||
|
openWarningPopout: (props: any) => any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SendListener = (channelId: string, messageObj: MessageObject, extra: MessageExtra) => Promisable<void | { cancel: boolean; }>;
|
export type SendListener = (channelId: string, messageObj: MessageObject, extra: MessageExtra) => Promisable<void | { cancel: boolean; }>;
|
||||||
@ -48,7 +88,8 @@ export type EditListener = (channelId: string, messageId: string, messageObj: Me
|
|||||||
const sendListeners = new Set<SendListener>();
|
const sendListeners = new Set<SendListener>();
|
||||||
const editListeners = new Set<EditListener>();
|
const editListeners = new Set<EditListener>();
|
||||||
|
|
||||||
export async function _handlePreSend(channelId: string, messageObj: MessageObject, extra: MessageExtra) {
|
export async function _handlePreSend(channelId: string, messageObj: MessageObject, extra: MessageExtra, replyOptions: MessageReplyOptions) {
|
||||||
|
extra.replyOptions = replyOptions;
|
||||||
for (const listener of sendListeners) {
|
for (const listener of sendListeners) {
|
||||||
try {
|
try {
|
||||||
const result = await listener(channelId, messageObj, extra);
|
const result = await listener(channelId, messageObj, extra);
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Logger from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
import { Channel, Message } from "discord-types/general";
|
import { Channel, Message } from "discord-types/general";
|
||||||
import type { MouseEventHandler } from "react";
|
import type { MouseEventHandler } from "react";
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
import "./styles.css";
|
import "./styles.css";
|
||||||
|
|
||||||
import { useSettings } from "@api/settings";
|
import { useSettings } from "@api/Settings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import { React, useEffect, useMemo, useState, useStateFromStores, WindowStore } from "@webpack/common";
|
import { React, useEffect, useMemo, useState, useStateFromStores, WindowStore } from "@webpack/common";
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Settings } from "@api/settings";
|
import { Settings } from "@api/Settings";
|
||||||
import { Queue } from "@utils/Queue";
|
import { Queue } from "@utils/Queue";
|
||||||
import { ReactDOM } from "@webpack/common";
|
import { ReactDOM } from "@webpack/common";
|
||||||
import type { ReactNode } from "react";
|
import type { ReactNode } from "react";
|
||||||
|
@ -17,10 +17,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import * as DataStore from "@api/DataStore";
|
import * as DataStore from "@api/DataStore";
|
||||||
import { Settings } from "@api/settings";
|
import { Settings } from "@api/Settings";
|
||||||
import { classNameFactory } from "@api/Styles";
|
import { classNameFactory } from "@api/Styles";
|
||||||
import { useAwaiter } from "@utils/misc";
|
|
||||||
import { closeModal, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal";
|
import { closeModal, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal";
|
||||||
|
import { useAwaiter } from "@utils/react";
|
||||||
import { Alerts, Button, Forms, moment, React, Text, Timestamp, useEffect, useReducer, useState } from "@webpack/common";
|
import { Alerts, Button, Forms, moment, React, Text, Timestamp, useEffect, useReducer, useState } from "@webpack/common";
|
||||||
import { nanoid } from "nanoid";
|
import { nanoid } from "nanoid";
|
||||||
import type { DispatchWithoutAction } from "react";
|
import type { DispatchWithoutAction } from "react";
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Logger from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
|
|
||||||
const logger = new Logger("ServerListAPI");
|
const logger = new Logger("ServerListAPI");
|
||||||
|
|
||||||
|
@ -17,9 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { debounce } from "@utils/debounce";
|
import { debounce } from "@utils/debounce";
|
||||||
import IpcEvents from "@utils/IpcEvents";
|
|
||||||
import { localStorage } from "@utils/localStorage";
|
import { localStorage } from "@utils/localStorage";
|
||||||
import Logger from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
import { mergeDefaults } from "@utils/misc";
|
import { mergeDefaults } from "@utils/misc";
|
||||||
import { putCloudSettings } from "@utils/settingsSync";
|
import { putCloudSettings } from "@utils/settingsSync";
|
||||||
import { DefinedSettings, OptionType, SettingsChecks, SettingsDefinition } from "@utils/types";
|
import { DefinedSettings, OptionType, SettingsChecks, SettingsDefinition } from "@utils/types";
|
||||||
@ -94,7 +93,7 @@ const DefaultSettings: Settings = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var settings = JSON.parse(VencordNative.ipc.sendSync(IpcEvents.GET_SETTINGS)) as Settings;
|
var settings = JSON.parse(VencordNative.settings.get()) as Settings;
|
||||||
mergeDefaults(settings, DefaultSettings);
|
mergeDefaults(settings, DefaultSettings);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
var settings = mergeDefaults({} as Settings, DefaultSettings);
|
var settings = mergeDefaults({} as Settings, DefaultSettings);
|
||||||
@ -173,7 +172,7 @@ function makeProxy(settings: any, root = settings, path = ""): Settings {
|
|||||||
PlainSettings.cloud.settingsSyncVersion = Date.now();
|
PlainSettings.cloud.settingsSyncVersion = Date.now();
|
||||||
localStorage.Vencord_settingsDirty = true;
|
localStorage.Vencord_settingsDirty = true;
|
||||||
saveSettingsOnFrequentAction();
|
saveSettingsOnFrequentAction();
|
||||||
VencordNative.ipc.invoke(IpcEvents.SET_SETTINGS, JSON.stringify(root, null, 4));
|
VencordNative.settings.set(JSON.stringify(root, null, 4));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -249,10 +248,7 @@ export function migratePluginSettings(name: string, ...oldNames: string[]) {
|
|||||||
logger.info(`Migrating settings from old name ${oldName} to ${name}`);
|
logger.info(`Migrating settings from old name ${oldName} to ${name}`);
|
||||||
plugins[name] = plugins[oldName];
|
plugins[name] = plugins[oldName];
|
||||||
delete plugins[oldName];
|
delete plugins[oldName];
|
||||||
VencordNative.ipc.invoke(
|
VencordNative.settings.set(JSON.stringify(settings, null, 4));
|
||||||
IpcEvents.SET_SETTINGS,
|
|
||||||
JSON.stringify(settings, null, 4)
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -16,11 +16,11 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Logger from "@utils/Logger";
|
import { proxyLazy } from "@utils/lazy";
|
||||||
import { proxyLazy } from "@utils/proxyLazy";
|
import { Logger } from "@utils/Logger";
|
||||||
import { findModuleId, wreq } from "@webpack";
|
import { findModuleId, wreq } from "@webpack";
|
||||||
|
|
||||||
import { Settings } from "./settings";
|
import { Settings } from "./Settings";
|
||||||
|
|
||||||
interface Setting<T> {
|
interface Setting<T> {
|
||||||
/**
|
/**
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import IpcEvents from "@utils/IpcEvents";
|
|
||||||
import { Button } from "@webpack/common";
|
import { Button } from "@webpack/common";
|
||||||
|
|
||||||
import { Heart } from "./Heart";
|
import { Heart } from "./Heart";
|
||||||
@ -27,9 +26,7 @@ export default function DonateButton(props: any) {
|
|||||||
{...props}
|
{...props}
|
||||||
look={Button.Looks.LINK}
|
look={Button.Looks.LINK}
|
||||||
color={Button.Colors.TRANSPARENT}
|
color={Button.Colors.TRANSPARENT}
|
||||||
onClick={() =>
|
onClick={() => VencordNative.native.openExternal("https://github.com/sponsors/Vendicated")}
|
||||||
VencordNative.ipc.invoke(IpcEvents.OPEN_EXTERNAL, "https://github.com/sponsors/Vendicated")
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<Heart />
|
<Heart />
|
||||||
Donate
|
Donate
|
||||||
|
@ -16,9 +16,9 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Logger from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import { LazyComponent } from "@utils/misc";
|
import { LazyComponent } from "@utils/react";
|
||||||
import { React } from "@webpack/common";
|
import { React } from "@webpack/common";
|
||||||
|
|
||||||
import { ErrorCard } from "./ErrorCard";
|
import { ErrorCard } from "./ErrorCard";
|
||||||
|
83
src/components/Icons.tsx
Normal file
83
src/components/Icons.tsx
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* 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 { classes } from "@utils/misc";
|
||||||
|
import type { PropsWithChildren } from "react";
|
||||||
|
|
||||||
|
interface BaseIconProps extends IconProps {
|
||||||
|
viewBox: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IconProps {
|
||||||
|
className?: string;
|
||||||
|
height?: number;
|
||||||
|
width?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
function Icon({ height = 24, width = 24, className, children, viewBox }: PropsWithChildren<BaseIconProps>) {
|
||||||
|
return (
|
||||||
|
<svg
|
||||||
|
className={classes(className, "vc-icon")}
|
||||||
|
aria-hidden="true"
|
||||||
|
role="img"
|
||||||
|
width={width}
|
||||||
|
height={height}
|
||||||
|
viewBox={viewBox}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Discord's link icon, as seen in the Message context menu "Copy Message Link" option
|
||||||
|
*/
|
||||||
|
export function LinkIcon({ height = 24, width = 24, className }: IconProps) {
|
||||||
|
return (
|
||||||
|
<Icon
|
||||||
|
height={height}
|
||||||
|
width={width}
|
||||||
|
className={classes(className, "vc-link-icon")}
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
>
|
||||||
|
<g fill="none" fill-rule="evenodd">
|
||||||
|
<path fill="currentColor" d="M10.59 13.41c.41.39.41 1.03 0 1.42-.39.39-1.03.39-1.42 0a5.003 5.003 0 0 1 0-7.07l3.54-3.54a5.003 5.003 0 0 1 7.07 0 5.003 5.003 0 0 1 0 7.07l-1.49 1.49c.01-.82-.12-1.64-.4-2.42l.47-.48a2.982 2.982 0 0 0 0-4.24 2.982 2.982 0 0 0-4.24 0l-3.53 3.53a2.982 2.982 0 0 0 0 4.24zm2.82-4.24c.39-.39 1.03-.39 1.42 0a5.003 5.003 0 0 1 0 7.07l-3.54 3.54a5.003 5.003 0 0 1-7.07 0 5.003 5.003 0 0 1 0-7.07l1.49-1.49c-.01.82.12 1.64.4 2.43l-.47.47a2.982 2.982 0 0 0 0 4.24 2.982 2.982 0 0 0 4.24 0l3.53-3.53a2.982 2.982 0 0 0 0-4.24.973.973 0 0 1 0-1.42z" />
|
||||||
|
<rect width={width} height={height} />
|
||||||
|
</g>
|
||||||
|
</Icon>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Discord's copy icon, as seen in the user popout right of the username when clicking
|
||||||
|
* your own username in the bottom left user panel
|
||||||
|
*/
|
||||||
|
export function CopyIcon(props: IconProps) {
|
||||||
|
return (
|
||||||
|
<Icon
|
||||||
|
{...props}
|
||||||
|
className={classes(props.className, "vc-copy-icon")}
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
>
|
||||||
|
<g fill="currentColor">
|
||||||
|
<path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1z" />
|
||||||
|
<path d="M15 5H8c-1.1 0-1.99.9-1.99 2L6 21c0 1.1.89 2 1.99 2H19c1.1 0 2-.9 2-2V11l-6-6zM8 21V7h6v5h5v9H8z" />
|
||||||
|
</g>
|
||||||
|
</Icon>
|
||||||
|
);
|
||||||
|
}
|
@ -1,51 +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 { debounce } from "@utils/debounce";
|
|
||||||
import IpcEvents from "@utils/IpcEvents";
|
|
||||||
import { Queue } from "@utils/Queue";
|
|
||||||
import { find } from "@webpack";
|
|
||||||
|
|
||||||
import monacoHtml from "~fileContent/monacoWin.html";
|
|
||||||
|
|
||||||
const queue = new Queue();
|
|
||||||
const setCss = debounce((css: string) => {
|
|
||||||
queue.push(() => VencordNative.ipc.invoke(IpcEvents.SET_QUICK_CSS, css));
|
|
||||||
});
|
|
||||||
|
|
||||||
export async function launchMonacoEditor() {
|
|
||||||
const features = `popup,width=${Math.min(window.innerWidth, 1000)},height=${Math.min(window.innerHeight, 1000)}`;
|
|
||||||
const win = open("about:blank", "VencordQuickCss", features);
|
|
||||||
if (!win) {
|
|
||||||
alert("Failed to open QuickCSS popup. Make sure to allow popups!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
win.setCss = setCss;
|
|
||||||
win.getCurrentCss = () => VencordNative.ipc.invoke(IpcEvents.GET_QUICK_CSS);
|
|
||||||
win.getTheme = () =>
|
|
||||||
find(m =>
|
|
||||||
m.ProtoClass?.typeName.endsWith("PreloadedUserSettings")
|
|
||||||
)?.getCurrentValue()?.appearance?.theme === 2
|
|
||||||
? "vs-light"
|
|
||||||
: "vs-dark";
|
|
||||||
|
|
||||||
win.document.write(monacoHtml);
|
|
||||||
|
|
||||||
window.__VENCORD_MONACO_WIN__ = new WeakRef(win);
|
|
||||||
}
|
|
@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
import { debounce } from "@utils/debounce";
|
import { debounce } from "@utils/debounce";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import { makeCodeblock } from "@utils/misc";
|
|
||||||
import { canonicalizeMatch, canonicalizeReplace } from "@utils/patches";
|
import { canonicalizeMatch, canonicalizeReplace } from "@utils/patches";
|
||||||
|
import { makeCodeblock } from "@utils/text";
|
||||||
import { ReplaceFn } from "@utils/types";
|
import { ReplaceFn } from "@utils/types";
|
||||||
import { search } from "@webpack";
|
import { search } from "@webpack";
|
||||||
import { Button, Clipboard, Forms, Parser, React, Switch, Text, TextInput } from "@webpack/common";
|
import { Button, Clipboard, Forms, Parser, React, Switch, Text, TextInput } from "@webpack/common";
|
||||||
|
@ -17,13 +17,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { generateId } from "@api/Commands";
|
import { generateId } from "@api/Commands";
|
||||||
import { useSettings } from "@api/settings";
|
import { useSettings } from "@api/Settings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Flex } from "@components/Flex";
|
import { Flex } from "@components/Flex";
|
||||||
|
import { proxyLazy } from "@utils/lazy";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import { classes, LazyComponent } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import { ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize } from "@utils/modal";
|
import { ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize } from "@utils/modal";
|
||||||
import { proxyLazy } from "@utils/proxyLazy";
|
import { LazyComponent } from "@utils/react";
|
||||||
import { OptionType, Plugin } from "@utils/types";
|
import { OptionType, Plugin } from "@utils/types";
|
||||||
import { findByCode, findByPropsLazy } from "@webpack";
|
import { findByCode, findByPropsLazy } from "@webpack";
|
||||||
import { Button, FluxDispatcher, Forms, React, Text, Tooltip, UserStore, UserUtils } from "@webpack/common";
|
import { Button, FluxDispatcher, Forms, React, Text, Tooltip, UserStore, UserUtils } from "@webpack/common";
|
||||||
@ -128,6 +129,8 @@ export default function PluginModal({ plugin, onRestartNeeded, onClose, transiti
|
|||||||
return <Forms.FormText>There are no settings for this plugin.</Forms.FormText>;
|
return <Forms.FormText>There are no settings for this plugin.</Forms.FormText>;
|
||||||
} else {
|
} else {
|
||||||
const options = Object.entries(plugin.options).map(([key, setting]) => {
|
const options = Object.entries(plugin.options).map(([key, setting]) => {
|
||||||
|
if (setting.hidden) return null;
|
||||||
|
|
||||||
function onChange(newValue: any) {
|
function onChange(newValue: any) {
|
||||||
setTempSettings(s => ({ ...s, [key]: newValue }));
|
setTempSettings(s => ({ ...s, [key]: newValue }));
|
||||||
}
|
}
|
||||||
@ -150,7 +153,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 +183,7 @@ export default function PluginModal({ plugin, onRestartNeeded, onClose, transiti
|
|||||||
<Text variant="heading-lg/semibold" style={{ flexGrow: 1 }}>{plugin.name}</Text>
|
<Text variant="heading-lg/semibold" style={{ flexGrow: 1 }}>{plugin.name}</Text>
|
||||||
<ModalCloseButton onClick={onClose} />
|
<ModalCloseButton onClick={onClose} />
|
||||||
</ModalHeader>
|
</ModalHeader>
|
||||||
<ModalContent style={{ marginBottom: 8, marginTop: 8 }}>
|
<ModalContent>
|
||||||
<Forms.FormSection>
|
<Forms.FormSection>
|
||||||
<Forms.FormTitle tag="h3">About {plugin.name}</Forms.FormTitle>
|
<Forms.FormTitle tag="h3">About {plugin.name}</Forms.FormTitle>
|
||||||
<Forms.FormText>{plugin.description}</Forms.FormText>
|
<Forms.FormText>{plugin.description}</Forms.FormText>
|
||||||
|
@ -20,7 +20,7 @@ import "./styles.css";
|
|||||||
|
|
||||||
import * as DataStore from "@api/DataStore";
|
import * as DataStore from "@api/DataStore";
|
||||||
import { showNotice } from "@api/Notices";
|
import { showNotice } from "@api/Notices";
|
||||||
import { useSettings } from "@api/settings";
|
import { useSettings } from "@api/Settings";
|
||||||
import { classNameFactory } from "@api/Styles";
|
import { classNameFactory } from "@api/Styles";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Flex } from "@components/Flex";
|
import { Flex } from "@components/Flex";
|
||||||
@ -29,10 +29,12 @@ import { Badge } from "@components/PluginSettings/components";
|
|||||||
import PluginModal from "@components/PluginSettings/PluginModal";
|
import PluginModal from "@components/PluginSettings/PluginModal";
|
||||||
import { Switch } from "@components/Switch";
|
import { Switch } from "@components/Switch";
|
||||||
import { ChangeList } from "@utils/ChangeList";
|
import { ChangeList } from "@utils/ChangeList";
|
||||||
import Logger from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import { classes, LazyComponent, useAwaiter } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import { openModalLazy } from "@utils/modal";
|
import { openModalLazy } from "@utils/modal";
|
||||||
|
import { onlyOnce } from "@utils/onlyOnce";
|
||||||
|
import { LazyComponent, useAwaiter } from "@utils/react";
|
||||||
import { Plugin } from "@utils/types";
|
import { Plugin } from "@utils/types";
|
||||||
import { findByCode, findByPropsLazy } from "@webpack";
|
import { findByCode, findByPropsLazy } from "@webpack";
|
||||||
import { Alerts, Button, Card, Forms, Parser, React, Select, Text, TextInput, Toasts, Tooltip } from "@webpack/common";
|
import { Alerts, Button, Card, Forms, Parser, React, Select, Text, TextInput, Toasts, Tooltip } from "@webpack/common";
|
||||||
@ -125,7 +127,7 @@ function PluginCard({ plugin, disabled, onRestartNeeded, onMouseEnter, onMouseLe
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if the plugin has patches, dont use stopPlugin/startPlugin. Wait for restart to apply changes.
|
// if the plugin has patches, dont use stopPlugin/startPlugin. Wait for restart to apply changes.
|
||||||
if (plugin.patches) {
|
if (plugin.patches?.length) {
|
||||||
settings.enabled = !wasEnabled;
|
settings.enabled = !wasEnabled;
|
||||||
onRestartNeeded(plugin.name);
|
onRestartNeeded(plugin.name);
|
||||||
return;
|
return;
|
||||||
@ -258,6 +260,9 @@ export default ErrorBoundary.wrap(function PluginSettings() {
|
|||||||
requiredPlugins = [];
|
requiredPlugins = [];
|
||||||
|
|
||||||
for (const p of sortedPlugins) {
|
for (const p of sortedPlugins) {
|
||||||
|
if (!p.options && p.name.endsWith("API") && searchValue.value !== "API")
|
||||||
|
continue;
|
||||||
|
|
||||||
if (!pluginFilter(p)) continue;
|
if (!pluginFilter(p)) continue;
|
||||||
|
|
||||||
const isRequired = p.required || depMap[p.name]?.some(d => settings.plugins[d].enabled);
|
const isRequired = p.required || depMap[p.name]?.some(d => settings.plugins[d].enabled);
|
||||||
@ -341,7 +346,7 @@ export default ErrorBoundary.wrap(function PluginSettings() {
|
|||||||
);
|
);
|
||||||
}, {
|
}, {
|
||||||
message: "Failed to render the Plugin Settings. If this persists, try using the installer to reinstall!",
|
message: "Failed to render the Plugin Settings. If this persists, try using the installer to reinstall!",
|
||||||
onError: handleComponentFailed,
|
onError: onlyOnce(handleComponentFailed),
|
||||||
});
|
});
|
||||||
|
|
||||||
function makeDependencyList(deps: string[]) {
|
function makeDependencyList(deps: string[]) {
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { showNotification } from "@api/Notifications";
|
import { showNotification } from "@api/Notifications";
|
||||||
import { Settings, useSettings } from "@api/settings";
|
import { Settings, useSettings } from "@api/Settings";
|
||||||
import { CheckedTextInput } from "@components/CheckedTextInput";
|
import { CheckedTextInput } from "@components/CheckedTextInput";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Link } from "@components/Link";
|
import { Link } from "@components/Link";
|
||||||
|
@ -16,11 +16,11 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { useSettings } from "@api/settings";
|
import { useSettings } from "@api/Settings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Link } from "@components/Link";
|
import { Link } from "@components/Link";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import { useAwaiter } from "@utils/misc";
|
import { useAwaiter } from "@utils/react";
|
||||||
import { findLazy } from "@webpack";
|
import { findLazy } from "@webpack";
|
||||||
import { Card, Forms, React, TextArea } from "@webpack/common";
|
import { Card, Forms, React, TextArea } from "@webpack/common";
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ export default ErrorBoundary.wrap(function () {
|
|||||||
<Card className="vc-settings-card vc-text-selectable">
|
<Card className="vc-settings-card vc-text-selectable">
|
||||||
<Forms.FormTitle tag="h5">Paste links to .theme.css files here</Forms.FormTitle>
|
<Forms.FormTitle tag="h5">Paste links to .theme.css files here</Forms.FormTitle>
|
||||||
<Forms.FormText>One link per line</Forms.FormText>
|
<Forms.FormText>One link per line</Forms.FormText>
|
||||||
<Forms.FormText>Make sure to use the raw links or github.io links!</Forms.FormText>
|
<Forms.FormText><strong>Make sure to use the raw links or github.io links!</strong></Forms.FormText>
|
||||||
<Forms.FormDivider className={Margins.top8 + " " + Margins.bottom8} />
|
<Forms.FormDivider className={Margins.top8 + " " + Margins.bottom8} />
|
||||||
<Forms.FormTitle tag="h5">Find Themes:</Forms.FormTitle>
|
<Forms.FormTitle tag="h5">Find Themes:</Forms.FormTitle>
|
||||||
<div style={{ marginBottom: ".5em" }}>
|
<div style={{ marginBottom: ".5em" }}>
|
||||||
|
@ -16,16 +16,18 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { useSettings } from "@api/settings";
|
import { useSettings } from "@api/Settings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { ErrorCard } from "@components/ErrorCard";
|
import { ErrorCard } from "@components/ErrorCard";
|
||||||
import { Flex } from "@components/Flex";
|
import { Flex } from "@components/Flex";
|
||||||
import { handleComponentFailed } from "@components/handleComponentFailed";
|
import { handleComponentFailed } from "@components/handleComponentFailed";
|
||||||
import { Link } from "@components/Link";
|
import { Link } from "@components/Link";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import { classes, useAwaiter } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import { relaunch } from "@utils/native";
|
import { relaunch } from "@utils/native";
|
||||||
import { changes, checkForUpdates, getRepo, isNewer, rebuild, update, updateError, UpdateLogger } from "@utils/updater";
|
import { onlyOnce } from "@utils/onlyOnce";
|
||||||
|
import { useAwaiter } from "@utils/react";
|
||||||
|
import { changes, checkForUpdates, getRepo, isNewer, update, updateError, UpdateLogger } from "@utils/updater";
|
||||||
import { Alerts, Button, Card, Forms, Parser, React, Switch, Toasts } from "@webpack/common";
|
import { Alerts, Button, Card, Forms, Parser, React, Switch, Toasts } from "@webpack/common";
|
||||||
|
|
||||||
import gitHash from "~git-hash";
|
import gitHash from "~git-hash";
|
||||||
@ -125,7 +127,6 @@ function Updatable(props: CommonProps) {
|
|||||||
onClick={withDispatcher(setIsUpdating, async () => {
|
onClick={withDispatcher(setIsUpdating, async () => {
|
||||||
if (await update()) {
|
if (await update()) {
|
||||||
setUpdates([]);
|
setUpdates([]);
|
||||||
await rebuild();
|
|
||||||
await new Promise<void>(r => {
|
await new Promise<void>(r => {
|
||||||
Alerts.show({
|
Alerts.show({
|
||||||
title: "Update Success!",
|
title: "Update Success!",
|
||||||
@ -251,5 +252,5 @@ function Updater() {
|
|||||||
|
|
||||||
export default IS_WEB ? null : ErrorBoundary.wrap(Updater, {
|
export default IS_WEB ? null : ErrorBoundary.wrap(Updater, {
|
||||||
message: "Failed to render the Updater. If this persists, try using the installer to reinstall!",
|
message: "Failed to render the Updater. If this persists, try using the installer to reinstall!",
|
||||||
onError: handleComponentFailed,
|
onError: onlyOnce(handleComponentFailed),
|
||||||
});
|
});
|
||||||
|
@ -18,15 +18,15 @@
|
|||||||
|
|
||||||
|
|
||||||
import { openNotificationLogModal } from "@api/Notifications/notificationLog";
|
import { openNotificationLogModal } from "@api/Notifications/notificationLog";
|
||||||
import { Settings, useSettings } from "@api/settings";
|
import { Settings, useSettings } from "@api/Settings";
|
||||||
import { classNameFactory } from "@api/Styles";
|
import { classNameFactory } from "@api/Styles";
|
||||||
import DonateButton from "@components/DonateButton";
|
import DonateButton from "@components/DonateButton";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { ErrorCard } from "@components/ErrorCard";
|
import { ErrorCard } from "@components/ErrorCard";
|
||||||
import IpcEvents from "@utils/IpcEvents";
|
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import { identity, useAwaiter } from "@utils/misc";
|
import { identity } from "@utils/misc";
|
||||||
import { relaunch, showItemInFolder } from "@utils/native";
|
import { relaunch, showItemInFolder } from "@utils/native";
|
||||||
|
import { useAwaiter } from "@utils/react";
|
||||||
import { Button, Card, Forms, React, Select, Slider, Switch } from "@webpack/common";
|
import { Button, Card, Forms, React, Select, Slider, Switch } from "@webpack/common";
|
||||||
|
|
||||||
const cl = classNameFactory("vc-settings-");
|
const cl = classNameFactory("vc-settings-");
|
||||||
@ -39,7 +39,7 @@ type KeysOfType<Object, Type> = {
|
|||||||
}[keyof Object];
|
}[keyof Object];
|
||||||
|
|
||||||
function VencordSettings() {
|
function VencordSettings() {
|
||||||
const [settingsDir, , settingsDirPending] = useAwaiter(() => VencordNative.ipc.invoke<string>(IpcEvents.GET_SETTINGS_DIR), {
|
const [settingsDir, , settingsDirPending] = useAwaiter(VencordNative.settings.getSettingsDir, {
|
||||||
fallbackValue: "Loading..."
|
fallbackValue: "Loading..."
|
||||||
});
|
});
|
||||||
const settings = useSettings();
|
const settings = useSettings();
|
||||||
@ -101,40 +101,35 @@ function VencordSettings() {
|
|||||||
<DonateCard image={donateImage} />
|
<DonateCard image={donateImage} />
|
||||||
<Forms.FormSection title="Quick Actions">
|
<Forms.FormSection title="Quick Actions">
|
||||||
<Card className={cl("quick-actions-card")}>
|
<Card className={cl("quick-actions-card")}>
|
||||||
{IS_WEB ? (
|
|
||||||
<Button
|
|
||||||
onClick={() => require("../Monaco").launchMonacoEditor()}
|
|
||||||
size={Button.Sizes.SMALL}
|
|
||||||
disabled={settingsDir === "Loading..."}>
|
|
||||||
Open QuickCSS File
|
|
||||||
</Button>
|
|
||||||
) : (
|
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
|
{!IS_WEB && (
|
||||||
<Button
|
<Button
|
||||||
onClick={relaunch}
|
onClick={relaunch}
|
||||||
size={Button.Sizes.SMALL}>
|
size={Button.Sizes.SMALL}>
|
||||||
Restart Client
|
Restart Client
|
||||||
</Button>
|
</Button>
|
||||||
|
)}
|
||||||
<Button
|
<Button
|
||||||
onClick={() => VencordNative.ipc.invoke(IpcEvents.OPEN_MONACO_EDITOR)}
|
onClick={() => VencordNative.quickCss.openEditor()}
|
||||||
size={Button.Sizes.SMALL}
|
size={Button.Sizes.SMALL}
|
||||||
disabled={settingsDir === "Loading..."}>
|
disabled={settingsDir === "Loading..."}>
|
||||||
Open QuickCSS File
|
Open QuickCSS File
|
||||||
</Button>
|
</Button>
|
||||||
|
{!IS_WEB && (
|
||||||
<Button
|
<Button
|
||||||
onClick={() => showItemInFolder(settingsDir)}
|
onClick={() => showItemInFolder(settingsDir)}
|
||||||
size={Button.Sizes.SMALL}
|
size={Button.Sizes.SMALL}
|
||||||
disabled={settingsDirPending}>
|
disabled={settingsDirPending}>
|
||||||
Open Settings Folder
|
Open Settings Folder
|
||||||
</Button>
|
</Button>
|
||||||
|
)}
|
||||||
<Button
|
<Button
|
||||||
onClick={() => VencordNative.ipc.invoke(IpcEvents.OPEN_EXTERNAL, "https://github.com/Vendicated/Vencord")}
|
onClick={() => VencordNative.native.openExternal("https://github.com/Vendicated/Vencord")}
|
||||||
size={Button.Sizes.SMALL}
|
size={Button.Sizes.SMALL}
|
||||||
disabled={settingsDirPending}>
|
disabled={settingsDirPending}>
|
||||||
Open in GitHub
|
Open in GitHub
|
||||||
</Button>
|
</Button>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
)}
|
|
||||||
</Card>
|
</Card>
|
||||||
</Forms.FormSection>
|
</Forms.FormSection>
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ import { classNameFactory } from "@api/Styles";
|
|||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { handleComponentFailed } from "@components/handleComponentFailed";
|
import { handleComponentFailed } from "@components/handleComponentFailed";
|
||||||
import { isMobile } from "@utils/misc";
|
import { isMobile } from "@utils/misc";
|
||||||
|
import { onlyOnce } from "@utils/onlyOnce";
|
||||||
import { Forms, SettingsRouter, TabBar, Text } from "@webpack/common";
|
import { Forms, SettingsRouter, TabBar, Text } from "@webpack/common";
|
||||||
|
|
||||||
import BackupRestoreTab from "./BackupRestoreTab";
|
import BackupRestoreTab from "./BackupRestoreTab";
|
||||||
@ -86,8 +87,10 @@ function Settings(props: SettingsProps) {
|
|||||||
</Forms.FormSection >;
|
</Forms.FormSection >;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onError = onlyOnce(handleComponentFailed);
|
||||||
|
|
||||||
export default function (props: SettingsProps) {
|
export default function (props: SettingsProps) {
|
||||||
return <ErrorBoundary onError={handleComponentFailed}>
|
return <ErrorBoundary onError={onError}>
|
||||||
<Settings tab={props.tab} />
|
<Settings tab={props.tab} />
|
||||||
</ErrorBoundary>;
|
</ErrorBoundary>;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
gap: 1em;
|
gap: 1em;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-evenly;
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
flex-flow: row wrap;
|
flex-flow: row wrap;
|
||||||
margin-bottom: 1em;
|
margin-bottom: 1em;
|
||||||
@ -59,7 +59,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.vc-text-selectable,
|
.vc-text-selectable,
|
||||||
.vc-text-selectable :not(a, button) {
|
.vc-text-selectable :not(a, button, a *, button *) {
|
||||||
/* make text selectable, silly discord makes the entirety of settings not selectable */
|
/* make text selectable, silly discord makes the entirety of settings not selectable */
|
||||||
user-select: text;
|
user-select: text;
|
||||||
|
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
<!doctype html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8" />
|
||||||
<title>Vencord QuickCSS Editor</title>
|
<title>Vencord QuickCSS Editor</title>
|
||||||
<link rel="stylesheet" data-name="vs/editor/editor.main"
|
<link
|
||||||
href="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.34.0/min/vs/editor/editor.main.min.css">
|
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>
|
<style>
|
||||||
html,
|
html,
|
||||||
body,
|
body,
|
||||||
@ -24,17 +28,30 @@
|
|||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="container"></div>
|
<div id="container"></div>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.34.0/min/vs/loader.min.js"></script>
|
<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>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
require.config({ paths: { 'vs': 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.34.0/min/vs' } });
|
require.config({
|
||||||
require(["vs/editor/editor.main"], () => {
|
paths: {
|
||||||
getCurrentCss().then(css => {
|
vs: "https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.37.1/min/vs",
|
||||||
var editor = monaco.editor.create(document.getElementById('container'), {
|
},
|
||||||
value: css,
|
|
||||||
language: 'css',
|
|
||||||
theme: getTheme(),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
require(["vs/editor/editor.main"], () => {
|
||||||
|
getCurrentCss().then((css) => {
|
||||||
|
var editor = monaco.editor.create(
|
||||||
|
document.getElementById("container"),
|
||||||
|
{
|
||||||
|
value: css,
|
||||||
|
language: "css",
|
||||||
|
theme: getTheme(),
|
||||||
|
}
|
||||||
|
);
|
||||||
editor.onDidChangeModelContent(() =>
|
editor.onDidChangeModelContent(() =>
|
||||||
setCss(editor.getValue())
|
setCss(editor.getValue())
|
||||||
);
|
);
|
||||||
@ -44,9 +61,6 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Logger from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
|
|
||||||
if (IS_DEV) {
|
if (IS_DEV) {
|
||||||
var traces = {} as Record<string, [number, any[]]>;
|
var traces = {} as Record<string, [number, any[]]>;
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
import "./updater";
|
import "./updater";
|
||||||
|
|
||||||
import { debounce } from "@utils/debounce";
|
import { debounce } from "@utils/debounce";
|
||||||
import IpcEvents from "@utils/IpcEvents";
|
import { IpcEvents } from "@utils/IpcEvents";
|
||||||
import { Queue } from "@utils/Queue";
|
import { Queue } from "@utils/Queue";
|
||||||
import { BrowserWindow, ipcMain, shell } from "electron";
|
import { BrowserWindow, ipcMain, shell } from "electron";
|
||||||
import { mkdirSync, readFileSync, watch } from "fs";
|
import { mkdirSync, readFileSync, watch } from "fs";
|
||||||
@ -44,7 +44,7 @@ export function readSettings() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getSettings(): typeof import("@api/settings").Settings {
|
export function getSettings(): typeof import("@api/Settings").Settings {
|
||||||
try {
|
try {
|
||||||
return JSON.parse(readSettings());
|
return JSON.parse(readSettings());
|
||||||
} catch {
|
} catch {
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import IpcEvents from "@utils/IpcEvents";
|
import { IpcEvents } from "@utils/IpcEvents";
|
||||||
import { execFile as cpExecFile } from "child_process";
|
import { execFile as cpExecFile } from "child_process";
|
||||||
import { ipcMain } from "electron";
|
import { ipcMain } from "electron";
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { VENCORD_USER_AGENT } from "@utils/constants";
|
import { VENCORD_USER_AGENT } from "@utils/constants";
|
||||||
import IpcEvents from "@utils/IpcEvents";
|
import { IpcEvents } from "@utils/IpcEvents";
|
||||||
import { ipcMain } from "electron";
|
import { ipcMain } from "electron";
|
||||||
import { writeFile } from "fs/promises";
|
import { writeFile } from "fs/promises";
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Settings } from "@api/settings";
|
import { Settings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
|
|
||||||
|
@ -22,12 +22,11 @@ import ErrorBoundary from "@components/ErrorBoundary";
|
|||||||
import { Flex } from "@components/Flex";
|
import { Flex } from "@components/Flex";
|
||||||
import { Heart } from "@components/Heart";
|
import { Heart } from "@components/Heart";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import IpcEvents from "@utils/IpcEvents";
|
import { Logger } from "@utils/Logger";
|
||||||
import Logger from "@utils/Logger";
|
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import { closeModal, Modals, openModal } from "@utils/modal";
|
import { closeModal, Modals, openModal } from "@utils/modal";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { Forms } from "@webpack/common";
|
import { Forms, Toasts } from "@webpack/common";
|
||||||
|
|
||||||
const CONTRIBUTOR_BADGE = "https://cdn.discordapp.com/attachments/1033680203433660458/1092089947126780035/favicon.png";
|
const CONTRIBUTOR_BADGE = "https://cdn.discordapp.com/attachments/1033680203433660458/1092089947126780035/favicon.png";
|
||||||
|
|
||||||
@ -48,7 +47,29 @@ const ContributorBadge: ProfileBadge = {
|
|||||||
link: "https://github.com/Vendicated/Vencord"
|
link: "https://github.com/Vendicated/Vencord"
|
||||||
};
|
};
|
||||||
|
|
||||||
const DonorBadges = {} as Record<string, Pick<ProfileBadge, "image" | "description">>;
|
let DonorBadges = {} as Record<string, Pick<ProfileBadge, "image" | "description">[]>;
|
||||||
|
|
||||||
|
async function loadBadges(noCache = false) {
|
||||||
|
DonorBadges = {};
|
||||||
|
|
||||||
|
const init = {} as RequestInit;
|
||||||
|
if (noCache)
|
||||||
|
init.cache = "no-cache";
|
||||||
|
|
||||||
|
const badges = await fetch("https://gist.githubusercontent.com/Vendicated/51a3dd775f6920429ec6e9b735ca7f01/raw/badges.csv", init)
|
||||||
|
.then(r => r.text());
|
||||||
|
|
||||||
|
const lines = badges.trim().split("\n");
|
||||||
|
if (lines.shift() !== "id,tooltip,image") {
|
||||||
|
new Logger("BadgeAPI").error("Invalid badges.csv file!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const line of lines) {
|
||||||
|
const [id, description, image] = line.split(",");
|
||||||
|
(DonorBadges[id] ??= []).push({ image, description });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "BadgeAPI",
|
name: "BadgeAPI",
|
||||||
@ -56,21 +77,17 @@ export default definePlugin({
|
|||||||
authors: [Devs.Megu, Devs.Ven, Devs.TheSun],
|
authors: [Devs.Megu, Devs.Ven, Devs.TheSun],
|
||||||
required: true,
|
required: true,
|
||||||
patches: [
|
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 */
|
/* Patch the badge list component on user profiles */
|
||||||
{
|
{
|
||||||
find: "Messages.PROFILE_USER_BADGES,role:",
|
find: "Messages.PROFILE_USER_BADGES,role:",
|
||||||
replacement: [
|
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
|
// 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 ?? ...
|
// ...badge.props, ..., src: badge.image ?? ...
|
||||||
replace: "...$1.props,$& $1.image??"
|
replace: "...$1.props,$& $1.image??"
|
||||||
},
|
},
|
||||||
@ -86,29 +103,30 @@ export default definePlugin({
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
toolboxActions: {
|
||||||
|
async "Refetch Badges"() {
|
||||||
|
await loadBadges(true);
|
||||||
|
Toasts.show({
|
||||||
|
id: Toasts.genId(),
|
||||||
|
message: "Successfully refetched badges!",
|
||||||
|
type: Toasts.Type.SUCCESS
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
async start() {
|
||||||
|
Vencord.Api.Badges.addBadge(ContributorBadge);
|
||||||
|
await loadBadges();
|
||||||
|
},
|
||||||
|
|
||||||
renderBadgeComponent: ErrorBoundary.wrap((badge: ProfileBadge & BadgeUserArgs) => {
|
renderBadgeComponent: ErrorBoundary.wrap((badge: ProfileBadge & BadgeUserArgs) => {
|
||||||
const Component = badge.component!;
|
const Component = badge.component!;
|
||||||
return <Component {...badge} />;
|
return <Component {...badge} />;
|
||||||
}, { noop: true }),
|
}, { noop: true }),
|
||||||
|
|
||||||
async start() {
|
|
||||||
Vencord.Api.Badges.addBadge(ContributorBadge);
|
|
||||||
const badges = await fetch("https://gist.githubusercontent.com/Vendicated/51a3dd775f6920429ec6e9b735ca7f01/raw/badges.csv").then(r => r.text());
|
|
||||||
const lines = badges.trim().split("\n");
|
|
||||||
if (lines.shift() !== "id,tooltip,image") {
|
|
||||||
new Logger("BadgeAPI").error("Invalid badges.csv file!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (const line of lines) {
|
|
||||||
const [id, description, image] = line.split(",");
|
|
||||||
DonorBadges[id] = { image, description };
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
getDonorBadge(userId: string) {
|
getDonorBadges(userId: string) {
|
||||||
const badge = DonorBadges[userId];
|
return DonorBadges[userId]?.map(badge => ({
|
||||||
if (badge) {
|
|
||||||
return {
|
|
||||||
...badge,
|
...badge,
|
||||||
position: BadgePosition.START,
|
position: BadgePosition.START,
|
||||||
props: {
|
props: {
|
||||||
@ -121,7 +139,7 @@ export default definePlugin({
|
|||||||
const modalKey = openModal(props => (
|
const modalKey = openModal(props => (
|
||||||
<ErrorBoundary noop onError={() => {
|
<ErrorBoundary noop onError={() => {
|
||||||
closeModal(modalKey);
|
closeModal(modalKey);
|
||||||
VencordNative.ipc.invoke(IpcEvents.OPEN_EXTERNAL, "https://github.com/sponsors/Vendicated");
|
VencordNative.native.openExternal("https://github.com/sponsors/Vendicated");
|
||||||
}}>
|
}}>
|
||||||
<Modals.ModalRoot {...props}>
|
<Modals.ModalRoot {...props}>
|
||||||
<Modals.ModalHeader>
|
<Modals.ModalHeader>
|
||||||
@ -172,7 +190,6 @@ export default definePlugin({
|
|||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
};
|
}));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -22,17 +22,29 @@ import definePlugin from "@utils/types";
|
|||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "MessageEventsAPI",
|
name: "MessageEventsAPI",
|
||||||
description: "Api required by anything using message events.",
|
description: "Api required by anything using message events.",
|
||||||
authors: [Devs.Arjix, Devs.hunt],
|
authors: [Devs.Arjix, Devs.hunt, Devs.Ven],
|
||||||
patches: [
|
patches: [
|
||||||
{
|
{
|
||||||
find: '"MessageActionCreators"',
|
find: '"MessageActionCreators"',
|
||||||
replacement: [{
|
replacement: {
|
||||||
match: /_sendMessage:(function\([^)]+\)){/,
|
// editMessage: function (...) {
|
||||||
replace: "_sendMessage:async $1{if(await Vencord.Api.MessageEvents._handlePreSend(...arguments))return;"
|
match: /\beditMessage:(function\(.+?\))\{/,
|
||||||
}, {
|
// editMessage: async function (...) { await handlePreEdit(...); ...
|
||||||
match: /\beditMessage:(function\([^)]+\)){/,
|
|
||||||
replace: "editMessage:async $1{await Vencord.Api.MessageEvents._handlePreEdit(...arguments);"
|
replace: "editMessage:async $1{await Vencord.Api.MessageEvents._handlePreEdit(...arguments);"
|
||||||
}]
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
find: ".handleSendMessage=",
|
||||||
|
replacement: {
|
||||||
|
// props.chatInputType...then((function(isMessageValid)... var parsedMessage = b.c.parse(channel,... var replyOptions = f.g.getSendMessageOptionsForReply(pendingReply);
|
||||||
|
// Lookbehind: validateMessage)({openWarningPopout:..., type: i.props.chatInputType, content: t, stickers: r, ...}).then((function(isMessageValid)
|
||||||
|
match: /(props\.chatInputType.+?\.then\(\()(function.+?var (\i)=\i\.\i\.parse\((\i),.+?var (\i)=\i\.\i\.getSendMessageOptionsForReply\(\i\);)(?<=\)\(({.+?})\)\.then.+?)/,
|
||||||
|
// props.chatInputType...then((async function(isMessageValid)... var replyOptions = f.g.getSendMessageOptionsForReply(pendingReply); if(await Vencord.api...) return { shoudClear:true, shouldRefocus:true };
|
||||||
|
replace: (_, rest1, rest2, parsedMessage, channel, replyOptions, extra) => "" +
|
||||||
|
`${rest1}async ${rest2}` +
|
||||||
|
`if(await Vencord.Api.MessageEvents._handlePreSend(${channel}.id,${parsedMessage},${extra},${replyOptions}))` +
|
||||||
|
"return{shoudClear:true,shouldRefocus:true};"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
find: '("interactionUsernameProfile',
|
find: '("interactionUsernameProfile',
|
||||||
|
@ -32,7 +32,7 @@ export default definePlugin({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
find: "Messages.SERVERS",
|
find: "Messages.SERVERS,children",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /(Messages\.SERVERS,children:)(.+?default:return null\}\}\)\))/,
|
match: /(Messages\.SERVERS,children:)(.+?default:return null\}\}\)\))/,
|
||||||
replace: "$1Vencord.Api.ServerList.renderAll(Vencord.Api.ServerList.ServerListRenderPosition.In).concat($2)"
|
replace: "$1Vencord.Api.ServerList.renderAll(Vencord.Api.ServerList.ServerListRenderPosition.In).concat($2)"
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Settings } from "@api/settings";
|
import { Settings } from "@api/Settings";
|
||||||
import { classNameFactory } from "@api/Styles";
|
import { classNameFactory } from "@api/Styles";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { findByPropsLazy, findStoreLazy } from "@webpack";
|
import { findByPropsLazy, findStoreLazy } from "@webpack";
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
import "./betterFolders.css";
|
import "./betterFolders.css";
|
||||||
|
|
||||||
import { definePluginSettings } from "@api/settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy, findLazy, findStoreLazy } from "@webpack";
|
import { findByPropsLazy, findLazy, findStoreLazy } from "@webpack";
|
||||||
|
@ -16,9 +16,8 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Settings } from "@api/settings";
|
import { Settings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { makeLazy } from "@utils/misc";
|
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
@ -30,7 +29,7 @@ export default definePlugin({
|
|||||||
{
|
{
|
||||||
find: "hideNote:",
|
find: "hideNote:",
|
||||||
all: true,
|
all: true,
|
||||||
predicate: makeLazy(() => Vencord.Settings.plugins.BetterNotesBox.hide),
|
predicate: () => Vencord.Settings.plugins.BetterNotesBox.hide,
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /hideNote:.+?(?=[,}])/g,
|
match: /hideNote:.+?(?=[,}])/g,
|
||||||
replace: "hideNote:true",
|
replace: "hideNote:true",
|
||||||
|
@ -16,12 +16,11 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* 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 { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { Clipboard, Toasts } from "@webpack/common";
|
import { Clipboard, Toasts } from "@webpack/common";
|
||||||
|
|
||||||
migratePluginSettings("BetterRoleDot", "ClickableRoleDot");
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "BetterRoleDot",
|
name: "BetterRoleDot",
|
||||||
authors: [Devs.Ven],
|
authors: [Devs.Ven],
|
||||||
@ -30,10 +29,10 @@ export default definePlugin({
|
|||||||
|
|
||||||
patches: [
|
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: {
|
replacement: {
|
||||||
match: /viewBox:"0 0 20 20"/,
|
match: /,viewBox:"0 0 20 20"/,
|
||||||
replace: "$&,onClick:()=>$self.copyToClipBoard(e.color),style:{cursor:'pointer'}",
|
replace: "$&,onClick:()=>$self.copyToClipBoard(arguments[0].color),style:{cursor:'pointer'}",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Settings } from "@api/settings";
|
import { Settings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Settings } from "@api/settings";
|
import { Settings } from "@api/Settings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
|
@ -23,7 +23,6 @@ import {
|
|||||||
removePreEditListener,
|
removePreEditListener,
|
||||||
removePreSendListener
|
removePreSendListener
|
||||||
} from "@api/MessageEvents";
|
} from "@api/MessageEvents";
|
||||||
import { migratePluginSettings } from "@api/settings";
|
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
|
|
||||||
@ -33,7 +32,6 @@ import { defaultRules } from "./defaultRules";
|
|||||||
const reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
const reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
||||||
const reHasRegExpChar = RegExp(reRegExpChar.source);
|
const reHasRegExpChar = RegExp(reRegExpChar.source);
|
||||||
|
|
||||||
migratePluginSettings("ClearURLs", "clearURLs");
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "ClearURLs",
|
name: "ClearURLs",
|
||||||
description: "Removes tracking garbage from URLs",
|
description: "Removes tracking garbage from URLs",
|
||||||
|
@ -17,9 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { showNotification } from "@api/Notifications";
|
import { showNotification } from "@api/Notifications";
|
||||||
import { definePluginSettings } from "@api/settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import Logger from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
import { closeAllModals } from "@utils/modal";
|
import { closeAllModals } from "@utils/modal";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { maybePromptToUpdate } from "@utils/updater";
|
import { maybePromptToUpdate } from "@utils/updater";
|
||||||
|
@ -16,11 +16,11 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { definePluginSettings } from "@api/settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { Link } from "@components/Link";
|
import { Link } from "@components/Link";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { isTruthy } from "@utils/guards";
|
import { isTruthy } from "@utils/guards";
|
||||||
import { useAwaiter } from "@utils/misc";
|
import { useAwaiter } from "@utils/react";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { filters, findByCodeLazy, findByPropsLazy, mapMangledModuleLazy } from "@webpack";
|
import { filters, findByCodeLazy, findByPropsLazy, mapMangledModuleLazy } from "@webpack";
|
||||||
import {
|
import {
|
||||||
|
@ -16,15 +16,13 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { addContextMenuPatch, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu";
|
|
||||||
import { showNotification } from "@api/Notifications";
|
import { showNotification } from "@api/Notifications";
|
||||||
import { definePluginSettings } from "@api/settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import Logger from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
import { canonicalizeMatch, canonicalizeReplace } from "@utils/patches";
|
import { canonicalizeMatch, canonicalizeReplace } from "@utils/patches";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { filters, findAll, search } from "@webpack";
|
import { filters, findAll, search } from "@webpack";
|
||||||
import { Menu } from "@webpack/common";
|
|
||||||
|
|
||||||
const PORT = 8485;
|
const PORT = 8485;
|
||||||
const NAV_ID = "dev-companion-reconnect";
|
const NAV_ID = "dev-companion-reconnect";
|
||||||
@ -238,33 +236,25 @@ function initWs(isManual = false) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const contextMenuPatch: NavContextMenuPatchCallback = children => () => {
|
|
||||||
children.unshift(
|
|
||||||
<Menu.MenuItem
|
|
||||||
id={NAV_ID}
|
|
||||||
label="Reconnect Dev Companion"
|
|
||||||
action={() => {
|
|
||||||
socket?.close(1000, "Reconnecting");
|
|
||||||
initWs(true);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "DevCompanion",
|
name: "DevCompanion",
|
||||||
description: "Dev Companion Plugin",
|
description: "Dev Companion Plugin",
|
||||||
authors: [Devs.Ven],
|
authors: [Devs.Ven],
|
||||||
settings,
|
settings,
|
||||||
|
|
||||||
|
toolboxActions: {
|
||||||
|
"Reconnect"() {
|
||||||
|
socket?.close(1000, "Reconnecting");
|
||||||
|
initWs(true);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
initWs();
|
initWs();
|
||||||
addContextMenuPatch("user-settings-cog", contextMenuPatch);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
socket?.close(1000, "Plugin Stopped");
|
socket?.close(1000, "Plugin Stopped");
|
||||||
socket = void 0;
|
socket = void 0;
|
||||||
removeContextMenuPatch("user-settings-cog", contextMenuPatch);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
import { addContextMenuPatch, findGroupChildrenByChildId, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu";
|
import { addContextMenuPatch, findGroupChildrenByChildId, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu";
|
||||||
import { CheckedTextInput } from "@components/CheckedTextInput";
|
import { CheckedTextInput } from "@components/CheckedTextInput";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import Logger from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import { ModalContent, ModalHeader, ModalRoot, openModal } from "@utils/modal";
|
import { ModalContent, ModalHeader, ModalRoot, openModal } from "@utils/modal";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
|
@ -16,8 +16,11 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { definePluginSettings } from "@api/settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
|
import { ErrorCard } from "@components/ErrorCard";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
|
import { Margins } from "@utils/margins";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByPropsLazy } from "@webpack";
|
||||||
import { Forms, React } from "@webpack/common";
|
import { Forms, React } from "@webpack/common";
|
||||||
@ -87,6 +90,13 @@ export default definePlugin({
|
|||||||
match: /"staging"===window\.GLOBAL_ENV\.RELEASE_CHANNEL/,
|
match: /"staging"===window\.GLOBAL_ENV\.RELEASE_CHANNEL/,
|
||||||
replace: "true"
|
replace: "true"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
find: 'H1,title:"Experiments"',
|
||||||
|
replacement: {
|
||||||
|
match: 'title:"Experiments",children:[',
|
||||||
|
replace: "$&$self.WarningCard(),"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
@ -109,5 +119,19 @@ export default definePlugin({
|
|||||||
</Forms.FormText>
|
</Forms.FormText>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
|
|
||||||
|
WarningCard: ErrorBoundary.wrap(() => (
|
||||||
|
<ErrorCard id="vc-experiments-warning-card" className={Margins.bottom16}>
|
||||||
|
<Forms.FormTitle tag="h2">Hold on!!</Forms.FormTitle>
|
||||||
|
|
||||||
|
<Forms.FormText>
|
||||||
|
Experiments are unreleased Discord features. They might not work, or even break your client or get your account disabled.
|
||||||
|
</Forms.FormText>
|
||||||
|
|
||||||
|
<Forms.FormText className={Margins.top8}>
|
||||||
|
Only use experiments if you know what you're doing. Vencord is not responsible for any damage caused by enabling experiments.
|
||||||
|
</Forms.FormText>
|
||||||
|
</ErrorCard>
|
||||||
|
), { noop: true })
|
||||||
});
|
});
|
||||||
|
@ -17,11 +17,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { addPreEditListener, addPreSendListener, removePreEditListener, removePreSendListener } from "@api/MessageEvents";
|
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 { Devs } from "@utils/constants";
|
||||||
import { ApngBlendOp, ApngDisposeOp, getGifEncoder, importApngJs } from "@utils/dependencies";
|
import { ApngBlendOp, ApngDisposeOp, getGifEncoder, importApngJs } from "@utils/dependencies";
|
||||||
import { getCurrentGuild } from "@utils/discord";
|
import { getCurrentGuild } from "@utils/discord";
|
||||||
import { proxyLazy } from "@utils/proxyLazy";
|
import { proxyLazy } from "@utils/lazy";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByCodeLazy, findByPropsLazy, findLazy, findStoreLazy } from "@webpack";
|
import { findByCodeLazy, findByPropsLazy, findLazy, findStoreLazy } from "@webpack";
|
||||||
import { ChannelStore, FluxDispatcher, Parser, PermissionStore, UserStore } from "@webpack/common";
|
import { ChannelStore, FluxDispatcher, Parser, PermissionStore, UserStore } from "@webpack/common";
|
||||||
@ -149,8 +149,6 @@ const settings = definePluginSettings({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
migratePluginSettings("FakeNitro", "NitroBypass");
|
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "FakeNitro",
|
name: "FakeNitro",
|
||||||
authors: [Devs.Arjix, Devs.D3SOX, Devs.Ven, Devs.obscurity, Devs.captain, Devs.Nuckyz, Devs.AutumnVN],
|
authors: [Devs.Arjix, Devs.D3SOX, Devs.Ven, Devs.obscurity, Devs.captain, Devs.Nuckyz, Devs.AutumnVN],
|
||||||
@ -643,7 +641,7 @@ export default definePlugin({
|
|||||||
if (!settings.enableStickerBypass)
|
if (!settings.enableStickerBypass)
|
||||||
break stickerBypass;
|
break stickerBypass;
|
||||||
|
|
||||||
const sticker = StickerStore.getStickerById(extra?.stickerIds?.[0]!);
|
const sticker = StickerStore.getStickerById(extra.stickers?.[0]!);
|
||||||
if (!sticker)
|
if (!sticker)
|
||||||
break stickerBypass;
|
break stickerBypass;
|
||||||
|
|
||||||
@ -665,7 +663,7 @@ export default definePlugin({
|
|||||||
link = `https://distok.top/stickers/${packId}/${sticker.id}.gif`;
|
link = `https://distok.top/stickers/${packId}/${sticker.id}.gif`;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete extra.stickerIds;
|
extra.stickers!.length = 0;
|
||||||
messageObj.content += " " + link + `&name=${encodeURIComponent(sticker.name)}`;
|
messageObj.content += " " + link + `&name=${encodeURIComponent(sticker.name)}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// This plugin is a port from Alyxia's Vendetta plugin
|
// This plugin is a port from Alyxia's Vendetta plugin
|
||||||
import { definePluginSettings } from "@api/settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { ApplicationCommandOptionType } from "@api/Commands";
|
import { ApplicationCommandOptionType } from "@api/Commands";
|
||||||
import { Settings } from "@api/settings";
|
import { Settings } from "@api/Settings";
|
||||||
import { makeRange } from "@components/PluginSettings/components";
|
import { makeRange } from "@components/PluginSettings/components";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
|
@ -17,9 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
|
import { insertTextIntoChatInputBox } from "@utils/discord";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { filters, mapMangledModuleLazy } from "@webpack";
|
import { filters, mapMangledModuleLazy } from "@webpack";
|
||||||
import { ComponentDispatch } from "@webpack/common";
|
|
||||||
|
|
||||||
const ExpressionPickerState = mapMangledModuleLazy('name:"expression-picker-last-active-view"', {
|
const ExpressionPickerState = mapMangledModuleLazy('name:"expression-picker-last-active-view"', {
|
||||||
close: filters.byCode("activeView:null", "setState")
|
close: filters.byCode("activeView:null", "setState")
|
||||||
@ -40,7 +40,7 @@ export default definePlugin({
|
|||||||
|
|
||||||
handleSelect(gif?: { url: string; }) {
|
handleSelect(gif?: { url: string; }) {
|
||||||
if (gif) {
|
if (gif) {
|
||||||
ComponentDispatch.dispatchToLastSubscribed("INSERT_TEXT", { rawText: gif.url + " " });
|
insertTextIntoChatInputBox(gif.url + " ");
|
||||||
ExpressionPickerState.close();
|
ExpressionPickerState.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
import * as DataStore from "@api/DataStore";
|
import * as DataStore from "@api/DataStore";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { useForceUpdater } from "@utils/misc";
|
import { useForceUpdater } from "@utils/react";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findByPropsLazy, findStoreLazy } from "@webpack";
|
import { findByPropsLazy, findStoreLazy } from "@webpack";
|
||||||
import { Tooltip } from "webpack/common";
|
import { Tooltip } from "webpack/common";
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { addContextMenuPatch, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu";
|
import { addContextMenuPatch, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu";
|
||||||
import { definePluginSettings } from "@api/settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { disableStyle, enableStyle } from "@api/Styles";
|
import { disableStyle, enableStyle } from "@api/Styles";
|
||||||
import { makeRange } from "@components/PluginSettings/components";
|
import { makeRange } from "@components/PluginSettings/components";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
|
@ -17,9 +17,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { registerCommand, unregisterCommand } from "@api/Commands";
|
import { registerCommand, unregisterCommand } from "@api/Commands";
|
||||||
import { Settings } from "@api/settings";
|
import { Settings } from "@api/Settings";
|
||||||
import Logger from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
import { Patch, Plugin } from "@utils/types";
|
import { Patch, Plugin } from "@utils/types";
|
||||||
|
import { FluxDispatcher } from "@webpack/common";
|
||||||
|
import { FluxEvents } from "@webpack/types";
|
||||||
|
|
||||||
import Plugins from "~plugins";
|
import Plugins from "~plugins";
|
||||||
|
|
||||||
@ -97,9 +99,9 @@ export function startDependenciesRecursive(p: Plugin) {
|
|||||||
if (!Settings.plugins[dep].enabled) {
|
if (!Settings.plugins[dep].enabled) {
|
||||||
startDependenciesRecursive(Plugins[dep]);
|
startDependenciesRecursive(Plugins[dep]);
|
||||||
// If the plugin has patches, don't start the plugin, just enable it.
|
// If the plugin has patches, don't start the plugin, just enable it.
|
||||||
|
Settings.plugins[dep].enabled = true;
|
||||||
if (Plugins[dep].patches) {
|
if (Plugins[dep].patches) {
|
||||||
logger.warn(`Enabling dependency ${dep} requires restart.`);
|
logger.warn(`Enabling dependency ${dep} requires restart.`);
|
||||||
Settings.plugins[dep].enabled = true;
|
|
||||||
restartNeeded = true;
|
restartNeeded = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -111,56 +113,64 @@ export function startDependenciesRecursive(p: Plugin) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const startPlugin = traceFunction("startPlugin", function startPlugin(p: Plugin) {
|
export const startPlugin = traceFunction("startPlugin", function startPlugin(p: Plugin) {
|
||||||
|
const { name, commands, flux } = p;
|
||||||
|
|
||||||
if (p.start) {
|
if (p.start) {
|
||||||
logger.info("Starting plugin", p.name);
|
logger.info("Starting plugin", name);
|
||||||
if (p.started) {
|
if (p.started) {
|
||||||
logger.warn(`${p.name} already started`);
|
logger.warn(`${name} already started`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
p.start();
|
p.start();
|
||||||
p.started = true;
|
p.started = true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error(`Failed to start ${p.name}\n`, e);
|
logger.error(`Failed to start ${name}\n`, e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p.commands?.length) {
|
if (commands?.length) {
|
||||||
logger.info("Registering commands of plugin", p.name);
|
logger.info("Registering commands of plugin", name);
|
||||||
for (const cmd of p.commands) {
|
for (const cmd of commands) {
|
||||||
try {
|
try {
|
||||||
registerCommand(cmd, p.name);
|
registerCommand(cmd, name);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error(`Failed to register command ${cmd.name}\n`, e);
|
logger.error(`Failed to register command ${cmd.name}\n`, e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flux) {
|
||||||
|
for (const event in flux) {
|
||||||
|
FluxDispatcher.subscribe(event as FluxEvents, flux[event]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}, p => `startPlugin ${p.name}`);
|
}, p => `startPlugin ${p.name}`);
|
||||||
|
|
||||||
export const stopPlugin = traceFunction("stopPlugin", function stopPlugin(p: Plugin) {
|
export const stopPlugin = traceFunction("stopPlugin", function stopPlugin(p: Plugin) {
|
||||||
|
const { name, commands, flux } = p;
|
||||||
if (p.stop) {
|
if (p.stop) {
|
||||||
logger.info("Stopping plugin", p.name);
|
logger.info("Stopping plugin", name);
|
||||||
if (!p.started) {
|
if (!p.started) {
|
||||||
logger.warn(`${p.name} already stopped`);
|
logger.warn(`${name} already stopped`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
p.stop();
|
p.stop();
|
||||||
p.started = false;
|
p.started = false;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error(`Failed to stop ${p.name}\n`, e);
|
logger.error(`Failed to stop ${name}\n`, e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p.commands?.length) {
|
if (commands?.length) {
|
||||||
logger.info("Unregistering commands of plugin", p.name);
|
logger.info("Unregistering commands of plugin", name);
|
||||||
for (const cmd of p.commands) {
|
for (const cmd of commands) {
|
||||||
try {
|
try {
|
||||||
unregisterCommand(cmd.name);
|
unregisterCommand(cmd.name);
|
||||||
} catch (e) {
|
} 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;
|
return true;
|
||||||
}, p => `stopPlugin ${p.name}`);
|
}, p => `stopPlugin ${p.name}`);
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { insertTextIntoChatInputBox } from "@utils/discord";
|
||||||
import {
|
import {
|
||||||
ModalContent,
|
ModalContent,
|
||||||
ModalFooter,
|
ModalFooter,
|
||||||
@ -24,7 +25,7 @@ import {
|
|||||||
ModalRoot,
|
ModalRoot,
|
||||||
openModal,
|
openModal,
|
||||||
} from "@utils/modal";
|
} 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";
|
import { encrypt } from "../index";
|
||||||
|
|
||||||
@ -84,9 +85,7 @@ function EncModal(props: ModalProps) {
|
|||||||
const toSend = noCover ? encrypted.replaceAll("d", "") : encrypted;
|
const toSend = noCover ? encrypted.replaceAll("d", "") : encrypted;
|
||||||
if (!toSend) return;
|
if (!toSend) return;
|
||||||
|
|
||||||
ComponentDispatch.dispatchToLastSubscribed("INSERT_TEXT", {
|
insertTextIntoChatInputBox(toSend);
|
||||||
rawText: `${toSend}`
|
|
||||||
});
|
|
||||||
|
|
||||||
props.onClose();
|
props.onClose();
|
||||||
}}
|
}}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { addButton, removeButton } from "@api/MessagePopover";
|
import { addButton, removeButton } from "@api/MessagePopover";
|
||||||
import { definePluginSettings } from "@api/settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { getStegCloak } from "@utils/dependencies";
|
import { getStegCloak } from "@utils/dependencies";
|
||||||
@ -85,7 +85,7 @@ function ChatBarIcon() {
|
|||||||
onMouseLeave={onMouseLeave}
|
onMouseLeave={onMouseLeave}
|
||||||
innerClassName={ButtonWrapperClasses.button}
|
innerClassName={ButtonWrapperClasses.button}
|
||||||
onClick={() => buildEncModal()}
|
onClick={() => buildEncModal()}
|
||||||
style={{ padding: "0 4px" }}
|
style={{ padding: "0 2px", scale: "0.9" }}
|
||||||
>
|
>
|
||||||
<div className={ButtonWrapperClasses.buttonWrapper}>
|
<div className={ButtonWrapperClasses.buttonWrapper}>
|
||||||
<svg
|
<svg
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
import * as DataStore from "@api/DataStore";
|
import * as DataStore from "@api/DataStore";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
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 {
|
export interface LogoutEvent {
|
||||||
type: "LOGOUT";
|
type: "LOGOUT";
|
||||||
@ -37,63 +37,54 @@ interface PreviousChannel {
|
|||||||
channelId: string | null;
|
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({
|
export default definePlugin({
|
||||||
name: "KeepCurrentChannel",
|
name: "KeepCurrentChannel",
|
||||||
description: "Attempt to navigate to the channel you were in before switching accounts or loading Discord.",
|
description: "Attempt to navigate to the channel you were in before switching accounts or loading Discord.",
|
||||||
authors: [Devs.Nuckyz],
|
authors: [Devs.Nuckyz],
|
||||||
|
|
||||||
isSwitchingAccount: false,
|
flux: {
|
||||||
previousCache: {} as PreviousChannel,
|
LOGOUT(e: LogoutEvent) {
|
||||||
|
({ isSwitchingAccount } = e);
|
||||||
attemptToNavigateToChannel(guildId: string | null, channelId: string) {
|
|
||||||
if (!ChannelStore.hasChannel(channelId)) return;
|
|
||||||
NavigationRouter.transitionTo(`/channels/${guildId ?? "@me"}/${channelId}`);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onLogout(e: LogoutEvent) {
|
CONNECTION_OPEN() {
|
||||||
this.isSwitchingAccount = e.isSwitchingAccount;
|
if (!isSwitchingAccount) return;
|
||||||
|
isSwitchingAccount = false;
|
||||||
|
|
||||||
|
if (previousCache?.channelId)
|
||||||
|
attemptToNavigateToChannel(previousCache.guildId, previousCache.channelId);
|
||||||
},
|
},
|
||||||
|
|
||||||
onConnectionOpen() {
|
async CHANNEL_SELECT({ guildId, channelId }: ChannelSelectEvent) {
|
||||||
if (!this.isSwitchingAccount) return;
|
if (isSwitchingAccount) return;
|
||||||
this.isSwitchingAccount = false;
|
|
||||||
|
|
||||||
if (this.previousCache.channelId) this.attemptToNavigateToChannel(this.previousCache.guildId, this.previousCache.channelId);
|
previousCache = {
|
||||||
},
|
|
||||||
|
|
||||||
async onChannelSelect({ guildId, channelId }: ChannelSelectEvent) {
|
|
||||||
if (this.isSwitchingAccount) return;
|
|
||||||
|
|
||||||
this.previousCache = {
|
|
||||||
guildId,
|
guildId,
|
||||||
channelId
|
channelId
|
||||||
};
|
};
|
||||||
await DataStore.set("KeepCurrentChannel_previousData", this.previousCache);
|
await DataStore.set("KeepCurrentChannel_previousData", previousCache);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async start() {
|
async start() {
|
||||||
const previousData = await DataStore.get<PreviousChannel>("KeepCurrentChannel_previousData");
|
previousCache = await DataStore.get<PreviousChannel>("KeepCurrentChannel_previousData");
|
||||||
if (previousData) {
|
if (!previousCache) {
|
||||||
this.previousCache = previousData;
|
previousCache = {
|
||||||
|
|
||||||
if (this.previousCache.channelId) this.attemptToNavigateToChannel(this.previousCache.guildId, this.previousCache.channelId);
|
|
||||||
} else {
|
|
||||||
this.previousCache = {
|
|
||||||
guildId: SelectedGuildStore.getGuildId(),
|
guildId: SelectedGuildStore.getGuildId(),
|
||||||
channelId: SelectedChannelStore.getChannelId() ?? null
|
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);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -16,10 +16,10 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { definePluginSettings } from "@api/settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { Link } from "@components/Link";
|
import { Link } from "@components/Link";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import Logger from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { filters, findByPropsLazy, mapMangledModuleLazy } from "@webpack";
|
import { filters, findByPropsLazy, mapMangledModuleLazy } from "@webpack";
|
||||||
import { FluxDispatcher, Forms } from "@webpack/common";
|
import { FluxDispatcher, Forms } from "@webpack/common";
|
||||||
|
@ -20,31 +20,34 @@ import ErrorBoundary from "@components/ErrorBoundary";
|
|||||||
import { Flex } from "@components/Flex";
|
import { Flex } from "@components/Flex";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { getCurrentChannel } from "@utils/discord";
|
import { getCurrentChannel } from "@utils/discord";
|
||||||
import { useForceUpdater } from "@utils/misc";
|
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findStoreLazy } from "@webpack";
|
import { findStoreLazy } from "@webpack";
|
||||||
import { FluxDispatcher, Tooltip } from "@webpack/common";
|
import { SelectedChannelStore, Tooltip, useStateFromStores } from "@webpack/common";
|
||||||
|
import { FluxStore } from "@webpack/types";
|
||||||
|
|
||||||
const counts = {} as Record<string, [number, number]>;
|
const GuildMemberCountStore = findStoreLazy("GuildMemberCountStore") as FluxStore & { getMemberCount(guildId: string): number | null; };
|
||||||
let forceUpdate: () => void;
|
const ChannelMemberStore = findStoreLazy("ChannelMemberStore") as FluxStore & {
|
||||||
|
getProps(guildId: string, channelId: string): { groups: { count: number; id: string; }[]; };
|
||||||
const GuildMemberCountStore = findStoreLazy("GuildMemberCountStore");
|
};
|
||||||
|
|
||||||
function MemberCount() {
|
function MemberCount() {
|
||||||
const guildId = getCurrentChannel().guild_id;
|
const { id: channelId, guild_id: guildId } = useStateFromStores([SelectedChannelStore], () => getCurrentChannel());
|
||||||
const c = counts[guildId];
|
const { groups } = useStateFromStores(
|
||||||
|
[ChannelMemberStore],
|
||||||
|
() => ChannelMemberStore.getProps(guildId, channelId)
|
||||||
|
);
|
||||||
|
const total = useStateFromStores(
|
||||||
|
[GuildMemberCountStore],
|
||||||
|
() => GuildMemberCountStore.getMemberCount(guildId)
|
||||||
|
);
|
||||||
|
|
||||||
forceUpdate = useForceUpdater();
|
if (total == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
if (!c) return null;
|
const online =
|
||||||
|
(groups.length === 1 && groups[0].id === "unknown")
|
||||||
let total = c[0].toLocaleString();
|
? 0
|
||||||
if (total === "0" && c[1] > 0) {
|
: groups.reduce((count, curr) => count + (curr.id === "offline" ? 0 : curr.count), 0);
|
||||||
const approx = GuildMemberCountStore.getMemberCount(guildId);
|
|
||||||
total = approx ? approx.toLocaleString() : "Loading...";
|
|
||||||
}
|
|
||||||
|
|
||||||
const online = c[1].toLocaleString();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex id="vc-membercount" style={{
|
<Flex id="vc-membercount" style={{
|
||||||
@ -55,7 +58,7 @@ function MemberCount() {
|
|||||||
alignContent: "center",
|
alignContent: "center",
|
||||||
gap: 0
|
gap: 0
|
||||||
}}>
|
}}>
|
||||||
<Tooltip text={`${online} Online`} position="bottom">
|
<Tooltip text={`${online} Online in this Channel`} position="bottom">
|
||||||
{props => (
|
{props => (
|
||||||
<div {...props}>
|
<div {...props}>
|
||||||
<span
|
<span
|
||||||
@ -72,7 +75,7 @@ function MemberCount() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip text={`${total} Total Members`} position="bottom">
|
<Tooltip text={`${total} Total Server Members`} position="bottom">
|
||||||
{props => (
|
{props => (
|
||||||
<div {...props}>
|
<div {...props}>
|
||||||
<span
|
<span
|
||||||
@ -102,37 +105,10 @@ export default definePlugin({
|
|||||||
patches: [{
|
patches: [{
|
||||||
find: ".isSidebarVisible,",
|
find: ".isSidebarVisible,",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /(var (.)=.\.className.+?children):\[(.\.useMemo[^}]+"aria-multiselectable")/,
|
match: /(var (\i)=\i\.className.+?children):\[(\i\.useMemo[^}]+"aria-multiselectable")/,
|
||||||
replace: "$1:[$2.startsWith('members')?$self.render():null,$3"
|
replace: "$1:[$2.startsWith('members')?$self.render():null,$3"
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
|
|
||||||
onGuildMemberListUpdate({ guildId, groups, memberCount, id }) {
|
render: ErrorBoundary.wrap(MemberCount, { noop: true })
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
counts[guildId] = [memberCount, count];
|
|
||||||
forceUpdate?.();
|
|
||||||
},
|
|
||||||
|
|
||||||
start() {
|
|
||||||
FluxDispatcher.subscribe("GUILD_MEMBER_LIST_UPDATE", this.onGuildMemberListUpdate);
|
|
||||||
},
|
|
||||||
|
|
||||||
stop() {
|
|
||||||
FluxDispatcher.unsubscribe("GUILD_MEMBER_LIST_UPDATE", this.onGuildMemberListUpdate);
|
|
||||||
},
|
|
||||||
|
|
||||||
render: () => (
|
|
||||||
<ErrorBoundary noop>
|
|
||||||
<MemberCount />
|
|
||||||
</ErrorBoundary>
|
|
||||||
)
|
|
||||||
});
|
});
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { addClickListener, removeClickListener } from "@api/MessageEvents";
|
import { addClickListener, removeClickListener } from "@api/MessageEvents";
|
||||||
import { migratePluginSettings } from "@api/settings";
|
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByPropsLazy } from "@webpack";
|
||||||
@ -29,8 +28,6 @@ const keyup = (e: KeyboardEvent) => e.key === "Backspace" && (isDeletePressed =
|
|||||||
|
|
||||||
const MANAGE_CHANNELS = 1n << 4n;
|
const MANAGE_CHANNELS = 1n << 4n;
|
||||||
|
|
||||||
migratePluginSettings("MessageClickActions", "MessageQuickActions");
|
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "MessageClickActions",
|
name: "MessageClickActions",
|
||||||
description: "Hold Backspace and click to delete, double click to edit",
|
description: "Hold Backspace and click to delete, double click to edit",
|
||||||
|
@ -17,11 +17,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { addAccessory } from "@api/MessageAccessories";
|
import { addAccessory } from "@api/MessageAccessories";
|
||||||
import { definePluginSettings } from "@api/settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants.js";
|
import { Devs } from "@utils/constants.js";
|
||||||
import { classes, LazyComponent } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import { Queue } from "@utils/Queue";
|
import { Queue } from "@utils/Queue";
|
||||||
|
import { LazyComponent } from "@utils/react";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { find, findByCode, findByPropsLazy } from "@webpack";
|
import { find, findByCode, findByPropsLazy } from "@webpack";
|
||||||
import {
|
import {
|
||||||
@ -51,7 +52,7 @@ const SearchResultClasses = findByPropsLazy("message", "searchResult");
|
|||||||
let AutoModEmbed: React.ComponentType<any> = () => null;
|
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 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 {
|
interface Attachment {
|
||||||
height: number;
|
height: number;
|
||||||
|
@ -19,11 +19,11 @@
|
|||||||
import "./messageLogger.css";
|
import "./messageLogger.css";
|
||||||
|
|
||||||
import { addContextMenuPatch, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu";
|
import { addContextMenuPatch, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu";
|
||||||
import { Settings } from "@api/settings";
|
import { Settings } from "@api/Settings";
|
||||||
import { disableStyle, enableStyle } from "@api/Styles";
|
import { disableStyle, enableStyle } from "@api/Styles";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import Logger from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByPropsLazy } from "@webpack";
|
||||||
import { FluxDispatcher, i18n, Menu, moment, Parser, Timestamp, UserStore } from "@webpack/common";
|
import { FluxDispatcher, i18n, Menu, moment, Parser, Timestamp, UserStore } from "@webpack/common";
|
||||||
@ -51,11 +51,28 @@ const patchMessageContextMenu: NavContextMenuPatchCallback = (children, props) =
|
|||||||
|
|
||||||
if (!deleted && !editHistory?.length) return;
|
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((
|
children.push((
|
||||||
<Menu.MenuItem
|
<Menu.MenuItem
|
||||||
id={REMOVE_HISTORY_ID}
|
id={REMOVE_HISTORY_ID}
|
||||||
key={REMOVE_HISTORY_ID}
|
key={REMOVE_HISTORY_ID}
|
||||||
label="Remove Message History"
|
label="Remove Message History"
|
||||||
|
color="danger"
|
||||||
action={() => {
|
action={() => {
|
||||||
if (deleted) {
|
if (deleted) {
|
||||||
FluxDispatcher.dispatch({
|
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({
|
export default definePlugin({
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
import { ApplicationCommandInputType, ApplicationCommandOptionType, findOption, registerCommand, sendBotMessage, unregisterCommand } from "@api/Commands";
|
import { ApplicationCommandInputType, ApplicationCommandOptionType, findOption, registerCommand, sendBotMessage, unregisterCommand } from "@api/Commands";
|
||||||
import * as DataStore from "@api/DataStore";
|
import * as DataStore from "@api/DataStore";
|
||||||
import { Settings } from "@api/settings";
|
import { Settings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
|
|
||||||
|
@ -17,11 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { findOption, OptionalMessageOption } from "@api/Commands";
|
import { findOption, OptionalMessageOption } from "@api/Commands";
|
||||||
import { migratePluginSettings } from "@api/settings";
|
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
|
|
||||||
migratePluginSettings("MoreKaomoji", "moarKaomojis");
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "MoreKaomoji",
|
name: "MoreKaomoji",
|
||||||
description: "Adds more Kaomoji to discord. ヽ(´▽`)/",
|
description: "Adds more Kaomoji to discord. ヽ(´▽`)/",
|
||||||
|
@ -16,9 +16,9 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { definePluginSettings } from "@api/settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { proxyLazy } from "@utils/proxyLazy.js";
|
import { proxyLazy } from "@utils/lazy.js";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { find, findByPropsLazy } from "@webpack";
|
import { find, findByPropsLazy } from "@webpack";
|
||||||
import { ChannelStore, GuildStore } from "@webpack/common";
|
import { ChannelStore, GuildStore } from "@webpack/common";
|
||||||
|
@ -16,12 +16,12 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { definePluginSettings } from "@api/settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { makeRange } from "@components/PluginSettings/components/SettingSliderComponent";
|
import { makeRange } from "@components/PluginSettings/components/SettingSliderComponent";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { sleep } from "@utils/misc";
|
import { sleep } from "@utils/misc";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
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";
|
import { Message, ReactionEmoji } from "discord-types/general";
|
||||||
|
|
||||||
interface IMessageCreate {
|
interface IMessageCreate {
|
||||||
@ -80,14 +80,15 @@ export default definePlugin({
|
|||||||
description: "🗿🗿🗿🗿🗿🗿🗿🗿",
|
description: "🗿🗿🗿🗿🗿🗿🗿🗿",
|
||||||
settings,
|
settings,
|
||||||
|
|
||||||
async onMessage(e: IMessageCreate) {
|
flux: {
|
||||||
if (e.optimistic || e.type !== "MESSAGE_CREATE") return;
|
async MESSAGE_CREATE({ optimistic, type, message, channelId }: IMessageCreate) {
|
||||||
if (e.message.state === "SENDING") return;
|
if (optimistic || type !== "MESSAGE_CREATE") return;
|
||||||
if (settings.store.ignoreBots && e.message.author?.bot) return;
|
if (message.state === "SENDING") return;
|
||||||
if (!e.message.content) return;
|
if (settings.store.ignoreBots && message.author?.bot) return;
|
||||||
if (e.channelId !== SelectedChannelStore.getChannelId()) 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++) {
|
for (let i = 0; i < moyaiCount; i++) {
|
||||||
boom();
|
boom();
|
||||||
@ -95,35 +96,24 @@ export default definePlugin({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onReaction(e: IReactionAdd) {
|
MESSAGE_REACTION_ADD({ optimistic, type, channelId, userId, emoji }: IReactionAdd) {
|
||||||
if (e.optimistic || e.type !== "MESSAGE_REACTION_ADD") return;
|
if (optimistic || type !== "MESSAGE_REACTION_ADD") return;
|
||||||
if (settings.store.ignoreBots && UserStore.getUser(e.userId)?.bot) return;
|
if (settings.store.ignoreBots && UserStore.getUser(userId)?.bot) return;
|
||||||
if (e.channelId !== SelectedChannelStore.getChannelId()) return;
|
if (channelId !== SelectedChannelStore.getChannelId()) return;
|
||||||
|
|
||||||
const name = e.emoji.name.toLowerCase();
|
const name = emoji.name.toLowerCase();
|
||||||
if (name !== MOYAI && !name.includes("moyai") && !name.includes("moai")) return;
|
if (name !== MOYAI && !name.includes("moyai") && !name.includes("moai")) return;
|
||||||
|
|
||||||
boom();
|
boom();
|
||||||
},
|
},
|
||||||
|
|
||||||
onVoiceChannelEffect(e: IVoiceChannelEffectSendEvent) {
|
VOICE_CHANNEL_EFFECT_SEND({ emoji }: IVoiceChannelEffectSendEvent) {
|
||||||
if (!e.emoji?.name) return;
|
if (!emoji?.name) return;
|
||||||
const name = e.emoji.name.toLowerCase();
|
const name = emoji.name.toLowerCase();
|
||||||
if (name !== MOYAI && !name.includes("moyai") && !name.includes("moai")) return;
|
if (name !== MOYAI && !name.includes("moyai") && !name.includes("moai")) return;
|
||||||
|
|
||||||
boom();
|
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/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { ModalContent, ModalFooter, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal";
|
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 { findByProps, findStoreLazy } from "@webpack";
|
||||||
import { Button, Text } from "@webpack/common";
|
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({
|
export default definePlugin({
|
||||||
name: "MuteNewGuild",
|
name: "MuteNewGuild",
|
||||||
description: "Mutes newly joined guilds",
|
description: "Mutes newly joined guilds",
|
||||||
authors: [Devs.Glitch, Devs.Nuckyz],
|
authors: [Devs.Glitch, Devs.Nuckyz, Devs.carince],
|
||||||
patches: [
|
patches: [
|
||||||
{
|
{
|
||||||
find: ",acceptInvite:function",
|
find: ",acceptInvite:function",
|
||||||
@ -62,10 +81,17 @@ export default definePlugin({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
settings,
|
||||||
|
|
||||||
handleMute(guildId: string | null) {
|
handleMute(guildId: string | null) {
|
||||||
if (guildId === "@me" || guildId === "null" || guildId == null) return;
|
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() {
|
start() {
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Settings } from "@api/settings";
|
import { Settings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByPropsLazy } from "@webpack";
|
||||||
|
@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* Vencord, a modification for Discord's desktop app
|
|
||||||
* Copyright (c) 2022 Samu and Linnea Gräf
|
|
||||||
*
|
|
||||||
* 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 { addPreSendListener, MessageObject, removePreSendListener } from "@api/MessageEvents";
|
|
||||||
import { Settings } from "@api/settings";
|
|
||||||
import { Devs } from "@utils/constants";
|
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
|
||||||
|
|
||||||
export default definePlugin({
|
|
||||||
name: "NoCanaryMessageLinks",
|
|
||||||
description: "Allows you to change/remove the subdomain of discord message and channel links",
|
|
||||||
authors: [Devs.Samu, Devs.nea],
|
|
||||||
options: {
|
|
||||||
linkPrefix: {
|
|
||||||
description: "The subdomain for your discord message links",
|
|
||||||
type: OptionType.STRING,
|
|
||||||
default: "",
|
|
||||||
restartNeeded: false,
|
|
||||||
},
|
|
||||||
alwaysUseDiscordHost: {
|
|
||||||
description: "Always use discord.com host (replace discordapp.com)",
|
|
||||||
type: OptionType.BOOLEAN,
|
|
||||||
default: false,
|
|
||||||
restartNeeded: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
dependencies: ["MessageEventsAPI"],
|
|
||||||
|
|
||||||
removeBetas(msg: MessageObject) {
|
|
||||||
const settings = Settings.plugins.NoCanaryMessageLinks;
|
|
||||||
msg.content = msg.content.replace(
|
|
||||||
/https:\/\/(?:canary\.|ptb\.)?(discord(?:app)?\.com)(\/channels\/(?:\d{17,20}|@me)\/\d{17,20}(?:\/\d{17,20})?)/g,
|
|
||||||
(_, host, path) => "https://" + (settings.linkPrefix ? settings.linkPrefix + "." : "") + (settings.alwaysUseDiscordHost ? "discord.com" : host) + path
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
start() {
|
|
||||||
this.preSend = addPreSendListener((_, msg) => this.removeBetas(msg));
|
|
||||||
},
|
|
||||||
|
|
||||||
stop() {
|
|
||||||
removePreSendListener(this.preSend);
|
|
||||||
}
|
|
||||||
});
|
|
@ -16,12 +16,9 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { migratePluginSettings } from "@api/settings";
|
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
|
|
||||||
migratePluginSettings("NoDevtoolsWarning", "STFU");
|
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "NoDevtoolsWarning",
|
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.",
|
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/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { migratePluginSettings } from "@api/settings";
|
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
|
|
||||||
migratePluginSettings("NoF1", "No F1");
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "NoF1",
|
name: "NoF1",
|
||||||
description: "Disables F1 help bind.",
|
description: "Disables F1 help bind.",
|
||||||
|
@ -16,11 +16,9 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { migratePluginSettings } from "@api/settings";
|
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
|
|
||||||
migratePluginSettings("NoRPC", "No RPC");
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "NoRPC",
|
name: "NoRPC",
|
||||||
description: "Disables Discord's RPC server.",
|
description: "Disables Discord's RPC server.",
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { definePluginSettings } from "@api/settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import type { Message } from "discord-types/general";
|
import type { Message } from "discord-types/general";
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
import { ApplicationCommandInputType, ApplicationCommandOptionType, Argument, CommandContext, findOption, sendBotMessage } from "@api/Commands";
|
import { ApplicationCommandInputType, ApplicationCommandOptionType, Argument, CommandContext, findOption, sendBotMessage } from "@api/Commands";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { getGifEncoder } from "@utils/dependencies";
|
import { getGifEncoder } from "@utils/dependencies";
|
||||||
import { makeLazy } from "@utils/misc";
|
import { makeLazy } from "@utils/lazy";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findByCodeLazy, findByPropsLazy } from "@webpack";
|
import { findByCodeLazy, findByPropsLazy } from "@webpack";
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ import definePlugin from "@utils/types";
|
|||||||
import { Channel } from "discord-types/general";
|
import { Channel } from "discord-types/general";
|
||||||
|
|
||||||
import { addContextMenus, removeContextMenus } from "./contextMenus";
|
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({
|
export default definePlugin({
|
||||||
name: "PinDMs",
|
name: "PinDMs",
|
||||||
@ -44,7 +44,7 @@ export default definePlugin({
|
|||||||
},
|
},
|
||||||
|
|
||||||
isPinned,
|
isPinned,
|
||||||
getSnapshot: () => snapshotArray,
|
getSnapshot: sortedSnapshot,
|
||||||
|
|
||||||
getScrollOffset(channelId: string, rowHeight: number, padding: number, preRenderedChildren: number, originalOffset: number) {
|
getScrollOffset(channelId: string, rowHeight: number, padding: number, preRenderedChildren: number, originalOffset: number) {
|
||||||
if (!isPinned(channelId))
|
if (!isPinned(channelId))
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { definePluginSettings, Settings, useSettings } from "@api/settings";
|
import { definePluginSettings, Settings, useSettings } from "@api/Settings";
|
||||||
import { OptionType } from "@utils/types";
|
import { OptionType } from "@utils/types";
|
||||||
import { findStoreLazy } from "@webpack";
|
import { findStoreLazy } from "@webpack";
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ export function togglePin(id: string) {
|
|||||||
save([...snapshot]);
|
save([...snapshot]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sortedSnapshot() {
|
export function sortedSnapshot() {
|
||||||
requireSnapshot();
|
requireSnapshot();
|
||||||
if (settings.store.pinOrder === PinOrder.LastMessage)
|
if (settings.store.pinOrder === PinOrder.LastMessage)
|
||||||
return PrivateChannelSortStore.getPrivateChannelIds().filter(isPinned);
|
return PrivateChannelSortStore.getPrivateChannelIds().filter(isPinned);
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
import { addBadge, BadgePosition, ProfileBadge, removeBadge } from "@api/Badges";
|
import { addBadge, BadgePosition, ProfileBadge, removeBadge } from "@api/Badges";
|
||||||
import { addDecorator, removeDecorator } from "@api/MemberListDecorators";
|
import { addDecorator, removeDecorator } from "@api/MemberListDecorators";
|
||||||
import { addDecoration, removeDecoration } from "@api/MessageDecorations";
|
import { addDecoration, removeDecoration } from "@api/MessageDecorations";
|
||||||
import { Settings } from "@api/settings";
|
import { Settings } from "@api/Settings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
@ -30,7 +30,7 @@ import { User } from "discord-types/general";
|
|||||||
const SessionsStore = findStoreLazy("SessionsStore");
|
const SessionsStore = findStoreLazy("SessionsStore");
|
||||||
|
|
||||||
function Icon(path: string, viewBox = "0 0 24 24") {
|
function Icon(path: string, viewBox = "0 0 24 24") {
|
||||||
return ({ color, tooltip }: { color: string; tooltip: string; }) => (
|
return ({ color, tooltip, wantMargin }: { color: string; tooltip: string; wantMargin: boolean; }) => (
|
||||||
<Tooltip text={tooltip} >
|
<Tooltip text={tooltip} >
|
||||||
{(tooltipProps: any) => (
|
{(tooltipProps: any) => (
|
||||||
<svg
|
<svg
|
||||||
@ -39,6 +39,12 @@ function Icon(path: string, viewBox = "0 0 24 24") {
|
|||||||
width="20"
|
width="20"
|
||||||
viewBox={viewBox}
|
viewBox={viewBox}
|
||||||
fill={color}
|
fill={color}
|
||||||
|
style={{
|
||||||
|
marginLeft: wantMargin ? 4 : 0,
|
||||||
|
verticalAlign: "top",
|
||||||
|
position: "relative",
|
||||||
|
top: wantMargin ? 1 : 0,
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<path d={path} />
|
<path d={path} />
|
||||||
</svg>
|
</svg>
|
||||||
@ -57,16 +63,16 @@ type Platform = keyof typeof Icons;
|
|||||||
|
|
||||||
const getStatusColor = findByCodeLazy(".TWITCH", ".STREAMING", ".INVISIBLE");
|
const getStatusColor = findByCodeLazy(".TWITCH", ".STREAMING", ".INVISIBLE");
|
||||||
|
|
||||||
const PlatformIcon = ({ platform, status }: { platform: Platform, status: string; }) => {
|
const PlatformIcon = ({ platform, status, wantMargin }: { platform: Platform, status: string; wantMargin: boolean; }) => {
|
||||||
const tooltip = platform[0].toUpperCase() + platform.slice(1);
|
const tooltip = platform[0].toUpperCase() + platform.slice(1);
|
||||||
const Icon = Icons[platform] ?? Icons.desktop;
|
const Icon = Icons[platform] ?? Icons.desktop;
|
||||||
|
|
||||||
return <Icon color={`var(--${getStatusColor(status)}`} tooltip={tooltip} />;
|
return <Icon color={`var(--${getStatusColor(status)}`} tooltip={tooltip} wantMargin={wantMargin} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getStatus = (id: string): Record<Platform, string> => PresenceStore.getState()?.clientStatuses?.[id];
|
const getStatus = (id: string): Record<Platform, string> => PresenceStore.getState()?.clientStatuses?.[id];
|
||||||
|
|
||||||
const PlatformIndicator = ({ user, inline = false, marginLeft = "4px" }: { user: User; inline?: boolean; marginLeft?: string; }) => {
|
const PlatformIndicator = ({ user, wantMargin = true }: { user: User; wantMargin?: boolean; }) => {
|
||||||
if (!user || user.bot) return null;
|
if (!user || user.bot) return null;
|
||||||
|
|
||||||
if (user.id === UserStore.getCurrentUser().id) {
|
if (user.id === UserStore.getCurrentUser().id) {
|
||||||
@ -99,29 +105,21 @@ const PlatformIndicator = ({ user, inline = false, marginLeft = "4px" }: { user:
|
|||||||
key={platform}
|
key={platform}
|
||||||
platform={platform as Platform}
|
platform={platform as Platform}
|
||||||
status={status}
|
status={status}
|
||||||
|
wantMargin={wantMargin}
|
||||||
/>
|
/>
|
||||||
));
|
));
|
||||||
|
|
||||||
if (!icons.length) return null;
|
if (!icons.length) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<span className="vc-platform-indicator">
|
||||||
className="vc-platform-indicator"
|
|
||||||
style={{
|
|
||||||
marginLeft,
|
|
||||||
gap: "4px",
|
|
||||||
display: inline ? "inline-flex" : "flex",
|
|
||||||
alignItems: "center",
|
|
||||||
transform: inline ? "translateY(4px)" : undefined
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{icons}
|
{icons}
|
||||||
</div>
|
</span>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const badge: ProfileBadge = {
|
const badge: ProfileBadge = {
|
||||||
component: p => <PlatformIndicator {...p} marginLeft="" />,
|
component: p => <PlatformIndicator {...p} wantMargin={false} />,
|
||||||
position: BadgePosition.START,
|
position: BadgePosition.START,
|
||||||
shouldShow: userInfo => !!Object.keys(getStatus(userInfo.user.id) ?? {}).length,
|
shouldShow: userInfo => !!Object.keys(getStatus(userInfo.user.id) ?? {}).length,
|
||||||
key: "indicator"
|
key: "indicator"
|
||||||
@ -146,7 +144,7 @@ const indicatorLocations = {
|
|||||||
description: "Inside messages",
|
description: "Inside messages",
|
||||||
onEnable: () => addDecoration("platform-indicator", props =>
|
onEnable: () => addDecoration("platform-indicator", props =>
|
||||||
<ErrorBoundary noop>
|
<ErrorBoundary noop>
|
||||||
<PlatformIndicator user={props.message?.author} inline />
|
<PlatformIndicator user={props.message?.author} />
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
),
|
),
|
||||||
onDisable: () => removeDecoration("platform-indicator")
|
onDisable: () => removeDecoration("platform-indicator")
|
||||||
|
@ -16,66 +16,59 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Settings } from "@api/settings";
|
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByPropsLazy } from "@webpack";
|
||||||
import { UserStore } from "@webpack/common";
|
import { UserStore } from "@webpack/common";
|
||||||
import { Message } from "discord-types/general";
|
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");
|
const styles: Record<string, string> = findByPropsLazy("timestampInline");
|
||||||
|
|
||||||
function shouldShow(message: Message): boolean {
|
function shouldShow(message: Message): boolean {
|
||||||
// Respect showInMessages
|
if (!settings.store.showInMessages)
|
||||||
if (!Settings.plugins.PronounDB.showInMessages)
|
|
||||||
return false;
|
return false;
|
||||||
// Don't bother fetching bot or system users
|
|
||||||
if (message.author.bot || message.author.system)
|
if (message.author.bot || message.author.system)
|
||||||
return false;
|
return false;
|
||||||
// Respect showSelf options
|
if (!settings.store.showSelf && message.author.id === UserStore.getCurrentUser().id)
|
||||||
if (!Settings.plugins.PronounDB.showSelf && message.author.id === UserStore.getCurrentUser().id)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function PronounsChatComponentWrapper({ message }: { message: Message; }) {
|
export function PronounsChatComponentWrapper({ message }: { message: Message; }) {
|
||||||
if (!shouldShow(message))
|
return shouldShow(message)
|
||||||
return null;
|
? <PronounsChatComponent message={message} />
|
||||||
|
: null;
|
||||||
return <PronounsChatComponent message={message} />;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function CompactPronounsChatComponentWrapper({ message }: { message: Message; }) {
|
export function CompactPronounsChatComponentWrapper({ message }: { message: Message; }) {
|
||||||
if (!shouldShow(message))
|
return shouldShow(message)
|
||||||
return null;
|
? <CompactPronounsChatComponent message={message} />
|
||||||
|
: null;
|
||||||
return <CompactPronounsChatComponent message={message} />;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function PronounsChatComponent({ message }: { message: Message; }) {
|
function PronounsChatComponent({ message }: { message: Message; }) {
|
||||||
const result = awaitAndFormatPronouns(message.author.id);
|
const result = useFormattedPronouns(message.author.id);
|
||||||
if (result != null) {
|
|
||||||
return (
|
return result
|
||||||
|
? (
|
||||||
<span
|
<span
|
||||||
className={classes(styles.timestampInline, styles.timestamp)}
|
className={classes(styles.timestampInline, styles.timestamp)}
|
||||||
>• {result}</span>
|
>• {result}</span>
|
||||||
);
|
)
|
||||||
}
|
: null;
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function CompactPronounsChatComponent({ message }: { message: Message; }) {
|
export function CompactPronounsChatComponent({ message }: { message: Message; }) {
|
||||||
const result = awaitAndFormatPronouns(message.author.id);
|
const result = useFormattedPronouns(message.author.id);
|
||||||
if (result != null) {
|
|
||||||
return (
|
return result
|
||||||
|
? (
|
||||||
<span
|
<span
|
||||||
className={classes(styles.timestampInline, styles.timestamp, "vc-pronoundb-compact")}
|
className={classes(styles.timestampInline, styles.timestamp, "vc-pronoundb-compact")}
|
||||||
>• {result}</span>
|
>• {result}</span>
|
||||||
);
|
)
|
||||||
}
|
: null;
|
||||||
|
|
||||||
return 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 "./styles.css";
|
||||||
|
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
|
|
||||||
import PronounsAboutComponent from "./components/PronounsAboutComponent";
|
import PronounsAboutComponent from "./components/PronounsAboutComponent";
|
||||||
import { CompactPronounsChatComponentWrapper, PronounsChatComponentWrapper } from "./components/PronounsChatComponent";
|
import { CompactPronounsChatComponentWrapper, PronounsChatComponentWrapper } from "./components/PronounsChatComponent";
|
||||||
import PronounsProfileWrapper from "./components/PronounsProfileWrapper";
|
import { useProfilePronouns } from "./pronoundbUtils";
|
||||||
|
import { settings } from "./settings";
|
||||||
export enum PronounsFormat {
|
|
||||||
Lowercase = "LOWERCASE",
|
|
||||||
Capitalized = "CAPITALIZED"
|
|
||||||
}
|
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "PronounDB",
|
name: "PronounDB",
|
||||||
authors: [Devs.Tyman, Devs.TheKodeToad],
|
authors: [Devs.Tyman, Devs.TheKodeToad, Devs.Ven],
|
||||||
description: "Adds pronouns to user messages using pronoundb",
|
description: "Adds pronouns to user messages using pronoundb",
|
||||||
patches: [
|
patches: [
|
||||||
// Add next to username (compact mode)
|
// Add next to username (compact mode)
|
||||||
@ -51,59 +47,30 @@ export default definePlugin({
|
|||||||
replace: "[$1, $self.PronounsChatComponentWrapper(e)]"
|
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: {
|
replacement: {
|
||||||
match: /\(0,.\.jsx\)\((?<PronounComponent>\i\..),(?<pronounProps>{currentPronouns.+?:(?<fullProps>\i)\.pronouns.+?})\)/,
|
match: /=(\i)\.pronouns/,
|
||||||
replace: "$<fullProps>&&$self.PronounsProfileWrapper($<PronounComponent>,$<pronounProps>,$<fullProps>)"
|
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: {
|
replacement: {
|
||||||
match: /\.showPronouns/,
|
match: /\).showPronouns/,
|
||||||
replace: ".showPronouns||true"
|
replace: ").showPronouns||true;const vcPronounce=$self.useProfilePronouns(arguments[0].user.id);if(arguments[0].displayProfile)arguments[0].displayProfile.pronouns=vcPronounce"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
options: {
|
settings,
|
||||||
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
|
|
||||||
}
|
|
||||||
},
|
|
||||||
settingsAboutComponent: PronounsAboutComponent,
|
settingsAboutComponent: PronounsAboutComponent,
|
||||||
|
|
||||||
// Re-export the components on the plugin object so it is easily accessible in patches
|
// Re-export the components on the plugin object so it is easily accessible in patches
|
||||||
PronounsChatComponentWrapper,
|
PronounsChatComponentWrapper,
|
||||||
CompactPronounsChatComponentWrapper,
|
CompactPronounsChatComponentWrapper,
|
||||||
PronounsProfileWrapper
|
useProfilePronouns
|
||||||
});
|
});
|
||||||
|
@ -16,14 +16,20 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Settings } from "@api/settings";
|
import { Settings } from "@api/Settings";
|
||||||
import { VENCORD_USER_AGENT } from "@utils/constants";
|
import { VENCORD_USER_AGENT } from "@utils/constants";
|
||||||
import { debounce } from "@utils/debounce";
|
import { debounce } from "@utils/debounce";
|
||||||
import { useAwaiter } from "@utils/misc";
|
import { useAwaiter } from "@utils/react";
|
||||||
|
import { UserStore } from "@webpack/common";
|
||||||
|
|
||||||
import { PronounsFormat } from ".";
|
import { settings } from "./settings";
|
||||||
import { PronounCode, PronounMapping, PronounsResponse } from "./types";
|
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
|
// A map of cached pronouns so the same request isn't sent twice
|
||||||
const cache: Record<string, PronounCode> = {};
|
const cache: Record<string, PronounCode> = {};
|
||||||
// A map of ids and callbacks that should be triggered on fetch
|
// 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 {
|
export function useFormattedPronouns(id: string): string | null {
|
||||||
const [result, , isPending] = useAwaiter(() => fetchPronouns(id), {
|
const [result] = useAwaiter(() => fetchPronouns(id), {
|
||||||
fallbackValue: getCachedPronouns(id),
|
fallbackValue: getCachedPronouns(id),
|
||||||
onError: e => console.error("Fetching pronouns failed: ", e)
|
onError: e => console.error("Fetching pronouns failed: ", e)
|
||||||
});
|
});
|
||||||
@ -53,6 +59,16 @@ export function awaitAndFormatPronouns(id: string): string | null {
|
|||||||
return 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!
|
// Gets the cached pronouns, if you're too impatient for a promise!
|
||||||
export function getCachedPronouns(id: string): PronounCode | null {
|
export function getCachedPronouns(id: string): PronounCode | null {
|
||||||
return cache[id] ?? 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 { addButton, removeButton } from "@api/MessagePopover";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
|
import { insertTextIntoChatInputBox } from "@utils/discord";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { ChannelStore, ComponentDispatch } from "@webpack/common";
|
import { ChannelStore } from "@webpack/common";
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "QuickMention",
|
name: "QuickMention",
|
||||||
@ -34,7 +35,7 @@ export default definePlugin({
|
|||||||
icon: this.Icon,
|
icon: this.Icon,
|
||||||
message: msg,
|
message: msg,
|
||||||
channel: ChannelStore.getChannel(msg.channel_id),
|
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/>.
|
* 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 { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByPropsLazy } from "@webpack";
|
||||||
@ -29,7 +29,6 @@ const isMac = navigator.platform.includes("Mac"); // bruh
|
|||||||
let replyIdx = -1;
|
let replyIdx = -1;
|
||||||
let editIdx = -1;
|
let editIdx = -1;
|
||||||
|
|
||||||
migratePluginSettings("QuickReply", "InteractionKeybinds");
|
|
||||||
|
|
||||||
const enum MentionOptions {
|
const enum MentionOptions {
|
||||||
DISABLED,
|
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 { Devs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { FluxDispatcher } from "@webpack/common";
|
|
||||||
|
|
||||||
import { forEachEvent } from "./events";
|
import { onChannelDelete, onGuildDelete, onRelationshipRemove, removeFriend, removeGroup, removeGuild } from "./functions";
|
||||||
import { removeFriend, removeGroup, removeGuild } from "./functions";
|
|
||||||
import settings from "./settings";
|
import settings from "./settings";
|
||||||
import { syncAndRunChecks } from "./utils";
|
import { syncAndRunChecks, syncFriends, syncGroups, syncGuilds } from "./utils";
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "RelationshipNotifier",
|
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() {
|
async start() {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
syncAndRunChecks();
|
syncAndRunChecks();
|
||||||
}, 5000);
|
}, 5000);
|
||||||
forEachEvent((ev, cb) => FluxDispatcher.subscribe(ev, cb));
|
|
||||||
},
|
|
||||||
|
|
||||||
stop() {
|
|
||||||
forEachEvent((ev, cb) => FluxDispatcher.unsubscribe(ev, cb));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
removeFriend,
|
removeFriend,
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { definePluginSettings } from "@api/settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { OptionType } from "@utils/types";
|
import { OptionType } from "@utils/types";
|
||||||
|
|
||||||
export default definePluginSettings({
|
export default definePluginSettings({
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
import { DataStore, Notices } from "@api/index";
|
import { DataStore, Notices } from "@api/index";
|
||||||
import { showNotification } from "@api/Notifications";
|
import { showNotification } from "@api/Notifications";
|
||||||
import { ChannelStore, GuildStore, RelationshipStore, UserUtils } from "@webpack/common";
|
import { ChannelStore, GuildMemberStore, GuildStore, RelationshipStore, UserStore, UserUtils } from "@webpack/common";
|
||||||
|
|
||||||
import settings from "./settings";
|
import settings from "./settings";
|
||||||
import { ChannelType, RelationshipType, SimpleGroupChannel, SimpleGuild } from "./types";
|
import { ChannelType, RelationshipType, SimpleGroupChannel, SimpleGuild } from "./types";
|
||||||
@ -30,11 +30,20 @@ const friends = {
|
|||||||
requests: [] as string[]
|
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() {
|
export async function syncAndRunChecks() {
|
||||||
|
await runMigrations();
|
||||||
const [oldGuilds, oldGroups, oldFriends] = await DataStore.getMany([
|
const [oldGuilds, oldGroups, oldFriends] = await DataStore.getMany([
|
||||||
"relationship-notifier-guilds",
|
guildsKey(),
|
||||||
"relationship-notifier-groups",
|
groupsKey(),
|
||||||
"relationship-notifier-friends"
|
friendsKey()
|
||||||
]) as [Map<string, SimpleGuild> | undefined, Map<string, SimpleGroupChannel> | undefined, Record<"friends" | "requests", string[]> | undefined];
|
]) as [Map<string, SimpleGuild> | undefined, Map<string, SimpleGroupChannel> | undefined, Record<"friends" | "requests", string[]> | undefined];
|
||||||
|
|
||||||
await Promise.all([syncGuilds(), syncGroups(), syncFriends()]);
|
await Promise.all([syncGuilds(), syncGroups(), syncFriends()]);
|
||||||
@ -97,14 +106,18 @@ export function deleteGuild(id: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function syncGuilds() {
|
export async function syncGuilds() {
|
||||||
|
guilds.clear();
|
||||||
|
|
||||||
|
const me = UserStore.getCurrentUser().id;
|
||||||
for (const [id, { name, icon }] of Object.entries(GuildStore.getGuilds())) {
|
for (const [id, { name, icon }] of Object.entries(GuildStore.getGuilds())) {
|
||||||
|
if (GuildMemberStore.isMember(id, me))
|
||||||
guilds.set(id, {
|
guilds.set(id, {
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
iconURL: icon && `https://cdn.discordapp.com/icons/${id}/${icon}.png`
|
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) {
|
export function getGroup(id: string) {
|
||||||
@ -117,6 +130,8 @@ export function deleteGroup(id: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function syncGroups() {
|
export async function syncGroups() {
|
||||||
|
groups.clear();
|
||||||
|
|
||||||
for (const { type, id, name, rawRecipients, icon } of ChannelStore.getSortedPrivateChannels()) {
|
for (const { type, id, name, rawRecipients, icon } of ChannelStore.getSortedPrivateChannels()) {
|
||||||
if (type === ChannelType.GROUP_DM)
|
if (type === ChannelType.GROUP_DM)
|
||||||
groups.set(id, {
|
groups.set(id, {
|
||||||
@ -126,7 +141,7 @@ export async function syncGroups() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await DataStore.set("relationship-notifier-groups", groups);
|
await DataStore.set(groupsKey(), groups);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function syncFriends() {
|
export async function syncFriends() {
|
||||||
@ -145,5 +160,5 @@ export async function syncFriends() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await DataStore.set("relationship-notifier-friends", friends);
|
await DataStore.set(friendsKey(), friends);
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,10 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Settings } from "@api/settings";
|
import { Settings } from "@api/Settings";
|
||||||
|
|
||||||
import { Review } from "../entities/Review";
|
import { Review } from "../entities/Review";
|
||||||
|
import { ReviewDBUser } from "../entities/User";
|
||||||
import { authorize, showToast } from "./Utils";
|
import { authorize, showToast } from "./Utils";
|
||||||
|
|
||||||
const API_URL = "https://manti.vendicated.dev";
|
const API_URL = "https://manti.vendicated.dev";
|
||||||
@ -32,8 +33,12 @@ interface Response {
|
|||||||
updated: boolean;
|
updated: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const WarningFlag = 0b00000010;
|
||||||
|
|
||||||
export async function getReviews(id: string): Promise<Review[]> {
|
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 };
|
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) {
|
if (!res.success) {
|
||||||
@ -43,6 +48,7 @@ export async function getReviews(id: string): Promise<Review[]> {
|
|||||||
id: 0,
|
id: 0,
|
||||||
comment: "An Error occured while fetching reviews. Please try again later.",
|
comment: "An Error occured while fetching reviews. Please try again later.",
|
||||||
star: 0,
|
star: 0,
|
||||||
|
timestamp: 0,
|
||||||
sender: {
|
sender: {
|
||||||
id: 0,
|
id: 0,
|
||||||
username: "Error",
|
username: "Error",
|
||||||
@ -108,8 +114,10 @@ export async function reportReview(id: number) {
|
|||||||
showToast(await res.message);
|
showToast(await res.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getLastReviewID(id: string): Promise<number> {
|
export function getCurrentUserInfo(token: string): Promise<ReviewDBUser> {
|
||||||
return fetch(API_URL + "/getLastReviewID?discordid=" + id)
|
return fetch(API_URL + "/api/reviewdb/users", {
|
||||||
.then(r => r.text())
|
body: JSON.stringify({ token }),
|
||||||
.then(Number);
|
method: "POST",
|
||||||
|
})
|
||||||
|
.then(r => r.json());
|
||||||
}
|
}
|
||||||
|
@ -16,14 +16,14 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Settings } from "@api/settings";
|
import { Settings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Logger } from "@utils/Logger";
|
||||||
import Logger from "@utils/Logger";
|
|
||||||
import { openModal } from "@utils/modal";
|
import { openModal } from "@utils/modal";
|
||||||
import { findByProps } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { FluxDispatcher, React, SelectedChannelStore, Toasts, UserUtils } from "@webpack/common";
|
import { FluxDispatcher, React, SelectedChannelStore, Toasts, UserUtils } from "@webpack/common";
|
||||||
|
|
||||||
import { Review } from "../entities/Review";
|
import { Review } from "../entities/Review";
|
||||||
|
import { UserType } from "../entities/User";
|
||||||
|
|
||||||
export async function openUserProfileModal(userId: string) {
|
export async function openUserProfileModal(userId: string) {
|
||||||
await UserUtils.fetchUser(userId);
|
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 const sleep = (ms: number) => new Promise(r => setTimeout(r, ms));
|
||||||
|
|
||||||
export function canDeleteReview(review: Review, userId: string) {
|
export function canDeleteReview(review: Review, userId: string) {
|
||||||
if (review.sender.discordID === userId) return true;
|
if (review.sender.discordID === userId || Settings.plugins.ReviewDB.userType === UserType.Admin) return true;
|
||||||
|
|
||||||
const myId = BigInt(userId);
|
|
||||||
return myId === Devs.mantikafasi.id ||
|
|
||||||
myId === Devs.Ven.id ||
|
|
||||||
myId === Devs.rushii.id;
|
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,8 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { classes, LazyComponent } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
|
import { LazyComponent } from "@utils/react";
|
||||||
import { findByProps } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
|
|
||||||
export default LazyComponent(() => {
|
export default LazyComponent(() => {
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user