#development

1 messages ยท Page 202 of 1

frosty gale
#

actually i just solved my own problem nvm

warm imp
#

Do you need node.js app open or nah

wicked pivot
#

I have a problem, I am setting up an API to read json but this also allows access to the source code as removed?

const express = require('express');
const app = express();
const port = 80;
const fs = require('fs');

const endpoints = [
    '/boss',
    '/chorus',
    '/clicker',
    '/egghunt',
    '/end',
    '/faction',
    '/koth',
    '/money',
    '/trixiumFaction',
    '/trixiumPlayer'
];

app.get('/', (req, res) => {
    res.json({
        endpoints
    });
});

endpoints.map(endpoint => {
    app.get(endpoint, (req, res) => {
        res.json(JSON.parse(fs.readFileSync(`./data${endpoint}.json`)));
    });
});```

base_url/faction work
but base_url/index.js works when it shouldn't ![sueur](https://cdn.discordapp.com/emojis/876219216313856060.webp?size=128 "sueur")
sharp geyser
#

Sounds like a good idea

#

Iโ€™d set a max amount per message tho

#

I also have no idea what they are talking about

wicked pivot
#

That's why I would like to change that xD

sharp geyser
#

Better off using a permission system at that point

#

Depending on how wide scale this api is

serene horizon
#

Does anyone use NextJS or React

#

im on the verge of breaking down

#

because data and userGroups doesn't want to accept data existin-

#

wait

#

brb

tawny lava
#

ur not awating the fetch

spark flint
#

You canโ€™t in useEffect

tawny lava
#

so just .then then

spark flint
#

@serene horizon do fetch.then() and handle the set stuff in there

#

Yeah

serene horizon
#

my friend told me to remove the .then

#

๐Ÿ˜ญ

tawny lava
#

useeffect worst thing ever made gg

serene horizon
#

i genuinely despise jextns so much

real rose
#

i got desperate once and just made an asynchronous function inside useeffect and called it straight away

#

lol

#

worked like a dream

serene horizon
#

yeah mine did that b4

#

but thats mes-

#

brb

#

okay yeah nvm

#

it didnt work

#

wait

#

was i using the wrong api this entire time

#

omg i fuckign hate my life

#

nope still no data yay..

frosty gale
#

jsx is the definition of bloatware in the web dev world

serene horizon
#

its not that bad

#

๐Ÿ’€

#

its bad but not that bad

#

it handles fine

#

and i dont like svelte

#

its just react shenanigans

serene horizon
#

i did try that...

#

lemme try again

solemn latch
#

I think these days route handlers are the "correct" approach.

serene horizon
#

still get hit w no data

#

the data IS there

#

idk its weird

#

@solemn latchidk if i did it right or

#

if react is against that lol

#

but thats what i did

#

lol i love _next being exposed all the time

real rose
#

ts-ignore

serene horizon
#

(they exist)

#

i do

#

I just cba being typesafe rn

#

i been doin this for 7 hrs

#

^ thats that 1

#

wait-

#

brb...

solemn latch
serene horizon
#

xdd

solemn latch
#

wasnt there a way to rename the _next endpoints? ๐Ÿ‘€

civic scroll
serene horizon
#

mhm

civic scroll
# serene horizon

type is not annotated
you will have to manually type the response type

fetch(...)
.then(res => res.json())
.then(data => consume(data as T))
serene horizon
#

okie lemme try this

civic scroll
serene horizon
#

jus did

#

2 sec lemme

#

make sure it all "works"

#

No data found-

#

wtf

#

so it does exist

#

but it still isnt setting state and idk why

civic scroll
serene horizon
civic scroll
serene horizon
#

oh

#

yh

#

i forgor about that

#

i HATE that ๐Ÿ˜ญ

civic scroll
#

react state change happens in next cycle

#

so touche

serene horizon
#

it smells

civic scroll
#

nah

serene horizon
#

yeah lemme do dat rq

civic scroll
#

you stinky for depending on state like that

serene horizon
#

copilot...

#

really tried

#

i didnt even mean to press tab ๐Ÿ˜ญ

civic scroll
#

if state changes eagerly, your application will hang

serene horizon
#

my friend told me to use state

civic scroll
#

how you used it was

serene horizon
#

o h

civic scroll
#

also to use the state

const [state, setState] = useState<T>();
                                   ^

specify the type, if you don't have an initial value for the state

#

oh chris i'm on phone

serene horizon
#

ur doinwell for phone--

#

๐Ÿ˜ญ

civic scroll
#

fixed it

#

not a well experience

serene horizon
#

pfft-

#

๐Ÿ˜Ž

#

its y e l l i n g

#

i havent inferred

civic scroll
serene horizon
#

yes i have

serene horizon
#

it kinda jus

civic scroll
serene horizon
#

does its thing

serene horizon
civic scroll
#

as long as you can verify the results

#

i had to disable copilot

serene horizon
#

what dis mean

serene horizon
civic scroll
serene horizon
#

i use it for logic that i cant think of

serene horizon
#

so ...[] = Array<...>

civic scroll
#

array types are suffixed with []

serene horizon
#

Kewl

civic scroll
#

yup

civic scroll
#

use it for what you already know but too lazy to type

serene horizon
#

this no?

serene horizon
#

i mean SIMPLEEE things

#

like

#

"i forgor how to check if x ISNT y..."

#

yes this happens often.

#

๐Ÿ˜ญ

civic scroll
serene horizon
#

its still yelling :(

civic scroll
#

as for the object i would recommend using null for empty value instead

civic scroll
serene horizon
#

yeah it doesnt like null

civic scroll
#

you will need to annotate the type

serene horizon
serene horizon
civic scroll
serene horizon
#

uh

#

wat-

civic scroll
serene horizon
#

im so confused im sorry- ๐Ÿ˜ญ

civic scroll
# serene horizon wat-

you declare a generic type that is maybe null, then use it in use state function
so that it allows null values

#

for example

const [user, setUser] = useState<Nullable<UserData>>(null);
#

this is useful when you have state with initially no meaningful values

serene horizon
#

like this?

civic scroll
#

yeah

serene horizon
#

oo oki

#

am i doing the right thing so far-

civic scroll
#

what is fetchAll

serene horizon
civic scroll
#

i don't like its signature

#

annotate return type of fetchAll

serene horizon
serene horizon
#

or

#

sorry

#

A [UserData | UserGroupData | null]?

civic scroll
#

nope

function fetchAll(...): [UserData, UserGroupData[]] {
    // ...
}
wheat mesa
#

I donโ€™t like returning arrays of different types like that

civic scroll
#

that and the error should go away

serene horizon
#

errr

#

it has to be a promise though

#

because its async

wheat mesa
#

I prefer a structure that wraps around both types as a member

serene horizon
#

because await fetch

civic scroll
serene horizon
#

or- do i not need await-

wheat mesa
#

You can wrap a promise in it

#

Promise<InnerType>

serene horizon
civic scroll
serene horizon
#

T?

#

T=YourType?

wheat mesa
#

T being your type

#

Yes

serene horizon
#

ahhh

#

im learning fr

wheat mesa
#

No worries

serene horizon
#

The fuck you mean

wheat mesa
#

The syntax can be challenging at first

serene horizon
#

UserGroupData isnt UserGroupData

civic scroll
serene horizon
#

idiot silly thingy smh.

wheat mesa
#

Youโ€™re not returning a promise

#

It wants a promise

serene horizon
#

wait

#

how do i return apromise-

civic scroll
#

hang on, just... do fetchAll first

serene horizon
#

oh

#

mu bad

#

oops

#

I forgot the []

#

lol

civic scroll
#

change the signature and reflect return type

#

actually, you don't even need the return type annotations if you return it as an object

serene horizon
#

I want to return as an obj

civic scroll
civic scroll
serene horizon
#

do u know what i can do about this btw

#

bc nextauth seems to think a valid discord oauth is name emial image

#

:Cri:

serene horizon
civic scroll
serene horizon
#

It's a predefined Session

#

idk how to change that

civic scroll
civic scroll
serene horizon
#

this ?

civic scroll
#

except you rename in the first case

civic scroll
serene horizon
serene horizon
civic scroll
#

would help reduce nesting

serene horizon
civic scroll
serene horizon
#

productionnnn

serene horizon
#

I think so-

civic scroll
#

no

civic scroll
serene horizon
#

oop

#

get rid of it all together?

civic scroll
#

just from dependency array would do

#

you can keep the rest

serene horizon
#

uh

#

how am i detecting if their

#

wait

#

status lol

civic scroll
#

you can mutate states even if it is not present in the dependency array

warm imp
#

Anyone still able to help me I am on PC now

civic scroll
serene horizon
#

uhh now i

#

figure out why its giving an empty array

civic scroll
#

useEffect is the effect callback, after the component rerenders because of a state change (an effect)

#

eg. you changing user

solemn latch
#

lol

civic scroll
#

wait that might not be the correct description

#

hmmm

warm imp
#

How to fix

civic scroll
civic scroll
warm imp
serene horizon
#

thats better

civic scroll
serene horizon
#

now im getting an error

#

well "error"

warm imp
civic scroll
#

also use screenshot (Win + Shift + S)

civic scroll
warm imp
serene horizon
#

awe that's cute

#

adorable

warm imp
civic scroll
#

you might also wanna check your environment variables as well

#

in Path

serene horizon
#

smacks lips

civic scroll
serene horizon
#

500.. oh thats database error

warm imp
serene horizon
#

ruh roh raggy

#

sounds about right

#

okay time to

civic scroll
serene horizon
#

cache the data

civic scroll
serene horizon
#

lmfao

#

i dont know how to

#

so

#

yay docs time :D

civic scroll
#

make a mock database server

serene horizon
civic scroll
#

you heard it

serene horizon
#

alr time to jooj

civic scroll
#

kidding

serene horizon
#

oh

#

i dont understand humour ngl

civic scroll
#

you really need to throttle your page reloads

#

jeez

serene horizon
#

uh

#

how

civic scroll
#

tbh, create a mock server that stores the cached data

#

that way you can avoid the 429

serene horizon
#

like a jest 1?

civic scroll
#

have the server request once, then store in the cache

#

change the url to temporarily point to your server

civic scroll
eternal osprey
#

i've seen it all

#
  1. Code bins
  2. Screenshots of code
  3. Pictures of a screen that has an error
serene horizon
serene horizon
#

anyways

#

ill go try make a mock server

civic scroll
serene horizon
#

๐Ÿ˜Ž

warm imp
serene horizon
#

that

#

npm cant not find itself

#

๐Ÿ˜ญ

civic scroll
#

the heck

#

i think i know

serene horizon
#

tfw npm errored finding npm

civic scroll
#

wait

#

in nodejs installer, did you check the box to also install npm

warm imp
#

Ummmmmm

#

idk

civic scroll
serene horizon
#

guess what kind of project this was

warm imp
#

Want me to redownload the whole node again or

civic scroll
# warm imp idk

run the installer again, modify the installation and check carefully

serene horizon
#

e a spors

civic scroll
#

make sure you have npm installed

#

then you will be good

serene horizon
#

@civic scroll cant i jus use a json-server lol

warm imp
#

Which one do i pick

serene horizon
#

i hate life

civic scroll
#

yeah

warm imp
sharp geyser
#

Itโ€™s crazy Iโ€™ve never seen someone struggle to install node

warm imp
#

or

sharp geyser
civic scroll
warm imp
serene horizon
#

mm true.

civic scroll
serene horizon
#

i could jus send them to the api

#

or make an entire new one

civic scroll
serene horizon
#

lol

#

I 429'd on roblox

#

bc it

civic scroll
#

assuming your page reloads on save

warm imp
#

It didnt download anything

serene horizon
#

requests from roblox

eternal osprey
#

honestly, try to find a tutorial online on how to install node ๐Ÿคท

serene horizon
civic scroll
warm imp
sharp geyser
#

Just hit enter

civic scroll
#

spawn a new terminal session and check if npm is still there

sharp geyser
#

It literally tells you what to do

civic scroll
#

if it is, restart vscode

serene horizon
sharp geyser
#

I am being nice

serene horizon
#

be sayu rn

civic scroll
#

what

sharp geyser
#

But I also donโ€™t understand people who canโ€™t read

warm imp
#

It aint me. its the flipping thing

sharp geyser
#

๐Ÿ’€

warm imp
warm imp
#

and did it

civic scroll
#

welp time to deploy the machine

warm imp
#

not sure why it isnt working

sharp geyser
#

Try running node -v in a terminal

civic scroll
sharp geyser
#

Okay then whatโ€™s the issue

civic scroll
#

not the target script file tho

sharp geyser
#

Well if he redownloaded it, then it would of fixed that

warm imp
#

I have 5 times

#

i'll do it again

sharp geyser
#

No

civic scroll
#

Win + X, then press I

#

now

warm imp
#

OK now what

civic scroll
#

type npm

#

see if it's there

warm imp
#

Same error

sharp geyser
#

Show the error

warm imp
eternal osprey
#

crazy it's a 3v1 and the error still outplaying you.

warm imp
#

But the code isnt in those files where it is searches

civic scroll
#

malformed environment variables

#

or rather, not present

warm imp
#

what does that mean

sharp geyser
#

it's looking in the wrong place

warm imp
#

Yeah

#

How to change it

sharp geyser
#

your path variables are fucked

warm imp
#

Ik

#

Dont know how to change

sharp geyser
#

change your path variable for nodejs

#

point it to look in the correct location, and run npm again

warm imp
#

How

#

just do dir (location)'

sharp geyser
#

Right, there is no way you don't know how to change environment variables

#

๐Ÿ’€

civic scroll
#

okay let's go

sharp geyser
warm imp
civic scroll
#

open environment variables settings

sharp geyser
#

Follow that video

#

thats the best ima help you

civic scroll
#

you have the window opened?

sharp geyser
#

it has visual exampls too :)

sharp geyser
#

just let him watch the video

#

If he can't even watch a video, then you explaining it will trip him up as well

civic scroll
sharp geyser
#

it will save us all the headache if he just watches a 1 minute video

#

๐Ÿ’€

civic scroll
#

@warm imp look in Path and look for any path that has nodejs or node in it
verify that it is correct
if not, remove that entry
then reinstall node

#

actually don't have to reinstall, but i wanted to make aure

civic scroll
sharp geyser
#

All he has to do is make it point to the root nodejs dir

serene horizon
#

@civic scroll thanks for helping hon

serene horizon
#

imma try the mock server stuff tomorrow (or when i get the energy to)

sharp geyser
#

C:\Users\user\ProgramData\nodejs or wherever its installed

serene horizon
#

on this.

civic scroll
serene horizon
#

Some might say I was stuck.

sharp geyser
#

that works too

civic scroll
serene horizon
#

2 breakdowns ThumbsUp

warm imp
#

How do i find where node is

sharp geyser
#

๐Ÿ’€

warm imp
#

where. node

#

right?

civic scroll
warm imp
#

k

warm imp
civic scroll
#

i hate that i have to run with .exe

sharp geyser
#

use cmd ;)

civic scroll
#

actually, it was an alias WAH

sharp geyser
#

better yet, run where.exe npm just to be extra extra sure

#

๐Ÿ’€

civic scroll
sharp geyser
#

rip

civic scroll
#

is node supposed to be this heavy

warm imp
#

Path is there

sharp geyser
#

I just find it kind of funny how when I first started out with node, I don't remember ever having this much trouble getting it to work

warm imp
#

But it is still going to the other location

sharp geyser
#

have you tried pressing ok to save your changes

civic scroll
sharp geyser
#

and then opening a NEW terminal

serene horizon
serene horizon
#

youre the one who cant find npm....

sharp geyser
#

path doesn't lie brother

serene horizon
#

infact...

warm imp
#

Still didnt work

serene horizon
warm imp
sharp geyser
#

right not to be rude

sharp geyser
#

:)

warm imp
#

See still going after i changed it

serene horizon
#

need to sleep

#

gn

civic scroll
# warm imp

for the case of vscode, you will need to restart it

serene horizon
#

@civic scroll again cheers

sharp geyser
#

right

warm imp
#

i got it lol

sharp geyser
#

I am not going to teach you how to use a fucking application

civic scroll
serene horizon
# warm imp

ctrl shift esc - Ctrl + f "Visual Studio Code"

civic scroll
#

jeez

serene horizon
#

๐Ÿ’€

#

shit hates the idea of deleting

civic scroll
serene horizon
#

or at least

#

in my experience

warm imp
#

I am gonna Pepega_Gun

civic scroll
#

restarting vscode would also refresh the env vars since it has to start a new console host

#

so yeah

warm imp
#

I did

civic scroll
#

what's the result?

warm imp
serene horizon
#

wait so

warm imp
#

Same thing

serene horizon
#

theyre able to find npm outside vsc ?

#

right-?

warm imp
#

No

sharp geyser
#

๐Ÿ’€

serene horizon
#

if you

#

cant find it outside vsc

warm imp
#

It was getting lost in command prompt too

serene horizon
#

you wont fifnd it IN vsc

sharp geyser
#

THEN TELL US THAT YOU BOZO

warm imp
#

I did

civic scroll
warm imp
#

๐Ÿ‘

serene horizon
#

allow me to introduce you to corepack

civic scroll
#

type in ```
ls C:\Users\natha\Roaming\npm\node_modules\npm\bin

