#๐งฉ-plugin-development
1 messages ยท Page 14 of 1
congrats on not losing any karma xd
fr
most viewed post though!
||https://www.reddit.com/r/ProgrammerHumor/comments/rpkvvb/oh_god_oh_fuck_i_learned_rust_wtf_do_i_do_guys ||
but i believe in you โ if anyone can do it, you can!
i'm new though!
: more rust
i luv rust :3
๐ฑ
Me! If you can wait a few hours ๐ญ
oh! thank you very much
ok !!
i think it's better to review via pr
you can create a draft
(of course you may already know all this so sorry to be patronising!)
yes, but I don't know the best practices for the project
yes i thinks
how can i disconnect someone from voicestate (guild)
https://github.com/Vendicated/Vencord/pull/600/commits/63dd3d5393da28974bc75296fb6d620adeb601cf
You can see how it was done here
i've done it x)
that's their own pr...

how do you load the development build into the browser?
pnpm buildWeb --watch i think but i cant check rn
phew... i can use firefox devtools (i can't find prettify though :()
i'm now trying to implement the pronouns section without the experiment!
i never finished that
oh sweet!๐
PRONOUNSABOUT ME
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?
i just remade the commits
@green vessel please review? https://github.com/Vendicated/Vencord/pull/483
is it not already
i thought that would be the first thing you did
thats what im asking
probably
but support servers are hell so a lot probably dont want to join xd
Close your DMs, problem solved
just like powercord used to
does anyone know how discord decides if a server has an animated icon?
boost or partnered flag
Vencord does not support Discord PTB, Canary, or Development. Please switch to Stable to receive support.
It doesn't support but it generally works on Canary
?
elaborate
if you want to know how to determine whether an icon is animated based on its hash, the hash will start with a_
AH
bruh
let me test that out
BRUH yes now i see it...
i am very dumb
before knowing this information i just do an XHR to test if it fails if I use gif
lol
amazing
Lmao
any way to access discords i18n?
webpack find
yea, tho what do i search for?
find it urself!
take any string you see somewhere in the ui and search for it
and you will find the module
i see, thx
meh, doesn't find anything
how
use search like here
you love out of memory
fookn 32 bit smh
Vencord.Webpack.findAll(Vencord.Webpack.filters.byProps("DM_TEXTAREA_PLACEHOLDER")) ๐
any way to do Webpack.findAll as lazy?
why do u need it
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
why do you need i18n
const i18n = find(m => m.Messages?.["en-US"]);
console.log(i18n.Messages.DM_TEXTAREA_PLACEHOLDER)
thx
will there be a way to unlock the new client themes using fakenitro since its mostly client sided?
already is
Oh
does anyone know how the animations on super reactions are played? Aka is there a way I can trigger that animation https://c.lunish.nl/r/UvCFsq.gif
i think its related to mouse proximity tho i havent tested it
hm, because I would like to trigger them anyhow inside a plugin
what would be the purpose?
just a little trolling
not fully rolled out
@dull magnet
yeye
is there a way to send a message as the current user? (outside of any injected application command)
ye
(how)
findByProps("editMessage").sendMessage
thanls, could find any plugin that does that to copy
start() {
this.preSend = addPreSendListener((_, message) => {
if (message.content.startsWith(".thing")) {
const res = 'just a string'
findByProps("editMessage").sendMessage({
content: res.toString() || "undefined"
});
}
});
},
you can just edit the content lol
it should send the original message and an extra message with the res lol
ah
this is normal
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
doesnt matter now, I just work with edit lol
my friend wanted eval command lol
.eval 3+5
8
wym proper lmao
/ eval
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
well yeah 
.eval Vencord.Webpack.Common.UserStore.getCurrentUser().phone
911
hey, when does a plugin's stop() get invoked, if ever?
when disabled
What's the process for getting a PR reviewed and merged in this project? The CONTRIBUTING doc doesn't really go into detail ๐
what's the point of an eval command when u can just use console
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.
you just make a PR there's not really a complex workflow or anything
have you got requiresRestart
cool, done - do I need to request a review from anyone?
ven will personally review all of them
no, heh
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?
you may have forgotten to build
it depends
me when i debug something and i forget to build (all the time)
I considered that, but I have a similar log in start() and it's logging.
^
oh actually hm

yeah send your plugin file
cuz obviously something isnt right but we cant work it out without seeing
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'");
},
});
remove your patches array

