#๐Ÿงฉ-plugin-development

1 messages ยท Page 14 of 1

pure temple
#

yes

#

idk why it doesn't show already

lofty crypt
#

congrats on not losing any karma xd

pure temple
#

i haven't done anything!

#

that would be impressive

lofty crypt
#

fr

pure temple
lofty crypt
#

but i believe in you โ€“ if anyone can do it, you can!

pure temple
#

i'm new though!

pure temple
#

๐Ÿš€

#

i don't think discord has the pronouns section in the dialog

lofty crypt
#

how odd

#

welp, itโ€™s unfinished

hexed cargo
#

i luv rust :3

faint siren
#

๐Ÿ˜ฑ

lost granite
#

I've finished my plugin, can anyone do a review?

novel gale
lost granite
novel gale
#

Ofc!!

#

Do u have a link to it?

lost granite
#

yes

novel gale
#

Thank

#

I will test when I home

lost granite
#

ok !!

pure temple
#

you can create a draft

#

(of course you may already know all this so sorry to be patronising!)

lost granite
pure temple
#

hmm

#

should be?

lost granite
#

yes i thinks

green vessel
#

how can i disconnect someone from voicestate (guild)

dull magnet
#

might be guild member update

#

not sure

#

use react devtools to find out

dull magnet
#

that's their own pr...

ruby turtle
#

Oh my

#

Can we all just forget this happened?

green vessel
pure temple
#

how do you load the development build into the browser?

viral roost
#

pnpm buildWeb --watch i think but i cant check rn

dull magnet
#

ye

#

it builds userscript and extension zip

pure temple
#