see what you get
serene horizon
#

corepack install pnpm
corepack enable pnpm bang

sharp geyser
#

well

#

definitely not the Sayuri part

#

๐Ÿ’€

civic scroll
#

forgor

warm imp
#

ls wont work

sharp geyser
#

ls.exe

serene horizon
sharp geyser
#

๐Ÿ’€

civic scroll
#

ls is a powershell command alias

sharp geyser
#

is ls even a windows cmd

serene horizon
#

nope

#

its pwsh

#

not windows

sharp geyser
#

right

#

so is he on powershell?

serene horizon
#

imma be honest

#

idk

civic scroll
#

according to last screenshot, yes

warm imp
sharp geyser
#

well, i would not be surprised if he decided to switch it up on us

#

ok

civic scroll
warm imp
#

I did both

#

command & window

civic scroll
#

it was my mistake, apologies

sharp geyser
#

right

serene horizon
#

ls C:\Users\natha\Roaming\npm\node_modules\npm\bin @warm imp

civic scroll
#
ls C:\Users\natha\Roaming\npm\node_modules\npm\bin
sharp geyser
#

but you should be able to read right? Sayuri is obviouslly not a user on your system

civic scroll
sharp geyser
serene horizon
#

FUCK

#

jk it didnt ping them

sharp geyser
#

