#🧩-plugin-development

1 messages · Page 69 of 1

vast karma
#

Oh, so discord fucked something up again?

flint bronze
#

Yes

#

oh that patch I just made will genuinely take time getting used to

vast karma
#

?

flint bronze
#

I removed the boosting progress bar blobcatcozy

#

At this point I need to ask

vast karma
#

Ah yeah

#

I've left it so far since it's not super in your face like the other things are

flint bronze
#

Is there any way to glob all the files in a directory and import them somehow without writing my own esbuild script?

vast karma
#

Not that I know, or I'd have used it for my meta loader

flint bronze
#

How does that work?

flint bronze
#

is that cjs require hollow

vast karma
#

Better than needing multiple lines per plugin

hushed loom
turbid spruce
#

this might not be the right channel but why does vencord yoink itself anytime i try to connect to a websocket that isnt localhost?

#

for clarity by yoink i mean like it doesnt load until i rebuild it without the websocket that isnt localhost

#

its even on the local network?

pulsar zodiac
#

I'm inclined to get channels to pop open in a row like threads do but multiplied, kinda hate react though so I wouldn't mind some strategic advice from smart people

vast karma
#

Consider unhating react

fallow minnow
#

hi there,
i want to create my own plugin (not necesarly publish it) but i'm not really familiar with vencord and i don't find how and where i can add my code.
if someone can give me a quick resume of how i can manage to do that, it will be really cool !

tropic ice
fallow minnow
#

okay i check it thanks !

humble tulip
fallow minnow
fallow minnow
#

okay i made it thanks for all, do you think it's possible to add some animation while typing like a little fade in. i add some for loading the chat when you switch between and when you send a new chat but i can't make one for typing

reef patrol
#

It's like F6 to toggle all active plugins on/off and F7 for the theme iirc

vast karma
#

Plugins can't be toggled without reloading

reef patrol
vast karma
#

Which would require adding such a mode to every plugin

reef patrol
#

Fair, but this is the source code

#

might give any idea

vast karma
#

Yep, it does .stop() on every plugin (except itself)

#

Which is not possible for most vencord plugins without restarting

reef patrol
#

Fair enough

#

But what if we could implement hot reloading for the plugins?

#

Probably a massive pain tho

vast karma
#

That would require changing every patch in every plugin to have a play-dead mode

reef patrol
#

Yeah

oak sundial
#

which is not worth the effort to maintian because y'all are in servers that do not like client mods

#

just use a different client if you must screenshot something on your client but don't want to risk anything

reef patrol
oak sundial
#

"almost all" none of the ones i'm in care

reef patrol
#

You hit the server jackpot ig

vast karma
#

I've never met anyone who gives a single fuck

reef patrol
#

They don't give a fuck until some nosy snitch decides to report

oak sundial
#

the only times i've seen any server actually care is because people are going around and reposting deleting messages

reef patrol
#

It wasn't even a big deal, the whoreacted plugin

#

but the server staff weren't too strict about it, so it's whatever

craggy latch
#

Hey quick question, making a plugin and wanted to know how can i put something below the status of friends in the friend list page?

I know that the sortFriendRequests plugin shows the date the request was received below them by finding .Messages.FRIEND_REQUEST_CANCEL (you can see the result on the first image and second image) but I think it replaces the cancel with that, and what I want is to target the status below the username (look at last picture) and add the new line below.

I basically wanna put the date when a friend added you below the status.

craggy latch
#

struggling so much

trail ginkgo
#

the module for that component is 170245 but i have no idea how you'd write a find string for this module lol

trail ginkgo
#

nvm just found out finds can be regex patterns

#
find: String.raw`/usernameClass:[^,]{0,50},discriminatorClass:[^,]{0,50},showAccountIdentifier:/`,
replacement: {
    match: /(?<=className:\i\.subtext,children:)\i,
    replace: "$self.renderSubtext($&)",
},
craggy latch
#

Tried, but it's not showing

#

Here is the code so far

