#🧩-plugin-development

1 messages · Page 10 of 1

stuck falcon
near aurora
#

no

vague echo
#

mew

eternal lion
#

Anyone know the flux event for opening member list on mobile web version?

#

how do u even find flux events?

#

like how did u know that MOBILE_WEB_SIDEBAR_OPEN opens sidebar

eternal lion
#

so ig u found that with Webpack.Common.FluxDispatcher._actionHandlers._orderedActionHandlers

#

but i dont see anything about memberlist there

dull magnet
#

actually

#

react devtools

#

install RDT in armcord and enable mobile mode in settings

#

then inspect the member list button

#

see what it do

eternal lion
#

Oke will do

magic violet
#

is it just me or viewicons didnt work? like its causing crash?

#

am i in the wrong channel

viral roost
torpid fable
#

I am going to bed bye guys

austere gulch
#

gn lol

eternal lion
#

(@dull magnet)

austere gulch
#

double ping moment

eternal lion
#

Oops

#

Sorry

#

I thought I didn't reply ping

foggy mason
#

wtf is this

#

why are they bigints 😭

#

@dull magnet will explain

dull magnet
#

no particular reason

foggy mason
#

it just makes it harder to work with

dull magnet
#

bigints are more efficient though and it doesn't really matter which one we use

dull magnet
foggy mason
dull magnet
#

for what

foggy mason
#

for the open profile thing

dull magnet
#

you can pass bigints to discords functions

#

works fine

foggy mason
#

oh i didnt know that

foggy mason
dull magnet
#

since they will be implicitly converted to strings when indexing objects and other stuff

dull magnet
foggy mason
#

requires maintenance and upkeep and doesn't really improve performance at all

dull magnet
#

it's easier this way than to specify it manually in each plugin

foggy mason
#

well i would prob do it like unbound

#

with json manifests

#

but im a fan of multiple file layouts

#

ik some people like bd structure for some reason

dull magnet
#

that's just less convenient since you need to copy paste it multiple times now if you have multiple plugins

foggy mason
#

copy and paste what

dull magnet
#

your author object

#

as for single file vs multiple file, plugins can arbitrarily choose but since most plugins are only 200ish lines it's usually single file

foggy mason
#

oh do you have manifest parsing

#

or r u just saying import it

#

and have ts compile inline

dull magnet
#

you just specify your manifest on the plugin object

#

have u not looked at some plugins to get an idea of how they look?

foggy mason
#

what no i have

#

none of them use json manifests

dull magnet
#

yeah

foggy mason
#

i alr made a plugin

dull magnet
#

oh cool

foggy mason
#

but its kinda useless i might not publish

dull magnet
#

what is it

foggy mason
proud parrotBOT
# foggy mason its just this https://github.com/swishs-client-mod-plugins/cumcord-plugins/blob/...

**index.ts: **

namespace GlobalSub {
  const CHUNK_NAME = 'webpackChunkdiscord_app';

  let __webpack_require__;
  export function initialize() {
    if (__webpack_require__) return __webpack_require__;

    const chunk = [[Symbol('global-substitution')], {}, _ => _];
    __webpack_require__ = window[CHUNK_NAME].push(chunk);
    window[CHUNK_NAME].splice(window[CHUNK_NAME].indexOf(chunk), 1);

    return __webpack_require__;
  }

  let cachedModule;
  export function onLoad() {
    const req = initialize();

    const id = (Object.values(req.c) as any)
      .find(m => m.exports.parseAndRebuild).id;

    const module = req.m[id];
    const cached = req.c[id];

    // Save for the unpatch.
    cachedModule = cached.exports;

    // I'm still not sure if any webpack modules use this but it's here in case.
    const firstArg = { exports: {}, id, loaded: false };

    const replacedFunction = module.toString().replace(/var (.)=(.)\.content.replace/, 'var $1=$2\.content.replaceAll');

    // This mutates the second argument.
    eval(replacedFunction)(firstArg, cached.exports, req);
  }

  export function onUnload() {
    if (!cachedModule) return;

    const req = initialize();

    const id = (Object.values(req.c) as any)
      .find(m => m.exports.parseAndRebuild).id;

    Object.assign(req.c[id].exports, cachedModule);
  }
}

export default GlobalSub;

dull magnet
#

cumcord plugins real

#

wait what does that do

foggy mason
#

cumcord didnt expose wreq instance so i had to grab my own

foggy mason
dull magnet
#

ohhh

#

95% of that is just patching code unrelated to the plugin

foggy mason
#

cuz that was the only way to make it

foggy mason
#

i tried monkeypatching to make it work believe me

#

discord doesnt expose anything in that module of use

#

its the parser module

#

which im sure you know is a fucking headache

dull magnet
#

that's a pretty cool plugin actually, I think if u wanted it to be more useful you could make it more powerful, as in add more capabilities of sed

#

regex, groups in replacement, global or case insensitive flag etc

#

I planned making that for powercord ages ago but got lazy

foggy mason
#

i think it supports regex

#

nope it doesnt

#

lol

#

well i found a way to edit nothing

dull magnet
#

lmao

#

how

foggy mason
#

s/any character not present/

#

mobiles had been able to do that for ages though

#

theres no checks on it for some reason

dull magnet
#

s/ehjweiwjkwjejwkwkejejej/

foggy mason
#

prob cuz it affects nothing and would require effort to put in the backend

dull magnet
foggy mason
#

discord only has so much of that to spare

dull magnet
#

triple greet

#

even without nitro

foggy mason
#

seems like they patched it

dull magnet
#

no

#

you can only do it in response to welcome messages

#

if you don't have nitro

foggy mason
#

oh

#

im dumb

dull magnet
#

cause otherwise you don't have sticker perms

foggy mason
#

ah i see

dull magnet
#

yes welcome messages explicitly allow you to use welcome stickers in normal messages even without nitro

#

they now have a dedicated endpoint for it but when that feature was new they just sent it as a normal message