probably

serene horizon
#

oh

#

for fuck sake

civic scroll
#

for 2nd time

serene horizon
#

shhh

#

๐Ÿ˜ญ

warm imp
#

Still didnt work

serene horizon
serene horizon
civic scroll
sharp geyser
#

This is starting to feel like teaching Joe biden how to walk up a flight of steps

civic scroll
#

normally it would show something like this

serene horizon
#

There's an alternative to npm

sharp geyser
#

please dont

#

if he cant even use npm

serene horizon
sharp geyser
#

he wont ever be able to use anything else

warm imp
#

see to make it that i aint doing it in the wrong spot

serene horizon
#

youre

#

hon

spark flint
#

ls isn't a windows command

serene horizon
#

why are you in administrator

sharp geyser
#

welcome to the madness :)

serene horizon
#

ls C:\Users\natha\Roaming\npm

civic scroll
serene horizon
#

oh

serene horizon
#

yeah appdata

serene horizon
sharp geyser
civic scroll
serene horizon
#

silly goose!

warm imp
#

C:\Program Files\nodejs\node.exe

spark flint
#

oh in powershelll?

warm imp
#

Thats where node is

spark flint
#

anyone that uses powershell is insane

civic scroll
sharp geyser
#

that's what I said

spark flint
#

VM time

