#development

1 messages · Page 25 of 1

boreal iron
#

That sounds more like a driver issue

#

Sadly I had already two GPU cards with malfunction until ASUS finally sent a new one

ancient nova
#

before I got banned in windows community the guys told me that it's def a broken gpu

#

I bought a new one and never had that happen to me again

ancient nova
#

wait are u in windows community?

boreal iron
#

Of course for free

#

Never heard of warranty?

ancient nova
ancient nova
boreal iron
#

Instead of returning it to the seller

boreal iron
#

There are only a few big companies issuing warranty requests only via third party companies

#

Most of em providing customer support and care themselves

lyric mountain
#

you didn't know how warranty works?

wheat mesa
#

Issues with particular areas or apps on the screen can be caused by GPU damage, or drivers, or other reasons. However with physical damage you’re far more likely to have… more noticeable effects than that

lyric mountain
#

like smoke smell

wheat mesa
#

Somebody probably fucked up their OpenGL/Vulkan shit KEKW

#

I’ve had my pc for more than 3 years, only things I’ve needed to replace are my SSD that randomly fucking died and my network card

#

So overall the repairs I’ve done to this pc in the last 3 years probably total to about $90-120

#

Which is really good considering this was my first ever build

boreal iron
wheat mesa
#

Have you fixed it?

#

If it’s with a certain app it’s more likely than not that it’s a driver issue

boreal iron
#

I did several benchmark tests and only one could consistently show the issue before the screen freezes with a really colorful image

boreal iron
#

It’s there for a very long time already

wheat mesa
#

My go to thing for display issues is just doing a quick check to make sure my drivers are up to date

boreal iron
#

After closing RDP and restarting the machine the issue is gone

wheat mesa
#

Interesting

boreal iron
#

Like I said before RDP seems to cause this

#

For a long time already

#

So let’s get rid of the last Windows VMs I guess

#

Porting stuff over to Ubuntu

#

oh no he’s using a bloat OS oh noooo

winter tapir
#

https://sourceb.in/iP2zxxzvDQ

I have this event handler and I am currently getting this error

Conversion of type '{ name: "ready"; description: string; once: true; run(client: Client<true>): void; }' to type 'EventPayload<keyof ClientEvents | keyof RestEvents>' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
  Types of property 'run' are incompatible.
    Type '(client: Client<true>) => void' is not comparable to type '(args_0: UnionToType) => void'.
      Types of parameters 'client' and 'args_0' are incompatible.
        Type 'UnionToType' is missing the following properties from type 'Client<true>': actions, presence, _eval, _validateOptions, and 45 more.ts(2352)

when I did some testing and removed the Client<true> annotation and now I get the issue Property 'user' doesn’t appear on type 'UnionToType.

How would i solve this type issue for my event handler?

elder oxide
#

you should send the code.

#

the event handler code.

#

nvm, i am dumb.

#

@winter tapir alright, try UnionToType[K] instead of [UnionToType]

solid coral
#

My bot is already published for months and you can vote, but since yesterday (14.08) is there and I can no longer Liken comments. If I like the Like disappears after refreshing the page the Like again

#

Does anyone know why?

elder oxide
boreal iron
#

The message you see will always be there

#

As the developers don’t seem to be able to hide the message after the verification process or after X days of the submission

solid coral
#

Oh ok. Thx

tight zealot
#

can anyone help me

sharp geyser
#

State your issue, provide relative evidence (e.g code and errors) and those who can answer will

tight zealot
#

so i have a search command and i was wondering how i can make it for the search command turn into a whole number instead of decimals

#

let cash = Math.random() * (20 - 75 + 1) + 75
;

sharp geyser
#

The thing is Math.random() innately returns anything between 0-1

#

so you will get decimals

#

If you wanna get rid of it, you can round it though

#

or use Math.floor()

tight zealot
#

what does the mathfloor do

earnest phoenix
#

Hey um can I talk to Nekomaki?

#

For a bot disapproval

sharp geyser
#

Basically floors the value, e.g removes the decimal

#

leaving the whole number

earnest phoenix
#

._.

#

Ok noted

#

You helped me for my exam

sharp geyser
tight zealot
#

so just swap the Math,random to Math.floor

#

?

sharp geyser
#

no

earnest phoenix
#

I can tfined em

#

*find

sharp geyser
#

Math.floor should be used with math.random

#

Math.floor(Math.random())

tight zealot
#

ah okay okay

sharp geyser
earnest phoenix
#

Ty

tight zealot
#

misty

sharp geyser
#

?

tight zealot
#

it gives me this

sharp geyser
#

That means you aren't returning a number

#

NaN = Not a Number

#

Are you parsing anything per chance?

tight zealot
#

whats parsing

sharp geyser
#

e.g taking "1" -> 1

#

it parses a string to a int if possible

#

so smth like parseInt would be used

tight zealot
#

no im not doing that

#

wanna see the code

sharp geyser
#

Yes

#

Please

#

please

#

putting it in a bin makes it easier to read

tight zealot
#

i did it how do i send it

sharp geyser
#

Once you put it in the bin press CTRL + S and then copy the new link in the search bar

#

and send it here

tight zealot
#

okie there

sharp geyser
#

Okay so

#

No wonder you got NaN

tight zealot
#

whys that

sharp geyser
#

you misunderstood what I said

#

let cash = Math.floor(Math.random) * (20 - 75 + 1) + 75
you wanna floor the entire thing

#

this is what you are currently doing

#

what you wanna do is
let cash = Math.floor(Math.random() * (20 - 75 + 1) + 75)

tight zealot
#

oh

#

i had that but i deleted that

#

by accident

#

okay now i see

sharp geyser
#

Although tbh I wouldn't use that method of generating your cash

#

Unless you always want it to be a number less than 80

#

Also, your at risk of a corrupted "DB"

tight zealot
#

what other method would you fo

#

do

sharp geyser
#

JSON files have a low consistent read/write allowance

#

so you can easily corrupt your json files

#

making the data in them useless

sharp geyser
tight zealot
#