#

they still have that on the api side so you can just go bonkers in reply to welcome messages

south ledge
#

strap you seatbelts on, we have classname changes gone

-              className: G().wordmarkWindows,
+              className: U.Z.wordmarkWindows,```
dull magnet
#

its super easy lol

#

i just had to remove () from everything

tired terrace
dull magnet
#

huh

shadow ruin
#

ok now i understand why people say i should name my variables something good

#

the fuck is cbt

dull magnet
trail ginkgo
#

i will never understand

cedar marsh
#

Whenever I can't think of a good variable name I legitimately just bash my keyboard

#

//TODO: good var name

dull magnet
#

how do you ever not have a better name for a variable

#

surely it has some purpose you can name it after

eternal lion
#

Yeah

dull magnet
eternal lion
#

Just make it descriptive

cedar marsh
#

I don't like long var names

dull magnet
#

don't make it long

#

unless you're a java dev

cedar marsh
#

So thinking of something descriptive under 8 characters

eternal lion
#

What scenario?

cedar marsh
#

I mainly run into this issue when I am solving a logical puzzle like AofCode and am not quite sure how I will use a variable yet, but I know that I will need it

proud parrotBOT
eternal lion
#

Yeah

dull magnet
#

Also why are you using PascalCase in java

#

criminal

cedar marsh
#

"names in pascal case start with a capital letter"

I must have done it accidentally for the var name and not noticed when using tab autofill when I was using it

#

I will fix later

trail ginkgo
#

i would at least like have a letter

#

or something

#

some atrocious abbreviation

cedar marsh
#

Just bash your keyboard at that point and //TODO your problems away

trail ginkgo
#

how do u remember what ur variable is called

cedar marsh
#

I remember the first 2 letters then press tab

trail ginkgo
#

insane

cedar marsh
#

//TODO think of better way to name variables

azure siren
#

so is there a way to patch the componentDidMount function of a component?

grim hare
#

is the image view layer completely borked right now

#

I crash when trying to view someone's pfp as well as when trying to view album art from the spotify plugin

dull magnet
#

huh

#

they use the same code

#

so it's probably just broken

grim hare
#

well yes

#

I said both to point to it being the shared code being broken

dull magnet
#

u will fix

#

didn't find module

#

broken filter be like

grim hare
#

I will explod

dull magnet
proud parrotBOT
dull magnet
#

it's the first one

#

notice how stacktrace says line 27

grim hare
#

I know where it is yeah, i'm just bad at finxing modules xd
might look at it later today but working on other things at the moment

grim hare
#

the updater apparently has been failing builds for me for the last while but didn't show an error

#

lovely

#

manually building has fixed it

#

i'll figure out what was causing it to fail the build but it was probably some weird stale file somewhere

foggy mason
#

how fix

foggy mason
#

@dull magnet my man you've got to stop shipping this many plugins into the client the amount of lag when opening up plugins is crazy

dull magnet
#

the lag is caused by the ui code

#

not by the amount of items

#

I think

foggy mason
#

well im overhauling ur plugin cards cuz they look like shit (no offense) so ill see what i can do

#

also vencord for kernel when so i can unisolate this garbage app

dull magnet
#

I mean

#

should just be able to load the browser bundle

#

right?

foggy mason
#

im just gonna edit the patcher index.js to load both

foggy mason
dull magnet
#

but that has some limitations

#

and everything is stored in local storage / indexeddb

foggy mason
dull magnet
#

there's v2 and v3

#

which refers to the manifest version

foggy mason
#

ah

#

@dull magnet are plugins ever going to have version control

dull magnet
#

I don't plan to

#

I don't really want the trouble of third party plugins being the norm

#

all inbuilt works well so far

green vessel
#

someone go make a user plugin that implements version control for user plugins trolley

dull magnet
#

yop

foggy mason
#

i think shipping a client with any amount of non inbuilt plugins makes it feel bloaty

#

thats the mindset behind astra and unbound

#

to have a verified plugins list and let users choose what plugins they want

#

also just having a version number helps immensely in debugging

#

the first thing that should be asked when someone has an issue with a plugin is "what version are you running"

foggy mason
#

ven do you have something against export default cuz like

#

why not just import { proxyLazy } from "@utils";

#

so much cleaner

dull magnet
#

circular import hell

#

I also don't manually import tho

#

I do it everything with ide auto complete

foggy mason
#

ah thats why your import statements are unreadable

#

ok that came across more hostile than i meant...

dull magnet
#

Lol what

#

why u even looking at imports anyway

foggy mason
#

moving the avatar component out of the modal

#

im gonna put it on the actual card

dull magnet
#

that's not possible without fetching all users

#

which is a bad idea since there's like 20 plugin devs and even more in the future

#

or do you have any better idea

foggy mason
#

i mean first off just have less plugins

#

but also discord requests a shit ton of users at all times

#

as long as you use the right endpoint itll be fine

green vessel
#

u keep saying have less plugins like the bundle size is 300 mb or something

foggy mason
#

when did the norm switch to including fart v2 as an inbuilt plugin

#

like half of the included plugins are meme plugins

dull magnet
green vessel
#

gaslighting

foggy mason
#

moyai oneko petpet

foggy mason
green vessel
#

oneko is my favourite plugin please give it more respect

dull magnet
#

I use it often

eternal lion
tropic galleon
dull magnet
#

PluginCards take 0.1ms

#

so not the cards

#

i wonder what's making the plugins page kinda slow

granite vault
#

Discord UI components trolley

dull magnet
#

didnt do much for me

#

someone make a plugin to replace React with React Development

#

so we can use profiler

#

i think it might unironically be one of Discord's components that's laggy

#

wouldnt surprise me

dull magnet
#

okay so

#

the rendering itself is very fast

#

the slow part is actually React rendering the Components

#

Which means the bottleneck is very likely one of Discord's Components

#

LOL

#

i found it

#

it's the Switch Component that's laggy

#

@foggy mason

#

Discord yucky at coding

foggy mason
#

wow

proud parrotBOT
# dull magnet https://github.com/Vendicated/Vencord/blob/main/src/components/PluginSettings/in...

**index.tsx: **Lines 149-173

return (
    <Flex className={cl("card")} flexDirection="column" onMouseEnter={onMouseEnter} onMouseLeave={onMouseLeave}>
        <Switch
            onChange={toggleEnabled}
            disabled={disabled}
            value={isEnabled()}
            note={<Text className={cl("note")} variant="text-md/normal">{plugin.description}</Text>}
            hideBorder={true}
        >
            <Flex className={cl("flex")}>
                <Text
                    variant="text-md/bold"
                    className={cl("name")}
                >
                    {plugin.name}{isNew && <Badge text="NEW" color="#ED4245" />}
                </Text>
                <button role="switch" onClick={() => openModal()} className={classes("button-12Fmur", cl("info-button"))}>
                    {plugin.options
                        ? <CogWheel />
                        : <InfoIcon width="24" height="24" />}
                </button>
            </Flex>
        </Switch>
    </Flex>
);
dull magnet
#

gotta reimplement this without Switches

#

this is hilarious because Switches are also what makes Aliucord's Settings laggy

#

Switches are laggy on both Desktop and Android (Java)

#

discord will fix lag

trim igloo
#

vencord will merge prs

granite vault
#

Discord insane

trail ginkgo
austere gulch
#

I'm already tracer

dull magnet
#

it be tracing

#

surprised you didnt notice this earlier

#

its used in some parts of the code

austere gulch
tired terrace
#

read if ||gay ||

#

wait not general

dusty ruin
#

@dull magnet for annoiler I can either of the following:

  1. PR the annoil command to the MoreCommands plugin
  2. Make it's separate plugin and PR that plugin
#

Which one should I do

dull magnet
#

if annoiler = spoiler spam then neither

dusty ruin
#

SO option 3
3rd Party plugin

#

Another question regarding authors field in DefinePlugin
Does it have to be from { Devs } from "@utils/constants" or I can just type in text normally?

dull magnet
#

you can just type it in manually

trail ginkgo
dull magnet
#

there's probably a better way to do this

#

but it works soooo

dusty ruin
dusty ruin
dull magnet
#

error is pretty obvious

#

you're setting it to a string when it should be an array of plugin author objects

dusty ruin
dull magnet
#

typescript is structurally typed

#

authors: [{ name: "blah", id: 123456789n }]

dusty ruin
#

Alright

dusty ruin
dull magnet
#

don't post it there

#

annoying plugin

dusty ruin
#

Guh

foggy mason
dull magnet
#

i mean it is annoying

#

i dont want 12yos sspamming spoiler spam here

foggy mason
#

||@dull magnet|| ||s||||t||||i||||n||||k||||e||||r||

dull magnet
#

I DONT STKNK

foggy mason
#

go take a shower

dull magnet
#

NOOO

#

you can't make me

unkempt swift
#

Did someone say shower???

remote kestrel
#

ok insane idea

#

for testing could something be made that pulls the latest discord stable, or canary then patches it and lets you test your local changes without running on your actual discord?
like as a npm task or something

dull magnet
#

define testing

#

just test if it works or actually launch a discord

#

@remote kestrel

green vessel
#

test if patch patches I guess

#

you'd need to fetch a ton of stuff but could be cached I think

remote kestrel
#

so i can have a copy of vencord thats working on my main discord

#

and for development another copy

dull magnet
#

easiest it to just use two clients

remote kestrel
#

that would be ideal but i can survive with editing the main one

dull magnet
#

stable and canary

remote kestrel
#

oh

#

horror

#

does vencord let you change the install path

dull magnet
#

wha

remote kestrel
#

~/.config/vencord/dist

dull magnet
#

oh

#

with environment variable

#

it's not the best

remote kestrel
#

fix

dull magnet
#

but the development build doesn't put the files there

#

if you patch with pnpm inject it won't alter your ~/.config/Vencord files

remote kestrel
#

oh

#

i see

dull magnet
#

Fixed React Devtools for everyone, if you want them fixed do this

Vencord Settings -> Open Settings Folder > Extension Cache > Delete fmkadmapgofadopljbjfkapdkoienihi

trail ginkgo
#

@dusty spire hey :3

#

i want to pick your typescript brain

#

I have this type ts export interface DefinedSettings<D extends SettingsDefinition = SettingsDefinition, C extends SettingsChecks<D> = {}> { store: SettingsStore<D>; use<F extends Extract<keyof D, string>>(filter?: F[]): Pick<SettingsStore<D>, F>; def: D; checks: C; pluginName: string; }

#

SettingsDefinition is just a Record<string, some setting definition>

#

so I'm using a generic F here

export function useShikiSettings<F extends keyof ShikiSettings>(settingKeys: F[], overrides?: Partial<ShikiSettings>) {
    const settings = pluginSettings.use(settingKeys);```