sharp geyser
#

At this point completly delete node and never touch it again :)

warm imp
#

๐Ÿ˜ฆ

sharp geyser
#

use rust

serene horizon
sharp geyser
#

better language

civic scroll
sharp geyser
#

๐Ÿ’ช

serene horizon
#

@warm imp can i get you to try corepack rq to see if that can solve it

spark flint
#

me when VM ๐Ÿ—ฃ๏ธ ๐Ÿ”ฅ

serene horizon
#

run this for me rq

sharp geyser
#

all he needs to do is completely remove it from his system, reinstall it to the correct place and then try it again

warm imp
#

To know where i am downloading it

civic scroll
spark flint
#

depends

sharp geyser
serene horizon
#

corepack install --global pnpm@stable @warm imp

civic scroll
sharp geyser
spark flint
#

just... use npm

#

stop confusing them

serene horizon
spark flint
#

ffs

serene horizon
#

they cant even use npm dude

sharp geyser
#

no one fucking cares

serene horizon
#

pnpm is a simpler installation.

spark flint
#

yeah then pnpm wont help lol

civic scroll
serene horizon
sharp geyser
#

Because you are the most fucking annoying person here

#

Yo uaren't even helping

serene horizon
#

no need for the aggression all the time

sharp geyser
#

so shut the fuck up