/*
 * 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 { definePluginSettings } from "@api/Settings";
import { Flex } from "@components/Flex";
import { Devs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types";
import { RelationshipStore } from "@webpack/common";
import { User } from "discord-types/general";

const settings = definePluginSettings({
    showDates: {
        type: OptionType.BOOLEAN,
        description: "Show dates on friend list",
        default: true,
        restartNeeded: true
    }
});

export default definePlugin({
    name: "SortFriendList",
    authors: [gii],
    description: "Sorts friends by date of addition",
    settings,

    patches: [{
        find: "getRelationshipCounts(){",
        replacement: {
            match: /\}\)\.sortBy\((.+?)\)\.value\(\)/,
            replace: "}).sortBy(row => $self.wrapSort(($1), row)).value()"
        }
    }, {
        find: String.raw`/usernameClass:[^,]{0,50},discriminatorClass:[^,]{0,50},showAccountIdentifier:/`,
        replacement: {
            predicate: () => settings.store.showDates,
            match: /subText:(\i)(?<=user:(\i).+?)/,
            replace: (_, subtext, user) => `subText:$self.makeSubtext(${subtext},${user})`
        }
    }],

    wrapSort(comparator: Function, row: any) {
        return row.type === 3 || row.type === 4
            ? -this.getSince(row.user)
            : comparator(row);
    },

    getSince(user: User) {
        return new Date(RelationshipStore.getSince(user.id));
    },

    makeSubtext(text: string, user: User) {
        const since = this.getSince(user);
        return (
            <Flex flexDirection="column" style={{ gap: 0, flexWrap: "wrap", lineHeight: "0.9rem" }}>
                <span>{text}</span>
                {!isNaN(since.getTime()) && <span>Received &mdash; {since.toDateString()}</span>}
            </Flex>
        );
    }
});

I need to go sleep now as it's 4am, but if someone could share some wisdom on why it's not working, I will love you

iron epoch
#

I have an issue where the component is not updating when its state is changing in a the onChange handler.
what i am trying to do is modify the text value and force update but i am failing.
module number: 287746. responsible for rendering channels text area

#

oh wow, the screenshots are depressing. thanks discord

craggy latch
vast karma
#

find: String.raw`/../` what

craggy latch
#

It works, allows to use regex

vast karma
#

I very doubt that

#

That would search for a discord module containing that regex

#

Which probably doesn't exist

#

To use a regex, you'd use a regex

craggy latch
#

let me try without it

vast karma
#

Yes, that finds discord's regex for parsing code blocks

#

It does not run that regex over discord's code

craggy latch
#
/*
 * 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 { definePluginSettings } from "@api/Settings";
import { Devs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types";
import { RelationshipStore } from "@webpack/common";
import { User } from "discord-types/general";

const settings = definePluginSettings({
    showDates: {
        type: OptionType.BOOLEAN,
        description: "Show dates on friend list",
        default: true,
        restartNeeded: true
    }
});

export default definePlugin({
    name: "SortFriendList",
    authors: [Devs.Megu],
    description: "Sorts friends by date of addition",
    settings,

    patches: [{
        find: "getRelationshipCounts(){",
        replacement: {
            match: /\}\)\.sortBy\((.+?)\)\.value\(\)/,
            replace: "}).sortBy(row => $self.wrapSort(($1), row)).value()"
        }
    }, {
        find: /usernameClass:[^,]{0,50},discriminatorClass:[^,]{0,50},showAccountIdentifier:/,
        replacement: {
            predicate: () => settings.store.showDates,
            match: /(?<=className:\i\.subtext,children:)\i/,
                replace: "[$&, $self.makeSubtext(arguments[0])]"
        }
    }],

    wrapSort(comparator: Function, row: any) {
        return row.type === 3 || row.type === 4
            ? -this.getSince(row.user)
            : comparator(row);
    },

    getSince(user: User) {
        return new Date(RelationshipStore.getSince(user.id));
    },

    makeSubtext({ user }: { user: User; }) {
        const since = this.getSince(user);
        if (isNaN(since.getTime())) {
            return null;
        }

        return (
            <span>Added &mdash; {since.toDateString()}</span>
        );
    },
});
bronze dove
oak sundial
#

pending 2661
wtf??

bronze dove
#

150k followers on connected twitter crazy

craggy latch
#

I tried
find: /usernameClass:[^,]{0,50},discriminatorClass:[^,]{0,50},showAccountIdentifier:/
find: ".discordTag,{"

#

both of which result in it being added to requests

bronze dove
#

i mean i would hope so considering those finds match the same module

craggy latch
#

How do I only match the friend list one

bronze dove
craggy latch
#

Yeah so, I'ts getting both right

bronze dove
#

go thru where it is used and search thru them and find something that would indicate its the friend list

craggy latch
#

Wouldn't these indicate that

#

requests have the accept and deny

bronze dove
craggy latch
#

Isnt it the same element?

#

Like it's the friend list thing

#

The friend request plugin for example targets the cancel button

#

and it gets it to look like this

bronze dove
#

wait so what do you want to do

craggy latch
bronze dove
#

in only this tab?

craggy latch
#

only online and all yes

#

pending is for the friend request plugin

cedar olive
craggy latch
#

yup

bronze dove
#

701861 patch this

cedar olive
#

that doesn't look like the right thing

#

LOL

craggy latch
#

oh

cedar olive
#

I wrote that speaking something at the same time

#

it didnt work

craggy latch
#

My plan was to also add extra controls to sort by Name/Status/Add Date
Would make purging a friend list easier, I've got so many people added from a long time and going one by one is annoying lol

cedar olive
#

170245

#

this is what you want

#

a should be this

#

and then you can modify it to add something or whatever u want

bronze dove
bronze dove
#

but they diddnt want to do that because it applied to other places

cedar olive
#

oh

#

LOL

#

there's no much escape you can insert something inside that one specific place without patching that module

#

unless u insert something in the sides

#

which is then in another module of course

humble tulip
#

Could you just look at the other children and check for the pending request subtext?

cedar olive
#

u just need to patch where subtext is beign set actually lol

humble tulip
craggy latch
humble tulip
#
{
    find: "peopleListItemRef",
    replacement: {
        predicate: () => settings.store.showDates,
        match: /(?<=children:.*user:(\i),.*subText:).+?(?=,hovered:\i,showAccountIdentifier)/,
        replace: "$self.makeSubtext($1, $&)"
    }
}```
```ts
makeSubtext(user: User, origSubtext: any) {
    const since = this.getSince(user);
    if (isNaN(since.getTime())) {
        return null;
    }

    return (
        <>
            {origSubtext}
            <span>Added &mdash; {since.toDateString()}</span>
        </>
    );
}
#

You could probably make the match better

craggy latch
#

Tweaked and now it's working great;
But the sorting by date is not and don't get exactly why:

{
            find: "getRelationshipCounts(){",
            replacement: {
                match: /\}\)\.sortBy\((.+?)\)\.value\(\)/,
                replace: "}).sortBy(row => $self.wrapSort(($1), row)).value()"
            }
        },```
#

By the way how exactly do I send the plugin to be added to the list of plugins so others can use it?

normal wagon
#

and implement it for blocked, and pending too

#

Blocked at this time friend request received at this time

craggy latch
normal wagon
craggy latch
#

huh

#

Like this? @normal wagon

normal wagon
#

nope that’s for your online friends i’m talking about the original plugin that you modified

craggy latch
#

im using the request's format

#

just with the icon added

normal wagon
#

oh

#

there’s no way to format the time too?

craggy latch
#

Format as in

normal wagon
#

sorry format the exact time in which the friend was added

craggy latch
normal wagon
#

if you can it’s not necessary it’s just nice to know exactly when someone added you

craggy latch
#

It's how it's formatted everywhere

craggy latch
normal wagon
craggy latch
#

I'm unsure how even if i wanted

#

I did make it smaller which i think looks better

normal wagon
#

i guess everyone has their own preference

craggy latch
#

Talking about text and icon size, not formatting

normal wagon
#

yep you’re right

#

formatting is different

craggy latch
#

ideally it would just be a timestamp tbh

#

so u could hover and get more info

#

If you can figure out how to make this "{since.toDateString()}" the way you think it's better then send it over

craggy latch
normal wagon
#

trying to make a plugin, to stop discord from locking scroll wheel when pressing keys like Shift, CTRL, and Tab i've tried removing the event listener for keydown, and other stuff but that doesn't seem to work

#

i cant scroll up when holding down those keys

lapis fable
#

Hello uhm how do I run a function for every message when It's rendered/updated (when its loaded, when its edited, when its send, etc.) and get the element that the message is

lapis fable
# hushed loom https://xyproblem.info/

Alright-... I'm trying to make something where if you hover text parts of a message that are tone indicators (/j, /srs, etc.) it shows you the full meaning of it in a little tooltip. I have tried going through other plugins and looking what they do but most of them use patches that I cant apply for what I wanna do

#

The actual hovering part isnt my problem though, Im struggling with selecting message elements in the first place

hushed loom
#

do you know what patches are

lapis fable
#

i have a vague understanding of them but i have no idea how to implement them myself

hushed loom
#

what patches do is find a module by using a string that is unique to that module

#

then change the code with regex

lapis fable
#

alr-

hushed loom
#

you want to enable the react dev tools in vencord settings

lapis fable
#

ok

hushed loom
#

and you can patch things like components to add/remove things

lapis fable
#

and how do i patch code

#

specifically in a way that i can run something for each message?

hushed loom
#

you might want to use a message accessory

lapis fable
#

a what?

hushed loom
#

its what plugins like translate

#

use

lapis fable
#

hmm

#

i want it to be like seamless

#

so the messages already have tooltips for /j to moment theyre rendered

#

so you just have to hover them

#

i dont want users to need to press a button first

#

i want it to act more like how discords markdown acts

humble tulip
lapis fable
#

alr thx ill look at it

lapis fable
#

Ok so Im creating a markdown rule now but it has a patch conflict with one of my friend's markdown plugin

hushed loom
#

send the two patches

lapis fable
#
        {
            find: "parseToAST:",
            replacement: {
                match: /(parse[\w]*):(.*?)\((\i)\),/g,
                replace: `$1:$2({...$3,${patch}}),`,
            },
        },

theyre both the same but we dont know how to not make them the same

hushed loom
#

okay...
first of all
what is the contents of patch

lapis fable
#

my friends one:

Patch: wiggly:$self.rulesByName["wiggly"],highlighted:$self.rulesByName["highlighted"],spinning:$self.rulesByName["spinning"],glowing:$self.rulesByName["glowing"],rainbow:$self.rulesByName["rainbow"],blinking:$self.rulesByName["blinking"],scaling:$self.rulesByName["scaling"],bouncing:$self.rulesByName["bouncing"],html:$self.rulesByName["html"],slam:$self.rulesByName["slam"],cursive:$self.rulesByName["cursive"],

#

mine:

Tone Indicator Patch: jIndicator:$self.toneIndicatorsByName["jIndicator"],hjIndicator:$self.toneIndicatorsByName["hjIndicator"],sIndicator:$self.toneIndicatorsByName["sIndicator"],genIndicator:$self.toneIndicatorsByName["genIndicator"],gIndicator:$self.toneIndicatorsByName["gIndicator"],srsIndicator:$self.toneIndicatorsByName["srsIndicator"],nsrsIndicator:$self.toneIndicatorsByName["nsrsIndicator"],posIndicator:$self.toneIndicatorsByName["posIndicator"],pcIndicator:$self.toneIndicatorsByName["pcIndicator"],neuIndicator:$self.toneIndicatorsByName["neuIndicator"],negIndicator:$self.toneIndicatorsByName["negIndicator"],ncIndicator:$self.toneIndicatorsByName["ncIndicator"],pIndicator:$self.toneIndicatorsByName["pIndicator"],rIndicator:$self.toneIndicatorsByName["rIndicator"],cIndicator:$self.toneIndicatorsByName["cIndicator"],lIndicator:$self.toneIndicatorsByName["lIndicator"],lyIndicator:$self.toneIndicatorsByName["lyIndicator"],lhIndicator:$self.toneIndicatorsByName["lhIndicator"],nmIndicator:$self.toneIndicatorsByName["nmIndicator"],luIndicator:$self.toneIndicatorsByName["luIndicator"],nbhIndicator:$self.toneIndicatorsByName["nbhIndicator"],nsbIndicator:$self.toneIndicatorsByName["nsbIndicator"],sxIndicator:$self.toneIndicatorsByName["sxIndicator"],xIndicator:$self.toneIndicatorsByName["xIndicator"],nsxIndicator:$self.toneIndicatorsByName["nsxIndicator"],nxIndicator:$self.toneIndicatorsByName["nxIndicator"],rhIndicator:$self.toneIndicatorsByName["rhIndicator"],rtIndicator:$self.toneIndicatorsByName["rtIndicator"],tIndicator:$self.toneIndicatorsByName["tIndicator"],ijIndicator:$self.toneIndicatorsByName["ijIndicator"],mIndicator:$self.toneIndicatorsByName["mIndicator"],liIndicator:$self.toneIndicatorsByName["liIndicator"],hypIndicator:$self.toneIndicatorsByName["hypIndicator"],fIndicator:$self.toneIndicatorsByName["fIndicator"],thIndicator:$self.toneIndicatorsByName["thIndicator"],cbIndicator:$self.toneIndicatorsByName["cbIndicator"],

hushed loom
#

@lapis fable unrelated to the patches colliding

#

use a spread operator

#

and a function called with self

lapis fable
#

every time i try to use spread operators it just kinda screams at me (vscode)

lapis fable
#

alr lemme reproduce it

#

ok but where would i put them

hushed loom
#

what does this patch even do anyway

#

what is the goal of it

lapis fable
#

it just inserts the markdown rules

hushed loom
#

do you really need a separate rule for each one

#

just make one for anything that could be a tone tag, then filter them out later in your own code

lapis fable
#

uhhh

#

true

inner monolith
#

where do i see the plugins that break after discord updates?

#

oh nevermind it's the channel under this one i'm stupid

#

wait no that's general changes

flint bronze
inner monolith
#

okay thanks :D

flint bronze
#

it's a webhook

#

TIL you can search for has:forward

lapis fable
#

but now the patch isnt working

hushed loom
#

send patch

lapis fable
#
patches: [
        {
            find: "parseToAST:",
            replacement: {
                match: /(parse[\w]*):(.*?)\((\i)\),/g,
                replace: "$1:$2({...$3,toneIndicator:$self.getToneIndicator,}),",
            },
        },
    ],
hushed loom
#

@lapis fable upload your complete plugin code

lapis fable
#
/*
 * Vencord, a Discord client mod
 * Copyright (c) 2024 Vendicated and contributors
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

import { Devs } from "@utils/constants";
import definePlugin from "@utils/types";
import { React } from "webpack/common/react";

const test = (data, output) => {
    return <span>{output(data.content)} skiibid</span>;
};

/* function toneIndicator(short: string[], long: string, sourceDisplay: string, source: string) {
    return {
        short: short,
        long: long,
        sourceDisplay: sourceDisplay,
        source: source
    };
}

const ti = ["toneindicators.carrd.co", "https://toneindicators.carrd.co/"];
const toneIndicators = [
    toneIndicator(["j"], "joking", ti[0], ti[1]),
    toneIndicator(["hj"], "half-joking", ti[0], ti[1]),
    toneIndicator(["s"], "sarcastic", ti[0], ti[1]),
    toneIndicator(["gen", "g"], "genuine", ti[0], ti[1]),
    toneIndicator(["srs"], "serious", ti[0], ti[1]),
    toneIndicator(["nsrs"], "non-serious", ti[0], ti[1]),
    toneIndicator(["pos", "pc"], "positive connotation", ti[0], ti[1]),
    toneIndicator(["neu"], "neutral connotation", ti[0], ti[1]),
    toneIndicator(["neg", "nc"], "negative connotation", ti[0], ti[1]),
    toneIndicator(["p"], "platonic", ti[0], ti[1]),
    toneIndicator(["r"], "romantic", ti[0], ti[1]),
    toneIndicator(["c"], "copypasta", ti[0], ti[1]),
    toneIndicator(["l", "ly"], "lyrics", ti[0], ti[1]),
    toneIndicator(["lh"], "light-hearted", ti[0], ti[1]),
    toneIndicator(["nm"], "not mad", ti[0], ti[1]),
    toneIndicator(["lu"], "a little upset", ti[0], ti[1]),
    toneIndicator(["nbh"], "vagueposting/venting directed at **nobody here**", ti[0], ti[1]),
    toneIndicator(["nsb"], "not subtweeting", ti[0], ti[1]),
    toneIndicator(["sx", "x"], "sexual intent", ti[0], ti[1]), // brother ew
    toneIndicator(["nsx", "nx"], "non-sexual intent", ti[0], ti[1]),
    toneIndicator(["rh", "rt"], "rhetorical question", ti[0], ti[1]),
    toneIndicator(["t"], "teasing", ti[0], ti[1]),
    toneIndicator(["ij"], "inside joke", ti[0], ti[1]),
    toneIndicator(["m"], "metaphorically", ti[0], ti[1]),
    toneIndicator(["li"], "literally", ti[0], ti[1]),
    toneIndicator(["hyp"], "hyperbole", ti[0], ti[1]),
    toneIndicator(["f"], "fake", ti[0], ti[1]),
    toneIndicator(["th"], "threat", ti[0], ti[1]),
    toneIndicator(["cb"], "clickbait", ti[0], ti[1])
]; */