#

ShikiSettings is typeof store from the defined settings

#

settings has no members in this generic case

#

im wondering if its possible to have .use return a partial of the store in a generic case like this

covert nimbus
#

is the equivelent of js const { x } = getModule(['y'], false)
from powercord/old replugged ts const x = findByPropsLazy("y").x;
or am i being dum

dull magnet
#

don't destructure

covert nimbus
#

the one with destructuring is from powercord/old replugged

#

i figured out the no destructuring thing when it broke my vencord

dull magnet
#

you're still doing it

#

.x

covert nimbus
#

then how do i get the .x thing

dull magnet
#
const { x } = getModule(['y'], false)```
 ```ts
const xModule = findByPropsLazy("y")

xModule.x()```
covert nimbus
#

i see

trail ginkgo
# covert nimbus i see

the reason is because it doesnt actually look for the module until you try to access x
so if you are doing it before vencord gets to see the modules (like immediately when the plugin file is initialized) it will throw
but if you only access x when you're actually using it, it's likely that it will be at a point where the webpack stuff is loaded

covert nimbus
trail ginkgo
#

real

dull magnet
#

yeah that's what the lazy stands for

#

we need to add like prefetching for lazy webpack @trail ginkgo @trail ginkgo

#

like detect when the client is idle and prefetch all the lazys

covert nimbus
#

why is the property a string husk

trail ginkgo
#

not needed t b h

#

prefetch them all exactly 50000ms after renderer init

#

you know what we should add

trail ginkgo
#

but in a lazy way

green vessel
#

lazy-load them (after 2 milliseconds)

covert nimbus
dull magnet
trail ginkgo
dull magnet
#

like when do you need this?

dull magnet
covert nimbus
dull magnet
#

this is probably strings or api routes or smth

green vessel
#

see how lastfm does it

trail ginkgo
#

i wanted to use a component that is only loaded when you go to a specific page, in this case its the file upload component

covert nimbus
#

oh yeah i forgot lastfm

dull magnet
#

run wp.findAllByProps("SET_ACTIVITY")

#

in console

#

see if you get multiple

green vessel
#

wp not defined trolley

dull magnet
#

but also what r u trying to do

trail ginkgo
#

the chunk with the file upload component only loads when you open the server sticker settings

dull magnet
#

Should I make console shortcuts required in dev builds 🔥

green vessel
#

yop

covert nimbus
dull magnet
#

same module twice

green vessel
#

told u wp not defined trolley

dull magnet
#

epic discord

dull magnet
green vessel
#

i do

#

@covert nimbus will

covert nimbus
#

okay

green vessel
#

ven will make pnpm build be dev build by default

covert nimbus
#

wait that's a dispatcher event?

green vessel
#

yes

covert nimbus
#

that means im gonna have fun porting my old neofetch-RPC plugin to the new replugged codebase eventually

trail ginkgo
dull magnet
#

yeah probably

trail ginkgo
#

probably blobcatfearful

covert nimbus
#

is it a smart thing to dispatch LOCAL_ACTIVITY_UPDATE every time a setting is updated yep

probably not, unless the onChange function is called only when the setting is saved

#

okay from looking at the source, it seems to be called in saveAndClose()

dull magnet
#

is okay

covert nimbus
#

discords way of handling rich presence button is the embodiment of "wtf am i reading"

covert nimbus
#

I'm gonna assume OptionType.BIGINT is best for unix timestamps, right?

austere gulch
#

normal numbers are safe

covert nimbus
#

ok

green vessel
#

but they won't be after november 12, 285428751, at 07:36:31 UTC

south ledge
proud parrotBOT
south ledge
#

this is reversed

#

should be options.frame = !settings.frameless;

dull magnet
#

@stray imp dum

stray imp
dull magnet
#

i fixed

trail ginkgo
#

poor jai paul

south ledge
civic elk
dull magnet
#

the gui doesnt use git

#

youre using your local install

opal fern
lapis swallow
#

using a "gui" for git

fallen wagon
#

i Forget who made the Logging Plugin, But for whoever made it, you fixed the photos that now go black and white when deleted, but Gifs do not go black and white when deleted

tropic galleon
#

Is there a (simple) way to patch the message menu?

dull magnet
#

which

tropic galleon
#

Ye

foggy mason
#

patch the ret of this func

#

oh wait no moneky patch

#

how tf do u add shit to a menu with transform patch guh

#

spagetti string

dull magnet
#

discord switching to jsxs made it more painful tho

foggy mason
#

also what

foggy mason
#

ur joking

dull magnet
#

that means that function isn't exported

#

jsxs swish

#

the function

#

r.jsxs()
r.jsx()

foggy mason
dull magnet
#

it's new version of React.createElement

#

that puts children inside the props as array

foggy mason
#

is it not just an aklias

dull magnet
#

no it's a bit different

#

the main diff is that children are an array inside props instead of being params

#

which is way more painful to match

foggy mason
#

is it just a discord thing

dull magnet
#

nah react

foggy mason
#

ok thats not true

#

js has 3 substring functions

#

but still what the hell is the point of this

dull magnet
#

Well it's not meant to be used by you (the user), it's just a compiler change for better performance

foggy mason
#

i just mean

dull magnet
foggy mason
#

solid is out here actually inovating

granite vault
#

React devolving

foggy mason
#

and react just adds what most bundlers already do

granite vault
foggy mason
#

why did they have to team up with babel for this what

dull magnet
#

lmao

foggy mason
#

this doesnt require collaboration

#

whatever

dull magnet
#

the most compelling reasons for the new runtime is that it doesn't require you to import React anymore and minifies better

#

since before there were hundreds of "React.createElement" that can now be minified to one letter function

#

xd

foggy mason
#

well yeah importing the entire React object certainly increases ram usage

dull magnet
#

btw there's two functions in the new transform

#

r.jsx and r.jsxs

#

they're the same in production

#

jsx is used for any element that has multiple children```jsx
<span>{1}{2}</span>
<a>{1}</a>

