#🧩-plugin-development

1 messages · Page 8 of 1

cedar olive
#

then why did you ask?

#

oh I see

#

someone told you later

#

sorry about that

opal fern
#

yeah no worries m8

visual berry
visual berry
#

hmmm

#

wait no

#

it would only work for web discord

trail ginkgo
visual berry
#

It would

trail ginkgo
#

it seems like a fix for all chromium

visual berry
#

i just realized how though

#

because desktop uses mediaengine

#

while the web discord uses the chrome api

#

so what if we just trick desktop that its browser

#

aka the BetterDiscord emulator plugin, but for just screensharing

trail ginkgo
#

i mean if u use armcord

visual berry
#

I dont want a different client to screenshare

trail ginkgo
#

real

visual berry
#

That already exist

#

with vencord able to be installed

#

because its just a qt app with web discord and patches applied

trail ginkgo
#

i guess u could just delete MediaEngine

#

and it will prob fall back to chromium api

visual berry
#

I dont think you can

trail ginkgo
#

as in delete mediaengine

#

sure u can just find where its export is defined and patch it

visual berry
#

yah thats what im trying to do

#

but iim too stupid to figure it out since the new discord repack shit

trail ginkgo
#

i can try

visual berry
#

please do

trail ginkgo
#

yeye

visual berry
#

This would actually be based

#

I will legit pay for this to be done

trail ginkgo
#

me when i scroll for 5 years just to find a single letter with a = n(219i320194) next to it

visual berry
#

seems about right

trail ginkgo
#

looks like its module 149556

#

that does the determining of if mediaengine should be Native or not

#

very easy patch