export default definePlugin({
    name: "ToneIndicators",
    description: "Adds descriptions when hovering over tone indicators.",
    authors: [Devs.Jaegerwald, Devs.Zoid], // crediting zoid cause this is based off moremarkdown

    patches: [
        {
            find: "parseToAST:",
            replacement: {
                match: /(parse[\w]*):(.*?)\((\i)\),/g,
                replace: "$1:$2({...$3,toneIndicator:$self.getToneIndicator,}),",
            },
        },
    ],

    getToneIndicator: {
        order: 24,
        match: source => { console.warn("i swear to god if this warn doesnt appear in the console even though this should run for every message"); return source.match(/[\s\S]*/); },
        parse: (capture, transform, state) => ({
            content: transform(capture[1], state)
        }),
        react: (data, output) => test(data, output),
    },
});
dull magnet
#

(that plugin won't be accepted btw if that matters)

lapis fable
swift delta
#

this is just

lapis fable
#

wait what

flint bronze
#

which is horribly broken

hushed loom
lapis fable
#

woah

hushed loom
lapis fable
#

thx so much lol

flint bronze
#

i can barely understand with all the placeholders

hushed loom
flint bronze
#

Big push to talk button

#

Did I cook?

cedar olive
#

why

#

push to talk feels useless if you need to press a button in the app

flint bronze
#

i know it's stupid but I want to remove the keyboard shortcut if it's locked to some dumb modifier

#

well

#

I have it mapped to a key that is hard to press (on a different layer)

#

ideally I want to hook it up more like a video conferencing solution where you can PTT with just space bar on a voice page

#

idk why that isnt a thing in Discord

#

this could be useful on Vendroid (for the 2 people who use it)

normal wagon
#

i really think you could expand that edit you did on voice utilities by adding a button to manage rather than right clicking context menu

#

like Mute all in Call (Locally), Mute all Soundboards, Disable all Cameras, and the other stuff i guess maybe exclusions too that’d be way more convenient than the PTT

swift delta
hoary pilot
flint bronze
#

LMAO

flint bronze
#

?remindme 2d emote cloner bulk import from other server

fathom pivotBOT
#

Alright @flint bronze, in 2 days: emote cloner bulk import from other server

hushed loom
#

also ratelimit

#

(downloading zip, not uploading them)

flint bronze
#

I know

balmy sky
#

I'm trying to send a message replying to something else (just text content, no attachments or funky stuff), and iirc someone told me the only way is to do something similar to this
pretty much everything is fine, but i want to check which flags i should pass (more specifically if it varies because a voice message is being sent in the reference)

GitHub

The cutest Discord client mod. Contribute to Vendicated/Vencord development by creating an account on GitHub.

oak sundial
#

you only have to send the content and message reference

#

nonce is optionally but you can do it to keep it inline with what the rest of the client does

rustic ivy
#

Hello! I have a quick question to plugins. Is there a way to detect when the User exits the config menu of the Plugin? Like when the "Save & Exit" button is pressed? And that this action can be used to execute a function?

humble tulip
#

I believe the onChange function of each setting is executed when the save button is clicked

rustic ivy
#

How would i write that in Code? Could you give me an Example?

humble tulip
#

I'm not at my PC right now so I'm speaking from memory and could just be completely wrong but if you had

someSetting:{
    type: STRING,
    ...
    onChange: newValue => {
        // do something with the new value of someSetting
    }
}
#

I think onChange runs on save

rustic ivy
#

Thank you very much!

#

Yep it works thanks a lot!!

humble tulip
#

np thumb

green vessel
#

Hi

#

I've just found something that is Not used

#

And that some people will use

#

There is this data in group calls

{
//...
    "call": {
        "participants": [
            "806442568564604968",
            "881574130573508748",
            "862738768183296061"
        ],
        "endedTimestamp": null,
        "duration": null
    },
//...
}
#

There should be some icon next to call

green vessel
#

(On call that ended)

iron epoch
oak sundial
#

Making view as role available for everyone is causing me pain because of course it is this is discord

#

it changes the permissionstore depending on what roles you are viewing as, which is annoying because you don't actually have access to those channels

#

so i can't just steal patches from ShowHiddenChannels

#

if it only fucks with the PermissionStore maybe I can get around it by calculating the permissions manually but i'd rather not do that

#

i thought this was gonna be a small little silly plugin with a couple patches but i don't get that luxury

iron epoch
proud parrotBOT
# dull magnet https://github.com/Vendicated/Vencord/blob/main/src/plugins/permissionsViewer/co...

RolesAndUsersPermissions.tsx: Lines 225-246

{(settings.store as any).unsafeViewAsRole && (
    <Menu.MenuItem
        id={cl("view-as-role")}
        label={i18n.Messages.VIEW_AS_ROLE}
        action={() => {
            const role = GuildStore.getRole(guild.id, roleId);
            if (!role) return;

            onClose();
            FluxDispatcher.dispatch({
                type: "IMPERSONATE_UPDATE",
                guildId: guild.id,
                data: {
                    type: "ROLES",
                    roles: {
                        [roleId]: role
                    }
                }
            });
        }}
    />
)}
oak sundial
#

mm

#

i thought making a version of this that doesn't send invalid requests would be easier

#

😔

#

Its just some big task that i thought would've been way smaller, basically its looking like stealing basically every ShowHiddenChannels patch and modifying the check to manually calculate permissions.

And this all assumes that it only messes with PermissionStore and not GuildStore and ChannelStore

iron epoch
oak sundial
#

Calculating permissions manually doesn't seem that bad (and looks like the only option) and duplicating ShowHiddenChannels patches is annoying because well... they'll be 2 of them!

#

(and this is stuff I only have discovered yet, maybe theres other stuff thats also annoying af that needs patching, like accessing automod rules and shit)

#

This just isn't worth it 😔

iron epoch
oak sundial
#

As in you can actually view server as role without permissions to do so normally? yes

iron epoch
#

because you can have shc as a dependencie

oak sundial
#

Well I would need to duplicate them because not every user would have both ShowHiddenChannels and this plugin on & ShowHiddenChannels isn't even enough because it relies on the PermissionStore (which discord changes with this feature)

#

and this function would also need changing in the copied version to manually calculate the permissions instead

#

And like I said before this doesn't count like the guild settings menus that you shouldn't be able to access normally without permissions (expressions, automod etc etc)

#

Its a big project for something that would not make it into vencord

normal wagon
#

is there a documentation on the functionality of different stuff being imported like for example define plugins settings all the attributes?

iron epoch
normal wagon
#

and i understand patches a little bit but how would i get regex or whatever because there’s a certain replacement pattern

#

i have an understanding of how to find stuff but replacement there’s a certain pattern you need

#

i meant like i wanna learn regex. where would be a good place for that?

iron epoch
#

I used to look at this when starting, reading "Contributing a Plugin" section. @normal wagon throwing it here because maybe others will see it useful

oak sundial
#

thats fine until you realise that one of the functions has to be modified (unless that can also be done) and not all patches need to be used

humble tulip
#

I'm kidding anyway but I think it would point $self to your plugin anyway so you'd have to implement any functions SHC does

#

If that line would even work in the first place

green vessel
#

I will try making it myself

empty adder
#

hello i added a command and i cant use it (doesnt appear) although ive rebuilt and reinjected vencord, the plugin is enabled

#

nvm it just appeared somehow 😭

#

okay so it only works on servers

#

and i want it to be usable everywhere

#

okay i got it 🔥

iron epoch
#

?

#

ghost pings

fathom pivotBOT
#

@flint bronze, <t:1729400994:R>: emote cloner bulk import from other server

green vessel
#

do you guys know how i could add users profile pictures next to messages

vast karma
#

What do you mean

#

It's already there

flint bronze
#

clueless?

flint bronze
#

no im not

#

this is not worth it

#

i would end up just wanting to refactor the mess that is the existing plugin

vast karma
#

Do

flint bronze
#

With a few extra features

vast karma
#

I don't care about that plugin

#

But I like seeing people doing probably unnecessary work

flint bronze
#

"probably unnecessary" soft-fork with some 20 original tiny plugins

hushed loom
flint bronze
#

Also all of these PRs blobcatcozy

flint bronze
#

oh i see

#

you nuked it already

#

since a month ago

hushed loom
balmy sky
#

Is this not just basic react

tulip notch
#

Hello, I am learning the vencord api by looking at other plugins, however is there any definitive documentation of the vencord api I can read?

swift delta
tulip notch
#
       >       3 │ import definePlugin, { OptionType } from "@vencord/types/utils/types";
       >         ╵                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       >
       >   You can mark the path "@vencord/types/utils/types" as external to exclude it from the bundle, which will remove this error.
       >
       > 1 error
#

How do i fix this?

#

I assumed vencord used webpack so i marked it as external under webpack.config.js but that didnt work

humble tulip
#

It should just be "@utils/types"

tulip notch
#

I had that, nodejs kept on giving me errors

#

as it isnt a package

#

is there any way to fix that error?

#

like link vencord and @utils

humble tulip
#

It should be like this in your tsconfig.json

tulip notch
#

Wait no

#

in node_modules/@vencord/types/utils/types

humble tulip
#

I don't think vencord should be in your node modules folder, these are just pointing to directories in the /src folder

#

Unless this is something related to vesktop or something? I'm not familiar with that

tulip notch
#

I am developing this outside of the vencord directory

#

uhhh, I am using something called nixcord which manages plugins declaratively, so i cant develop inside the files themselfs

#

But anyways i got it working so thanks

humble tulip
#

I see

tulip notch
#
       >       5 │ ...chCallback, removeContextMenuPatch } from "@utils/api/ContextMenu";
       >         ╵                                              ~~~~~~~~~~~~~~~~~~~~~~~~
       >
       >   You can mark the path "@utils/api/ContextMenu" as external to exclude it from the bundle, which will remove this error.
       >