```js
jsxs("span", { props: [1, 2] });
jsx("a", { props: 1 }]
#

I think it's so they can differentiate whether the array was created by react (multiple children) or passed by you so they can issue key warnings

foggy mason
#

i see

wraith carbon
#

can someone who actually knows how github works explain why I can't resolve conflicts in my PR

tropic galleon
#

You need to sync changes on your fork on github, pull those changes on local main branch, then merge it to your patch branch (if you did create a branch), then resolve conflicts, and commit + push

wraith carbon
#

I think I've managed to do it

#

I wish GitHub liked me more mswearylegs

tropic galleon
#

Oh god, kill me

#

It's been 3 hours figuring out why the patches wont apply, and then i realised the plugin wasn't activated husk

pulsar zodiac
dull magnet
#

there's no reason to rebase in a pr

#

plus the odds of fucking it up if you're not good with git are high so just don't

granite vault
austere gulch
#

rebase bad

#

it kinda voids the whole point of git

#

having a canonical list of changes

#

a merge makes it obvious where main branch was merged into your branch

granite vault
deft hull
#

does the message popover api still work here?

#

I'm trying to get it to work on replugged but I cannot find the source for the life of me

viral roost
#

broken on canary

deft hull
#

that's why

#

shit

covert nimbus
#

how do I access this component in vencord?

sonic badger
#

I was just working on a plugin. It sends a code block from lines of a git file. It seems to work, but it sometimes sends messages with a bot tag and doesn't let me edit/delete them. Why is that?

opal fern
#

Send your code

#

Can't tell what's happening if we don't know what's happening

sonic badger
#

It's not doing anything special so I didn't think it would matter. Only thing I thought might explain it is that it's async.

cedar olive
#

well send your code

solar maple
#

you don't need to spend a penny for it

trail ginkgo
#

i think you still have to pay $5 license fee

#

because u still need to submit your extension to be signed into a .crx file

sonic badger
#

I haven't had it happen again since the first day

#

the code has changed a bit, but i don't know js/ts so it's not done yet

#

index.ts:80-89

async function sendCodeBlock(url: string): Promise<string> {
    const { name, ext, lineStart, lineEnd } = getFileInfo(url);
    const response = await fetch("https://cors.proxy.consumet.org/" + url);
    const text = await response.text();
    const lines = text.split("\n");
    const code = lines.slice(lineStart ?? 0, lineEnd ?? 26).join("\n");
    const title = `**${name}**` + (lineStart ? `:${lineStart}` : "") + (lineEnd ? `-${lineEnd}` : "");
    return `${title}\n\`\`\`${ext}\n${unindent(code)}\n\`\`\``;
}
#