mhm it just went back to giving me decimals now

sharp geyser
#

So for example, if you wanted a number between 1 - 20

#

you'd do
Math.floor(Math.random() * 20) + 1

tight zealot
#

Math.floor(Math.random() * 50) + 20

#

thats if i want 20-50?

vivid fulcrum
#

also store user ids instead of their tag

sharp geyser
vivid fulcrum
#

a user's tag can change at any moment

tight zealot
#

or does it have to be 1

sharp geyser
#

Lets think about it like this

#

Math.random() gives a pseudo random number between 0-1

#

So us doing Math.floor(Math.random() * 50) will give us number between 50 and 0
Math.floor(Math.random() * 50) + 1 would be 1-50
But you also gotta think that you are essentially just adding to the result of what Math.floor returns as well, so doing what you did Math.floor(Math.random() * 50) + 20, is the same as asking for it to be as high as 70 (Assuming, I am thinking about this correctly that is)

tight zealot
#

so the best option would be to do Math.floor(Math.random() * 50) + 1

sharp geyser
#

Well, not necessarily

#

It really depends on what you want

#

if you want them to get as low as 1 sure

#

although the chance for that is also rather low

tight zealot
#

i want them to get atleast some (cash-

sharp geyser
#

I will be honest with you I haven't use the Math stuff a lot as I suck at math

#

Either way, it depends on what you want

#

You can always play around with it until you get the ideal result

tight zealot
#

yeah thats why i use a test bot

sharp geyser
#

What I do is open a dev tools console on the browser and mess with the math stuff

#

:p

tight zealot
#

ahh okay

#

thanks for your time.

#

i will go to sleep and do some experimenting tomorrow thanks.

sharp geyser
#

mk

ashen orbit
#
const express = require('express');
const app = express();

app.get('/', (req, res) => {
  res.sendFile(`/index.html`)
});
app.get('/projects', (req, res) => {
    res.sendFile(`/projects.html`)
});

// Start the server
const PORT = parseInt(process.env.PORT) || 8080;
app.listen(PORT, () => {
console.log(`Listening on port ${PORT}`)
});

module.exports = app;

Error: ENOENT: no such file or directory, stat '/index.html'

#

btw it does the same when its /views/index.html

fluid pivot
#

i haven't done js is a while so if im wrong i apologise

ashen orbit
#

ill try

#

TypeError: path must be absolute or specify root to res.sendFile

#

hold on

#

stack overflow

#

oh shit

#

works

#

i love stack overflox

fluid pivot
ashen orbit
#

im very skilled when it comes to googling stuff

#

my website has no css at all

#

i actually need a new website

fervent moss
#

It doesn't it just shows up file when downloaded nothing is there inside a jpg file

#

Did now it shows only document file and not preview what's the problem?

#

And when downloading it , it's just a blank image

#

If someone knows help me

#

I'm lost af

#

Or Minecraft pai sucks a lot

#

They cant just provide with url of skin.

They provide with baseurl which you need to encode and get the image it's not even that the baseurl gives out url for skin

rustic nova
#

if its less than a kb

#

then its likely wrongly converted

#

you need to encode it

#

likely base64 encoded

fervent moss
rustic nova
#

then I highly doubt it's valid data

fervent moss
fervent moss
civic scroll
eternal osprey
#

hey guys,how would i create an endpoint that would be able to receive data from an interaction?

#

Basically, i need to create an endpoint server that will be able to receive the interaction data, so it's readable for other bots as well

boreal iron
#

You just have to listen for webhooks coming from discord which need to be responded accurately

boreal iron
#

Creating a webserver and the code which is listening and receiving the webhook

#

Like listening for topgg webhooks

#

Or any other webhooks

eternal osprey
#

I know, i've never worked with djs webhooks tho

boreal iron
#

Once you enter your endpoint you will not receive the interactionCreate event anymore

#

iirc

eternal osprey
boreal iron
#

Yes you can

eternal osprey
#

Well, i can then make my other bot read that endpoint to get the interaction data.

boreal iron
#

I mean you actually know the token and webhook ID you have to respond to

eternal osprey
#

or would there be any other way to do this:

boreal iron
#

But you would probably defer any interaction to give your endpoint enough time to respond as the 3s limit still is present

eternal osprey
#

I basically have 3 buttons. One play button, stop and pause. I have 3 different music bots. They need to be able to respond to these buttons.

#

The buttons are being sent by bot#1, but how would i make bot#2 and bot#3 respond to it as well?

boreal iron
#

Either through an internal endpoint dealing with the request in the backend or via IPC between those bots

eternal osprey
#

I was thinking about an endpoint to push the interaction data to #2, #3. But there might be an easier approach?

boreal iron
#

Up to you

boreal iron
#

Inter process communication

#

Are those three bots running on the same machine?

#

Literally a socket connection between all those bots sending and receiving data

#

Or somehow just an endpoint receiving your interaction and pushing the data to the two other bots

#

There are a ton of days how to do it

eternal osprey
#

what's the easiest approach to make these bots connect to the same buttons?

boreal iron
#

What’s actually the reason of having 3 different bots requiring to receive the data of a pressed button of another bot?

eternal osprey
#

A music bot cannot join 3 different voice channels at the same time ofc

#

so i want to check if a channel is occupied by discord bot #1, #2 then gets into the game and joins the vc!

#

However, I will need the interaction data of bot #1, the buttons that are being sent

#

This is being sent by bot #1

boreal iron
#

Not sure what to say which is the easiest… that depends on your skills of course

#

But a simple node-ipc package for all three bots, a socket connection between them and emitting an event when a button was pressed might be the cleanest solution

eternal osprey
#

I've had a quick research and found that redis works with ipc

#

however, I have no clue how I would open such socket connection between the bots

#
#

this one might work as well \0/

elder oxide
#

DO NOT USE THE LATEST VERSION

boreal iron
#

I mean I dunno what you’re familiar with

eternal osprey
eternal osprey
elder oxide
#

If you don't know, peacenotwar is legit a malware.

eternal osprey
#

like nothing at wall

boreal iron
#

you can also create a local webserver on all three bots sending the data around you need

elder oxide
#

and node-ipc use it.

#

so by installing, you are essentiially install a malware that only russian user can get

eternal osprey
#

Should i then import the webserver from my ready event to my interactioncreate event and just send the data to the webserver?

elder oxide
#

if you REALLY need to use node-ipc, use version 10.1.0

eternal osprey
#

I can't ofc create the webbserver in the event itself as it otherwise will create multiple

eternal osprey
elder oxide
#

No problem, stay safe.

ancient nova
#

isn't there a button limit

boreal iron
#

WITH-LOVE-FROM-AMERICA.txt

#

lmao

#

The author of that peace bull shit lib is in the top 5 of the dumbest people I have ever seen

earnest phoenix
#

"This code serves as a non-destructive example of why controlling your node modules is important. It also serves as a non-violent protest against Russia's aggression that threatens the world right now. This module will add a message of peace on your users' desktops, and it will only do it if it does not already exist just to be polite."

boreal iron
#

“Love from America”…
Americans couldn’t be happier to sell their weps to Ukrainian and Russian hands under the hood

#

I gotta love my ass off

earnest phoenix
#

yeah lol

boreal iron
#

Any conflict is what the biggest nations selling weps makes them happy - a lot

#

Funny enough people including that sort of bullshit in their projects

boreal iron
#

Aka 5 buttons per row - max 5 rows

ancient nova
#

ahhhh smart

eternal osprey
#

huh wait

#

my brain is melting from my dumb ass logic

#

look

#

If we sent the interaction data to an endpoint*

#

we could make the bots read that interaction data and do things ofc.

#

However, i imagine if there are multiple interaction data's at the same time>?

#

It would just overwrite

rustic nova
#

interactions dont come at once

#

unless you're referring to like a row of 5 buttons

#

then yes, thats included in the raw data

eternal osprey
#

I have 3 bots. This is sent by bot #1.

rustic nova
#

yes, all these components are returned in the interaction data

#

i think

#

either that or only the pressed one

eternal osprey
#

Imagine if a user clicked the play button and bot #1 is ocupied, bot 2 will then read the data and play. But imagine if both bots are active and playing, and a user clicks the stop button... how the fuck would the bots know which one to stop?

#

This is a dilemma fellow discord users

rustic nova
#

thats something you'd need to track internally

#

perhaps a handler?

#

maybe assign a unique id to each music session? then add that to the custom id by for example pause_sessionid_userid

#

is how I'd solve that

eternal osprey
rustic nova
#

yes, the raw data has the custom id in it

#

so you can tell from which session that button press came from, then pause or stop from it accordingly

eternal osprey
#

If it was one bot it would be easy ofc, but these are 3 different music bots lmao

boreal iron
rustic nova
eternal osprey
#

So it would always have the same message id and same client id (of bot #1)

rustic nova
#

so the case could be, the music is being played by bot 3, but the controls are on bot 1

#

am still for associating a session id to a bot playing music, then having that session id in the custom id

#

thats also how I made per-session interactions possible, even after a restart

eternal osprey
#

or wait

#

how would i set custom ids if this message above is only being sent once?

boreal iron
#

You always know which user pressed the button and with which bots he’s in a channel

#

Tf your system sounds weird to me

rustic nova
#

or does the bot who plays the music change sometimes?

eternal osprey
#

Let me explain my system, one sec

rustic nova
#

then just change the Id of the bot whos playing within your session

#

no need to change the custom id

eternal osprey
#

These buttons are being sent once by bot number #1. If you click the play button, bot #1 will join and play music for your silly ass. After that, if another user wants to listen to some music to forget his problems, he could click the play button as well and bot #2 would join, and so on.

#

Imagine all 3 bots are playing.

rustic nova
#

so, it just starts the same music?

#

or wdym

eternal osprey
#

what if a user clicks the stop button, how would the code know which bot to stop?

rustic nova
#

yeah then honestly

boreal iron
#

I feel like he has one bot being controlled by the buttons but 3 different clients which can join channels to serve for example 3 channels at the same time

eternal osprey
rustic nova
#

then check what bot is with the user in a channel

eternal osprey
boreal iron
#

But only one bot is the master controlling the clients

#

So one master and two slaves serving the music

rustic nova
#

sounds like it

boreal iron
#

Which are responding on the buttons from the master

rustic nova
#

best way there would prob check which of the slave bots are in the voice channel of the user interacting

boreal iron
#

Damn… that sounds like some SM shit

eternal osprey
#

I could indeed do this:

-Upon the play interaction, check which bot is in a channel. Imagine bot #3 is in a channel, number 4 would join

-Then read the interactions from the endpoint, and check the vc the member is in to see if the bot is also in there```
boreal iron
eternal osprey
#

I see!

boreal iron
#

He knows which slave is in his channel or the master

eternal osprey
#

Wait a damn minute lmao

boreal iron
#

So sending the request to all theee bots and if the client ID is not the one the user is in the channel with then return

eternal osprey
#

instead of creating a dumb ass endpoint, can't we just check the interaction.member and see with which bot he's in? In each file i could put a check.

boreal iron
#

If the client ID is the one the user is in the channel with, react

rustic nova
#

so just to further understand:

no bots playing music. User presses play on master bot, bot 1 joins

a second user wants to play music, presses play on master bot, bot 2 joins since 1 is used

user 1 wants to skip, presses skip button, the master bot checks which bot is in the channel, get the bot and skip music there

rustic nova
#

yeah that can easily be done, shouldn't be hard

#

maybe associate a bot with a user id

boreal iron
rustic nova
#

that could allow multiple bots playing in the channel

#

which doesnt make sense

#

but would save a bit of debugging headache later

boreal iron
#

Then sending the data to your bot forcing him to play the music or whatever button got pressed

rustic nova
#

ye

eternal osprey
rustic nova
#

btw just realized, we all have cat pfps

#

anyways

boreal iron
#

well

#

Mine is just… yeah

#

Looks like a cat

rustic nova
#

cat

boreal iron
eternal osprey
#

But that means i will have to create 3 different endpoints for the bots. Or else, 3 different categories within the one endpoint

boreal iron
#

Two

#

The master controlls the two slaves

eternal osprey
#

Yeah two sorry

boreal iron
#

If the client is not inside the channel with the master only then the master will send the data to its slave client

civic scroll
#

or use the stack model

boreal iron
#

With the data the slave should serve

ancient nova
#

HOW THE HELL is this done

civic scroll
#

or just send a menu

ancient nova
#

how is this possible

civic scroll
#

"Which bot to stop?"

ancient nova
#

I thought it wasn't

#

wth

rustic nova
civic scroll
ancient nova
#

you can fetch the invite, how? I thought the only way is to log it on inviteCreate

#

wtf

#

wtf

eternal osprey
boreal iron
#

My gosh…

ancient nova
#

bro no Istg yall told me that not long ago

civic scroll
eternal osprey
rustic nova
#

doesnt need authorization

ancient nova
eternal osprey
civic scroll
#

you lied

ancient nova
rustic nova
rustic nova
boreal iron
rustic nova
civic scroll
#

jk sorry

#

i'm so crigne

boreal iron
#

True

#

That’s why you’re in jail

civic scroll
boreal iron
civic scroll
ancient nova
boreal iron
#

Jail is jail you criminal

civic scroll
#

no

#

not when the jail is typed

ancient nova
#

I actually heard using raw api is better since u can do everything exactly how u want it

civic scroll
#

discord.js is just an abstraction layer

ancient nova
#

rather an unpopular opinion tho

eternal osprey
#

btw thanks Fake and Aurel! I will try it out and let you guys know if i've got any results

rustic nova
#

if the library has that feature

#

take advantage of it

#

cuz effort

civic scroll
#

it abstracted away those control over parameters and endpoints

#

but again you are not making a discord anime girl real time

#

so just use it

ancient nova
#

wait no way so don't tell me I can even make an invite tracker with client.fetchInvite???
I can fetch all invites, filter the specific one byID and then get that invite my user tag

#

omgomgomg

boreal iron
ancient nova
#

anyone has a regex for filtering the code out from an invite link or am I just too lazy?

#

bruh

boreal iron
#

lmao

#

Im gonna send him one

ancient nova
#

I would send him a picture of realistic pacman

civic scroll
#

💀

boreal iron
#

Those rare moments making this channel funny instead of confusing

ancient nova
#

I found it

#

NOOOO I'M too late

#

mans already gone PeepoSad

#

anyone else want it?

boreal iron
ancient nova
#

anyone got that regex tho?

eternal osprey
#

hey guys...

#

a bit of a dumb question

#

I've created an express server named dataserver in my ready event...

boreal iron
eternal osprey
#

how would i export it to my interactioncreate event lmao

#

i tried to import it in my module.exports but it doesn't work

vocal flint
#

Hi guys!

civic scroll
civic scroll
eternal osprey
#

yeah

civic scroll
#

you can emit events

boreal iron
#

No but they are on the same machine

#

Or not

eternal osprey
#

they are

boreal iron
#

Did you lie before?

civic scroll
#

using EventEmitter

boreal iron
eternal osprey
civic scroll
boreal iron
#

Three separated processes or one?

eternal osprey
civic scroll
#

i mean EventEmitter

#

sorry

boreal iron
#

Okay so three independent processes running

eternal osprey
#

yeah

civic scroll
#

💀

#

dies

ancient nova
#

what's presenceCount?

civic scroll
#

like how different processes communicate with each other

ancient nova
#

the amount of user who joined with that invite that are still in the server?

civic scroll
#

or set up a server for each bot with a predetermined address

#

then write the address to a file

#

so other bots and read it and pick it up

eternal osprey
#

I don't think you guys understand what i am trying to do

boreal iron
#

Either IPC or simply your familiar solution creating an endpoint on both slaves

civic scroll
#

three bots on three different processes tryna communicate with each other, right?

boreal iron
#

No

eternal osprey
#

I have one variable named dataserver , it's an express server. it's in my ready event of my bot. I want to send this variable over to my interactioncreate event so i can work with the posts to dataserver

boreal iron
civic scroll
eternal osprey
#

Guys whahaha no

boreal iron
#

Tf

civic scroll
#

just. send. the. endpoint

#

basically you set up a data server, itself already has an http endpoint

eternal osprey
#

I have declared the variable dataserver in my ready event

eternal osprey
#

how can i use that avriable outside the ready event file

civic scroll
#

just send regular http request

eternal osprey
#

Imagine i have 2 different files

civic scroll
#

no

eternal osprey
#
  1. ready.js
    2.Interaction.js
#

how do i get my variable from 1 to 2

#

😭

civic scroll
#

assign them to the client object

#
client.dataServer = ...
boreal iron
#

Your two slaves both have a webserver running and your master sends a request to the one who has to take action

civic scroll
#

i give up

eternal osprey
boreal iron
#

Both using localhost and a different port

eternal osprey
#

Guys my god wait

civic scroll
#

both of you don't understand

#

my solution

eternal osprey
#

This is one bot okay.

boreal iron
eternal osprey
#

Imagine i have a variable created in ready.js that's called ugly.

boreal iron
#

Ok I’m creepy now ik

eternal osprey
#

How do i export that ugly variable to my interactionCreate.js

boreal iron
#

Forgive me sayuri

eternal osprey
#

so i can then do, console.log(ugly) in my InteractionCreate.js

boreal iron
#

As parameter

#

In your event handler

#

Or bind it to the client

#

Or some other var which is available in the event

civic scroll
#

@eternal osprey
when the client is ready

client.on('ready', (client, ...) => {
    client.dataServer = ...
});

then when you wanna use it in another event

client.on('event', whatever => {
    // consume data 
})
#

in other words, you need an event handler / register

#

for that, refer to discord.js guides

#

essentially you export those events as functions

#

then in another file that register those events, the client will be attached to it and executed at due time

boreal iron
#

Hes already using an event handler in reference to his structure

#

I guess

civic scroll
#

so you can consume those parameters as if they were there

civic scroll
#

just pass the client to the event

boreal iron
#

Which is what I suggested

#

To bind it to the client

eternal osprey
civic scroll
#

here's what i did

#

ignore the music player

#

the last line is basically binding the client object as the first parameter of an event callback

#

then you can consume it like this

civic scroll
#

you must attach the server as a property of the client

eternal osprey
#

Wait i think i must only import dataserver

#

and then call client.dataserver

wheat mesa
#

You can’t do something like const func = (client.dataserver) => …

#

That’s not how function args work

civic scroll
#

then consume the dataServer prop inside functions body

#

else you might wanna learn how object destructuring works

civic scroll
eternal osprey
#

I see

civic scroll
#
  1. syntax error
#

did you even study how javascript is written

#

or are you making a new programming language?

boreal iron
ancient nova
#

now, with the onMemberJoined event can I somehow fetch just the invite code the user used?

ancient nova
boreal iron
#

As we explained the last time already

ancient nova
#

YOU CAN'T

boreal iron
#

You can ONLY listen to the event

ancient nova
#

i forgot the entire conversation

earnest phoenix
#

Discord does not provide such information, so basically no

boreal iron
#

And count it

ancient nova
#

ok u count it but how do you know which invite they used again

boreal iron
#

But once you miss one event you’re fucked

boreal iron
earnest phoenix
#

Getting which invite is used can produce a lot of false positives, since there's no way to get it accurately, so I would recommend not implementing such thing

boreal iron
#

And listening to the event

earnest phoenix
#

And there already are many invite manager bots, so why bother?

boreal iron
#

It’s not like we already told him that like days/weeks ago

#

It’s not possible or let’s say accurate

earnest phoenix
#

Well it's Bae so what do we expect

boreal iron
ancient nova
#

why does the ?? op break my vps syntax highlight 💀

ancient nova
#

rate limit moment

boreal iron
#

Tf ask the theme author why it does that

#

Or the dude who wrote the syntax highlighting parser

ancient nova
#

it's the default pterodactyl 2.0 theme

boreal iron
#

?? Operator doesn’t exist for so long already

ancient nova
#

maybe that's why I learned it recently

#

how long did it exist for??

boreal iron
#

Dunno just a few years I would guess

eternal osprey
#

Does anyone know a good doc that shows how to send data to an express server?

#

I am trying to find things on the internet but they are confusing to me

boreal iron
ancient nova
#

u listen to an endpoint and then do a post request I think

eternal osprey
#

i have gathered some things together but it doesn't work

ancient nova
#

can u send the code?

boreal iron
#

Post request sending your stringyfied data as body

#

To your local endpoint

eternal osprey
#

and the .get property?

earnest phoenix
#

just do smth like

boreal iron
earnest phoenix
#
const express = require("express");
const bodyParser = require("body-parser");
const router = express.Router();
const app = express();

app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());

router.post(‘/handle’,(request,response) => {
console.log(request.body);
});

app.use("/", router);
#

make sure you npm install --save body-parser or whatever you're using too

rustic nova
#

fetch the invites

eternal osprey
#
  client.dataserver.get("/data", (req,res)=>{
        res.json( interaction );
    })```This returns me:
#

TypeError: Do not know how to serialize a BigInt

rustic nova
#

wait for event,

fetch the invites again

find the ones that have +1

eternal osprey
#

If the computer doesn't know, how should i 😭

boreal iron
rustic nova
#

nah i dont like to read

earnest phoenix
eternal osprey
#
    const express = require('express')
    const bodyParser = require('body-parser');
    const cors = require('cors');
    const app = express();
    const port = 3000;
    app.use(cors());
    app.use(bodyParser.urlencoded({ extended: false }));
    app.use(bodyParser.json());
    app.get('/', (req, res) => {
    res.send('main page')
    });
    app.listen(port, () => console.log(`All music bots listening on port ${port}!`));
     client.dataserver = app```
earnest phoenix
ancient nova
# rustic nova wrong

only way I found is to listen to the guildMemberAdd evevent and check EVERY invite for uses increase

boreal iron
ancient nova
#

quite stupid imo

earnest phoenix
ancient nova
#

not adding the invite tracker then

rustic nova
ancient nova
#

it's gonna increase my ram usage even more than it already is

earnest phoenix
eternal osprey
#

mhmm

elder oxide
earnest phoenix
#

have you got an app.post?

rustic nova
eternal osprey
#

yeah it's under the get:

 client.dataserver.post("/data", (req,res)=>{
        console.log(req.body)
    })```
elder oxide
rustic nova
#

oh damn its telling me to use -b hayper

eternal osprey
#

Each tutorial and doc i have seen told me to do these things

earnest phoenix
#

ok add the router first

eternal osprey
#
TypeError: Do not know how to serialize a BigInt```still hits me with this
earnest phoenix
#

const router = express.Router();

#

and change client.dataserver.post to router.post

eternal osprey
#

as i am using the cors package

earnest phoenix
#

ah

#

alright nvm I dunno

eternal osprey
earnest phoenix
boreal iron
eternal osprey
#

I am sending the normal interaction data from the interactionCreate event

#

does that contain a bigInt?

earnest phoenix
#

Yes

boreal iron
#

Yeah the permissions

eternal osprey
#

If yes, how would i convert it to a readable state?

#

JSON.parse()?

boreal iron
#

Convert it to a string for example

eternal osprey
#

I used .stringify

#

still returns me the same BigInt

boreal iron
eternal osprey
#

.toString() would that work?

earnest phoenix
#

can't you just x = String(x)

#

You can pass a replacer function to the JSON.stringify() method to convert the bigints to a string for example

boreal iron
#

The permissions bigints need to be converted to strings, yes

#

That’s probably the easiest solution

eternal osprey
#

This is really hot

lyric mountain
#

lmao

#

that's also the pov of people who use jsondb sometimes

boreal iron
#

jasondb

eternal osprey
#

Why the fuck is it saying object object, i am literally only passing a stringified interaction

boreal iron
#

I took the part Since Tim isn’t here atm

earnest phoenix
boreal iron
#

Uhh bigint is it’s own type?

earnest phoenix
#

Yes

earnest phoenix
#

stringify({}) -> [object Object]

eternal osprey
#

i see, yeah that's dumb

#

express still confused me.

#

So for some reason, the get method posts my data to my webserver

#

and the post reads?

boreal iron
#

Errr Wut

eternal osprey
earnest phoenix
#

👀 Huh?

eternal osprey
# boreal iron Errr Wut
 client.dataserver.get("/data", (req,res)=>{
    
        res.json(JSON.stringify(
            interaction,
            (_, value) => typeof value === 'bigint'
              ? value.toString()
              : value
          ));
    })```This is a .get method, but sends data to my webserver?
boreal iron
#

I ain’t see shit on mobile wtf

earnest phoenix
#

The res.json() method responds back to the GET request, so that's why that data is shown

boreal iron
#

The \ you see are escaping your quotes

#

Since the entire thing is a string

#

Already wrapped in quotes

eternal osprey
#

So parsing it back to json would remove the quotes right?

boreal iron
#

Quotes inside quotes need to be escaped

eternal osprey
#

and make it a usable json again?

earnest phoenix
#

Yes

boreal iron
#

Yes

eternal osprey
#

I see, awesome, thanks!

eternal osprey
#

It posts the data to the webserver

#

how would i pull the /data contents from the webserver now?

earnest phoenix
#

What exactly do you mean by that?

boreal iron
#

Well you simply respond with the stringyfied object to the get request

#

You just need to get the response

eternal osprey
#

Huh wait

#

wait wait

#

look

boreal iron
eternal osprey
#
 client.dataserver.get("/data", (req,res)=>{
       res.json(JSON.stringify(
            interaction,
            (_, value) => typeof value === 'bigint'
              ? value.toString()
              : value
          ));
    })
    client.dataserver.post("/data", (req,res)=>{
   
    })```If the .get is doing all the work, what the fuck is the .post data for?
boreal iron
#

Now get the response …json() it and you got your object again

eternal osprey
#

Because right now it seems like the .get is sending the data.

earnest phoenix
#

post is for posting data to the server

eternal osprey
earnest phoenix
#

you're sending a get req to the server with the information you want

boreal iron
#

get(“/data”) is just the listener for GET requests on that endpoint

earnest phoenix
#

and the server responds to the get req with the data

#

so you're GETing data

boreal iron
#

You must be calling that endpoint somewhere

eternal osprey
earnest phoenix
#

yes because it's replying to the get request

#

and that is what is shown

eternal osprey
#

huhhhh\

earnest phoenix
#

(req,res) is short for (request, response)

eternal osprey
#

bro a ghost is controlling my webserver

eternal osprey
earnest phoenix
#

yeah so the response is what is "sending the data"

boreal iron
eternal osprey
#

But right now the post doesn't do shit

#

if i for example do:

earnest phoenix
#

well you aren't making any post requests

boreal iron
#

Because you don’t post anything in your event

earnest phoenix
#

so that checks out

#

when you do res.json(...)

boreal iron
#

I’m gonna send you an example in a few seconds

earnest phoenix
#

you're sending the JSON response

boreal iron
#

Once the Pc has booted up

earnest phoenix
#

if you comment out res.json(...) it won't "send" anything

eternal osprey
#
client.dataserver.post("/data", (req,res)=>{
     
        
        res.json(JSON.stringify(
            interaction,
            (_, value) => typeof value === 'bigint'
              ? value.toString()
              : value
          ));
         
    })
    client.dataserver.get("/data", (req,res)=>{
        console.log(req)
         
           
        })```this for example doesn't post
#

but isn't the post supposed to fucking post

earnest phoenix
#

it supposed to handle a POST request

earnest phoenix
#

because you're now handling a POST request

#

not a get request

#

and you're sending a get request

boreal iron
earnest phoenix
#

and theres nothing in there but a console log

eternal osprey
#

So a get could do anything

eternal osprey
earnest phoenix
#

change them back

#

and do res.json({ bruh: true})

#

that's what it will respond with

boreal iron
#

Inside your interaction event you curl your two endpoint in simpe words and pass the data to it

boreal iron
#

Inside your interaction event you send this POST request to your two bot slave endpoints
And for both you create a POST request listener

eternal osprey
#

I did remove the post like you told me and it works too

boreal iron
#

Since both are starting a webserver you have to use two different ports for em

eternal osprey
#

i am so dumb

eternal osprey
earnest phoenix
#

here's a better explanation

GET is saying "I want the data in request, I am waiting for a response which should contain my data"

POST is saying "Do something with the data in request. I am waiting for a reponse which will tell me if you did it or not"

eternal osprey
#

so i am in fact not sending any data to the webserver, only returning them data i want to see?

earnest phoenix
#

you're only sending the request

eternal osprey
#

Okay i see

#

So in the /post, i must send the data.

boreal iron
#

Tf are you doing

eternal osprey
#

In the /get read the data

eternal osprey
boreal iron
#

I thought you wanna send the interaction data to your two other clients?

boreal iron
#

So both need to listen for post requests your master does

eternal osprey
#

i am trying to send the i data to the webserver

#

yeah

boreal iron
#

Ok then both slave clients are running that express server listening for post requests and your master just sends a post request using, http, node-fetch or undici lib for example

#

It actually sends two post requests

#

One to the first machine, one to the second machine

eternal osprey
boreal iron
#

Since both Webservers running locally require different ports

boreal iron
#

The master does not need to listen for anything

eternal osprey
#

So wait, i need to do a post request to the webserver on the masters end, and then read the data using a get requests on the slave's end?

boreal iron
#

Since he gets the interaction

eternal osprey
boreal iron
#

No

#

NOT BY USING A WEBSERVER

#

you simply send a http post request

#

It doesn’t need a webserver

#

You can use the inbuilt http lib or undici of nodejs

#

To simply send that post request to your Webservers on your slave clients

#

Or node-fetch

#

Whatever you like

#

With the interaction data as content

#

(body)

eternal osprey
eternal osprey
#

Okay wait i will try it out

boreal iron
#

Can’t be hard to figure out

#

The two slaves need a letter box to receive a letter but the master doesn’t need one to send a letter

#

He just needs the trigger to send his letter

#

Which is your interaction aka when an user presses your button

#

-> POST request to your other two clients

#

Those are listening for requests waiting to do something the master says

eternal osprey
#

OOOwh wow

boreal iron
#

server.post() creates a listener on that path for post requests

#

It doesn’t send one

#

I literally asked you what you are familiar with and you said express pepowot

#

That has been close enough to be as confusing as a discussion with Bae

eternal osprey
#

Okay i see

#

But like, js client.dataserver.post("/musicbot2", (req,res)=>{ console.log(res) })this is now setup to one of my slaves

#

and now i just do a post request to the webserver/musicbot2 path using http?

boreal iron
#

The path can be the same for both slaves

#

You app listen() requires to use two different ports

#

Since both Webservers are running on the same machine

eternal osprey
#

yup

boreal iron
#

And can’t occupy the same ports

eternal osprey
#
client.dataserver.post("/data", (req,res)=>{
      console.log(res)
    })```i must wrap this in an interval right
#

to continuously check for posts being done

quartz kindle
#

no?

#

its an event

eternal osprey
#

Owh sorry

boreal iron
#

Ffs I can’t start my PC

#

Bullshit

#

PSU doing strange sounds

#

Well fuck this I’m going to sleep the rest of the day

quartz kindle
#

hit it with a bat

boreal iron
#

lol but no the RGBs is still lighting up

#

Can’t destroy that

quartz kindle
#

put it on your christmas tree

boreal iron
#

Most important thing in a PC

#

lmao

#

Damn imagine a christmas tree with a 1080Ti

#

it would tip over and fall down

eternal osprey
#
var XMLHttpRequest = require('xhr2');
    let xhr = new XMLHttpRequest();
xhr.open("POST", "https://localhost:3000/data");


xhr.onreadystatechange = function () {
  if (xhr.readyState === 4) {
  }};

let data = JSON.stringify(
    interaction,
    (_, value) => typeof value === 'bigint'
      ? value.toString()
      : value
  )
console.log(data)
xhr.send(data);
    ```Okay i have set this in the masters file.
#

In the slave's file i've got this setup: js client.dataserver.post("/data", (req,res)=>{ console.log(req) })

#

It doesn't long anything tho. Nor does it send anything to the localhost url

boreal iron
#

Oof xml request

#

First of all your localhost doesn’t use the secure protocol

eternal osprey
#

i am just using this for testing

#

later on i will use the ports of my vps to start the servers

boreal iron
#

You can’t just use the secure protocol out of nowhere

#

There has to be a valid cert, a validation with the cert server an handshake going on etc.

#

So use non-secure http protocol

#

http://localhost:3000/data

#

Fuck auto correct

#

Also please the http lib, node-fetch or the ugly kid undici

#

Even axios is better than what I see

eternal osprey
boreal iron
#

Are all 3 clients on your local machine NOW?

eternal osprey
#

i am only use 1 master and 1 slave to test

#

and yeah

#
   var XMLHttpRequest = require('xhr2');
    let xhr = new XMLHttpRequest();
xhr.open("POST", "http://localhost:3000/data");


xhr.onreadystatechange = function () {
  if (xhr.readyState === 4) {
  }};

let data = JSON.stringify(
    interaction,
    (_, value) => typeof value === 'bigint'
      ? value.toString()
      : value
  )
console.log(data)
xhr.send(data);```This in the master
boreal iron
#

That’s being executed inside your interaction event?

eternal osprey
#
ready event:
const express = require('express')
            const bodyParser = require('body-parser');
            const cors = require('cors');
            const router = express.Router();
            const app = express();
            const port = 3000;
            app.use(cors());
            
            
            app.use(bodyParser.urlencoded({ extended: false }));
            app.use(bodyParser.json());
            app.get('/', (req, res) => {
                res.send('main page')
            });
        
            app.listen(port, () => console.log(`Bot #2 listening on port ${port}!`));
            client.dataserver = app``` and ```js
this on the interactioncreate event
  client.dataserver.post("/data", (req,res)=>{
      console.log(req)
    })```on the slave's end
eternal osprey
boreal iron
#

Tf

#

That event is never being triggered

eternal osprey
#

yeah

solemn latch
#

You're using a get event and sending a post request

boreal iron
#

No

eternal osprey
#

it's due to the event being in my interactioncreate

#

nvm

#

its still not working lol

boreal iron
#

Where is the code now?

elder oxide
#

wth is going on?

eternal osprey
#

because after my xhr2 send, i am checking the localhost/data and it's not displaying anything as well

boreal iron
#

It can’t be inside the interaction event

boreal iron
#

As I said

eternal osprey
#

I will switch then

boreal iron
#

Not sure if cors could prevent that local request, too

#

You will have to investigate

eternal osprey
elder oxide
#

cors will try everything to stop you

#

even on local

boreal iron
eternal osprey
#

how can i stop cors from stopping me?

boreal iron
#

You don’t need cors or the router at all here

#

So don’t import em

eternal osprey
#

okay, removing it

solemn latch
#
this on the interactioncreate event
  client.dataserver.post("/data", (req,res)=>{
      console.log(req)
    })

this is in another event? 👀

boreal iron
#

Yeah told him to move it out already

solemn latch
#

oh okay

boreal iron
#

The bot can’t even receive an interaction

eternal osprey
#

right now i am concerned on why this bitch of a code doesn't send the data to my endpoint

boreal iron
#

It is since the event is never been called

eternal osprey
#

oowh

boreal iron
#

Not to a get request

#

Works

#

Now back to your master

#

Use a fucking appropriate LIB

eternal osprey
boreal iron
#

Or I will scream

solemn latch
#

if you want to check that specific endpoint

boreal iron
# eternal osprey Huh

Opening that endpoint in your browser literally sends a GET request to it which is the default request method

eternal osprey
#

Is it okay if that piece of code is in the ready event?

#

Or wouldn't it work as well

boreal iron
#

Which piece of code

#

On which client

eternal osprey
#
  client.dataserver.post("/data", (req,res)=>{
        console.log(req)
     })```
solemn latch
#

ideally that would be outside of any event.

boreal iron
#

Yes it’s okay to create the listener once the client is ready

eternal osprey
#

I see

solemn latch
#

if you want to wait until the client is ready you would have a ready check in the event itself.

boreal iron
#

Since you need ready client to perform an action

solemn latch
#

ideally you would send a response if the client isnt ready.

boreal iron
#

Also a Solution yes

#

But the ready event is being sent once only

#

So it’s okay

eternal osprey
#
    client.dataserver.post("/data", (req,res)=>{
                console.log(req)
             })```this is indeed returning me the req data
#

to display the sent data, i would need to use req.body right?

boreal iron
#

But still creating the server outside would be better practice

#

No doubts

boreal iron
eternal osprey
#

😭

boreal iron
#

Did you actually send something g?

eternal osprey
#

xhr is sending: js {"type":3,"id":"1008744142978945054","applicationId":"1003343920484339733","channelId":"1007793153773940816","guildId":"996722689010061322","user":"345138133429649408","member":"345138133429649408","version":1,"appPermissions":"4398046511103","memberPermissions":"1071698660929","locale":"en-US","guildLocale":"en-US","message":"1008741523346694235","customId":"play","componentType":2,"deferred":false,"ephemeral":null,"replied":false,"webhook":{"id":"1003343920484339733"}}

boreal iron
#

That’s stringyfied

#

?

eternal osprey
#

yeah

boreal iron
#

Tf you’re still using xml

eternal osprey
#
let data = JSON.stringify(
    interaction,
    (_, value) => typeof value === 'bigint'
      ? value.toString()
      : value
  )
console.log(data)
xhr.send(data);```
#

wait

#

waiut

#

wait

boreal iron
#

I swear if you don’t change that I will punch you

eternal osprey
#

josn.Stringify is not a thing we could use

boreal iron
#

Now

eternal osprey
boreal iron
#

YOU FIX THAT LIB FIRST

#

pepowot 🔫

eternal osprey
#

console.log(xhr.status);
console.log(xhr.responseText); returns me 0

#

and blank lol

#

you know what , i am changing to axios but i bet for 10$ it's going to be the same

solemn latch
#

xhr wont have a response, you are not sending a response.

boreal iron
#

If you have to use a lib then at least node-fetch

elder oxide
#

axios is so much easier ngl (than xhr2)

eternal osprey
#

uhh

#

So i switched to axios and it worked lmao

boreal iron
boreal iron
eternal osprey
#

sssh

boreal iron
#

Ok your nickname now

#

Mr. bae 2

#

Change it

earnest phoenix
boreal iron
#

(or node-fetch)

#

The 50th time

eternal osprey
eternal osprey
#

unless i use an older client

boreal iron
#

No

#

Yea

#

Then just install v2

#

npm install node-fetch@2

earnest phoenix
#

Just use ESM

#

God damn it

boreal iron
#

(still maintained)

#

Shut up

#

php > * > cjs > esm

#

To expand Tim’s quote

#

A bit

earnest phoenix
#

FakE I'm going to remove CJS completely because you said that, you must use ESM!

boreal iron
#

Fuck it I’m gonna create my own environment then

eternal osprey
#

that req.body doesn't contain all the interaction info thoo

#

like customids etc

boreal iron
#

Well you fucked it up then

#

Show the code

eternal osprey
#

The first one is the req.body logged

#

the blue one is the real interaction response that's being sent by axios

eternal osprey
#

Yeah you see

#
{"type":3,"id":"1008746829501964398","applicationId":"1003343920484339733","channelId":"1007793153773940816","guildId":"996722689010061322","user":"345138133429649408","member":"345138133429649408","version":1,"appPermissions":"4398046511103","memberPermissions":"1071698660929","locale":"en-US","guildLocale":"en-US","message":"1008746821281136702","customId":"play","componentType":2,"deferred":false,"ephemeral":null,"replied":false,"webhook":{"id":"1003343920484339733"}}:''```this is the full string, it just didn't scroll with output lol
#

Tho how can i parse it back to json

boreal iron
#

well in the post listener add json() as method to the request parameter

eternal osprey
boreal iron
#

if that’s a thing in express ?!

#

Didn’t you already import the body parser?

eternal osprey
#

you can, using app = express.jons

boreal iron
#

If so then use it

solemn latch
#

if your bodyparser/express.json is setup then the only reason it would give you a string is if the content type isnt being set in the request

eternal osprey
earnest phoenix
#

Is it possible to get HWID from a system in a chrome extension? If so please link the api

eternal osprey
#

It's text inside an object

boreal iron
#

That’s why I said show the code

#

And you responded with the output

#

Instead

eternal osprey
#
  const response = await axios.post("http://localhost:3000/data", {
                headers: {
                    'Content-Type': 'application/json',
                 
                },
                data
            })      ```even after setting the content type
#

it still gives me the initial stringified result

#
 let data = JSON.stringify(
            interaction,
            (_, value) => typeof value === 'bigint'
              ? value.toString()
              : value
          )```
#

Is there really no way to re-parse it back to json

solemn latch
#

I do it all the time on express.

boreal iron
eternal osprey
#
console.log(JSON.parse(req.body.data))```forgot to parse it back to json
#

now it works

#

guys, it's been a rollercoaster of emotions today

elder oxide
#

axios already parse it for you though-

eternal osprey
#

but i wold love to thank everyone for helping me

solemn latch
#

yeah

eternal osprey
#

data only contains the string

earnest phoenix
#

At least this didn't take longer than Bae's requests for help

eternal osprey
#

But it works, so that's a good think

eternal osprey
boreal iron
#

You also ignored what I wanted to know