{
  find: '.AS.WEBRTC].find',
  replacement: {
    match: /\[(\w+)\.\AS\.NATIVE,\1\.AS\.WEBRTC\]/,
    replace: '[$1.AS.WEBRTC]',
  },
}```
#

@visual berry lmk if that works

visual berry
#

Ok well i need someone to help me test

visual berry
#

We need to grant discord the input device permission

#

lmao

trail ginkgo
#

death

trail ginkgo
visual berry
#

Linux

trail ginkgo
#

lit

#

yea u will probably need to modify the desktop client for this

#

at which point u might as well use an already made one

#

hm

visual berry
#

This is just electron looking for the chrome permission to use the mic

#

@trail ginkgo we technically have control over the entire electron app and how its started via the patcher

#

Ima try and grant the permissions there and see what happens

trail ginkgo
#

?

#

what patcher

visual berry
#

Vencord

trail ginkgo
#

vencord patcher only patches webpack modules

#

which is browser code

visual berry
#

Hmmm

#

it throws unknown getUserMedia error: NotSupportedError

visual berry
#

Its weird because this error doesnt happen with the betterdiscord emulator plugin

grand vessel
#

hi, react devtools shows "Locaing React Element tree........."

#

ive been waiting for like half an hour

dull magnet
#

restart or smth

#

rdt are really unstable for some reason

austere gulch
#

yop

grand vessel
#

already did

#

tried standalone rdt, added the script tag, rdt did not show a connection

austere gulch
#

close ur devtools when u reload discord

wait for discord to fully load

then open devtools and go to react components tab

if that doesn't work then no clue yop

dull magnet
#

you could also just use discord Web

#

for better integration

grand vessel
#

hmm, i'll try

#

hmmmmm

#

still same

dull magnet
#

can't fix then

#

open issue in their repo

grand vessel
#

'kay

visual berry
#

Does vencord not work with electron > 13?

dull magnet
#

it does

#

there's a button in the installer for broken canary/ptb, use it dogsmirkreverse

visual berry
dull magnet
#

install with installer, symlink your dist folder to the config folder

#

or install with installer then go to your discord folder and edit app.asar/index.js to require the correct file

green vessel
#

?? wha

visual berry
#

@trail ginkgo now i know why its not working

#

you are patching the wrong thing

#

you are patching the supported check and not actually making it use webrtc

dull magnet
#

Błąd

visual berry
#

So its trying to use native but since its patched out it claims it to not be supported

#

Thats why the error is being thrown

dull magnet
#

wha

visual berry
#

Trying to get desktop discord to use webrtc instead of native mediaengine

#

Because if we can do that then we can make it so linux can have screenshare audio

#

The patch given changes this:

#

and removes the NATIVE part

#

aka NATIVE is now not supported

#

lmao

dull magnet
#

can discord web share with audio

visual berry
#

Yes

dull magnet
#

🤔

#

are u sure

visual berry
#

Yes

austere gulch
#

on chrome it uses the chrome screenshare thing which supports audio

#

idk about Firefox

visual berry
#

Basically the issue for desktop is this:

#

However we can force desktop to think its web

#

and then use the normal webrtc

visual berry
#

which then allows us to use a device called "virtmic" which gets passed into the screenshare audio and not the mic audio

tall kiln
#

no

visual berry
#

damn

tall kiln
#

discord block getUserMedia in their fork, and getDisplayMedia doesn't exist in Electron

visual berry
#

in their electron fork?

#

Simple, just dont use their electron

tall kiln
#

"simple"

visual berry
#

pretty simple

tall kiln
#

no

#
  1. it is not that simple
  2. there are tradeoffs
  3. pretty sure that's impossible via just a vencord plugin, would need extra shit
  4. what is the point of desktop at that point
visual berry
tall kiln
tall kiln
visual berry
#

electron 20

dull magnet
#

just says disabled

#

I'm asking why did they disable it

tall kiln
#

it does tho

#

We don't use it and without proper user interaction / consent enforcement it is nothing but a liability.

tall kiln
visual berry
#

I dont care if it doesnt work with discord electron

tall kiln
#

i looked into this like over a year ago lmao

visual berry
#

i just want it to work

tall kiln
#

what navigator func do you need tho

visual berry
#

getUserMedia

tall kiln
#

cool

#

so you have it planned out?

visual berry
#

im working on it for the most part

tall kiln
#

just confused what you need help with lol

visual berry
#

I dont really understand vencord patching

#

nor knowing how to find and replace exactly what i need

tall kiln
#

i thought you found what to find and replace

tall kiln
visual berry
#

Thats the wrong thing

tall kiln
#

oh lol

visual berry
#

and that was found by @trail ginkgo

tall kiln
#

i tried patching it like a year ago and gave up soo

visual berry
#

Basically that just makes it so it breaks audio and video on discord because it makes NATIVE unsupported

tall kiln
#

glhf

green vessel
dull magnet
green vessel
#

guh why is violentmonkey stupit

opal fern
#

Does anyone know how I can potentially stop getting assfucked by this? ik it has something to do with the server itself

austere gulch
#

Access-Control-Allow-Origin: * if you want to allow all domains

#

or like Access-Control-Allow-Origin: https://discord.com

opal fern
austere gulch
#

oh

#

proxy it with a cloudflare worker or something trolley

#

smth like this ig

opal fern
#

Went with what megu said, and made a cloudflare worker

potent fox
#

WHAT DOES IT PREVENT ANYWAY

austere gulch
#

illegal

#

do not disable the cors

visual berry
#

I disabled cors

potent fox
potent fox
#

if I wanted to make something malicious

#

couldnt I just add

#

CORS HEADERS

#

IN WHICH CASE

#

it is useful

dull magnet
#

it's the other way round stupid

#

it's to protect other sites

#

and then maybe somehow abuse that

potent fox
dull magnet
#

it could do everything to other sites

dull magnet
#

that's what cors are for

austere gulch
#

browsers respect CORS for a reason :>

potent fox
#

I don really understand

#

I mean how does it protect

dull magnet
#

okay so

potent fox
#

also in app like discord

#

it gets all data from discord servers

#

there are no ads or something

#

and even if there is since in all browser cors is a thing

austere gulch
potent fox
#

there shouldnt be a ad that is malicious

dull magnet
#

cors prevents random sites to make requests to other sites

austere gulch
#

if the CORS header does allow example.com, the browser will then send the actual request

green vessel
#

although tbh i dont see how any malicous plugin could be added to vencord so it wont be an issue ever

austere gulch
#

one day we will make it easier to add custom plugins

#

and then it'll be a problem

wraith carbon
#

User plugins

potent fox
#

but since we are using discord I think we can safely disable that

austere gulch
#

nop

trail ginkgo
stray imp
#

meow

green vessel
#

nyan

cedar olive
#

here is a semi working version of a character counter plugin if anyone wants to finish it

the current issue is the counter appears on top of the emoji button if the text box only has a single line (like when empty)

/*
 * 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 { Devs } from "@utils/constants";
import definePlugin from "@utils/types";

export default definePlugin({
    name: "CharacterCounter",
    description: "Makes Discord character counter always enabled.",
    authors: [Devs.Nuckyz],
    patches: [
        {
            find: ".Messages.CHARACTER_COUNT_OVER_LIMIT",
            replacement: {
                match: /\.AnalyticsLocationProvider;return.+?\?(.+?).\?null:/,
                replace: (_, restOfFunction) => ""
                    + `.AnalyticsLocationProvider;return true?${restOfFunction}false?null:`
            }
        }
    ],
});
near aurora
#

custom banner plugin that

  1. fetches from USRBG
  2. allows easy(-er) uploading to USRBG
#

make it indistinguishable from nitro plugin, maybe only swap the small hover badge from nitro to some other icon

pulsar zodiac
#

aliucord badge exists, knowing the community a vencord badge is probably happening

near aurora
#

no USRBG originated from powercord iirc

#

like tropical made it

pulsar zodiac
#

yeah just meant the badge

wraith carbon
trail ginkgo
#

(talking about newpluginsError)

wraith carbon
#

oh

trail ginkgo
wraith carbon
#

fixed, ty

wraith carbon
#

What's the best way of creating a PR that uses a component added in another, still unmerged, PR? To just use the second PR's branch as a base and create the PR with all commits?

slow charm
#

yes

wraith carbon
#

Alright, I'll do that then

trail ginkgo
#

and wait til their pr is merged, rebase, open yours

wraith carbon
#

It has 23 commits but 22/23 are of the other PR

#

lol

trail ginkgo
#

oh u did it already

wraith carbon
#

yeah

trail ginkgo
#

lol manual co-author

wraith carbon
granite wharf
#

once their pr is merged you can merge master into your branch

#

and their commits will disappear

grim hare
#

why would you make a merge commit from master into your branch when you could just rebase omegajerry

austere gulch
#

i merge

#

clear git history

wraith carbon
#

i shall do that

#

when it's merged

grim hare
#

don't clear git history when you're updating your branch from main though ;w;

granite wharf
#

you can undo a merge commit with git reset --hard HEAD^

#

no?

grim hare
#

that's correct

#

but if you have an active main branch you'll have a ton of merge commits into your branch, which makes git history a mess

granite wharf
#

its better than a destructive operation

cinder wigeon
slow charm
#

real

#

i love git push -f

cinder wigeon
#

You love git reset --hard HEAD^1000 && git push -f

stone moon
#

Rebase is quite powerful even if not a best practice to use in 99.9% cases

#

Like you can use rebase to unsquash a commit (altho doing it manually and with no trace to commits before the squash, still you get to break up a commit into smaller ones)

#

(You can use git reset to state before squashing if it happened just now, rebase if happened long ago)

dull magnet
granite wharf
#

hoiw

dull magnet
#

git reflog

granite wharf
#

oh

stone moon
#

(as i just said on top xP)

#

but reflog doesnt go that far

granite wharf
#

so trolley

heavy garden
#

lets see what chatgpt can suggest

blissful trellis
#

is there a way to get the file extension on attachment?

#

like example.js i just want to get the js part

normal forge
#
split(".")
trail ginkgo
#

or in some other environment

blissful trellis
#

discord

#

anyway i found it

#

using MIME type

trail ginkgo
#

oh that is probably a better idea

hollow knot
opal fern
#

vendy do you mind pinning this

dull magnet
#

no cause its outdated

opal fern
#

fr??

dull magnet
#

lazyWebpack is kill

opal fern
#

Which is better?
Implementation that requires the message obj itself

export function dismissBotMessage(message: Message): boolean {
    MessageSender.dismissAutomatedMessage(message);

    return true;
}

Implementation that requires the channelId and messageId

export function dismissBotMessageViaId(channelId: string, messageId: string): boolean {
    MessageSender.deleteMessage(channelId, messageId, !0);

    return true;
}
#

@dull magnet

dull magnet
#

idk

#

are u sure dismiss automated message doesn't just need channel id and message id

opal fern
#

its really weird

#

ehh ill just use second implementation

dull magnet
#

but it literally just calls deleteMessage lmao

opal fern
#

Yeah

#

Ill use second implementation to cut middle man

#

idk what to make it return

#

ill just make it return nothin

cursive plank
#

@dull magnet am i doing smth wrong?

tired terrace
#

Uncle

cursive plank
#

doesn't findByCode find by code?

#

im confused

#

yeah, i get it now

#

findByCode doesnt find modules as a whole but their exports (?)

wraith carbon
wraith carbon
#

tytyty

potent fox
#

@dull magnet

dull magnet
#

hi

potent fox
#

I am gonna become grandpa

#

and you still

#

HAVENT MERGED MY PR

dull magnet
potent fox
#

MERGEE

cursive plank
#

@dull magnet dunno if you knew this or not
but you dont need a ref to get the value from a TextArea in the themes tab

you can attach an onInput event listener, and just do event.nativeEvent.target.value

eg

<TextArea
    onInput={ event => doSmth(event.nativeEvent.target.value); }
/>

(I'm saying this cause using refs is discouraged by react and you don't use it for anything else other than to get the value on the onBlur event)

dull magnet
#

ya, the only reason I used it was cause discord did as well

#

when I looked at their use of that component

cursive plank
#

what is the onBlur event btw?

dull magnet
#

when the element is blurred aka loses focus

cursive plank
#

naruhodo

#

saves the effort of debouncing it ig

dull magnet
#

idk why they call it blur

#

html spec is funny

cursive plank
#

progress so far:

#

nothing hardcoded

dull magnet
#

cool

#

maybe a way to remove an entry?

#

❌ button

cursive plank
#

when you save, if the link is empty it will be removed

#

but yeah i can add a button

wraith carbon
#

Would you merge a “Raw Copy” Button or should I make a user plugin for it

#

@ ven

dull magnet
#

View raw?

#

already a thing

wraith carbon
#

someone asked me for it

cursive plank
#

wow, both functionality in one button

#

nice

wraith carbon
#

I shall tell them ty

cursive plank
dull magnet
#

Uh

#

I think they do

cursive plank
#

hmm, their design system doesnt seem to need one

#

oh

dull magnet
#

actually no I think they just use a fat button with text

#

they do have a svg for it on mobile

dull magnet
#

idk if they have on desktop

potent fox
#

my reviewdb plugin steals svg from mobile

cursive plank
#

oh yeah

potent fox
#

actually I think there was on pc too

#

yeah

#

that

dull magnet
#

it's likely easier to just copy paste the svg than find it from webpack

cursive plank
#

PS react dev tools no workie for me

dull magnet
#

or use Google material icon

cursive plank
dull magnet
#

react devtools are a bitch

#

just restart devtools until it works

potent fox
#

I usually restart discord

#

and it works

cursive plank
#

I have done it more than 20 times, got tired of it

dull magnet
#

try using browser

#

maybe it works better there

potent fox
#

From my testing

#

I think it usually gets broken if you press F5 on dev tools

#

To refresh client I mean

cursive plank
#

Vencord.Webpack.wreq(Vencord.Webpack.findModuleId("M15 3.999V2H9V3.999H3V5.999H21V3.999H15Z")).Z
the delete icon!

#

now the question is, will the export named Z change or not?

#

it has been named that way for months now

#

hmm, i think i remember reading that Z is the default export?

#

ven hardcodes it

#

so ig it really is the default export

dull magnet
#

it is

#

Z = default
ZP = default + named export

cursive plank
#

for anyone that might want the icon:

const DeleteIcon = makeLazy(() => wreq(findModuleId("M15 3.999V2H9V3.999H3V5.999H21V3.999H15Z")!!).Z({ width: 24, height: 24, color: "red", foreground: "red" }));
#

I wish makeLazy allowed to pass arguments

#

but oh well

dull magnet
#
const DeleteIcon = LazyComponent(() => wreq(findModuleId(...));

<DeleteIcon width="24" height="24" color="red" foreground="red" />
#

there u go

cursive plank
#

oh yeah

#

lazyComponent

dull magnet
#

feel free to add arguments to makeLazy if u need it

cursive plank
#

forgot about it

dull magnet
#

also should use discords red instead of html red

#

--color-danger or smth like that

#

nop

cursive plank
#

dunno if that works

#

its a component

dull magnet
#

foreground="var(--blah)"

#

will work

cursive plank
#

I'll continue this tomorrow, gotta sleep

dull magnet
#
var vars = Array.from(document.styleSheets)
    .flatMap(styleSheet => Array.from(styleSheet.cssRules))
    .filter(cssRule => cssRule.selectorText === '.theme-dark' || cssRule.selectorText === ":root")
    .flatMap(cssRule => cssRule.cssText.split('{')[1].split('}')[0].trim().split(';'))
    .filter(Boolean)
    .map(text => text.split(':'))
    .map(parts => ({ key: parts[0].trim(), value: parts[1].trim() }))

console.log(vars)
#

prints most if not all css variables

#

or including every single colour

var vars = Array.from(document.styleSheets)
    .flatMap(styleSheet => Array.from(styleSheet.cssRules))
    .filter(cssRule => cssRule.selectorText === '.theme-dark' || cssRule.selectorText === ".theme-custom" || cssRule.selectorText === ":root")
    .flatMap(cssRule => cssRule.cssText.split('{')[1].split('}')[0].trim().split(';'))
    .filter(Boolean)
    .map(text => text.split(':'))
    .map(parts => ({ key: parts[0].trim(), value: parts[1].trim() }))
    .filter((p, i, arr) => arr.findIndex(x => x.key === p.key) === i)

console.log(vars)
chrome folio
# cursive plank

just as feedback:

  • centering the file names doesn't look all too good;
  • don't center the titles as well and add more margin bottom
  • add those thin dark grey lines between each sound yk
  • the trashcan maybe white, smaller and only visible if you hover over the sound
cursive plank
#

my css skills suck
so this may take a lot of refinement to look good

chrome folio
#

learning makes you a pro

cursive plank
#

funnily enough, I did not center the titles (if you mean the table headers)

chrome folio
#

I sucked 1.5 years ago as well, and even more suck now

cursive plank
#

I already know a lot of about css

#

A LOT

chrome folio
#

well yeah

cursive plank
#

i just suck at using it

#

I can make good UI, it just takes a huge amount of hours for the small stuff

chrome folio
#

welp same

#

I mean I am a web dev and I redesigned the whole site of my bot like 3 times in a month

cursive plank
#

anyways, gnight

chrome folio
#

gn

trail ginkgo
#

do spotify embeds come from backend???

dull magnet
#

yes

trail ginkgo
#

i hate

dull magnet
#

it's Spotify / Discord issue

#

well

#

it's just an embed

trail ginkgo
#

i get it because the cache image

dull magnet
#

iframe

trail ginkgo
#

yea i know

#

its probably discord issue

dull magnet
#

Spotify I'd say

#

Spotify is so unstable

#

the api randomly gives u 500s

trail ginkgo
#

no i mean spotify embeds seem to come from discord backend

dull magnet
trail ginkgo
#

is that rn

dull magnet
#

desktop

trail ginkgo
#

wtf

dull magnet
#

mobile has less powerful embeds

#

desktop just uses iframes

trail ginkgo
#

on desktop for me there is nothing

#

messages have an embed array

dull magnet
#

that's an old screenshot

trail ginkgo
#

that array is empty

trail ginkgo
dull magnet
#

it's not an embed

#

it's an iframe like I said

trail ginkgo
#

it is

dull magnet
#

discord silly

trail ginkgo
#

in frontend

#

it is part of the embeds array

#

with embed.provider as "Spotify"

dull magnet
#

Well it's both

#

but they don't embed it as embed

trail ginkgo
#

yea ik ikikikikesik

#

oookikiikkikiik

#

ikikkiki

dull magnet
#

sorry

trail ginkgo
#

i am porting my better spotify embed

#

plguin

dull magnet
#

oh

trail ginkgo
#

it is ok <3

dull magnet
#

why are embeds just dead rn

trail ginkgo
#

i know i HATE

#

i was gonna be like "oh lets just not rely on discord"

#

but IT IS BACKEND ?!?!?!?@3TRY

#

SPOTIFY EMBEDS GET SENT OVER GATEWAY/?!@#54

#

i will combust

dull magnet
#

wait r u saying discord doesn't send the embeds

#

lmao

trail ginkgo
#

yea

dull magnet
#

inb4 discord got api banned or smth

#

because we're abusing their tokens against Spotifys terms

trail ginkgo
#

death

#

if this isnt fixed tomorrow i will do my own embed detection and ignore the discord sent ones

dull magnet
#

shouldn't be too hard

trail ginkgo
#

the best part of discords though

dull magnet
#

but using discords would be smoother

#

cause you could just patch their Spotify embeds for 0 overhead

trail ginkgo
#

is they provided an image url

#

i didnt have to do an api request for it

#

so embeds were themed at render time

#

maybe not render time but a lot quicker than an api request

trail ginkgo
#

what the FUCK

trail ginkgo
#

also @dull magnet

#

i actually need the discord images

#

because it will cry about tainted canvas

dull magnet
#

huh

#

it shouldn't

#

you just need to set thingie to anonymous

trail ginkgo
#

i dont wanna rely on csp

dull magnet
proud parrotBOT
trail ginkgo
#

does that work on user script

dull magnet
#

idk

#

why

trail ginkgo
#

erg

dull magnet
#

you can use fetch if you really want to to bypass csp

#

but no need to bother imo

trail ginkgo
#

oh thats true

dull magnet
#

why doesn't the Firefox csp bypass work though

trail ginkgo
#

firefox hates you

dull magnet
#

that's really painful cause Firefox bans csp bypass so I'm not sure they will approve the update

#

I'm surprised they even approved v1.0 that has csp bypass

#

thankfully I haven't updated Firefox in a while

#

maybe if I push update that fix csp with big changes to other files they won't notice again

trail ginkgo
#

ok now to find where embed gate events come from

#

probably message updates

dull magnet
#

yes

#

that's how embeds work

#

First it dispatches message with no embeds

#

then it dispatches message update with the embeds once it finished building then

trail ginkgo
#

real

dull magnet
#

I think they describe it in the docs somewhere

trail ginkgo
#

ok then time to find what part of the logic handles the embed part

#

cus i dont wanna fire a whole message update

dull magnet
#

u can just fire a message update

#

I do that in hide attachments

#

Well for some reason it broke

#

it doesn't solve its intended purpose lol so it has no effect

granite wharf
trail ginkgo
#

the problem is u need to change the csp to access github pages

opal fern
#

Yes

#

But make the text boxes a little more obvious

chrome folio
#

well it’s better

cursive plank
#

this is not the final design, and you arent being helpful

chrome folio
# cursive plank

also maybe make the Link an mp3 blue like links, may look better(?)

cursive plank
#

rn im trying to fix a bug

#

@dull magnet uhh
what if I want to set the value of a TextArea
but I don't want to use a state

#

setting the value property makes it not accept any input

#

what im doing rn

#

(why am I making a copy? cause I got paranoid)

#

basically the text is saved properly

#

but since I dont set the value property, re-opening the settings means that if you click on the text area it will delete the existing (invisible) value

#

fixed

cursive plank
#

oh yeah, can't read settings when patching

#

F

#

now this is an issue

#

how great would it be if this just worked

#

alas

wraith carbon
#

nt

dull magnet
#

don't do like that

#

patch the function that gets the sounds

#

and return custom sound

trail ginkgo
#

literally HOW

dull magnet
#

findByCode finds a function by code

#

you want findModuleId

#

but also this should be find(m => m.prototype?.renderAudioMetadata)

trail ginkgo
#

oh right

#

grr

#

discord does not expose audiocontrols

dull magnet
#

you will export owo

#

patch

trail ginkgo
#

NOOO

#

DISCORD MOVED ALL THE AUDIO HANDLING OUTSIDE OF AUDIO CONTROLS

#

AND INTO THE FILE COMPONENT

#

i will use the file component and hide everything but the controls

austere gulch
#

trol

trail ginkgo
#

lovely class component

trail ginkgo
#

@dull magnet

#

idea

austere gulch
#

intellij

trail ginkgo
#

replace \v with [a-zA-Z$_] in patch replacements

austere gulch
#

\v

trail ginkgo
#

var

dull magnet
#

wha

#

oh

trail ginkgo
#

is for future proofing

dull magnet
#

just use \w

#

or .

trail ginkgo
#

\w doesnt contain $

#

. is 1

#

not a huge deal but it would include all possibilities

dull magnet
#

then u have to stringify regex, replace and recompile

#

and ide will hate

trail ginkgo
#

🤨

#

ide will not hate

#

is valid

#

nvm no-useless-escape

#

L

viral roost
#

the fuck is an ANNOUNCEMENT_THREAD

trail ginkgo
#

omg noo

#

they moved the color sampling to the backend

#

gonna cry

trail ginkgo
#

gonna steal the code from an old build

wraith carbon
proud cargo
cinder wigeon
#

@dull magnet what would the best way to store custom pronouns in

#

there isn't an appropriate OptionType, so should I just directly use localstorage/indexeddb or whatever?

dull magnet
#

uh

#

depends

#

either just do MySettings[id] = "balls"

#

or use DataStore

cinder wigeon
trail ginkgo
#

wow using gifenc was such a good idea

#

it really gets the most important colors

#

i just need to prioritize the colors based off something

trail ginkgo
#

its only enforced if u never edit the variable

cedar marsh
#

wrap it in a <textarea>, those parse newlines into actual new lines
or make a custom react component that splits a string on \n and then wraps each one of those with a <span>

#
export function TextRenderer({string}) {
  return <div>
    {string.split("\n").map((line,i)=>
      <><span key={i}>{line}</span><br/></>
    )}
  </div>
}

@green vessel

dull magnet
trail ginkgo
#

yupp

dull magnet
#

that library is really awesome

#

all the other gif encoder libraries I tried were all terrible shitcode

trail ginkgo
#

im converting the rgb to hsv

#

for color sorting

dull magnet
#

for example some of them forgot to declare some variables so it just makes globals

trail ginkgo
#

do u know anything i could use to replace that

dull magnet
#

others gave u the bytes as a string

#

instead of typedarray

trail ginkgo
dull magnet
#

meanwhile that library fast efficient and small

trail ginkgo
dull magnet
trail ginkgo
#

utils/colors.ts

dull magnet
trail ginkgo
#

yea makes senes

#

i love finding modern libraries

#

mm

trail ginkgo
regal rune
forest salmon
#

is the "find" field in the patches thing only used for finding the right webpack bundle by using its value

trail ginkgo
#

its for finding the right module

#

it basically looks for module.toString().includes(find)

forest salmon
#

mmmm i see

#

thought it was used for something more than that

thorny vector
cursive plank
#

not on my watch!

git push --force
heavy garden
#

if you don't wanna put your opinions above everyone else, do a --force-with-lease

simple folio
#

but my opinions are above everyone elses

visual berry
#

Wait so if you install vencord via a local git clone of it, when you update it inside the client, it updates that local clone of the repo right?

dull magnet
#

yes

visual berry
#

Now hear out my stupid idea

#

give me a second

#

the userplugins folder exist right

dull magnet
#

yes

visual berry
#

So why not make it so installing vencord with any method just clones the repo and builds it locally

#

and then if someone wants to add a plugin, they just put the plugin in the userplugins folder

#

prob the most stupidest yet hackiest idea ever

austere gulch
#

uh basically

#

most non-devs don't want to install node, git etc

#

we do plan on adding userplugin support for basic install one day

visual berry
#

ship it with the installer

austere gulch
#

the idea was that the installer & vencord would be as small as possible

#

bundling git and node is not very small

visual berry
#

You could also just make it a requirement

dull magnet
#

no

visual berry
#

¯_(ツ)_/¯

dull magnet
#

not everyone wants to have 1gb of junk on their pc

visual berry
#

installs electron application Yes nobody does

dull magnet
#

electron is like 200mb

visual berry
#

wait

#

pnpm can be installed standalone

#

and node is 80mb

dull magnet
#

git is probably pretty large cause it ships git bash as well

#

vencord has like ~150mb of dependencies

austere gulch
#

for windows you can use MinGit

#

but yeah dev deps are pretty chunky in vencord

dull magnet
#

in any case the idea is bad because many things can and will go wrong

#

git conflicts, build failing for some reason, unexpected behaviour on specific platform, etc

#

people complaining its taking too long

austere gulch
#

implementing user plugins shouldn't be terrible

dull magnet
#

people who have npm blocked for some reason

austere gulch
#

Vencord namespace is already global so

dull magnet
#

so many factors

visual berry
#

just remake vencord as a rust program that live patches the discord runtime

#

ez

austere gulch
#

blazing fast

forest salmon
#

wtf 🚀 🚀 🚀 🚀

nocturne dragon
#

for node, well, explode

austere gulch
nocturne dragon
#

I use libgit2 in vencorded

dull magnet
#

btw pro tip, chrome devtools has a function that finds instances of classes

#
queryObjects( find(m => m.prototype?.getTopEmojiWithoutFetchingLatest) )
#

gives you all instances of the EmojiStore for example

#

(dont run on very generic classes that will have thousands of instances unless u wanna die)

dusty spire
#

time to run on very generic classes that will have thousands of instances

dull magnet
#

its actually not too bad

#

but i think if i dare expand the array i will explode

#

ah no its not too bad cause it partitions arrays

simple folio
#

chrome team so smart

granite wharf
#

it would be funny to write a client mod with it

trail ginkgo
#

i dont think u can access those outside of the devtools vm

jagged dune
#

noooooo

dull magnet
#

ancient

trail ginkgo
#

i used to do entire HEAP SNAPSHOTS

#

for this exact purpose

dull magnet
#

theres way more utilities

#

another cool one is getEventListeners(htmlElement)

#

and monitor(function)

#

which logs calls and arguments

jagged dune
#

when nodejs implemntation

#

i will literally monitor(*) 🫄

trail ginkgo
#

the amount of times i have done all of these manually

cinder wigeon
trail ginkgo
cinder wigeon
#

even better

wraith carbon
astral nimbus
#

could anyone help me figure out what i'm doing wrong here. My find is unique and my regex works on the minified js but my run function never gets called. There are no errors in the console and my plugin appears to load successfully

export default definePlugin({
    name: "TypingAvatars",
    description: "Shows the avatars of typing users",
    authors: [
        {
            id: 398887208947286017n,
            name: "Pseudorizer",
        },
    ],
    patches: [{
        find: "Reactor: currentUser cannot be undefined",
        replacement: {
            match: /(\w+)=0===(\w+)\.length\?.+?;/gmi,
            replace: "$1=Vencord.Plugins.plugins.TypingAvatars.run($2);",
        },
    }],
    // Delete these two below if you are only using code patches
    start() {},
    stop() {},
    run(v: any) {
        console.log("TEST1234");
        console.debug(v);
        return "lol";
    },
});
granite vault
#

doesn't seem like the regex is working

astral nimbus
#

hmmmm okay, any ideas as to why it works in chrome but not in the patch?

granite vault
#

are you on canary or smth lol

astral nimbus
#

idk i just logged into discord web for the first time

#

so probs not?

granite vault
#

I can't match that regex lol

#

nvm i forgot to enable regex matching

astral nimbus
granite vault
#

Reactor: currentUser cannot be undefined

#

insane

#

what are you trying to replace @astral nimbus

astral nimbus
#

so the regex targets this ternary operator that decides what string to show for the typing indicators

#

that string then gets put into a span

granite vault
astral nimbus
#

bruh

granite vault
#

is that what u want

astral nimbus
#

uh

granite vault
#

if so then

{
    find: "Messages.SEVERAL_USERS_TYPING",
    replacement: {
        match: /(\w+)=0===(\w+)\.length\?.+?;/,
        replace: "$&Vencord.Plugins.plugins.TypingAvatars.run($1);"
    }
}
astral nimbus
#

that's not quite what i want no, i want to replace that whole ternary operator, not add a line after it

#

but let me see if that new find works

granite vault
#

remove the $& and you'll be replacing that entire line

astral nimbus
#

ahhh it was my find

#

now it works ty

granite vault
#

yes

#

idk where tf u got that find from

astral nimbus
#

ye ik i was showing it worked with the minified code

trail ginkgo
#

@astral nimbus btw $& puts the original match inside ur replacement

astral nimbus
#

mhm, switched to a better solution now anyhow, just re-assign instead of replacing

match: /(\w+)=\w\.typingUsers.+(\w+)=\w+\.channel.+(\w+)=\w+\.\w+\.getGuild\(\w+\).+(\w+)=0===(\w+)\.length\?.+?;/gmi,
replace: "$&$4=Vencord.Plugins.plugins.TypingAvatars.run($5,$3,$1,$2);",
dull magnet
#

is there not a better way to do this?

astral nimbus
#

¯_(ツ)_/¯

#

i just started doing this an hour ago

dull magnet
#

show what the function looks like?

astral nimbus
#

alright

trail ginkgo
#

venn i really want a custom escapee for clean identifier matchinggg

#

also what if $# => `Vencord.Plugins.plugins.${plugin.name}`

dull magnet
#

yop

#

make

#

pr

#

we could also also like $self

trail ginkgo
#

will u accept custom eslint regex rule for top thing

dull magnet
#

$self.balls

#

uh yea

trail ginkgo
#

what if $@

dull magnet
#

but make it so the ide doesnt cope about unnecessary escape or similar

trail ginkgo
#

coffeescript reference

dull magnet
#

nono $self best

#

coffeescript is bad

#

i prefer teascript

trail ginkgo
#

is $$ escape build into replace

#

it definitely is right

dull magnet
#

ye

trail ginkgo
#

ok easy

trail ginkgo
#

if im doing another package change i will make the @taips packages

dull magnet
astral nimbus
#

ye i was gonna change them out for named

dull magnet
#
replace: (fullMatch, group1, group2, group3) => `${group3}`
astral nimbus
#

regardless, that's enough late night random fixation

granite vault
trail ginkgo
#

stash push WHAT

jagged dune
trail ginkgo
eternal lion
#

If I made a PR that fixes the flashbang on load this weekend, would that be accepted?

#

I could just show a dark background.

#

Maybe with a logo if vencord gets a good one

eternal lion
#

I don't want to east my time if it will be denied

dull magnet
#

yeah sure

eternal lion
#

Yeah

#

Thx :)

dull magnet
#

I mean i personally don't have the flashbang lol

eternal lion
#

I can probs just but a BG on the webview or smth right?

eternal lion
dull magnet
#

nvm I have it lol

granite vault
dull magnet
#

it's already in a linearlayout

granite vault
#

Don't display webview till page is loaded ig

dull magnet
#

just need to give that layout a background colour

eternal lion
eternal lion
#

If I do it it will be my first PR ever :p

#

I always want to PR smth to a project but the codebase is too complicated so I can't figure it out

#

But vencord mobile codebase is pretty simple I think

#

So should be good :)

dull magnet
#

the codebase is not too big if you know what you wanna do and focus on that small part of the code

#

it's very overwhelming I agree

#

but if u focus on the small part u need to edit its oki

#

you don't need to understand the entire codebase to do changes to a part of them

#

honestly I don't think anyone knows the entire codebase in big projects like Linux or chromium

eternal lion
#

its projects like heroic that I am talking about

#

I wanted to port it to solidjs

#

But they have so many react-only deps lol

dull magnet
#

gotta rewrite a shit ton of stuff for that

eternal lion
#

I could have done it maybe

#

But there were so many dependencies that had no solidjs equivalent :(

#

Would have probs been easier to rewrite the whole thing lol

dull magnet
#

why did u even wanna do that

#

what's the gain

eternal lion
#

Performance

#

Also solid looks nicer

#

The syntax is better imo

dull magnet
#

why do you care about performance of a client you'll maybe use 2 minutes a day

eternal lion
#

I use it super often

#

Oh if I just launch a game tho

#

Yeah idk why I wanted to do that lol

#

Just felt like it

astral nimbus
#

any good docs for the unofficial discord api?

jagged dune
#

tf is a unofficial discord api

astral nimbus
#

isn't that what you call it?

jagged dune
#

oh you mea

astral nimbus
#

doesn't the client use api routes and such that say a bot wouldn't?

#

found some things on it, but they're all kinda meh

dull magnet
#

there's no reason to use api manually

#

discord has functions for everything

astral nimbus
#

hmm, ig so, global searching for function names the best option to find them?

slow charm
#

yea and putting breakpoints to find something relevant

#

it's pretty painful when you barely know what you are looking for

astral nimbus
#

haha yah it defo is

#

can i use these findBy utility functions to find a function by its name?

#

hmmm, so i have the module id that a function i want is coming from

#

so ig i could then find that module, find some code in it and then use findByCode?

astral nimbus
#

i could've just used the UserStore OMEGALUL

south ledge
#

YOU KNOW WHAT WOULD BE AWESOME FOR THE SPOTIFY MODULE

#

using this component

#

and icons are just

#

the play along one with the cool flexbox expand thing so they take up all the space

#

i love react devtools

#

we love

cursive plank
#

working on a cool plugin btw

#

this way css-snippets will be more accessible to others (cause not everyone knows how to edit the css file)

#

and tbh it is a hastle to edit it for every little thing

jagged dune
#

wah

queen sedge
#

i also hate using my brain

cursive plank
#

after install

#

after an edit

#

im quite satisfied with the buttons

#

all thats left is to actually apply the CSS
and to add a settings UI (ugh)

#

(and no, I don't need or want any advice/help, I just like posting my progress)

cursive plank
#

@dull magnet hey ven, ya free?

near aurora
cursive plank
grand vessel
#

yooo

#

that's so cool

#

now you could just link the snippet to the message id and have an install/uninstall feature somewhere in settings

#

showing the collapsible code block, the author, uninstall and jump (to the message) buttons

proud parrotBOT
trail ginkgo
cursive plank
cursive plank
#

I can't use react hooks

#

it errors

#

(yes I know how to use a react hook)

#

even tho the function returns JSX, it looks like discord doesn't treat it as a component or smth

#

hmm

#

since I can use components in it, I could just treat it as a wrapper

#

well that was a failure

#

the moment I use a hook react complains

#

giving the 321 error

eternal lion
#

Also BTW I couldn't use JSX because I was using kernel as a mod-loader, but with vencord u may be able to use JSX.

cursive plank
#

its not "you might" but "you can"

#

and I already am using JSX

#

I see you use a hook

#

i cant use hooks

eternal lion
#

Oh. What error?

#

Oh you send it

#

*sent

#

@cursive plank can I see your code?

cursive plank
#

just using a hook in SnippetManager is the issue

eternal lion
cursive plank
#

There is no useEffect in that component

#

You are looking at the wrong place

eternal lion
#

Also what is the purpose of the const useEffect near the top? Can't you just do const useEffect = React.useEffect?

cursive plank
#

Why would I do that?

#

First of, it would fail

#

Secondly, the other option is to do React.useEffect everywhere

eternal lion
#

Your line const useEffect = (...args: Parameters<typeof React.useEffect>) => React.useEffect(...args); seems like a longer implementation of the same thing

cursive plank
#

sighs

#

const useEffect = React.useEffect, on the top level?

#

that would fail

#

as React is lazy loaded in vencord

#

and it would not be available

#

please dont comment on code that already works

cursive plank
#

in Webpack/common.tsx

#

please, I know you are trying to help

#

but all you are doing is annoy me

#

I appreciate the attempt

#

my guess is that the array, my component is inserted into, is the issue

eternal lion
#

Hmm.

#

@cursive plank did you try having this eslint plugin on and see if there are any errors? https://www.npmjs.com/package/eslint-plugin-react-hooks

#

Maybe its the fact that its an array function thing

#

Idk.

#

I doubt it would work but you could try changing the definition to js SnippetManager: (props) => { // your component code here }

dull magnet
#

you can make a simple wrapper around your component that does give it the proper context

#
function ActualComponent() {
   useState()
}

function makeComponent() {
    return <ErrorBoundary><ActualComponent /></ErrorBoundary>
}

makeComponent() 
#

that's why some plugins have two functions with one just being a wrapper like this

eternal lion
#

How do i setup vencord android for development?

cursive plank
#

you need to make a keystore first

#

search google on how

#

after that, you need to set up some properties, typically there is a file named local.properties
you can set them there

#

although be careful to not commit your keystore

#

well, it aint that important if you are just messing around

#

the keystore is the signature for the apk

#

anyone who has it and knows the password can make an apk using that signature

#

anyways

#

if you dont plan on making a fork

#

then you shouldn't care

#

ven is the one that must care, to not leak his keystore

#

@dull magnet is there a more graceful way of modifying plugin settings (outside of the discord settings) than just Vencord.Settings.Plugins.CssSnippetManager.cssSnippets = ...?

#

ig I could make a wrapper function for just that
but it still doesn't feel great

#

updating the settings is slow, maybe bc it is not async or smth

eternal lion
cursive plank
#

then its ok

#

although its weird that ven did not allow debug builds w/o a keystore

#

or are they allowed, but the config assumes there is a keystore either way?

#

where is the vencord for android repo?

eternal lion
#

i havent really done much with android apps before, idk any of this keystore stuff

cursive plank
#

just google it

#

android studio can generate a keystore for you

#

you just fill in some info

#

mf doesnt have a debug release

#

darn

#

yeah, or just add a debug build

#

lol

#

w/o a signingConfig

#
debug {
    minifyEnabled false
}

ill assume that you can make that edit urself

#

edit the build.gradle (app)

#

add that build type, and use it

dull magnet
#

there is a debug release

#

it's implicit

eternal lion
dull magnet
#

the issue is that the config expects you to have key variables on ur system so you get an error if u don't

eternal lion
#

oh.

dull magnet
#

that should be removed in favour of passing command line arguments

#

I just did it that way cause I didn't know a better way

eternal lion
#

ah, so what do i have to do?

dull magnet
#

that's also how the settings ui does it

#

and it shouldn't be slow

#

obviously don't make 100 changes a second but other than that it shouldn't be slow

cursive plank
#

ofc, only once change per click happens

#

but it feels laggy

dull magnet
dull magnet
cursive plank
#

it feels like it takes a solid second to save

eternal lion
dull magnet
#

if you're changing custom css, it will take about half a second because of how it's implemented

#

anything else should be instant

dull magnet
cursive plank
#

its just the UI being slow

#

from a user's perspective

dull magnet
#

like switches?

#

that's just discord

cursive plank
#

im talking about discord freezing for some miliseconds