works well enough for the moment

wraith carbon
rapid verge
#

how can i get S from this insanity

tropic galleon
#

It seems it's Lq

rapid verge
#

i know

#

i need to find it from code

tropic galleon
#

Get the module id defined upper

#

Or

findByProps('Pl', 'sq', 'Ub', 'Lq', 'PP', /* and so on */);
rapid verge
#

i already can find module

#

how to get a right function if half of exports are similar to _ and are proxies to actual functions

rapid verge
#

i don't really like grabbing a function through patch but i already did that and it works

        find: ".GUILD_DISCOVERY,object:",
        replacement: {
            match: /(function ([a-zA-Z_]+)(?:(?!function ).)+\.GUILD_DISCOVERY,object:.*?\.apply\(this,arguments\)})/s,
            replace: "$1Vencord.Plugins.plugins.LurkGuild.setLurkGuild($2);"
        }
#

just want to know if there any less weird alternative to this

#

it works but also hitting me on some level lol

dull magnet
#

is it?

rapid verge
#

not the only but half of them look like this

dull magnet
#

so half of the exported functions are just X.apply(this, arguments)?

rapid verge
#

yes

#

some weird promisifying magic

dull magnet
#

lmao

#

so two options:

  1. patch
  2. use findModuleId and manually require the module then use regex / regular string search to find the name
rapid verge
#

for now went to patch

dull magnet
#

the latter is cleaner tbh

dull magnet
#
const MyFunc = proxyLazy(() => {
   const id = findModuleId(".GUILD_DISCOVERY,object:");
    // match "S" aka ur func name here
   const myFuncName = /.../.match(wreq.m[id].toString());
   return Object.values(wreq(id)).find(v => typeof v === "function" && v.toString().includes(`return ${myFuncName}.apply(this,arguments)`));
})```
#

this is how u would do it

rapid verge
#

hmm it works

#

thanks

tropic galleon
#

Hi, so, I don't know patching well, but I'm struggling with a problem.
The main problem is that a parent component requires a functional component, but not invoked, like;

const parent = find(...);
const child = find(...);

return <parent>{child}</parent>;

However, I cannot pass props to child, because otherwise it throws.
So, I did a ugly ass wrapper:

const parent = find(...);
const child = find(...);

const childWrapper = (props: Record<string, any>) => <child {...props} />

return <parent>{childWrapper({icon: myIcon })}</parent>;

It does not work properly, because a new component is created and the wrapper causes this, which leads to classes and other properties being applied to the wrapper instead of the children

dull magnet
#
<parent>
    {discordsProps => <child {...discordsProps} {...yourProps} />}
</parent>
tropic galleon
#

Omg thank you! I found the right way with your tip NepOkay

dull magnet
#

what is it

tropic galleon
#

Wdym?

#

The component?

dull magnet
#

show

tropic galleon
#

It's this

#

There's no icon cuz the sample svg is fucked up, but I'll add it one

dull magnet
#

I meant code

tropic galleon
#

Oh, sorry

dull magnet
#

InnerInnerChild blbctscrd

#

isnt the innerChild being a wrapper pointless

#

just pass directly

tropic galleon
#

Well, I removed InnerInnerChild, and it seems to work fine

#

Oh god, discord is so messy

dull magnet
#

how

tropic galleon
#

I'll try to remove some stuff and see if it breaks

trail ginkgo
#

oh wait

#

i should not be managing the streams directly

#

i should be managing the devices

dull magnet
trail ginkgo
#

oh im in development wtf

crisp jungle
#

how does discord inflate zlib stuff using the browser only?

#

all i can get online are ones that uses the nodejs zlib

#

when i try pako or zlib.js
it gives me error

#

nodejs's zlib works though

#

yes i didn't actually test pako or anything in the browser i just assumed the ones said to be compatible for browsers would work in nodejs

dull magnet
daring fractal
#

Does Vencord have i18n? Would love to translate this thing into my language! ❤️

woven lion
#

that sounds like an interesting challenge

austere gulch
#

I think we decided not to

#

since most plugins wont have i18n

woven lion
#

yeah, that was the challenge bit

#

wouldnt be surprised, i18n would bloat it quite a bit by ...

#

i dont know, i cant make up reasonable numbers

#

but i can say that it'd add loads of bloat that you wont ever use

#

and pulling strings from a remote isnt a reasonable solution either

#

so i guess No®️

lapis swallow
#

Then, it's not a good compressor/decompressor

green vessel
#

what

opal fern
#

bro has voices inside his head

austere gulch
#

is is the fastest smallest, and most versatile pure javascript compression library
how is that not "good"

lapis swallow
#

Javascript = slow

so create a compressor in javascript = slow

dull magnet
#

lol

#

no

austere gulch
#

brain rot

opal fern
#

bro??

dull magnet
#

Javascript can be insanely fast thanks to TypedArrays and jit

#

it doesn't matter anyway

austere gulch
#

yop

lapis swallow
#

Create compressor in rust mikuheart

opal fern
#

i dont fucking understand

lapis swallow
#

TypedArrays is fast but same with that I am not really convinced

dull magnet
#

okay it doesn't matter

lapis swallow
#

After maybe it depend for what kind of project

dull magnet
#

the author of that library claims

In fact, the compressor, in synchronous mode, compresses both more quickly and with a higher compression ratio than most compression software (even Info-ZIP, a C program), and in asynchronous mode it can utilize multiple threads to achieve over 3x the performance of any other utility

#

there's no reason not to believe him

green vessel
#

yeah because surely performance is extremely critical, since the discord client is so well-optimised and we don't want to ruin that

dull magnet
#

that library just used by build build tool and if you enable react devtools anyway

#

so it doesn't matter tears_holding_back_face

edgy berry
#

is there a function to fetch all guilds the user is in

dull magnet
#

findByProps("getGuilds", "getGuild").getGuilds()

#

but if u need only the guild count then use findByProps("getGuildCount").getGuildCount()

cedar olive
#

how would I use parseTopic with JSX

dull magnet
#
<div>{parseTopic()}</div>```
#