civic scroll
#

calm down folks

serene horizon
civic scroll
#

geez, calm down

#

no need to escalate

deft wolf
#

Holy monkaH

serene horizon
spark flint
#

tldr; pnpm won't help because it's just adding more confusing stuff

sharp geyser
#

Let us help him with the current problem

solemn latch
sharp geyser
#

instead of confusing shit

spark flint
#

if they use npm and the guides etc are using npm, then install npm since that is what they will need to follow

civic scroll
#

the main problem is, npm doesn't exist where it's supposed to be
so now we will need to do some shnenanigans

serene horizon
#

@warm imp lemme run it through with you

sharp geyser
civic scroll
#

we can manuyally download npm

serene horizon
#

mm

civic scroll
serene horizon
#

i need to

#

uninstall first

#

nevermind

#

WSL I COME

spark flint
civic scroll
warm imp
#

I redownload it

civic scroll
sharp geyser
#

He already did

spark flint
#

is this entire issue about failing to find npm

sharp geyser
#

And then reinstalled it

serene horizon
warm imp
#

I did i went into the control panel and delete it

civic scroll
#

then why node didn't install npm

spark flint
#

;C:\Program Files\nodejs\ on Path Variable -> User variable

civic scroll
#

weird

sharp geyser
spark flint
serene horizon
spark flint
#

then yeah just uninstall and reinstall node.js and it will fix itself ๐Ÿ‘

serene horizon
#

reinstall nodejs

warm imp
sharp geyser
#

Again, he already reinstalled it

sharp geyser
serene horizon
sharp geyser
#

there you go

serene horizon
#

npm 10

sharp geyser
#

go about your day

#

he can upgrade it

civic scroll
sharp geyser
#

npm install -g npm@latest

serene horizon
#

whys nodejs installation offering 10 by default wtf

#

2 sec

spark flint
#

isn't npm 10 the latest

warm imp
spark flint
#

npm version !== node version