#
    "compilerOptions": {
        "paths": {
            "@utils/types/*": ["./node_modules/@vencord/types/utils/*"],
            "@utils/api/*": ["./node_modules/@vencord/types/api/*"],
            "@utils/api/ContextMenu/*": ["./node_modules/@vencord/types/api/ContextMenu/*"],
        }
    },
}```
#

Sorry for being back so soon but I tried like 5 different combinations

#

Why is it saying contextMenu is not excluded

humble tulip
#

Is it just the /* at the end?

#

This is outside my wheelhouse so just a guess

tulip notch
#

same error

humble tulip
#

"@utils/api/ContextMenu" doesn't have a slash at the end though so it doesn't seem like that'd pick it up

tulip notch
#

Cannot find module '@utils/api/ContextMenu/' or its corresponding type declarations.

humble tulip
#

Just to clarify from the beginning, have you done
in your code: ... from "@utils/api/ContextMenu";
in your config: "@utils/api/ContextMenu": ["./node_modules/@vencord/types/api/ContextMenu"],

tulip notch
#

I tried that

humble tulip
#

I would've though "@utils/api/*" would've picked it up anyway tbf but yeah I don't know enough about this then, sorry

tulip notch
#

Oof

tulip notch
humble tulip
#

Oh your paths for /api/ have /types/ in them, that shouldn't be there, right?

tulip notch
#

For the @utils path it doesn't matter

#

For @vesktop I need to get the correct path to context menu which I did

#
       >       5 │ ...chCallback, removeContextMenuPatch } from "@utils/api/ContextMenu";
       >         ╵                                              ~~~~~~~~~~~~~~~~~~~~~~~~
       >
       >   You can mark the path "@utils/api/ContextMenu" as external to exclude it from the bundle, which will remove this error.
       >```