super simple

cedar olive
#

I did try that

dull magnet
#

should work

cedar olive
dull magnet
#

show full code?

cedar olive
edgy berry
cedar olive
edgy berry
#

idk why i had a feeling you would send the tryitandsee

cedar olive
#

OHHH

#

jesus I'm dumb

#

the third argument is an object

dull magnet
#

lmao

cedar olive
#

hmm yess

#

progress

dull magnet
#

hot

#

now add some margin

cedar olive
#

ya

dull magnet
#

is this still the same pr

cedar olive
#

I've literally rewrote the entire plugin

#

all patches

#

yeah

#

haven't pushed yet

#

hmmm

#

how would I add css to that component

dull magnet
#

wrap in a div and theme children of that div

#
.vc-shc-topic idk-some-selector {
}
cedar olive
#

well this works too

dull magnet
#

ye

#

whys the colour one needed

#

does parseTOpic not add that

cedar olive
#

It does not

dull magnet
#

L

cedar olive
#

I have finished

#

ew what??

#

oh wait

#

I used the wrong client

#

it's working correctly on the other

dull magnet
#

asdasd test 😁

cedar olive
#

at one point my main client crashed and applied the changes

dull magnet
#

#updates-fundoacordado

#

is that an actual word

cedar olive
#

smh stop bullying my channel names

dull magnet
#

ulgy timestamp

#

why not use the timestamp component

cedar olive
#

e

dull magnet
#

message lagger has example

cedar olive
#

oh

#

good point

#

lmao

#

@dull magnet should I make a Timestamp API plugin

#

to export the timestamp component

dull magnet
#

is it not easy to find without marker

#

nah its easy to find

cedar olive
#

oh

#

let me try

dull magnet
cedar olive
#

findbycode poggers

dull magnet
#

wp.findByCode("MESSAGE_EDITED_TIMESTAMP_A11Y_LABEL")

#

i think the plugin just adds that cause it patches that module anyway

#

so might as well

cedar olive
#

It doesn't

#

it just exports it

dull magnet
#

idk then

#

add it to webpack common and remove the patch if uwant

cedar olive
#

will do

#

turns out it looks the same

#

nvm it's a bit different

dull magnet
#

wait what

#

why does it look like that

cedar olive
#

well there is this

edgy berry
cedar olive
#

I think you meant a different timestamp component right

dull magnet
#

idk

#

no its the same

#

well it doesnt matter leave it that way

edgy berry
#

how

dull magnet
#

idk

#

in vscode u can enable lint on save

edgy berry
#

i added semicolons and i still have the same issue

edgy berry
#

but im p sure this eslint error isnt valid

dull magnet
#

i never used intellij for js so i cant help u

#

you will likely have a better experience in vscode

edgy berry
#

eee ok

#

thanks

cedar olive
#

@dull magnet it looks before now

#

I love compact mode

#

@dull magnet OHHHH

#

IT'S CUZ IT'S AN OLD MESSAGE

#

send a message in #private

#

also what's the correct order

dull magnet
dull magnet
cedar olive
#

I honestly have no idea what I wrote there

dull magnet
cedar olive
#

I made a typo and I forgot what I said

edgy berry
#

how would I get all cached channels

#

(this doesnt work)

dull magnet
#

what for

#
Object.fromEntries(Object.keys(findByProps("getGuilds", "getGuild").getGuilds()).map(g => [g, findByProps("getChannels").getChannels(g)]))
#

idk if theres a better way

edgy berry
#

so i need to store group chats

dull magnet
#

so you want groups not channels

#

so thats wrong

edgy berry
#

oh wait yeah

#

that only gets guild channels

dull magnet
#

findByProps("getSortedPrivateChannels").getSortedPrivateChannels()

edgy berry
#

ty

dull magnet
#

that gives all dms

#