civic scroll
#

samsung emoji

warm imp
serene horizon
#

wait no nvm i was thinking of py ๐Ÿ’€

spark flint
#

literally the latest...

sharp geyser
#

10.5.2

serene horizon
#

used to fixing peoples py311 installs

sharp geyser
warm imp
#

Its going to the wrong thing in VSC

serene horizon
#

not node installs

warm imp
sharp geyser
#

Restart your computer for good measure then

warm imp
#

I went in task manager and closed it

sharp geyser
#

Cause if you can use it outside of vsc

#

then it definitely is working

civic scroll
#

vsc was beyond saving

#

๐Ÿ˜”

warm imp
#

k BRB

serene horizon
#

shutdown /s /f /t 0 my beloved

civic scroll
#

Alt + F4

serene horizon
#

yeah u could do that

#

but

civic scroll
#

but what

serene horizon
#

what if ur in pwsh at the time

warm imp
#

Or ๐Ÿ”ซ PC

#

That Is another way to turn off pc

spark flint
serene horizon
#

why waste time alt f4'ing thru a bunch of screens

serene horizon
spark flint
#

then just reach for the back smh

serene horizon
#

i only do that once a week

warm imp
#

Ummmm

serene horizon
civic scroll
serene horizon
civic scroll
spark flint
#

personally i'd just use command prompt instead of vsc terminal

warm imp
serene horizon
#

^

#

i prefer to just use terminal

civic scroll
#

it has some utils that i like using

serene horizon
#

command prompt is fucked

#

but when possible

#

i use my wsl

civic scroll
#

oh

#

i misread that

#

my bad bun

warm imp
#

what happens if i delete VSC and redownload it

sharp geyser
serene horizon
#

what did u misread

serene horizon
#

youd waste about 5 mins of your time lol

#

maybe be a minor version up

warm imp
sharp geyser
warm imp
#

How to get there

serene horizon
#

ruh roh

#

i forgor my wsl password

sharp geyser
#

CTRL SHIFT P and iirc just search for Settings and it should give you an option to view the settings.json file

serene horizon
#

nvm

#

i got it

civic scroll
# serene horizon what did u misread
 command prompt instead of vsc terminal
 ^^^^^^^^^^^^^^            ^^^^^^^^^^^^
 |                         misread with `powershell`
 |
 caused by prediction of this prompt
 
 at Sayuri.ParseToken(dir: Linear, strategy: EagerReturnEval)
serene horizon
#

ruh roh

serene horizon
#

how long u spend writing that?

civic scroll
#

not long

serene horizon
#

too long? ๐Ÿ˜ญ

sharp geyser
#

๐Ÿ’€

#

this generation is hopeless

warm imp
#

Oh wait

civic scroll
warm imp
#

Lol\

serene horizon
#

@warm imp ctrl+r wt bish bash bosh use that

civic scroll
serene horizon
#

UR MSG DIDNT EVEN SEND THAT FAST.

civic scroll
warm imp
serene horizon
#

my dev drive has you in it fr

civic scroll
#

what

sharp geyser
#

guess its not vsc settings

serene horizon
#

sayu_smells

sharp geyser
#

see if that works

warm imp
#

K

sharp geyser
#

if not then its another issue entirely

warm imp
#

Google sucks

civic scroll
warm imp
#

It didnt show anything

sharp geyser
#

Though what that issue is, no idea because it works outside of it

serene horizon
civic scroll
sharp geyser
#

good thing im not a doctor

civic scroll
#

works in powershell, but not vscode terminal (which uses powershell)

serene horizon
#

yay its 00:00

#

OKAY GN.

civic scroll
#

i won fnaf

sharp geyser
#

honestly could be something fucked with vsc I wouldn't be surprised

warm imp
#

Do i change that

sharp geyser
#

no

warm imp
#

k

sharp geyser
#

unless you want to

warm imp
#

Ok it is now installed \

#

How do i restart my powershell

#

for the path

#

Wait it isnt VSC

#

idk

#

It's because the path

#

And I don't know how to change it

#

Besides going into environment variables which I already did

sharp geyser
#

shruganimated at this point Iโ€™ve exhausted all options

#

Youโ€™ve already reinstalled it completely which should logically fix it

sharp geyser
#

There is two different paths

#

User path and system path

warm imp
#

@sharp geyser

proven lantern
#

i was looking through my codebase for code smells and found a place where i'm using null. it looks like discord is requiring me to send content: null to get rid of the content. is discord planning to change this behavior?

#

is there anyway to avoid using null here? i think i would need discord to update their api

wheat mesa
#

Why do you care

#

Is this another one of those โ€œcode smellโ€ rants

proven lantern
#

removing code smells

#

i even said in my post

#