that'll do it
the existence of that prop instructs vencord to mark your plugin as requiring a restart
tfw a arr.length check should really be there but isn't
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
that generally violates principle of least surprise, though. empty arrays and missing properties should really be semantically identical, no?
no, they arent
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.
funny
we'll write a better documentation site soon dw
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
stop is ignored if your plugin has any features that require restarts (aka patches)
wrong reply moment
true
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
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
hmm looks like I could use slot to achieve this perhaps
yeah
was just about to mention
actually this is a good point 
i was going to write my service using astro and solidjs
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)
sounds good
might as well just use solidstart at this point
cause the entire site needs SSR anyway
Astroยฎ๏ธ
svelte doesnt render the slots if they're not needed
unless you mean it'll still download the component
in which case yes

<slot> name cannot be dynamic
never thought about doing that before
EXPLODE
first (haha new channel)
L (not first)
(L)
lgtm

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?
yeah, I was thinking it was easier/cleaner to stop and start so that timers can be canceled and then fired fresh
what r u u making
okay so the thiccness is related to me setting width: 100vw on the body
???
I'd like the plugin to measure/display words-per-minute speed.
new channel name nice.
Want to have the stat updated periodically, (either using setTimeout or setInterval - not sure).
โ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
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.
you can wait for settings to be updated. I believe updated settings are announced with an event, but not 100% sure
i think ur thinking of quickcss update
never knew quickcss emitted events
Any chance you can point to an example of how to do that?
cant rn, sorry mate
s'okay
all settings do
o
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
}
});
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...
onChange already only runs on save

hoi
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)
what's on the computed styles
erm
wdym
oh
whys this here
that div for some reason wants to be 100vw
but its not set to be 100vw
is it inheriting maybe?
nono

want me to push?
if you may
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
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
vw is literally the screen size, which wont take stuff into account, so applying the margin makes it overflow heavily
ye
yeah its uhhh...
When they called it Cascading style Sheets i didnt think They Meant The Website Cascades
there fixed
it hurts my head
oh god what did i do now
i love how no matter how long I do this i still fuck up like this

this is why i hate frontend
GHRRRR
astro
id recommend ripping out the global styles and putting them into a dedicated css file instead of putting them with your astro code
ye i did that on my site
ah wait yeah you can do that too
ye
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
layout first make pretty later
oops
looks like html parser just auto closes it for us lmao
so it works anyway
i love this
**platformIndicators.tsx: **Line 64
return <Icon color={`var(--${getStatusColor(status)}`} tooltip={tooltip} />;
yep lmao
wontfix :3
i will MicroCommit /s
https://discord.coffee/5aYCy7j.png works in ff
i know i said i wouldnt work on design at all but now its slightly better
(arbitrary colours)