#
    "compilerOptions": {
        "paths": {
            "@utils/types/*": ["./node_modules/@vencord/types/utils/*"],
            "@utils/api/*": ["./node_modules/@vencord/types/api/*"],
            "@utils/api/ContextMenu/*": ["./node_modules/@vencord/types/api/ContextMenu/*"],
        }
    },
}```
#

Anyone able to help?

dull magnet
#

bruh ask for help whoever made that tool instead of asking here

tulip notch
#

?
I read both of those pages. It didnt tell me how to fox my issue unfortunately. Also I don't know who made that tool, I don't know if discord or vesktop is the one to use it. I assumed it was tsconfig that I had to edit but maybe I'm doing something wrong?

dull magnet
#

follow the docs and you will have no problems

tulip notch
#

The maximum the docs mention is:

export default definePlugin({

name: "MyCoolPlugin",

description: "I am very cute!",

authors: [Devs.YourName],

});

And tsconfig is needed like this because vencord changes the location of its api to be in @utils and not in node_modules/@vesktop

#

This feels like some weird webpack issue anyways

dull magnet
#

do not use webpack

dull magnet
#

for setting up a vencord clone ready to develop

tulip notch
#

I dont use webpack

#

I was guessing what was the cause of the issue

#

Also I assume your talking about skipping the tsconfig bit and just putting my project inside the plugin folder

dull magnet
#

you can use whatever you want to use but don't ask for help with that here

#

go ask the authors of that tool

#

if you want help here, you do it the official way and follow the docs

#

if you want to do it differently, don't ask for help here

#

you wouldn't have any of the issues you're describing if you followed the official method

#

then why are you asking for help here

tulip notch
#

*ok one sec

#

I'll try to get it working the official way via vm or something

tulip notch
#

Ok I cloned vencord, I built vencord and set a new destination for the install of vencord under vesktop

#

@utils does not refer to anything, so I need to keep tsconfig.json, I am having @utils refer to ../../utils/* where all the utilities are kept

dull magnet
#

for the love of god delete everything you have done and follow the docs for setting up a proper clone

#

you will have 0 issues

tulip notch
#

I fixed these issues

tulip notch
#

How come neither "test" nor any message is sent to the console?

hushed loom
#

did you enable your plugin in settings

tulip notch
#

I mean maybe im in the wrong place for what im trying to find

#

yes ofc

#

I mean, it should still print

#

as i open context menus

#

its not activating at all

hushed loom
#

try this instead

#
const patchContextMenu: GlobalContextMenuPatchCallback = (navId, children) => {
    // Search for the element with the class 'peopleList_e0840f'
    const targetElement = children.find(child =>
      child?.props?.className?.includes('peopleList_e0840f')
    );
    console.log("test")
    // Log the target element if found
    if (targetElement) {
      console.log('Found the element with class peopleList_e0840f:', targetElement);
    } else {
      console.log('Element with class peopleList_e0840f not found in this context menu.');
    }
  };
#

also

tulip notch
#

I tried what you suggested

#

the logs are the same

hushed loom
#

@tulip notch

#

thats an issue with your build / code

tulip notch
#

Hm.

hushed loom
#

note

- const patchContextMenu: GlobalContextMenuPatchCallback = (navId, children) => () => {
+ const patchContextMenu: GlobalContextMenuPatchCallback = (navId, children) => {
lapis fable
#

Sorry for being stupid again but uhh, I'm trying to make a plugin to always show blocked messages, and I want it to skip the part where it checks if a message is blocked? Is that possible?

swift delta
lapis fable
normal wagon
#

You can keep the sounds if you install CustomSounds plugin @hollow jetty I sent the links in #🎨-theme-development

normal wagon
#

not part of official vencord.

flint bronze
#

It's not official

#

Don't tell us it's hosted somewhere in your highly modified Equicord install

normal wagon
#

no

#

i just know of a plugin that exist under that name i don’t use it or anything i’ve just heard of it

digital moon
#

Hey everyone,
This is my first time making a vencord plugin I had an idea and design. I want to make a HTML Preview plugin I currently have the button working but can't figure out how to make a div that I can apply the html content to. Anyone a idea on how to accomplish this.

vast karma
#

Does it support scripts

digital moon
#

i guesse

#

this is the only thing i have setup now

oak sundial
#

what are you doing that you need something like this

digital moon
#

I just have a bot that send html content to a message of ticket transcript and it would be fun i could directly see it in discord

vast karma
#

Make it send a rich embed instead

#

Or an image

#

A bot that is unusable without incredibly unsafe client plugins is not a good bot

oak sundial
#

you could probably just patch how embeds are rendered in the client if you want to do this

#

its just so niche

#

also leads the question of what can be exploited by you supporting this

flint bronze
#

hold on

#

Correction

#

You need to remove Content-Disposition header

digital moon
flint bronze
#

Also, I think someone's made an SVG preview plugin before, though I don't know where or when

flint bronze
digital moon
green vessel
#

Hi so is there any solution for communication between index.ts and native.ts since they both only have access to their own API's

#

for example if i set off a modal with index.ts and the user clicks "Delete File" then i have to use the fs library for node js what should i do?

iron epoch
green vessel
green vessel
#

i thought that would make it so the function only has access to what index.ts has

#

since you cant use Node APi in index.ts when you import the function from native it'd still be limited to index.ts

iron epoch
green vessel
#

Okay thank you 🙏

green vessel
iron epoch
green vessel
#
//index.tsx
import definePlugin from "@utils/types";

import nativeRead from "./native";

export default definePlugin({
    name: "testplugin",
    description: "description",
    authors: [{ name: "Ce", id: 615999706836893720n }],

    start() {
        console.log("yessir vencod");
        console.log(nativeRead());
    },

    stop() {
        console.log("exiting");
    }
});
//native.tsx
import { readFile } from "fs";

export default function nativeRead() {
    readFile("/text.txt", (err, data) => {
        if (err) throw err;
        return data;
    });
}
#

✘ [ERROR] [plugin ban-imports] Cannot import node inbuilt modules in browser code. You need to use a native.ts file

    src/userplugins/discordTouchBar/native.ts:7:25:
      7 │ import { readFile } from "fs";
        ╵                          ~~~~``` during build
flint bronze
green vessel
flint bronze
#

huh

green vessel
#

I don’t think it works because I’m trying to use a function that uses the node API inside of index.tsx?

flint bronze
#

oh

#

i think I might know what this could be

dull magnet
flint bronze
#

nvm

#

i'm blind and going insane

dull magnet
#

also you haven't understood how js callbacks work

#

this function returns undefined

flint bronze
#

you are treating a callback like an awaited promise

#

try an async function and use await readFile

#

import from fs/promises not fs to do this

dull magnet
flint bronze
proud parrotBOT
green vessel
dull magnet
#

yes

proud parrotBOT
green vessel
# dull magnet yes

I want to read more about how that works under the hood but I don’t know what to search because when I think about it if index.ts only has access to browser api I don’t understand how importing from native will give the imported function access to the api

#

Do you know what might cover these questions that I could go read?

proud parrotBOT
dull magnet
#

the first one is your native file, the second and third are how you call native exported functions in your index file

flint bronze
dull magnet
green vessel
dull magnet
#

it's not a workaround

#

it's how electron works

flint bronze
#

this is the simple way

dull magnet
#

index.ts is a web browser (literally chrome)

#

it has no nodejs

#

it doesnt know what nodejs is

green vessel
#

Right

flint bronze
#

well

dull magnet
#

native.ts runs in a different nodejs process

flint bronze
#

It's a simple way to interact with it

dull magnet
#

you cant share data between the two directly

#

you can only do that via IPC (inter process communication) by sending messages to the other process

green vessel
#

I see

dull magnet
#

normally that's more work but Vencord autogenerates IPC bindings for you on VencordNative.pluginHelpers.PluginName

#

so if your plugin is called CecePlugin and your native.ts file exports a method called eatBananas, then you can call that method via VencordNative.pluginHelpers.CecePlugin.eatBananas()

green vessel
#

How long have you been coding for? I feel so dumb sometimes I’ve been trying to read up on everything for a while but I always find myself running into issues I can’t really put into words to learn about

dull magnet
#

since 2020

green vessel
#

You both seem really good do you have any advice on what I should look into to understand all this more because right now I’ve just been reading JavaScript.info which isn’t node related

dull magnet
#

stop reading random stuff and just come up with a project idea

#

learn by doing

#