if u only want dm groups ```js
const GROUP_DM = 3;
const DMStore = findByPropsLazy("getSortedPrivateChannels");

const getDMGroups = () => DMStore.getSortedPrivateChannels().filter(c => c.type === GROUP_DM);

dull magnet
#

you should cache webpack searches

edgy berry
#

oh yea

#

thats prob a good idea

dull magnet
#

instead of doing it on function level, just add const Name = findByPropsLazy(...) on top level

#

the lazy will make it only actually do the search once it's used

edgy berry
#

like this right

dull magnet
#

no

#

you cannot destructure

edgy berry
#

oh

dull magnet
#

const DMStore = ...
consz GuildStore = ...

#

GuildStore is very likely in webpack commons

edgy berry
#

gotcha

dull magnet
#

destructuring would access it immediately which would remove the lazy factor and not work since plugins load way before webpack modules are ready

covert nimbus
austere gulch
#

you've always been able to make 1-member dm groups

covert nimbus
#

look near the top right

austere gulch
#

oh

#

yeah that's also old

#

it's added by the isStaff setting in the experiments plugin

#

if you're in a gdm of only staff members, that badge appears

#

so that staff know they can talk about NDA stuff easier

cedar olive
#

megu staff when

austere gulch
cedar olive
#

dang

covert nimbus
#

fake

crisp jungle
#

bruh

#

i just reversed engineered it instead

#

what is this

austere gulch
#

ye discord uses pako for compression

crisp jungle
#

i think i finally get it omg!!!

edgy berry
#

why do I get this when trying to use NavigationRouter.transitionTo("/channels/@me");

viral roost
#
const NavigationRouter = mapMangledModuleLazy('"transitionToGuild', {
    transitionTo: filters.byCode('"transitionTo '),
    transitionToGuild: filters.byCode('"transitionToGuild'),
    goBack: filters.byCode("goBack()"),
    goForward: filters.byCode("goForward()"),
});
#

i was too lazy to pr the fix

edgy berry
#

ah thanks

#

should i pr the fix with my plugin? or just define that separately inside

viral roost
#

pr it with the plugin

edgy berry
#

kk

edgy berry
#

why does this patch give this error

austere gulch
#

put it in the patch helper and it'll show you the resulting code

#

(it only appears if you build with pnpm watch)

viral roost
#

oh and also you can (should) use \i instead of .{1,2} for minified vars

covert nimbus
viral roost
covert nimbus
#

why would a regular user install using git

viral roost
#

third party plugins

edgy berry
#

looks like it should work

viral roost
#

also you should use pnpm watch for dev builds anyway

austere gulch
#

it's hidden for normal users

#

most people developing use watch anyways

austere gulch
edgy berry
austere gulch
#

this looks unsafe

edgy berry
#

oh

#

what should i do instead

#

i counted the function body and its like 190 chars when minified

austere gulch
#
removeRelationship: function(e, t, n) {
    return r.Z.delete({
        url: E.ANM.USER_RELATIONSHIP(e),
        context: t,
        oldFormErrors: !0
    }).then((function() {
        null == n || n()
    }
    )).catch((function() {
        i.Z.announce(p.Z.Messages.A11Y_ANNOUNCEMENT_GENERIC_FAIL)
    }
    ))
},
#

hmmies

#

@edgy berry what is the output that you want

#

the resulting js

edgy berry
#

i wanna insert my function at the start

#

using the e param

austere gulch
#

insert at the start, but keep the original return as well?

edgy berry
#

yeah

austere gulch
#

alr

#
"match": /(removeRelationship:function\((\i),\i,\i\){)/,
"replace": "$1$self.a($2);"
#

something like that?

#

keeps the return, but adds the YourPlugin bit

edgy berry
#

ill try that when i get back to my computer

austere gulch
#

👌

edgy berry
#

but somehow shows the diff in the console as well

covert nimbus
#

is that a space

#

do i see a space in an attribute

#

That is probably why.

edgy berry
#

oh

#

that mightve been the issue the entire time

#

lmfao

#

let me check

covert nimbus
#

probably

austere gulch
#

yeah lmao

#

vencord plugins names should be like RelationshipNotifier

#

we dont put spaces in the names

covert nimbus
#

trolley we will put spaces in every name

viral roost
#

omw to add spaces to message logger so no one can keep what i said and insta deleted

edgy berry
#

do i need to do anything else after changing the name

#

since it wont load now

#

nvm im dumb

covert nimbus
#

did you enable the plugin again

edgy berry
#

i had to reenable

#

yea

covert nimbus
edgy berry
#

ok awesome it works

#

if i wanna use an export from another file is it just $self.<filename>.export

dull magnet
#

its just tied to watch because i didnt wanna bother checking for something like node_env

covert nimbus
#

wait was it always tied to watch

dull magnet
#

yea

covert nimbus
#

oh then i'm an idiot

#

i could've sworn i saw it in settings when i was developing customRPC (i initially didn't use watch)

dull magnet
#

watch builds are non minified, have more strict errors / warning than non watch builds and have patch helper, more useful patch errors with diff, etc

#

they also have performance log spam in the console

#

many differences that most people wouldn't want

covert nimbus
#

huh, i always thought vencord just checked somehow if it was a manual install

dull magnet
#

no it's done at build time

#

there are 3 different types of builds:

  • dev ~ non minified, less optimised, many dev features
  • regular ~ minified and optimised, this is what you get if you just install with the installer
  • platform optimised ~ same as regular but platform specific code for different platform than you're on is stripped. this is what you use if you just run pnpm build
#

Well there are technically 6 different builds since there's this and then also this for web

trail ginkgo
edgy berry
#

i wanna use a function exported from a file i made called functions.ts

dull magnet
#

just import them

trail ginkgo
#

It'll be the same you just have to put that export in your main plugin object

dull magnet
#

the same way you would import from webpack or similar

#

oh I see

#

u wanna use the function in a patch

edgy berry
#

yeah

dull magnet
#

the way to do that is to do what vap said

#

import it in your index and put it on the plugin object

edgy berry
#

alr

#

thanks

trail ginkgo
#

Huge

edgy berry
#

if i store a map using DataStore.set() will it return a map object when using DataStore.get()

dull magnet
#

yes

#

it's indexeddb

edgy berry
#

okie thanks

sonic badger
#

I looked at the fakenitro plugin, but i'm not quite adept enough at typescript to understand how to apply the async messaging to my own plugin

#

Since it uses stickers and whatever else, I restructured my code to be similar in hopes something would change but no luck

#

I just need to replace each url with my message on send, but since it uses fetch the asynchronous response is causing me trouble with the listeners

dull magnet
#

.then() runs asynchronously

#

the function returns before it's done

#

you need to cancel the message send then send it manually

sonic badger
#

I'm pretty sure I tried it without that as well, but how do I do that?

cedar olive
#

It's literally what I suggested

sonic badger
#

I think that is what nookies suggest as well lol

cedar olive
#

yep

sonic badger
#

but it sends in the console at practically the exact same time the message sends, so surely there is a way to just wait right?

#

Or does the listener have a very limited amount of time to respond

dull magnet
#

it's impossible for an asynchronous operation to complete before the synchronous part completed

#

even if you make a promise that resolves immediately it will still happen after

sonic badger
#

but if the message is cancelled, the async operation completes, and then the message is sent... that would work?

#

how come messages cant just be sent asynchronously? since that's how bots worked I assumed discord would just function like that in general

dull magnet
#

discords logic for sending messages that we hook into is synchronous

sonic badger
#

I thought it was basically just an api call here too

cedar olive
#

it's a preSendListener

#

you are hooking into discord logic before it sends the message

#

all of that process is sync because discord did not make the api call yet

sonic badger
#

Okay that makes sense

dull magnet
#

I think it could be made async with some refactoring

sonic badger
#

that would be nice

#

where is the code that would need to be refactored?

dull magnet
#

u could try urself

sonic badger
#

are any other clients sending messages asynchronously?

ember wigeon
#

new to vencord still looking around for answers but uhh anyway to convert bd plugins to vencord easily without typescript source of the plugin? Trying to get my animation plugins back

dull magnet
#

no

#

it needs to be remade from scratch

sonic badger
#

okay so the discord message event is patched and replaces with the preSend listener, which intercepts the arguments and lets you change them before passing them back to discord's message handler right? Is a listener the context in which you can modify the message?

#

also how come you can cancel sending a message but not editing. Does editing start when you open the edit window rather than confirm it?

sonic badger
#

the set of listeners is empty now, and there is an error in a webpack module

#

in this function

#
sendMessage: function(e, t) {
    var n = !(arguments.length > 2 && void 0 !== arguments[2]) || arguments[2]
        , r = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : {};
    if (t.reaction)
        return Promise.resolve();
    var o = function() {
        return le._sendMessage(e, t, r)
    };
    return n ? new Promise((function(t, n) {
        x.Z.whenReady(e, (function() {
            return o().then(t, n)
        }
        ))
    }
    )) : o()
},
#

something about o

sonic badger
#

I got things functional again, everything is written asynchronously now at least

crisp jungle
#

i reversed engineered the webpack chunk thing and that works

crisp jungle
#

I tried using pako from the GitHub it no works

hybrid tiger
#

Hihi, how do I send a message with a plugin?

My command should return a message.

austere gulch
#

from the user? or from clyde (ephemeral)?

hybrid tiger
#

From the user

#

/command

returns: ...

austere gulch
#

take a look at line 108 in the spotifyShareCommands plugin

eternal lion
austere gulch
#

it has examples of sending user and bot msg

eternal lion
#

Like what plugin r u making

hybrid tiger
austere gulch
#

np

hybrid tiger
eternal lion
#

I actually don't

austere gulch
#

same

eternal lion
#

Idk if more meme plugins will even be accepted

austere gulch
#

they wont

hybrid tiger
#

I just want to make a /women command that returns ☕☕☕. I just want to learn ts with some random stuff, so I wanted to start simple.

eternal lion
#

Will it won't be accepted

hybrid tiger
eternal lion
#

Ah ok

hybrid tiger
#

(I have nothing against women, I just like the meme, don't judge pls) x-x

#

How do I debug or even try my plugin? I tried pnpm build but I have no idea what to do now x.x

hybrid tiger
hybrid tiger
austere gulch
#

did you refresh discord

hybrid tiger
#

CTRL + R, yep.

austere gulch
#

then your plugin isnt set up properly

#

compare it to the examples and figure out what's wrong

hybrid tiger
#

Is it still the userplugins folder? Mine is greyed out for some reason

austere gulch
#

its greyed out because git ignores it

hybrid tiger
#

Nvm xD

#

Well. No idea. Got no errors and my definePlugin seems fine aswell.

viral roost
#

did you enable it in settings

hybrid tiger
#

The thing is that it doesn't even show up in there

viral roost
#

did you rebuild

hybrid tiger
#

Yep

viral roost
#

and reinject?

hybrid tiger
#

Inject?

viral roost
#

pnpm inject

hybrid tiger
#

Well, didn't even do that once

viral roost
#

do that then restart discord from tray

hybrid tiger
#

☕☕☕

#

/women

#

Ayo it works

#

But it sends the command aswell.

hybrid tiger
#

@viral roost Any idea why the command is sent aswell?

viral roost
#

nope

dull magnet
#

youre using the wrong type

hybrid tiger
#

Type?

dull magnet
#

inputType on ur command

#

BUILT_IN_TEXT = respond with content

#

BUILT_IN = no response

hybrid tiger
#

Ohhh

inputType: ApplicationCommandInputType.BUILT_IN,

dull magnet
#

ye

hybrid tiger
#

Makes sense. Thank you c:

#

Is the pnpm inject thing written somewhere? Could not find it in the 2 plugin files for contribution. And it was not obvious to someone like me >.<

austere gulch
#

it's the manual install guide