you will use gruvbox
actually gruvbox would look hot
lmao
you will:
:root {
--gb-bg: #282828;
/* etc. */
}
@media (prefers-color-scheme: light) {
:root {
--gb-bg: #fbf1c7;
/* etc. */
}
}
gameboy bg
gameboy box o' gruv
add non-breaking space between : and (
yeah already figured
<nobr>
dont use nobr
but
i will slaughter you
use white-space: nowrap;
<nobr/>u<nobr/>s<nobr/>e<nobr/> <nobr/><<nobr/>n<nobr/>o<nobr/>b<nobr/>r<nobr/>><nobr/>

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
its very off center
Read messages after
oh the nweline
bad astro formatter moment
i got it after the 3rd read
basically
ill fiddle with it
inline elements use newlines as space
i need to sleep though lmfao
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"}
i had a really really bad hack to fix this
Astro just uses the jsx formatter as a base I'm pretty sure because it formats components like this
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
**PostListingLayout.astro: **Lines 33-42
<span class="date">
{dayjs(data.createdAt).format("Do MMM, YYYY")}
{data.modifiedAt && (
<>
(updated
{dayjs(data.modifiedAt).format("Do MMM, YYYY")}
{})
</>
)}
</span>
๐ญ
isn't the entirety of frontend just a collection of hacky workarounds though? lol
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
(it's not :P)
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)
How do i go about patching a webpack module using vencord
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
for the like 2 things that still have props or whatev
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)
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
you can still find everything but monkey patching is illegal
monkey patching so guh
who be monkey patching these days
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
you can do custom components
is there any documentation on them?
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
oh, that should work
with this, you can do setValue(yourNewValue) to update settings obj, and setError(true | false) to flag an error on the ui to prevent saving
alright, i'll give it a try, thanks!
np
how do I get user id if when I click on there profile in plugin code 
what
wdym what
"how do I get user id if when I click on there profile in plugin code
"
inject into the popup and get their id from args i guess
question: how does vencord work?
like
how can it reverse engineer all the discord features?
we replace the code itself before it gets loaded
we use regex to match strings
and replace them
inside the minified code of discord???
yep
its the fastest and safest way of doing it- if a patch breaks it normally just does nothing rather than breaking the entire client
tbh this could be a vencord settings option
like
myLongText: {
type: OptionType.LONG_STRING,
...
}
what do u think
with a textarea?
ye
lgtm
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
you likely need to fill more props
it just complains "Expected ">" but found "placeholder""
whats your file called
index.ts
.tsx
it needs to be named index.tsx to use jsx syntax
sob
idk why vscode cant show you a proper error
"jsx is only valid inside .tsx or .jsx files"
not hard to do
could've saved me like 30 min ๐ญ
what plugin is good example of options that have int picker
like a slider from 0-255 or 0 to 100
thamk
you just declare the max and min value and the markers u want
pretty straight forward
**volumeBooster.ts: **Lines 24-32
const settings = definePluginSettings({
multiplier: {
description: "Volume Multiplier",
type: OptionType.SLIDER,
markers: makeRange(1, 5, 1),
default: 2,
stickToMarkers: true,
}
});
it looks like it makes sense from the code i see
wait what, I was looking at lines 77-85 in the same file
youre looking at outdated code
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
what does that even do
if its to enable the new theme thing from discord thats part of FakeNitro
it doesn't do anything yet, but it will be the old client theme experiement
I am dumb
I would've done it if I could find the old non-installer based instructions
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
i forget thsi every time and i go insane
i hate react
youre using makeRange wrong
i think the args are start, end, step
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
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
LOL thats for colour
why not make the user enter a hex colour
or yeah just use the colour picker
because then I would have to convert to hsl and I am too lazy to find a way to do that right now
I am just doing minimum viable product rn
because I spent ~30 minutes trying to find the component using the react devtools but I have literally no idea what I am doing
why do u need hsl
that makes more sense now
because the css I made to recreate the old experiment uses HSL
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?
whats onInject
sorry, I feel like an absolute idiot with what I am doing
something that just runs once, on the plugin being enabled/discord starting
I guess that would just be start
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
then yes
if I do onChange in settings, will it run once on plugin inject?
no, only on change
make a generic function addStyles() or whatever and use it both as onChange and call it in start
alright
first import I have is
import "./clientTheme.css";
but the css isn't applying
wait what, ok it works now for some reason.
it probably works only for dev builds cause they have css hot reload
it edits a style node
oh
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}%;
}`;
}
- how do I get access to color picker
- 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?
**textReplace.tsx: **Lines 42-52
const settings = definePluginSettings({
replace: {
type: OptionType.COMPONENT,
description: "",
component: () =>
<>
<TextReplaceString />
<TextReplaceRegex />
</>
},
});
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
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
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/>;
react's createComponent func
except it does some funny shit
(0,[react].jsx)(ComponentType,{props},[children])
ye
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
that's what the chrome debugger is for
what
you'd have to search by props
or by code in the component
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
i.. actually don't know
all i can think of is the vencord common components
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
I am struggling to try and import a component from this as a test
not quite, the syntax is
(0,r.jsxs)(Component, { foo: bar, children: [] }, "key")```
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
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?
wdym
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
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
can I put anything into the name bit of waitForComponent or do I need to find that somewhere in the code
you can't use waitForComponent
it's an internal vencord function that simply wraps waitFor
the name is for debugging purposes
the only example that I have gotten for finding a component is the internal vencord one
const ColorPicker = LazyComponent(() => findByCode("whatever"));
<ColorPicker />
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
that should just be @webpack no?
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
yes
do not include the A
that's a minified variable name that will break
.Messages.PICK_A_COLOR,
this might work
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
it's a class
wait it's not
are you sure it's exported
Can I somehow add an export using patches
yes but don't
how do I access it then
I'll get on pc in a bit and help you
thanks
[g]ood [b]oy
L
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
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)
java
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
?managed
**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);
}
}
thank
boop
if you can just get the component imported I can take it from there
no rush, just ping me when you do
component is X, found in user profile customization
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
can someone make this gradient thing for free?
i know but i still want it even spoofed
too much effort
i thing i can make it using a theme
is there a way to add plugin from better discord
no
i have source code can someone add it to plugins thing
no
damm
check if its here https://github.com/Vendicated/Vencord/discussions/categories/ideas
if not, make a post on there
is this intentional
yes
type couldn't be any longer than ApplicationCommandOptionType 
is there any sort of pnpm watch for web instead of the actual client?
pnpm buildWeb --watch
ty
oh for subcommands
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
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)
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?
}
});
if u do pnpm build --watch u get a tab in ur settings called "Patch Helper"
ohh
and u can test ur patches there but basically
that's cool
each patch changes discord source code
I just want to basically change the content of the codeblock, but I'm afraid it will mess with the highlight
yeah i got that
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
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
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
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
and like, it'll freeze discord at the line of code u set the breakpoint at, u can hover over variables and if they're defined at that point it'll show u the contents
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
yeah
i think it'd be alphabetical
alright
so my patch would just fail and my plugin wouldnt load
oh i see
mostly its about being mindful about ur patches
yeah
only patch thats necessary
for u, u just need to replace the code content before the code gets rendered
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`
ok do webpackRequire.c
just do webpackRequire.c and you will see what happens

its becuase Im using replugged?
replugged messes with the webpack chunk stuff
probably
grr
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
if I were to make my own discord client mod, would I have to patch webpack (like vencord did)
you would yes
whats the reason for it tho
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
oh
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
(basically webpack chunks make it possible for mods to work in the first place)
oh
(without them you'd have to jump through massive hoops to patch standard discord code)
as of 22-03-2023 10:49 UTC i am still too noob to understand it ๐ฅบ
use console?
well but how would i make that automatically tho, thats not possible via console right
ah
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.
so you are making a plug-in?
what language are you using?
plugins can only be written in JS/TS ๐
ik
they are basically the same language but you canโt use them with the same application
pretty sure you can use them interchangably, just that TS needs to be compiled to js (which you need to do anyway?)
if it is that simple why arent we using better dc plug-ins to make plugins for vencord
i just realized how rude that sounded
so i fixed it
you are very confused
just because its the same language doesnt mean you can just drop a betterdiscord plugin in to vencord
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
that doesnt help with the betterdiscord/vencord compatibility
yes
JS ๐
TS is just JS but better
still "compiles" to JS tho
typescript is just JavaScript but with types
he said they were interchangeable
yeah as in the languages
this is all confusing
fuck now I'm wondering if I'm skilled enough to make bdcompat
someone already made a layer i think
i dont know how mature it is
but they got zerespluginlib working on vencord afaik
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
horror
i will make bdcompat but better
go for it xd
bd as in better discord?
yeah
bdfvccl
okay uhh im on laptop now and i have no idea what the BdApi has https://cdn.discordapp.com/emojis/1060919735560196147.webp?size=48&quality=lossless
time to do some investigation
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?
it makes sense tbf
C code doing the same would look very similar
this is doing extremely hacky stuff 
no but you can opt out of cache with fetch
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?
we already have flux subscriptions
rust ๐คค
FluxDispatcher.subscribe("EVENT_NAME", someHandler)
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
cool
i should really setup a TS environment or something because currently im just screwing around in console ๐ฅด
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
that is correct, you cannot import local files with vencord
tbh i feel that Vencord's api has more tools then BdApi so I guess you could pull it off pretty fast
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
monkeytype is at https://monkeytype.com
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)
a
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.
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
its a experimental feature and theyll fix it later along the line
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
dont pnpm update?
pnpm i
thanks
alot
wait so i just pnpm watch and then reload discord?
im prob missing something
pnpm build --watch
and then yea refresh discord
somehow doesnt work for me
its just not appearing in my Plugins tab
in pnpm build --watch?
no in discord
not anything i could find
there is no patch and i tested their file and it works fine 
no because my first build was like 20 minutes ago
eh i gotta work maybe if ur still having issues u can screenshare and i can try and see whats happending
you didnt pnpm inject
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
which si why authors empty rn
ya i swa
whatโs this for
nookies
?
eh nothing lol
Build Archive for https://github.com/Vendicated/Vencord, not much to see here - builds/plugins.json at main ยท Vencord/builds
27kb wtf
anyway lewi u can now fetch that file for plugins page
in fact lemme do that rn
Done! 
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
that is not a very good idea, they wouldn't get any updates and eventually things would start to break because of it
so how do I manage it then, so updates are received but this plugin also gets compiled properly
what changes did you make that you want to share?
I just added a new slash command just like /woke or /echo
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
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
well I don't feel like I have created anything here
might have to ask the dev of this plugin to add this probably๐ค
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
yeah then they will also need to install node and stuff
you could do that, yeah, the more commands plugin is kinda made for all those random small commands like that
๐
@opal fern sorry for the ping but I wanted to know if this could be added to your plugin๐
Yeah go ahead
how can i open a link externally from a plugin
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
You can just make a PR lol
what's a PR?๐
pull request
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
I don't feel like I have done anything here just copied the structure and added a simple function
I don't want the credit I just want the feature for me and my friend (who is not a programmer)