reading a thousand recipes isn't how you learn to cook

the way you learn to cook is that you pick one recipe, look up how to cook that, and then do it

#

it will probably be meh the first time but if you cook it a few more times you will get better

#

similarly, don't aimlessly read guides and such

instead, pick one project idea. anything. a website. a (discord or other app) chat bot. a small 2d game. a shell script. a gui app. ANYTHING

come up with any idea you find interesting. and optimally one that solves something you actually need. start off with a smaller project, don't go super crazy

then look up how to do that specific thing. read a guide on how to make that specific thing. then just start building. it will be poopy and you will get stuck, but whenever you do, look up solutions online or ask a friend. once you learned, you will likely realise your old code sucks ass so you will rewrite it from scratch with your new knowledge

#

the initial vencord code was hot garbage so i rewrote it from scratch

vast karma
#

Protip: don't be ashamed that your code is hot garbage. There does not exist code that is not hot garbage

dull magnet
#

^

#

sometimes i push code to vencord and the next day i look at it and wonder what the fuck i was smoking

green vessel
#

Loool

dull magnet
#

it happens less the more experience you have but even then it still happens

green vessel
#

But for example let’s say I ran into this issue that we were discussing I have no idea what IPC is and I had no idea that was the solution so how would I coke across that naturally?

dull magnet
#

bro this is advanced stuff it's not the right project for a entry level dev

flint bronze
#

Also If you need to send from native to renderer async, (for example, you implement a server that can allow other programs to control Discord) make a function that takes the arguments[0].sender.executeJavaScript function, saves it to a variable, and call a function exported in your plugin definition object, and call it in your plugin start function

There's no proper example for doing this in Vencord itself, just treat this like running eval to set a variable (use JSON.stringify twice on your data, for example). Don't accidentally make remote code execution.

https://github.com/Vendicated/Vencord/blob/main/src/plugins/consoleShortcuts/native.ts#L10 is the closest example of doing this in Vencord itself, it doesn't actually send any data though

proud parrotBOT
flint bronze
#

though

#

vencord taught me regex

flint bronze
#

It's not dumb to start with something advanced

#

It's GOOD to build something practical

#

I just can't with example guide to building [x]

#

Also after reading what you said way earlier, be careful regarding path traversal (adding ../../../someOtherFile) especially if it's a text field

green vessel
flint bronze
#

Yes

#

anyway, what are you actually trying to build?

#

what is your plugin trying to solve

green vessel
#

For fun

#

I’ve been using Js for a few years off and on but I’ve never really done anything to advanced I’ve really only made Full stacks for some people every now and then

flint bronze
#

I don't actually know how you'd do that, specifically how to get the BrowserWindow of Discord

#

oh

hushed loom
flint bronze
#

you probably just want to listen to browser-window-created events on the electron app object @green vessel

#

instead of using app.whenReady promise to create a window use the event's 2nd argument as the window

proud parrotBOT
# flint bronze https://github.com/Vendicated/Vencord/blob/main/src/plugins/fixYoutubeEmbeds.des...

native.ts: Lines 10-27

app.on("browser-window-created", (_, win) => {
    win.webContents.on("frame-created", (_, { frame }) => {
        frame.once("dom-ready", () => {
            if (frame.url.startsWith("https://www.youtube.com/")) {
                const settings = RendererSettings.store.plugins?.FixYoutubeEmbeds;
                if (!settings?.enabled) return;

                frame.executeJavaScript(`
                new MutationObserver(() => {
                    if(
                        document.querySelector('div.ytp-error-content-wrap-subreason a[href*="www.youtube.com/watch?v="]')
                    ) location.reload()
                }).observe(document.body, { childList: true, subtree:true });
                `);
            }
        });
    });
});
flint bronze
#

you won't be needing to send arbitrary data for this afaik

#

@green vessel what do you want to display on the touchbar

flint bronze
digital moon
green vessel
#

I’m thinking guilds deafen and mute and some other things I’m still coming up with the design thanks for the advice too

green vessel
flint bronze
flint bronze
green vessel
#

Wouldn’t the plugin be started after the window is created though

flint bronze
green vessel
#

Ohh okay

#

Also what’s a flux event? Lol

flint bronze
#

Maybe consider checking if your plugin is enabled in your functions

digital moon
flint bronze
green vessel
#

Ah

flint bronze
#

You will find flux events being listened to and action being taken upon them in a significant amount of plugins

green vessel
#

Thanks bro ur goated

flint bronze
#

Search for flux: and FluxDispatcher in the Vencord source to see examples

digital moon
flint bronze
#

i'll have a look

#

It's not on his github (from my brief search)

#

wait

digital moon
#

I will have a look thanks maybe he wants to collaborate :)

#

yeah like you said i didn't get anything useful out of this. I just need it to create a div below the message where it grabs the html content from.

#

this is want i have now

hushed loom
#

If you still want that SVG preview plugin and I haven't sent it within an hour or two, just ping me a bunch.

digital moon
#

@hushed loom You wanna work with me on this plugin :)

hushed loom
#

no

#

sorry, i have other things i need to do

digital moon
#

ahh okay

#

is it even possible to create a div

vast karma
#

Alas, creating divs is the one thing js cannot do

green vessel
# flint bronze i'll have a look

hey im trying to do what spooktober recommended but its undefined in the console