i was looking through my codebase for code smells

wheat mesa
#

Didnโ€™t read too much

proven lantern
#

it was the first sentence

wheat mesa
#

Code smells are a played up concept and you should not care this much about them

proven lantern
#

i just put out a big update and wanted to do some cleaning

wheat mesa
#

You are quite literally sending data to discord, and you yourself are not reading it anywhere. Null should not matter to you here

proven lantern
#

unless discord updates

wheat mesa
#

Pretty sure

#

You really shouldnโ€™t be caring this much. I hate the concept of โ€œcode smellsโ€ because they are a blanket of rules that say โ€œNEVER do [x]โ€ when in fact, there are plenty of valid situations where it is either unavoidable or unreasonable to avoid

proven lantern
#

yeah, every language should have undefined and null in it

wheat mesa
#

Every language has some concept of emptiness whether you agree with the name or not

proven lantern
#

every feature must be used

#

they usually have 1 concept of it

#

not 2

wheat mesa
#

Undefined is a mistake, I understand avoiding undefined

#

But null exists in every language whether you like it or not, there is just different ways of handling it

proven lantern
#

undefined is built into the language. null is extra. but if they renamed undefined to null and removed undefined that would work

wheat mesa
#

Rust has Option<T> instead of null, arguably one of the best ways of handling it

proven lantern
#

yeah, rust is pretty good for a typed language

wheat mesa
#

This level of code nitpicking makes it difficult to contribute to projects because you are more worried about your โ€œcode smellsโ€ than the actual code itself

#

Perfect code is not feasible to write. Strive for perfection, donโ€™t expect it

#

These small little things are not problematic to the point where you need to find ways around them

proven lantern
#

spaghetti code is easy at first, then you cant add anything to it

wheat mesa
#

Nobody said spaghetti code was okay to write

#

Youโ€™re trying to get rid of a null where it would make literally 0 difference because it is only ever touched by discord, not you

#

That is nitpicking

proven lantern
#

i wanted to remove a line of code. when you see null it's a sign that something could be wrong

wheat mesa
#

That is not a good mindset to have

#

I am pretty sure that nobody treats null as something that indicates a problem unless youโ€™re not expecting it to be possible to be null

proven lantern
# proven lantern

i need content: null here because discord wont delete the content part when you update a message unless you send content over

wheat mesa
#

And whatโ€™s wrong with that?

proven lantern
wheat mesa
#

Youโ€™re thinking about it far too deep

#

What about this line bothers you

proven lantern
#

i have to send content: null instead of just not sending content.

#

i had a bug because of that

wheat mesa
#

And you have solved the bug, no?

#

Then this line is not a code smell

proven lantern
#

it's discord's code smell transfering to my code

#

dang

wheat mesa
#

You have to do that, and thereโ€™s nothing you can do to change that. Saying itโ€™s a code smell because thereโ€™s null isnโ€™t valid

#

Sure, it might be odd on discordโ€™s end, but you are also worrying far too much over 1 line that you already figured out simply because an arbitrary set of rules says itโ€™s bad

proven lantern
#

i could probably use empty string instead

#

it is bad, it caused a bug

wheat mesa
#

If discord is expecting a content field, Iโ€™d imagine that it would be unhappy if it didnโ€™t receive one

proven lantern
#

the original message is an embed

wheat mesa
#

Well then again, not a problem on your end. Discord should give you an error and they didnโ€™t

#

Nothing you can do to fix that

proven lantern
#

then i update it with a content part to ping players when it's ready

#

then i update it again if someone leaves so it only has an embed with no content, but i have to send content: null instead of just ommiting it

#

it looks like they fixed it for attachments

quasi trench
#

Need a help

#

How can I change my bot pfp in top.gg

#

Please tell me someone !

lament rock
#

You cant

warm surge
lament rock
#

Whoops didn't see bot in there

#

Im r

warm surge
honest fox
#

uh guys where did my votes go?

#

any ideas?

harsh aspen
honest fox
#

yeah that makes some sense

#

ty

civic scroll
#

pylance is tripping

radiant kraken
civic scroll
#

so ofc

radiant kraken
#

ah yes java + python

#

worst of both worlds

civic scroll
#

i think the camel case is for people who have java muscle memory

frosty gale
#

thats what they get trying to bring their java shenanigans into python

elder eagle
#

Hi everyone, I'm programming my discord bot and I'm encountering this error, I don't understand how to fix it. Does anyone know what causes this problem? Many thanks in advance

lyric mountain
#

that means you tried to fetch or process an interaction (eg: buttons) that no longer exists

elder eagle
#

I have this in the code:

await interaction.reply({ files: [{ attachment: canvas.toBuffer(), name: 'profile.png' }] });