phew... i can use firefox devtools (i can't find prettify though :()

pure temple
#

i'm now trying to implement the pronouns section without the experiment!

pure temple
#

i never finished that

lofty crypt
#

PRONOUNSABOUT ME

empty jacinth
#

y'all i am having a git moment rn

#

i accidentally pushed some commits while on my local pr/483 branch. how can i switch to my fork without losing my commits?

empty jacinth
#

i just remade the commits

amber mantle
#

is it not already

torpid agate
#

i thought that would be the first thing you did

amber mantle
#

thats what im asking

#

probably

#

but support servers are hell so a lot probably dont want to join xd

solemn star
#

Close your DMs, problem solved

covert nimbus
#

just like powercord used to

crisp jungle
#

does anyone know how discord decides if a server has an animated icon?

amber mantle
#

boost or partnered flag

amber mantle
paper mountain
#

It doesn't support but it generally works on Canary

dull magnet
#

elaborate

#

if you want to know how to determine whether an icon is animated based on its hash, the hash will start with a_

crisp jungle
#

bruh

#

let me test that out

crisp jungle
#

i am very dumb

#

before knowing this information i just do an XHR to test if it fails if I use gif

amber mantle
#

lol

covert nimbus
#

amazing

untold briar
#

I was just trying to change the home button

#

lol

eternal lion
#

Lmao

faint siren
#

any way to access discords i18n?

dull magnet
#

webpack find

faint siren
#

yea, tho what do i search for?

dull magnet
#

find it urself!

#

take any string you see somewhere in the ui and search for it

#

and you will find the module

faint siren
#

i see, thx

dull magnet
faint siren
#

meh, doesn't find anything

dull magnet
#

how

faint siren
dull magnet
#

no

#

that finds functions

dull magnet
faint siren
#

duh, that crashed my discord ๐Ÿ˜‚

#

nvm worked now

dull magnet
faint siren
#

fookn 32 bit smh

#

Vencord.Webpack.findAll(Vencord.Webpack.filters.byProps("DM_TEXTAREA_PLACEHOLDER")) ๐Ÿ‘

faint siren
#

any way to do Webpack.findAll as lazy?

dull magnet
#

why do u need it

faint siren
#

if the user has a native language in discord like german it finds 2 i18n modules, the first is english and the second is the native language

#

they seem to not be loaded immediately, so i need to do it lazily

dull magnet
#

why do you need i18n

faint siren
#

message logger

#

the (edited) part

#

wanted to fix that

#

manually used proxyLazy now

dull magnet
#
const i18n = find(m => m.Messages?.["en-US"]);
console.log(i18n.Messages.DM_TEXTAREA_PLACEHOLDER)
faint siren
#

thx

maiden ruin
#

will there be a way to unlock the new client themes using fakenitro since its mostly client sided?

dull magnet
#

already is

maiden ruin
#

Oh

chrome folio
torpid agate
chrome folio
#

hm, because I would like to trigger them anyhow inside a plugin

pure temple
#

what would be the purpose?

chrome folio
pure temple
#

oh hehe

#

i can't seem to use these reactions on all servers... :(

covert nimbus
#

not fully rolled out

viral roost
#

@dull magnet

dull magnet
#

yeye

chrome folio
#

is there a way to send a message as the current user? (outside of any injected application command)

dull magnet
#

ye

chrome folio
#

(how)

dull magnet
#

findByProps("editMessage").sendMessage

chrome folio
#

thanls, could find any plugin that does that to copy

chrome folio
# dull magnet findByProps("editMessage").sendMessage
start() {
    this.preSend = addPreSendListener((_, message) => {
        if (message.content.startsWith(".thing")) {
            const res = 'just a string'
            findByProps("editMessage").sendMessage({
                content: res.toString() || "undefined"
            });
        }
    });
},
amber mantle
#

you can just edit the content lol

chrome folio
#

it should send the original message and an extra message with the res lol

amber mantle
#

ah

dull magnet
#

its cause you need to add more properties to the message object to it to make it happy

#

Also that's not how u use sendMessage

#

First arg is channel id

chrome folio
#

doesnt matter now, I just work with edit lol

#

my friend wanted eval command lol

#

.eval 3+5

8

dull magnet
#

why not make a proper command

chrome folio
#

wym proper lmao

amber mantle
#

/ eval

chrome folio
#

its funnier when others can see the input and output (for my friends)

#

can make a proper one for public if you even want that, eval just can be kind of dangerous

amber mantle
#

well yeah DEADASS

chrome folio
#

.eval Vencord.Webpack.Common.UserStore.getCurrentUser().phone

911

onyx yoke
#

hey, when does a plugin's stop() get invoked, if ever?

chrome folio
onyx yoke
#

What's the process for getting a PR reviewed and merged in this project? The CONTRIBUTING doc doesn't really go into detail ๐Ÿ™‚

green vessel
#

what's the point of an eval command when u can just use console

onyx yoke
# chrome folio when disabled

So, I'm testing with a simple stop() { console.log("HOBOKEN? I'M DYYYYYYIN'"); } and it doesn't log when I disable the plugin (it says "restart required"), and when I restart - basically, that console.log() never seems to get called, ever.

green vessel
woven lion
onyx yoke
woven lion
#

ven will personally review all of them

woven lion
#

this is not a thing

onyx yoke
woven lion
#

i had another project's API in my head that's not even related to discord

#

casual developer brain death

#

what's your plugin definition look like?

amber mantle
#

worksonmymachine you may have forgotten to build

woven lion
#

it depends

amber mantle
#

me when i debug something and i forget to build (all the time)

onyx yoke
amber mantle
woven lion
#

oh actually hm

#

yeah send your plugin file

#

cuz obviously something isnt right but we cant work it out without seeing

onyx yoke
# woven lion what's your plugin definition look like?
export default definePlugin({
    name: "AAA",
    description: "ABC",
    authors: [
        {
            id: 189195450555826176n,
            name: "Dossy",
        },
    ],
    patches: [],
    settings,

    start() {
        console.log("AAA start()");
    },

    stop() {
        console.log("HOBOKEN?  I'M DYYYYYYIN'");
    },
});
woven lion
#

remove your patches array

onyx yoke
amber mantle
#

that'll do it

onyx yoke
#

OMG, that was it.

#

WTaF

amber mantle
#

yeah you dont need things that you arent using

#

well it depends but

#

here you dont

woven lion
#

the existence of that prop instructs vencord to mark your plugin as requiring a restart

onyx yoke
#

tfw a arr.length check should really be there but isn't

woven lion
#

not really

#

that would've been a review point in a PR

#

you shouldn't have empty stuff for what you're not using, just don't provide it

onyx yoke
#

that generally violates principle of least surprise, though. empty arrays and missing properties should really be semantically identical, no?

woven lion
#

no, they arent

onyx yoke
#

that would be useful to at least document somewhere, like on docs/2_PLUGINS.md or somesuch, because the example has patches: [], which is where I got that from.

amber mantle
#

funny

woven lion
amber mantle
#

but yeah, just don't include what you aren't using, like how dependencies[] dont need to be specified unless you are using an api or another plugin

dull magnet
#

wrong reply moment

amber mantle
#

true

green vessel
#

jumpscare

#

discord will allow you to edit the message you replied to

dull magnet
#

im currently dying at the fact that I need to sveltify so many components unnecessarily in my astro codebase cause you cant import Astro components from svelte

woven lion
#

why do you need to use that much svelte tho

dull magnet
#

wdym

#

I have a svelte component

#

inside i want to use other components like LinkButton and Card

#

but you cant use Astro components in svelte

#

so I now also need to make LinkButton and Card svelte

woven lion
#

ahhhhh

#

okay

dull magnet
#

hmm looks like I could use slot to achieve this perhaps

woven lion
#

yeah

#

was just about to mention

#

actually this is a good point poi_think

#

i was going to write my service using astro and solidjs

dull magnet
#

I renamed this channel to coding btw, so it can serve as a general purpose coding channel, and only #๐Ÿ‘พ-core-development will be vencord exclusive (you can obviously still use this channel for vencord development)

woven lion
#

but if i want to use any UI components id have to write them solid

#

which sorta sux

woven lion
#

cause the entire site needs SSR anyway

dull magnet
#

will this work

#

the slots are astro components

woven lion
#

yip

#

should do

dull magnet
#

it works

#

wow

woven lion
#

Astroยฎ๏ธ

dull magnet
woven lion
#

it just

#

Does

dull magnet
#

ig the downside is that this renders all three

#

even if not visible

#

but mm

woven lion
#

svelte doesnt render the slots if they're not needed

#

unless you mean it'll still download the component

#

in which case yes

dull magnet
#

i will ```html
<slot name={selected + "Tab"} />

woven lion
dull magnet
#

<slot> name cannot be dynamic

woven lion
#

never thought about doing that before

dull magnet
#

EXPLODE

woven lion
#

ah

#

lol

#

yeah thought so

#

confuses the compiler

lament dew
#

first (haha new channel)

woven lion
#

L (not first)

lament dew
#

(L)

dull magnet
woven lion
dull magnet
#

yop

#

you love

#

tbh idk why this goes so THICC

#

shouldnt

onyx yoke
#

Is there an example of a plugin that restarts itself (e.g., calls its stop() then start()) when the settings "Save & Close" button is clicked?

dull magnet
#

why do u need to do that

#

often times there'll be a better solution

woven lion
#

a plugin shouldnt need to restart itself

#

that sounds.. concerning

onyx yoke
#

yeah, I was thinking it was easier/cleaner to stop and start so that timers can be canceled and then fired fresh

dull magnet
#

what r u u making

#

okay so the thiccness is related to me setting width: 100vw on the body

#

???

onyx yoke
#

I'd like the plugin to measure/display words-per-minute speed.

opal fern
#

new channel name nice.

onyx yoke
#

Want to have the stat updated periodically, (either using setTimeout or setInterval - not sure).

dull magnet
#
โ€‰WARNโ€‰ Issues with peer dependencies found
.
โ”œโ”€โ”ฌ @astrojs/mdx 0.18.1
โ”‚ โ””โ”€โ”ฌ @mdx-js/rollup 2.3.0
โ”‚   โ”œโ”€โ”€ โœ• missing peer rollup@>=2
โ”‚   โ””โ”€โ”ฌ @rollup/pluginutils 5.0.2
โ”‚     โ””โ”€โ”€ โœ• missing peer rollup@^1.20.0||^2.0.0||^3.0.0
โ””โ”€โ”ฌ @astrojs/svelte 2.1.0
  โ”œโ”€โ”ฌ @sveltejs/vite-plugin-svelte 2.0.3
  โ”‚ โ”œโ”€โ”€ โœ• missing peer vite@^4.0.0
  โ”‚ โ””โ”€โ”ฌ vitefu 0.2.4
  โ”‚   โ””โ”€โ”€ โœ• missing peer vite@"^3.0.0 || ^4.0.0"
  โ””โ”€โ”ฌ svelte2tsx 0.5.23
    โ””โ”€โ”€ โœ• missing peer typescript@^4.1.2
Peer dependencies that should be installed:
  rollup@">=2.0.0 <3.0.0 || >=3.0.0 <4.0.0"  vite@">=4.0.0 <5.0.0"
  typescript@^4.1.2
#

this is a nightmare holy cow

onyx yoke
#

Being able to reset counters when any settings are changed would be nice, and doing that with a clean stop()/start() would be really nice.

opal fern
amber mantle
#

i think ur thinking of quickcss update

opal fern
#

never knew quickcss emitted events

onyx yoke
opal fern
onyx yoke
#

s'okay

dull magnet
amber mantle
#

o

dull magnet
#

anyway

#

you can define onChange functions for each setting @onyx yoke

#
function restartTimers() {
  ...
}

const settings = definePluginSettings({
  mySetting: {
    type: OptionType.BOOLEAN,
    description: "very cool",
    onChange: restartTimers
  }
});
onyx yoke
#

That might be okay, except I don't want the setting changes to take effect on change, but only on save - if someone changes a setting then clicks Cancel, it's not obvious that the plugin will be functioning with the changed setting...

dull magnet
#

onChange already only runs on save

woven lion
onyx yoke
#

Cool, let me test that.

#

Nice! Perfect.

dull magnet
#

@woven lion mister css guy

#

i need your help

woven lion
#

hoi

dull magnet
#

i set the body to width: 100vw. This is important for properly applying background colour yadayada

#

now I have a card component with no width set

#

it for some reason goes like waaaay out of bounds

#

(see the scroller)

#

im very confused why

#

(i also have 20% margin set on the body)

woven lion
#

what's on the computed styles

dull magnet
#

erm

#

wdym

#

oh

#

whys this here

#

that div for some reason wants to be 100vw

#

but its not set to be 100vw

woven lion
#

is it inheriting maybe?

dull magnet
#

nono

dull magnet
#

nothing

woven lion
dull magnet
#

want me to push?

woven lion
#

if you may

dull magnet
#

okay so

#

i just removed the width from body

#

and it works

#

and is full width anyway

#

minus the beautiful scroller

#

yes this is the hottest site ever created i know

woven lion
#

oh derp

#

no wonder

#

100vw + margin

#

my brain completely missed that

dull magnet
#

ohhh right

#

i need border-box

#

OHHH

#

i get the issue now

#

in my own website (where i copied the width and margin from), i have the 100vw on body and use a wrapper div for the margin

woven lion
#

vw is literally the screen size, which wont take stuff into account, so applying the margin makes it overflow heavily

#

ye

dull magnet
#

this time i thought i could go cheap and just put both on body

#

haha

woven lion
#

yeah its uhhh...

#

When they called it Cascading style Sheets i didnt think They Meant The Website Cascades

dull magnet
#

idk how i forgot about this

#

i literally know this

#

the margin 100vw stuff

woven lion
#

xd

#

im not the brightest when it comes to spotting css mistakes

dull magnet
#

there fixed

woven lion
#

it hurts my head

dull magnet
#

oh god what did i do now

#

i love how no matter how long I do this i still fuck up like this

woven lion
#

this is why i hate frontend

dull magnet
#

GHRRRR

woven lion
#

Ah.

#

is this in svelte

#

or in astro

dull magnet
#

astro

woven lion
#

id recommend ripping out the global styles and putting them into a dedicated css file instead of putting them with your astro code

dull magnet
#

wait i just make not global

#

im dumb

woven lion
#

ah wait yeah you can do that too

dull magnet
woven lion
#

ye

dull magnet
#

long embed

#

ok here we go

#

btw im purposely not really paying attention to design

#

i dont wanna overengineer that rn

#

just get the content and basic layout

woven lion
#

layout first make pretty later

dull magnet
#

okay so

#

i just noticed a hilarious bug in vencord

#

fill="var(--yellow-300"

woven lion
#

oops

dull magnet
#

looks like html parser just auto closes it for us lmao

#

so it works anyway

#

i love this

woven lion
proud parrotBOT
woven lion
#

yep lmao

dull magnet
#

wontfix :3

woven lion
#

i will MicroCommit /s

dull magnet
#

NO

#

dont fix

#

this is hilarious

#

i love html parser error tolerance

woven lion
#

we will wait until it breaks before we fix it

#

:3

dull magnet
#

wait

#

does it work in every browser

#

i wonder

woven lion
dull magnet
#

i know i said i wouldnt work on design at all but now its slightly better

#

(arbitrary colours)

amber mantle
woven lion
#

you will use gruvbox

dull magnet
#

BRO

#

i was gonna type a sad smiley

woven lion
#

actually gruvbox would look hot

dull magnet
#

but it auto closed the )

#

and i cant repro now

#

but copilot suggested (we're broke)

woven lion
#

lmao

#

you will:

:root {
    --gb-bg: #282828;
    /* etc. */
}

@media (prefers-color-scheme: light) {
    :root {
        --gb-bg: #fbf1c7;
        /* etc. */
    }
}
green vessel
#

gameboy bg

woven lion
#

[g]ruv[b]ox

#

[g]ame[b]oy

green vessel
#

gameboy box o' gruv

dull magnet
#

now this is an unfortunate break

#

how do u fix that lmfao

green vessel
#

add non-breaking space between : and (

dull magnet
#

yeah already figured

green vessel
#

<nobr>

woven lion
#

dont use nobr

dull magnet
#

but

woven lion
#

i will slaughter you

dull magnet
#

not 0 width

#

it has width

woven lion
#

use white-space: nowrap;

dull magnet
#

IT LOOKS SO SAD

#

the space makes it better lmfao

green vessel
#

<nobr/>u<nobr/>s<nobr/>e<nobr/> <nobr/><<nobr/>n<nobr/>o<nobr/>b<nobr/>r<nobr/>><nobr/>

dull magnet
dull magnet
#

why does this look off center

#

oh

#

prettier doesnt know its an inline component

#

so it inserts a newline

#

which counts as whitespace in astro

trail ginkgo
dull magnet
#

Read messages after

trail ginkgo
#

oh the nweline

dull magnet
#

bad astro formatter moment

trail ginkgo
#

i got it after the 3rd read

dull magnet
#

basically

woven lion
#

ill fiddle with it

dull magnet
#

inline elements use newlines as space

woven lion
#

i need to sleep though lmfao

dull magnet
#

like

<code>
hi
</code>
#

this will insert a space before and after hi

#

in html

#

but in jsx it just strips the newline, instead you can insert a newline via {"\n"}

woven lion
#

i had a really really bad hack to fix this

dull magnet
#

thus inserting whitespace

#

they blacklist inline elements for newline insertions but if you make a custom component that is an inline component it will still insert newlines

#

just bad formatter

proud parrotBOT
woven lion
#

{} makes it eat the whitespace

#

๐Ÿฅด

#

i got tired of trying to fight the formatter

dull magnet
#

๐Ÿ˜ญ

green vessel
#

or maybe i'm just really bad at it, actually yeah i am really bad at it

#

but i do think there's some truth to it :p

grim hare
#

there are still some things that are kinda gross and hacky in frontend work but the situation has gotten much better in recent years, especially with the death of IE

#

most of the hacky stuff I've had to do in frontend I've had to do because I'm working around other ancient code that's already in the codebase and I don't have the time or authorization to fix

#

(I am looking specifically at jquery and its associated libraries)

#

(I cannot wait until later this year when I've been given the goahead to remove jquery from the project)

visual berry
#

How do i go about patching a webpack module using vencord

covert nimbus
#

you can use regex/plaintext patching (recommended) and maybe monkeypatching? o haven't tried the latter so i can't confirm. might be a patcher function somewhere too idk, ill look into it

#

from what i can tell, there doesn't seem to be a patcher function, so you'll have to monkeypatch (is it even possible?) or plaintext patch

amber mantle
#

for the like 2 things that still have props or whatev

gilded carbon
#

pretty sure we dont do monkey patching here

#

also there is the patch function which uses regex

#

i've been looking into it but havent had much time with full work. (im trying to make a plugin where it appends peoples nicknames to their actual name and not just the nickname showing)

amber mantle
#

I believe there is still findbyprops for things that you can find stuff with but that is barely anything so you're stuck with regex patching that is better but more annoying to find stuff

dull magnet
amber mantle
#

monkey patching so guh

faint siren
#

who be monkey patching these days

abstract spire
#

i'm making the settings panel for a plugin i'm working on, is there any way of getting multi-line string options?

#

as the OptionType.STRING type is limited to a single line

austere gulch
#

you can do custom components

abstract spire
#

is there any documentation on them?

austere gulch
#
type: OptionType.COMPONENT,
component: ({setValue, setError, option}) => <YourComponent />
#

if you check src/components/VencordSettings/ThemesTab.tsx we use a <TextArea /> component

#

which can be multiline

abstract spire
#

oh, that should work

austere gulch
abstract spire
#

alright, i'll give it a try, thanks!

austere gulch
#

np

muted thunder
#

how do I get user id if when I click on there profile in plugin code husk

austere gulch
#

what

muted thunder
austere gulch
#

"how do I get user id if when I click on there profile in plugin code husk"

#

inject into the popup and get their id from args i guess

muted thunder
#

How do i inject

#

into the popup

empty echo
#

question: how does vencord work?

#

like

#

how can it reverse engineer all the discord features?

austere gulch
#

we replace the code itself before it gets loaded

#

we use regex to match strings

#

and replace them

empty echo
#

inside the minified code of discord???

austere gulch
#

yep

empty echo
#

wow ok

#

crazy

austere gulch
#

you can check the src/plugins folder to see examples if you want

woven lion
#

its the fastest and safest way of doing it- if a patch breaks it normally just does nothing rather than breaking the entire client

empty echo
#

wow ok

#

amazing

austere gulch
#

its already happened

#

xd

dull magnet
#

like

myLongText: { 
  type: OptionType.LONG_STRING,
  ...
}
#

what do u think

woven lion
#

with a textarea?

dull magnet
#

ye

woven lion
#

lgtm

abstract spire
#

i actually can't manage to get any component to work, i tried adding buttons, i tried adding text areas

detectedPhrases: {
        description: "aa",
        type: OptionType.COMPONENT,
        component: () =>
            <TextArea
                placeholder="Theme Links"
            />
    },

this should work, right?

#

with TextArea imported from @webpack/common

dull magnet
#

you likely need to fill more props

abstract spire
#

it just complains "Expected ">" but found "placeholder""

dull magnet
#

whats your file called

abstract spire
#

index.ts

austere gulch
#

.tsx

dull magnet
#

it needs to be named index.tsx to use jsx syntax

abstract spire
#

sob

dull magnet
#

idk why vscode cant show you a proper error

#

"jsx is only valid inside .tsx or .jsx files"

#

not hard to do

abstract spire
#

could've saved me like 30 min ๐Ÿ˜ญ

cedar marsh
#

what plugin is good example of options that have int picker

dull magnet
#

int picker?

#

a number?

cedar marsh
#

like a slider from 0-255 or 0 to 100

dull magnet
#

ah

#

volumebooster

cedar marsh
#

thamk

dull magnet
#

you just declare the max and min value and the markers u want

#

pretty straight forward

proud parrotBOT
cedar marsh
#

it looks like it makes sense from the code i see

#

wait what, I was looking at lines 77-85 in the same file

dull magnet
#

thats a patch :3

#

the setting is what i just sent

cedar marsh
#

I have to look at the actual link you sent

dull magnet
#

youre looking at outdated code

cedar marsh
#

why is my vencord not up to date

#

fuck

#

I forgor to pull

#

I feel dumb, why isn't it exist

#

I have done a ctrl+r

viral roost
#

what does that even do

#

if its to enable the new theme thing from discord thats part of FakeNitro

cedar marsh
#

it doesn't do anything yet, but it will be the old client theme experiement

dull magnet
#

did you actually patch with ur dev install

#

pnpm inject :P

cedar marsh
cedar marsh
#

what did I do wrong

const settings = definePluginSettings({
    hue: {
        description: "hue",
        type: OptionType.SLIDER,
        markers: makeRange(0, 1, 360),
        default: 0
    },
    saturation: {
        description: "saturation",
        type: OptionType.SLIDER,
        markers: makeRange(0, 1, 100),
        default: 0
    },
    lightness: {
        description: "lightness",
        type: OptionType.SLIDER,
        markers: makeRange(0, 1, 100),
        default: 7
    }
});

the sliders don't move and aren't respecting default values

amber mantle
dull magnet
#

i think the args are start, end, step

cedar marsh
#

oh I did in wrong order

#

thanks

dull magnet
#

so you'd want 0, 360, 1, but also this would add 360 markers which would be insane

#

I'd not use more than 10 markers

cedar marsh
#

I will figure out a good marker step once I figure out what on earth it looks like

#

the plan is to eventually use the color picker component

dull magnet
#

LOL thats for colour

#

why not make the user enter a hex colour

#

or yeah just use the colour picker

cedar marsh
cedar marsh
dull magnet
#

why do u need hsl

cedar marsh
#

because the --primary colors are based on HSL

#
onInject() {
    addEditCSSFile("clientThemeBase", `:root:root {
        --primary-100-hsl: calc(var(--theme-h) + 20) calc(var(--theme-s) - 1.8%) 96.7%;
        ...
        --primary-500-hsl: calc(var(--theme-h) - 11.4) calc(var(--theme-s) - 4.1%) 32.5%;
    }`);
},
onChangeSettings({ hue, saturation, lightness }) {
    addEditCSSFile("clientThemeVars", `:root {
        --theme-h: ${hue};
        --theme-s: ${saturation}%;
        --theme-l: ${lightness}%;
    }`);
}

Is there hooks for plugins like onInject and onChangeSettings, similar to start/stop?
Also is there a built in way to add css?

dull magnet
#

whats onInject

cedar marsh
#

sorry, I feel like an absolute idiot with what I am doing

dull magnet
#

onChangeSettings, yes

#

options take an onChange property

cedar marsh
#

I guess that would just be start

dull magnet
#

yes start

#

or just top level code

#

but top level code runs extremely early so be careful, at that point all discord stuff doesn't exist yet

cedar marsh
#

ok

#

for adding css do I just add a style node to the head?

dull magnet
#

no

#

just import css file

cedar marsh
#

its dynamically generated though

#

based on options

dull magnet
#

then yes

cedar marsh
#

if I do onChange in settings, will it run once on plugin inject?

dull magnet
#

no, only on change

#

make a generic function addStyles() or whatever and use it both as onChange and call it in start

cedar marsh
#

alright

trail ginkgo
#

guh i never made interpolated vars css api

#

so sad

cedar marsh
#

wait what, ok it works now for some reason.

cedar marsh
viral roost
#

it probably works only for dev builds cause they have css hot reload

cedar marsh
#

it edits a style node

viral roost
#

oh

cedar marsh
#
function handleSettingChange() {
    const style = document.head.querySelector("style#clientThemeVars");
    if (!style) return;
    style.textContent = `:root {
        --theme-h: ${settings.store.hue};
        --theme-s: ${settings.store.saturation}%;
        --theme-l: ${settings.store.lightness}%;
    }`;
}
#
  1. how do I get access to color picker
  2. how do I render it in the settings of my plugin
#

are there any plugins that render a component in their settings modal I can look at?

woven lion
proud parrotBOT
cedar marsh
#

thank

#

how does the settings store work, can I just make the component control settings.store.var and it will save? or do I need to call some fancy store function thingy

woven lion
#

yes

#

pretty much

#

just

#

settings.store.var = ...

#

it'll write for you

cedar marsh
#

fantastic

#

will that trigger the setting's onChange as well?

woven lion
#

actually let me confirm that

#

i've never tried writing but i swear i've seen it before

#

yep, writing will automatically save the setting (its through the same settings proxy as everything else), onChange() is only fired by the UI when you save

cedar marsh
#

alright

#

thanks!

#

what do components look like in SWC
I am only familiar with react function component syntax, should I be looking for something like

function d({react component args you normally have, like}) {
return <div/>;
viral roost
#

except it does some funny shit

#

(0,[react].jsx)(ComponentType,{props},[children])

cedar marsh
#

so this is a component?

#

that looks like it matches

viral roost
#

ye

cedar marsh
#

ok and I just confirmed that it is infact the color picker by having a debugger freeze on it and it froze when I had a color picker pop up

#

now how do I go from knowing where it is in the source, to getting the component accesable in my plugin

viral roost
cedar marsh
#

what

woven lion
#

or by code in the component

cedar marsh
#

is there any plugins that get components through regex magic or whatever so I can get a vauge idea of what I am supposed to write

woven lion
#

i.. actually don't know

#

all i can think of is the vencord common components

dull magnet
#

react components are just functions or classes

#

if they're a class component you need to check m.prototype.render, if they're a function component you need to just use findByCode

cedar marsh
dull magnet
#

the function name can either be r.jsx or r.jsxs

#

they're functionally the same so it doesn't matter which one it is

#

it's used by react to differentiate whether an array was created by react due to passing multiple children or passed as child by the user

#

in the latter case keys are required and react warns in development if there aren't any

#

in production the functions do the same

#

react is almost always called r but I wouldn't depend on it

cedar marsh
#

I can't exactly do what components.ts does, because I don't have a readily available type, so do I have to initialize my own?

dull magnet
#

wdym

cedar marsh
#
export const Card = waitForComponent<t.Card>("Card", m => m.Types?.PRIMARY && m.defaultProps);

it uses the already made t.Card type thing

export type Card = ComponentType<PropsWithChildren<HTMLProps<HTMLDivElement> & {
    editable?: boolean;
    outline?: boolean;
    /** Card.Types.PRIMARY */
    type?: string;
}>> & {
    Types: Record<"BRAND" | "CUSTOM" | "DANGER" | "PRIMARY" | "SUCCESS" | "WARNING", string>;
};

but I am not looking for a card component

#

so I need to make my own type thing

#

I am calling it a type thing because I don't know the first thing about typescript other than everyone saying I should use it

woven lion
#

oh nono you dont need to do that

#

when you're doing the code searches yourself it returns any

#

you dont need to write types

cedar marsh
#

can I put anything into the name bit of waitForComponent or do I need to find that somewhere in the code

dull magnet
#

you can't use waitForComponent

#

it's an internal vencord function that simply wraps waitFor

#

the name is for debugging purposes

cedar marsh
#

the only example that I have gotten for finding a component is the internal vencord one

dull magnet
#
const ColorPicker = LazyComponent(() => findByCode("whatever"));

<ColorPicker />
cedar marsh
#

thank

#

I will try that later today, I need to go

#

automatic imports aren't being nice and working easily

#

I will figure out later

amber mantle
#

that should just be @webpack no?

dull magnet
#

ye

cedar marsh
#
return (0,
    r.jsxs)(u.VqE, {
        "aria-label": A.Z.Messages.PICK_A_COLOR,
        className: D().customColorPicker,
        children: [(0,
        r.jsx)(T, {

would findByCode("A.Z.Messages.PICK_A_COLOR") work here?

#

ooo vencord vscode plugin would help

dull magnet
#

yes

dull magnet
#

that's a minified variable name that will break

#

.Messages.PICK_A_COLOR,

#

this might work

cedar marsh
cedar marsh
#

I want this component
but selecting any of it's unique props, like suggestedColors gives no results

#

selecting any of the code in it's return, like customColorPicker gives no results

dull magnet
#

wait it's not

#

are you sure it's exported

cedar marsh
#

I didn't know to check for that

#

I guess it's not?

#

Gtg

cedar marsh
#

Can I somehow add an export using patches

dull magnet
#

yes but don't

cedar marsh
#

how do I access it then

dull magnet
#

I'll get on pc in a bit and help you

cedar marsh
#

thanks

dire fern
trail ginkgo
#

why...

dull magnet
#

L

trail ginkgo
#

why cant u do const x of iterator

#

in typescript

#

its literally normla

#

what the FUCK you BITCH im justr trying to make an INTERSPERSE util

#

fuck this why am i even using generators

oblique lark
#
Component.literal("\u2588").withStyle(Style.EMPTY.withColor(color))

me when I have to use Style.empty in order to style things (I hate minecraft chat formatting)

trail ginkgo
#

java

cedar marsh
#

I can't put import "./clientTheme.css" into my start function because imports have to be at the top level
but if it's at the top level it will fuck with colors of people who don't have my plugin enabled

#

I can give default vars so it looks very close to vanilla discord, but it will still fuck with saturation

dull magnet
#

?managed

proud parrotBOT
# dull magnet https://github.com/Vendicated/Vencord/blob/main/src/plugins/messageLogger/index....

**index.tsx: **Lines 30-44

import overlayStyle from "./deleteStyleOverlay.css?managed";
import textStyle from "./deleteStyleText.css?managed";

const i18n = findLazy(m => m.Messages?.["en-US"]);
const styles = findByPropsLazy("edited", "communicationDisabled", "isSystemMessage");

function addDeleteStyle() {
    if (Settings.plugins.MessageLogger.deleteStyle === "text") {
        enableStyle(textStyle);
        disableStyle(overlayStyle);
    } else {
        disableStyle(textStyle);
        enableStyle(overlayStyle);
    }
}
cedar marsh
#

thank

cedar marsh
#

component is X, found in user profile customization

green vessel
#

i'm trying to port CompleteTimestamps from betterdiscord... it seems like discord is using moment.js, tried patching a bunch of .calendar() calls but no luck so far

#

well for now i'm just hardcoding my own custom format, no config yet

green vessel
cedar marsh
#

its just gonna be client side

#

no one else will see it

green vessel
cedar marsh
#

too much effort

green vessel
#

i thing i can make it using a theme

lusty rampart
#

is there a way to add plugin from better discord

viral roost
#

no

lusty rampart
#

i have source code can someone add it to plugins thing

austere gulch
#

no

lusty rampart
#

damm

austere gulch
#

if not, make a post on there

covert nimbus
#

is this intentional

austere gulch
vague echo
#

type couldn't be any longer than ApplicationCommandOptionType trolley

mossy marsh
#

is there any sort of pnpm watch for web instead of the actual client?

woven lion
#

pnpm buildWeb --watch

mossy marsh
#

ty

covert nimbus
glacial kelp
#

Oh yeah I love variables, they all have so nice values?

#

Look at the code I wrote
Variable ==! 2
Then (Execute[ Do{ True[ Script send "" Hello world"]Timeout 10}]If not {Create Variable = 2 (timeout 3)})
Shutdown

#

:))))))))

#

If you don't understand you haven't mastered Script yet

amber condor
#

can anyone explain to me how i can run a simple piece of JS code after discord loads a page? Like when i click on a channel it loads the page, i want to post-process the page. The tutorial is kinda confusing (i dont have a background in JS, only other langs)

mossy marsh
#

I'm new to vencord, and discord plugins in general, I'm not quite sure how the patches option works, I looked at the "Shiki Codeblocks" plugin as my idea was similar, here's my current code, ignore the mess:

import { Devs } from "@utils/constants";
import { getPrettierParser, getPrettierStandalone } from "@utils/dependencies";
import Logger from "@utils/Logger";
import definePlugin from "@utils/types";

const logger = new Logger("BetterCodeblocks");

let formatter = (code: string) => code;

export default definePlugin({
    name: "PrettyCodeblocks",
    description: "Formats codeblocks with Prettier.",
    authors: [Devs.Duro],
    patches: [
        {
            find: "codeBlock:{react:function",
            replacement: {
                match: /codeBlock:\{react:function\((\i),(\i),(\i)\)\{/,
                replace: "$&return $self.format($1,$2,$3);",
            },
        },
    ],
    async start() {
        const { default: parser } = await getPrettierParser();
        const { default: prettier } = await getPrettierStandalone();

        formatter = (code: string) => prettier.format(code, { parser: "typescript", plugins: [parser] });
    },
    format({ lang, content }: { lang: string; content: string; }) {
        const res = formatter(content); // expected to be a formatted code string

        logger.info(res);

        // TOOD: what do i return here?
    }
});
trail ginkgo
mossy marsh
#

ohh

trail ginkgo
#

and u can test ur patches there but basically

mossy marsh
#

that's cool

trail ginkgo
#

each patch changes discord source code

mossy marsh
#

I just want to basically change the content of the codeblock, but I'm afraid it will mess with the highlight

mossy marsh
trail ginkgo
#

you'll need to find a snippet of text unique to the module u wanna patch

#

thats the find prop

#

and then the replacement is just a regex replace

#

\i being an escape for minified variable names

mossy marsh
#

yeah i copied your patch and it seemed to work, but im not really sure what to put as the return for the format

#

I was testing and just returned like <p>hello</p> and it seemed to work, but im not sure how i would still preserve the highlight and stuff with the new content of the codeblock

trail ginkgo
#

yea its probably best to go in devtools and look at the module ur patching

#

prettify it (its a button in devtools when ur looking at a file in the sources tab) and read the code and try to understand a bit of whats going on

#

if its hard to get whats going on (it usually is), u can set a breakpoint and then trigger the code

mossy marsh
#

good to know

#

I'm also curious if there's like a priority for the patches, like if my patch changed the content of the codeblock, and another had the same patch, which one would go first? Ideally I would want my patch to run, change the content, and then the ShikiCodeblocks would add the highlighting with the formatted content

trail ginkgo
#

and if u run code in the console while its frozen at a breakpoint it'll run that code with all the variables in scope that ur frozen at

mossy marsh
#

yeah

trail ginkgo
mossy marsh
#

alright

trail ginkgo
#

so my patch would just fail and my plugin wouldnt load

mossy marsh
#

oh i see

trail ginkgo
#

mostly its about being mindful about ur patches

mossy marsh
#

yeah

trail ginkgo
#

only patch thats necessary

#

for u, u just need to replace the code content before the code gets rendered

mossy marsh
#

yeah

#

i'll look into that

odd pelican
#

i am here

#

and now i shall need help for webpack

#

ok so using vendicated's discord reverse engineering guide (link: https://gist.github.com/Vendicated/dec16d3fd86f761558ce170d016ebc53) if you scroll all the way down, you see this thing

const webpackRequire = webpackChunkdiscord_app.push([
    [Symbol()], // Make sure our "chunk" id is unique
    {}, // No modules,
    require => require // the return value of this function will be the return value of push
]);```

so now he also later says to get the cache you do `webpackRequire.c`

but when I try that it just returns `undefined`
austere gulch
#

works for me โ„ข๏ธ

odd pelican
#

ok do webpackRequire.c

odd pelican
austere gulch
odd pelican
#

WTF

#

maybe its because im using replugged

#

wait do you have vencord injected

austere gulch
#

yes

#

and yes

odd pelican
#

its becuase Im using replugged?

austere gulch
#

replugged messes with the webpack chunk stuff

odd pelican
#

OH

#

oh my god

#

why didnt anyone tell me

#

what the fuck

austere gulch
#

probably

odd pelican
#

grr

austere gulch
#

i havent actually looked but i'd assume so

#

anyways replugged and vencord both have our own ways of looking for stuff

#

which is shown in that guide

#

well the vencord method is shown at least

#

:p

odd pelican
#

if I were to make my own discord client mod, would I have to patch webpack (like vencord did)

austere gulch
#

you would yes

odd pelican
#

whats the reason for it tho

austere gulch
#

webpack is what loads the code and manages imports and stuff

#

you have to use it to get anything

#

its all bundled up with webpack

#

so you have to use webpack to get them back

odd pelican
#

oh

austere gulch
#

every bit of discord code is stored in that webpack chunk variable

#

so it'd make sense you have to mess with that variable to get discords code

#

xd

woven lion
#

(basically webpack chunks make it possible for mods to work in the first place)

odd pelican
#

oh

woven lion
#

(without them you'd have to jump through massive hoops to patch standard discord code)

amber condor
amber condor
chrome elbow
#

ah

amber condor
# torpid agate what are you trying to add

Well, discord is a bit of a noob. Because when someone sends an embed, it should color the border of the embed based on the platform (twitter=blue, instagram=pink, youtube=red, etc..), but it doesnt always do that for certain links. So i just wanted to "fix" that.

torpid agate
#

what language are you using?

covert nimbus
torpid agate
#

they are basically the same language but you canโ€™t use them with the same application

covert nimbus
#

pretty sure you can use them interchangably, just that TS needs to be compiled to js (which you need to do anyway?)

torpid agate
#

i just realized how rude that sounded

#

so i fixed it

woven lion
#

you are very confused

#

just because its the same language doesnt mean you can just drop a betterdiscord plugin in to vencord

torpid agate
#

i thought the whole point of type script is it had a different functions

#

they use the same syntax and other stuff

#

but typescript handles info differently

woven lion
#

that doesnt help with the betterdiscord/vencord compatibility

amber condor
amber condor
#

TS is just JS but better

#

still "compiles" to JS tho

covert nimbus
torpid agate
covert nimbus
#

yeah as in the languages

torpid agate
#

ohh

#

nvm

covert nimbus
#

bd uses a completely different plugin structure

#

but it's still js

torpid agate
#

this is all confusing

covert nimbus
#

fuck now I'm wondering if I'm skilled enough to make bdcompat

woven lion
#

someone already made a layer i think

#

i dont know how mature it is

#

but they got zerespluginlib working on vencord afaik

torpid agate
#

honest to god i wish i had no friends rn i wanna learn to code but ik they are gonna try to get me to vc the instant i get started

covert nimbus
#

i will make bdcompat but better

woven lion
#

go for it xd

torpid agate
covert nimbus
covert nimbus
#

bdfdb time

woven lion
covert nimbus
#

time to do some investigation

tame nexus
#

If I need to add a new store to Vencord should I only do it for my plugin or add it and it types directly to Vencord itself?

river talon
#

Most sane rust code

dull magnet
#

C code doing the same would look very similar

#

this is doing extremely hacky stuff KoishiXD

#

no but you can opt out of cache with fetch

amber condor
#

idk how betterdiscord plugins are made (nor do i know vencord tbh lol), but it would be cool to have "subscriptions" that can be compiled into the source code.

for example:


function lowerAllMessages(ctx) {
    ctx.message = ctx.message.lower;
}
subscribe(Events.ReceiveMessage, lowerAllMessages);

the function would just be inserted into the source i guess?

austere gulch
#

we already have flux subscriptions

amber condor
austere gulch
#

FluxDispatcher.subscribe("EVENT_NAME", someHandler)

amber condor
#

do you have a small working example? I'd like to look into it a bit but starting from scratch is too confusing for me

austere gulch
#

go into repo
ctrl+f
Dispatcher

#

lol

amber condor
#

interesting

#

how do i know what guild / channel the client is currently in?

dull magnet
#

getCurrentChannel()
getCurrentGuild()

#

you can import from @utils/discord

amber condor
#

cool

#

i should really setup a TS environment or something because currently im just screwing around in console ๐Ÿฅด

dull magnet
#

in the console its Vencord.Util.discord

#

I think

amber condor
#

cool thanks โค๏ธ

#

i will try setting up TS later today

ionic breach
#

okay maybe im crazy, but i can't get @import url("<file path>") to work in quickCss.css?

#

it works fine if i have the files uploaded to a github

#

but if they're in the same directory as the quickcss file they don't seem to work

grim hare
#

that is correct, you cannot import local files with vencord

ionic breach
#

oh cool cool

#

i was worried i was having a brain fart

odd pelican
#

ok another webpack reverse engineering fail, now since i learned how to reverse engineer discord (sort of), i wanted to give it a go for monkeytype, so I decided to try this

#

i expected require.c to work

#

as it worked for discord

#

Ok actually i think it was require.m instead

#

I did object.keys(require)

dull magnet
#

not every site has cache as property on require

#

only m is guaranteed

#

not c

odd pelican
#

yea

#

did I do it correctly tho

#

using object.keys

tribal helm
#

a

#

support for opening profile links

#

in the app

#

How do I do that

#

Instead of it going to the browser, I want it to just open the profile

torpid agate
#

its a experimental feature and theyll fix it later along the line

amber condor
#

ERR_PNPM_PATCH_NOT_APPLIEDโ€‰ The following patches were not applied: eslint@8.28.0

Either remove them from "patchedDependencies" or update them to match packages in your dependencies.

#

getting this when trying to pnpm update

#

anyone know what im supposed to do

dull magnet
#

dont pnpm update?

amber condor
#

i wouldnt

#

but pnpm watch results in "cannot find pacakge 'esbuild'"

dull magnet
#

pnpm i

amber condor
#

thanks

#

alot

#

wait so i just pnpm watch and then reload discord?

#

im prob missing something

trail ginkgo
#

and then yea refresh discord

amber condor
#

its just not appearing in my Plugins tab

trail ginkgo
#

any errors in console?

#

maybe patch failed to apply

amber condor
trail ginkgo
#

no in discord

amber condor
#

not anything i could find

chrome elbow
trail ginkgo
#

maybe u too quickly refreshed before the build finished

#

try again maybe

amber condor
#

no because my first build was like 20 minutes ago

trail ginkgo
#

eh i gotta work maybe if ur still having issues u can screenshare and i can try and see whats happending

amber condor
#

hmm that'd be nice

#

im going off to sleep now tho

dull magnet
#

you didnt pnpm inject

amber condor
#

so there was something else

#

thanks it works now

#

well the plugin loads but idk if my code actually logs to the console?

#

idk goodnight all

dull magnet
#

@trail ginkgo rate

trail ginkgo
#

MASSIVE

#

will u parse the devs constant

dull magnet
#

yes

#

thats TODO

trail ginkgo
#

to map Devs.X to ids

#

real

dull magnet
#

which si why authors empty rn

trail ginkgo
#

ya i swa

dull magnet
#

:3

mossy marsh
dull magnet
#

@trail ginkgo

#

@woven lion

#

this is autogenerated

cedar olive
#

nookies

dull magnet
#

?

cedar olive
#

eh nothing lol

dull magnet
#

27kb wtf

#

anyway lewi u can now fetch that file for plugins page

#

in fact lemme do that rn

Done! AiriThumbUp

woven lion
#

:3

hollow tree
#

so I changed some lines of a plugin and did pnpm build which made dist folder and pnpm inject which opened the GUI again and it installed properly, now I wanna have my friend install the same thing, can I somehow share the dist folder and make him install this version

grim hare
#

that is not a very good idea, they wouldn't get any updates and eventually things would start to break because of it

hollow tree
grim hare
#

what changes did you make that you want to share?

hollow tree
#

it inserts emojis between spaces in text

#

just copied the command structure from above and made a new emojify function

{
    name: "mock",
    description: "mOcK PeOpLe",
    options: [RequiredMessageOption],
    execute: opts => ({
        content: mock(findOption(opts, "message", ""))
    }),
},
{
    name: "emojify",
    description: "Emojifies your messages ๐Ÿค“",
    options: [RequiredMessageOption],
    execute: opts => ({
        content: emojify(findOption(opts, "message", ""))
    }),
},
#

in moreCommands plugin

grim hare
#

the official way to do it would be to see if you can get your new commands added into the full plugin list by making a pull request

#

then everyone would have them and your friend wouldn't need to do anything special

hollow tree
#

might have to ask the dev of this plugin to add this probably๐Ÿค”

grim hare
#

the not official and not really supported way to do it would be to have your friend follow the same steps you did and make the same edits to the file

hollow tree
#

yeah then they will also need to install node and stuff

grim hare
hollow tree
#

๐Ÿ™ƒ

#

@opal fern sorry for the ping but I wanted to know if this could be added to your plugin๐Ÿ‘€

hasty stag
#

how can i open a link externally from a plugin

hollow tree
# opal fern Yeah go ahead

so I made these changes (in above messages) , to get random emojis from a list to your plugin would you be willing to add those as a feature in your plugin?
my emojify function (also requires an array of emoji names, not the smartest implementation)

function emojify(input: string): string {
    return input.trim()
        .replace(
            /\s/g,
            () =>
                " :" +
                emojis[Math.floor(emojis.length * Math.random())] +
                ": "
        );
}

Aliucord had a similar plugin that had /clap command which would replace spaces to clap emoji ๐Ÿ‘ , I have also modified that for myself as well

hollow tree
bright ocean
hollow tree
#

oh lol

#

yeah I can but.....

opal fern
#

It's not my code

#

It's yours

#

If I were to add it it would be under my name which I don't exactly want

hollow tree
#

I don't feel like I have done anything here just copied the structure and added a simple function

hollow tree