const Native = VencordNative.pluginHelpers.TouchBar as PluginNative<typeof import("./native")>;
#
//native.ts
export function nativeRead() {
    console.log("testing");
}```
iron epoch
flint bronze
#

Your plugin name is TouchBar yes?

green vessel
#

No does it have to match my pluginName

flint bronze
green vessel
#

Ohhhh

#

okay thanks lmao i would of never knew

green vessel
flint bronze
#

Vencord

green vessel
#

Ah

digital moon
# hushed loom no

Got it working im usign a api to generate the html to a image. im now using a paid one im currently setting up my own

normal wagon
#

that’s just an image though right

#

it’s more safe i guess but let’s say ur wanting to test an html element

digital moon
dull magnet
#

literally just render the html

digital moon
#

yeah i was trying but dident know how
so thats the why

vast karma
#

Either send to a weirdo service to sandbox, or sandbox/sanitize yourself

dull magnet
#

ever heard of this wonderful thing called iframes with permission policy

digital moon
#

i know but dont know how to create it with a plugin first time making a plugin

dull magnet
#

if you set iframe sandbox permissions to none and set a strict csp on the frame (only supported in chrome), it's safe

digital moon
#

To lazy rlly

dull magnet
#

or use raw dom manipulation

#

if you don't care about submitting it to be an official plugin

#

it likely won't be accepted either way from what I heard so far

digital moon
#

but like i think i now on how to make it in react but i dont know how to do it with a vencord plugin

dull magnet
#

look at any other plugin

digital moon
#

Could find any that does but i wil have a look again

#

i have no idea to do its and cant find any that have done it

digital moon
humble tulip
#

I did something similar as my first plugin too, I did mine via iframes

#

I didn't know as much then so it's a message accessory placed under each codeblock with a react portal

green vessel
#

Any possible way to grab discord browserwindow?

rose fiber
#

what are you trying to do

green vessel
#

Access the browser window discord uses to use a method on it

rose fiber
#

what method?

green vessel
#

Instead of creating a new window

pallid rain
#

İs there a way to sene notification to the system (not in @api/core)

rose fiber
pallid rain
rose fiber
pallid rain
rose fiber
pallid rain
rose fiber
#

?

pallid rain
# rose fiber ?

Im in Türkiye, in Türkiye discord is banned, im loggin in with tor proxy

digital moon
#

Is there a way to add a button to the files like the design

rose fiber
#

find the code of the component with react devtools and add a child to it

digital moon
rose fiber
digital moon
#

Ohh nvm thanks

rose fiber
digital moon
signal hemlock
#

is there a way to get the discord build hash

bronze dove
#

scroll settings down

digital moon
rose fiber
digital moon
rose fiber
#

you can take a look at other plugins that add things to the ui

signal hemlock
#

that seems to be hardcoded

#

what im trying to do rn is this but it has no effect apparently

#
patches: [
    {
        find: /.log\("[BUILD INFO]/,
        replacement: [
            {
                match: /Build Number: "\).concat\(("\d+")/,
                replace: "Build Number: \").concat($self.setBuildNumber($1)"
            },
            {
                match: /Version Hash: \"\).concat\(("\w+")/,
                replace: "Version Hash: \").concat($self.setVersionHash($1)"
            }
        ]
    }
],
setBuildNumber(buildNumber) {
    return BUILD_NUMBER = buildNumber;
},
setVersionHash(versionHash) {
    return VERSION_HASH = versionHash;
},
digital moon
bronze dove
signal hemlock
#

fire

#

ty

green vessel
#

anyway to access discords browserwindow?

amber mantle
#

try searching the server first

flint bronze
#

did I yap too much and it got lost in the sea of yap

green vessel
#

No I read that but I was in the car

#

Can I get discords browser window listening for that event?

flint bronze
#

You should be able to?

green vessel
#

Okay bet I’ve been looking at it all day and all i couldn’t find anything

#

Only other way was to use remote to access it

#

Which was deprecated

green vessel
# flint bronze You should be able to?

Incase that doesn’t work I was trying to create a second window that’s hidden but when I did that the touchbar turns off if I’m not focused on that window

green vessel
#

And I’m guessing there’s no solution to that right

tropic ice
honest stump
#

does anyone know how discord determines whenever you completed a quest? I thought it's via flags similar to other badges but it isnt apparently

digital moon
honest stump
#

some badges use user flags to determine whenever they should be added and some use a completely other method

#

like the 'quests' or 'originally known as' badge

tropic ice
#

like without making a new plugin

digital moon
tropic ice
#

open dev tools and press ctrl+shift+f to open search, and search the find value in the patch

digital moon
frosty otter
placid canyon
#

can i use a patch to modify what is returned when getting a field?

vast karma
#

Sure, but more common would be changing either the thing that sets the field, or the thing that reads it

placid canyon
#

id like to cosmetically change aspects of users

vast karma
#

Sure, patch the component

placid canyon
#
{
            find: "getUser:",
            replacement: {
                match: /(getUser:)(\i),/,
                replace: "$self.getModifiedUser($1),"
            }
        }

?

vast karma
#

Sounds like a good way to potentially brick your discord if you're careless

placid canyon
#

ah

vast karma
#

Plus that's invalid

placid canyon
#

oh

#

would you be able to tell me what's wrong with it?

vast karma
#

Replacing getUser: function(...) with $self.getModifiedUser(getUser:)(...) should be self explanatory

#

Not sure if it's a function expression or just a variable name there though, depends on what exactly you're patching

placid canyon
#

id just like to modify some fields?

vast karma
#

Modifying fields on discord's data stores is always risky

#

Better to just change how it's rendered

placid canyon
#

i'm not sure what i would need to patch in order to cover every place user information is renderer

waxen lily
#

Hello, I made a plugin for the WebScrobbler WebHook, so I use the Http library from node inside of native.ts file. But I have the error that said Cannot import node inbuilt modules in browser code. You need to use a native.ts file but the import is in the native.ts (in root directory of the plugin) ?

waxen lily
# iron epoch show code

native.ts:

/*
 * Vencord, a Discord client mod
 * Copyright (c) 2024 Vendicated and contributors
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

import * as http from "http";

export default http;

WebHookServer.js (only the import):

import { createServer, request } from "./native.ts";
iron epoch
#

what you trying to do is

const Native = VencordNative.pluginHelpers.MyPluginName as PluginNative<typeof import("./native")>;
iron epoch
#

there is a link some where explaining ipc

waxen lily
iron epoch
#

I assuming you mean by "use" is some format of compilation

iron epoch
waxen lily
waxen lily
#

Hum... I think there is a problem.

iron epoch
#

I probably need someone to validate every information I said and would say, I am 8 hours past my bedtime

waxen lily
iron epoch
waxen lily
iron epoch
waxen lily
oak sundial
#

for what purpose 😭

#

why would you want to use webscrobbler directly in discord though

hushed loom
#

this sounds very xy

waxen lily
#

One thing the time of the track

dull magnet
#

this is a terrible idea lmao

#

just make a browser extension

#

or use premid

#

that's not useful iamme

iron epoch
#

sorry

waxen lily
#

It can replace completely the Spotify integration for non user of Spotify

dull magnet
# iron epoch sorry

there is no practical use to reading that because it's a very complex topic and you don't need to understand any of that

you just need to understand that you have to export functions and call these functions via the global pluginHelpers object

rocky lynx
#

I am making a plugin that adds a button to send a random picture of my cat. I have it mostly working, but when I use it in a channel with slowmode it doesn't activate the slowmode timer. How would i go about making it activate the slowmode timer.

dull magnet
rocky lynx
dull magnet
#

import sendMessage

#

and use that

#

RestApi is very low level and should only be used as a last resort when there's no better option

rocky lynx
#

i was using sendMessage but i couldn't find how to send attachments with it

dull magnet
#

there's uploadFiles

#

use that

rocky lynx
#

i see, thank you for the help.

waxen lily
#

What I try to do is completely overkill, I think I will fork the extension (WebScrobbler) and make it work with Discord or a WebSocket

signal goblet
#

I was wondering why the patch was so long and the person who made it made the match go through the entire module for children: and the letters which children gives anyways so I trimed it down

vast karma
#

What's with the \i\i

signal goblet
#

they used it for the ... shrug

#

oh its probably for the other vc buttons

dusk kernel
#

what format does the user api /settings-proto return in

#

.settings has a string, which can be decoded with b64 but it also gives a bunch of junk with it

cedar olive
#

protobuf

dusk kernel
#

oh

#

thx

weak haven
#

Hello, i'm trying to get the cpu consumption data used by discord but since they don't have an api for it. So i manually put "pressure" on it in my code here (1st pic). but when i run the code over and over agian it doesn't seem to work at all. Is there another way of measuring cpu consumption used by discord within the app?

upping the samples time from 5 doesn't change anything, it remains at about a recorded of 0.39% with sometimes spikiking at 41% but clearly, discord uses way more

#
Discord

User: .buzzzzy
CPU Load: 0.37%
Used RAM: 239.09 MB
Total RAM: 272.79 MB
Network Traffic:
  - Outgoing Request Size: NaN bytes
  - Incoming Response Size: 648811 bytes

#

Bro

#

No way i js got a husk instantly

#

😭

hoary pilot
vast karma
#

You probably need a native.ts for that

weak haven
#

Aha

#

Alr

#

I'll try it

#
Discord

User: .buzzzzy
CPU Load: 100.00%
Used RAM: 419.44 MB
Total RAM: 433.76 MB
Network Traffic:
  - Outgoing Request Size: 450 bytes
  - Incoming Response Size: 206202 bytes

#

So i did a native.ts but i selfcooked at it shows 100% all the time husk

weak haven
#

I made a folder, in this folder i have an index.ts and a native.ts. I don't know why it's giving me this error, i have the correct import in index.ts for native.ts (3rd pic). the funtion name is also corret (4th pic). any ideas on how to fix this?

#

(ping me when you respond)

#

I also tried rewriting the import to
const { getCpuUsage } = await import("./native"); but i still get the "make a native.ts file" error

dull magnet
#

look at other plugins using native.ts

weak haven
#

Alrighty, ty

dull magnet
#

also that promise is pointless just remove it

weak haven
#

lol

#

Will do

weak haven
#

I can't get it to work, i'm using imports from electron and using ips, 😭 .

#

First pic is from native.ts and 2nd is index.ts

#

(ping on response)

hushed loom
#

do something like this


const Native = VencordNative.pluginHelpers.YOUR_PLUGIN_NAME as PluginNative<typeof import("./native")>;

weak haven
#

This?
`import { ApplicationCommandInputType, Argument, CommandContext } from "@api/Commands";
import { sendMessage } from "@utils/discord";
import definePlugin from "@utils/types";
import { GuildMemberStore, UserStore } from "@webpack/common";

const Native = VencordNative.pluginHelpers.vcBtop as PluginNative<typeof import("./native")>; // Reference the native helper`

#

Alright, got it, ty very much

hushed loom
#

use codeblocks

#

not inline code

weak haven
#

like this?

hushed loom
#

yes

weak haven
#

Sadan, thank you, you hlped a lot with that import. The plugin works perfect now

#
Discord

User: .buzzzzy
CPU Load: 19%
Used RAM: 232.61 MB
Total RAM: 255.24 MB
Network Traffic:
  - Outgoing Request Size: 1246 bytes
  - Incoming Response Size: 100567 bytes