Could that be what's causing this error?

lyric mountain
#

maybe, cant say much without the full code

wheat mesa
#

Chances are you either tried to fetch an expired interaction or something like that

#

Itโ€™s also possible that you didnโ€™t defer the interaction and it expired before you could respond

quartz kindle
#

if your code is taking too long to respond (seeing you have image generation with canvas), the interaction will expire

#

the 3 seconds also count network delays, so realistically your code has less time than that

elder eagle
#

Exactly, I have to generate a fairly complex image and it's possible that it takes me more than 3 seconds, but how can I solve it then? Isn't there another way?

quartz kindle
#

ie, if it takes 300ms for the request to arrive, then another 300ms for the response to be delivered, the actual code only has 2.4 seconds to respond

quartz kindle
#

afterwards you can take all the time you want

elder eagle
deft wolf
#

Change .reply() to .editReply()

elder eagle
#

Thanks so much guys โค๏ธโค๏ธโค๏ธ

#

I was going crazy over this error

lyric mountain
#

iirc it'll extend to 15 min or so after deferral

elder eagle
#

yes its perfect

#

thank you again

lyric mountain
#

daemon is better if you're building many times iirc

#

I meant building many times, like, edit build edit build edit build

#

not many projects

#

if you want to speed it up, it's better if u increase gradle threads

#

default is 4 iirc

wooden ember
#

How would I make a message response activate for a word like "no" but not activate where the word if part of another like "now"? I know there is a way but can't remember. I thought of just using .startswith or whatever the filter is called but that still wouldn't work for words like now and that.

#

my command handler makes the message content into an array so I suppose I could just use that. see if the first word matches "no" or whatever

wheat mesa
#

.split(' ')[0].trim().toLowerCase() === 'no'?

#

This is probably a tragic way of doing this but if youโ€™re only checking the first word then I donโ€™t see why it would be a big deal

wooden ember
#

does that just make the message into an array and then just see if the first argument is no?

wheat mesa
#

Assuming that youโ€™re using the full content of the message, yes

wooden ember
#

nice

wheat mesa
#

If itโ€™s already split by your handler then you can get rid of the .split

wooden ember
#

yeah thats what I was thinking

wheat mesa
#

But again, probably not a great way of doing it. Not sure what your needs are for this

solemn latch
#

If you just want it to only respond to "no"
Then content === "no" :p

quartz kindle
#

you dont need the trim either, if you split with \s+ regex for example

wheat mesa
#

If you just want to see if โ€œnoโ€ exists in a sentence somewhere in there, you can use a regex

#

Yeah

wooden ember
#

my needs are, "its a funny bot on a mates discord" so I don't really mind about bad practice lol. that went out the window long ago

wheat mesa
#

Regex can match basically anything you think of but I forget the syntax for stuff since I donโ€™t use it very often

wooden ember
#

I know a bit of it but its not fresh in my mind at all

#

for my use case (ie to just say yes when some one says no) it would work better if its only from the first word not if its at any point in a sentance

solemn latch
#

Why wouldnt

content === "no"

work then?

wooden ember
#

cuz

#

I didn't think of that

#

lol

deft wolf
wooden ember
#

I think I am just using .includes at the moment so yeah I think I will just change it to that.

#

one of these days I will actually make the auto responses their own command file instead of just being typed in the top of the message event file

#

but eh I will probabvyl do that when I have to rewrite my entire bot the next time I put it on another server because node.js will be on version 1000 by then and nothing will work

#

I'm tired of this grandpa

wheat mesa
#

Use d++

#

Itโ€™s better

#

;^)

sharp geyser
#

Everyone is recommending dpp lately

wheat mesa
#

Great library

#

Efficient too

frosty gale
#

its everything a discord library for a large bot should be

sharp geyser
#

indeed

frosty gale
#

storing things efficiently and caching sparingly becomes extremely crucial especially with discords JSON type data

sharp geyser
#

Its quite the jump from js to c++ tho

frosty gale
#

json is very inefficient to store and play with

#

its basically a map but lets you have nested maps inside of it as well

frosty gale
#

but a lot of discord developers dont do languages like that

sharp geyser
#

I agree

#

I would not recommend starting out using D++ though unless you are completely new to programming

#

If you are already far into using js then stick with it until the need for D++ arises

frosty gale
#

this library is only for reading json but it doesnt store it as a map https://simdjson.org/ (not rapidjson)

#

it lets you jump through the keys and values on demand

#

nothing gets parsed until you need it

#

and consumed values disappear so memory footprint is extremely low

#

but it takes away the simplicity of json really

frosty gale
#

you need a somewhat beefy server already at only a couple of thousand servers

#

it was even worse before they added in partials and better cache control

lyric mountain
sharp geyser