#

🔥

flint bronze
#

i am begging someone to PR a feature where it errors when you import native directly

hushed loom
#

you need to read other plugins code more before yapping

flint bronze
hushed loom
fathom pivotBOT
#

Alright @hushed loom, in 1 week and 1 hour: …

swift delta
#

That thing is a lot better than the other one anyway

hushed loom
flint bronze
dull magnet
#

cause I didn't expect people to be dumb and import native.ts from index husk

#

I added it to stop people from trying to import node stuff in index

hushed loom
dull magnet
#

no it doesn't lol

#

if you import the file then it's just the same as putting it in index

hushed loom
#

you expect people to think too much

dull magnet
#

well there could be black compiler magic automatically returning bindings when you import it

#

but no

#

actually I could do that

#

maybe

fathom pivotBOT
#

Alright @hushed loom, in 1 week and 1 hour: …

hushed loom
#

time for cursed esbuild shit

dull magnet
#

that doesn't sound good

#

I'll do it :P

flint bronze
green vessel
#

hey @flint bronze ive been trying to fix this for ages but i got the touchbar to work but anything i put on it for example a number , the bar doesnt render the update like it does normally it just stays the same value even though its actually updated

rose fiber
#

Are you updating the variable or the content of that box thing

green vessel
#

the content of the box is a template literal working with the variable

#

it works fine when i create its own browserwindow

#

when i attach it to discords main browserwindow thats when things stop working

rose fiber
#

Then it's probably some weird stuff with discord's electron

green vessel
#

yea... it would probably be super hard to fix let alone pin point the cause in that case right

green vessel
#

finally

#

it turns out discord creates two browserWindows, one for the loading when you open and the second for the actual application

#

and i attached the touchbar to the first one since

flint bronze
#

does electron only allow you to attach a touchbar to one window?

#

thats dumb design

green vessel
#

No

#

You can attach the same or multiple Touch Bars to as many windows

green vessel
flint bronze
#

show me your code?

flint bronze
green vessel
#

Wait nvm I attached it to every window in the event listener you told me about

#

So it was attached to the loader and the main app but I guess it breaks if you do it that way

flint bronze
#

Huh

#

Strange

#

@green vessel have you considered using a nodejs EventEmitter, sending updates to that, and create the touchbar for each window and listen to those events to update it / when the button is pressed?

#

this should make sure it works for all windows still

#

though it might not be so efficient

#

this is stupid why not just have an array of touchbars and remove them when windows close

green vessel
#

There’s only a need for one which is the actual discord window

green vessel
flint bronze
green vessel
#

My terminology is bad and event emitter is what broadcasts to listeners right

flint bronze
#

Probably not the most perfect idea but it could work

green vessel
flint bronze
#

Yes

green vessel
#

Yea

flint bronze
#

I don't think I can provide the best advice here though

#

You should look for some examples of TouchBar being used in multi-window electron apps

green vessel
#

That would be ideal if electron didn’t allow one touchbar object for multiple windows that need it

#

I’m still not sure if they do but when I added it to multiple windows on accident it broke so

unkempt hemlock
#

hey, I noticed that the ViewIcons plugin has a very short animation when opening the user avatar by left-click from the user's right-click->profile

it seems that it adjusts itself (not sure how to describe it); basically it doesn't already appear in the "correct" place

hushed loom
#

nobody cares enough to fix it

fiery kindle
#

Can you help with patches? How can I get find and match values?

oak sundial
#

react dev tools

#

would be nice to know what you are trying to achieve

tropic ice
#

for testing the find, you can use ctrl+shift+f in devtools

oak sundial
#

or the patch helper

fiery kindle
#

I would like to remove the gift button in the chat bar. Patch helper and dev tools helped a little, but I still don't understand

flint bronze
#

I hate saying this but I've already done this just over a month ago

#

With patches, not CSS

proud parrotBOT
fiery kindle
flint bronze
flint bronze
green vessel
#

Im trying to use querySelector but the element im trying to access isnt loaded yet is there any simple way to wait til its loaded?

vast karma
#

Why would you use querySelector

#

Sounds like you're trying to do dom manip

green vessel
vast karma
#

And you're doing that... from the dom?

green vessel
#

i found a way though

#

is there an api function

#

for vencord?

vast karma
#

Vencord.Webpack.Common.GuildStore

green vessel
#

how do i get all the guilds from that edit: nvm i got the guilds from it

#

i also need their pfps

#

theres an icon property with a value like ""3de0a07842b66707d81dd1671b545e3a"" do you have any idea how i can access the icon from that?

oak sundial
#

https://cdn.discordapp.com/icons/id/hash.extension

#

gif for animated webp for non animated

vast karma
#

Probably you'd want to use some premade react component for rendering the icon

swift delta
weak haven
#

Whag does that do

#

O wait

#

Hides nitro shit

swift delta
flint bronze
#

should I make a plugin that adds a calendar for events

weak haven
#

Vouch

flint bronze
#

would anyone else find this useful?

#

@hoary pilot need your advice do i actually make it

hoary pilot
#

good idea trolley

flint bronze
#

we will be needing a way to filter out always ongoing events

weak haven
#

I made a stupid plugin that gets an insult everytime you type /insult, i get this error. Is there a way to bypass it

#

I changed
https://evilinsult.com/generate_insult.php?lang=en&type=json
to
https://cors-anywhere.herokuapp.com/https://evilinsult.com/generate_insult.php?lang=en&type=json

#

Cors anywhere

#

Test

#

You are like a herd of swine being invited to the table of a prince. You understand not such an honor, but only ravage what is set before you, even soiling the prince.

#

I should prolly get a better api

#

This one is js too poetic

#

Last update report, i found a better one:
https://cors-anywhere.herokuapp.com/https://insult.mattbas.org/api/insult.json

#

You are as ugly as a revolting absurd heap of annoying monstrous detrimental cockroach dung

#

God damn stop husking me

humble tulip
#

I think if you wanna bypass cors you should send the request from native.ts instead

weak haven
#

I had one experience making a native.ts and it went awful, i had to be spoonfed the answer

#

But i'll try it

weak haven
#

I made a native.ts

#

Finally

#

Took a while but i did it independently

cyan pendant
#

I tried searching this up, referring to the documentation, and asking an AI (codeium) for why this is occurring and I cant figure it out.

#

and I created this file in the proper place too, its in its own folder in the userplugins section of the vencord dir

vast karma
#

Where are you getting that discord.js from? There's no such thing

cyan pendant
#

awe damn

#

I installed it using npm

#

should it still not work after that

vast karma
#

Only that it's completely irrelevant

#

It's for building discord clients/bots, which is irrelevant because vencord is already running in an existing client

cyan pendant
#

oh I see thank you

#

yeah thats my mistake

#

my brain is functioning clearly

cyan pendant
#

yeah im completely lost, I looked into the documentaiton but it just shows a plugin boilerplate no documentation on the api, how do I do this (This is my first every attempt at making a plugin, no less a vencord plugin)

#

I got an idea of what I want and how I want it to work I just dont know my tools, you get me?

vast karma
#

Copypaste another plugin that does something similar to what you want

cyan pendant
#

isnt that a taboo thing to do

#

whatever I guess ill do it

#

I mean

#

is that ok ?

vast karma
#

Why wouldn't it be?

#

Copypaste is the basis of all programming

cyan pendant
#

Ok so I looked into voice chat utilities ts

#

because what im trying to do has to do with voice chats

#

im trying to watch for a server mute or server deafen done on my user when im connected to a vc and when I am server muted I want to locally deafen my user and when I am server deafened I want to locally mute automatically.

I had an AI help a bit because I am not understanding some of the errors (as I never coded in ts/js before this)

#

well im gonna have to pause any further continuation of this headache, Im going to campfire with friends, when im back I might try a bit more but might have to leave this for tomorrow

fresh jetty
#

@novel canyon did a very good job 🙏

hoary pilot
cyan pendant
#

Anyone know how I may detect my voice state changing

#

like me being server muted or server deafened

#

using vencord API Im lost bruh

hushed loom
cyan pendant
#

Sigma, thank you, note taken

#

Ill do this when I wake up later today

flint bronze
#

warning: cursed

cyan pendant
#

why are they unerlined in red

#

for reference I have the plugin already sitting in my userplugins folder and in its own named folder, etc, just as the documentation says to do