#development
1 messages · Page 115 of 1
ya
or like this

Object.assign({}, { key: value })
i aint writing allat
nub
this is not correct
if x is a primitive, it will be a copy, not a reference
it should change it, but depends how you did it
show code
for example:
globalObject = { a:10 };
x = globalObject;
x.a = 20
console.log(globalObject) // { a: 20 }
// but
x = {} // this is a new object, not a reference
x.a = globalObject.a // this is a copy of the value from one object to another
x.a = 30;
console.log(globalObject) // { a: 20 }
thats interesting
however
if the value of a is another object inside the object instead of a number
then x.a = globalObject.a will not be a copy
it will still be a reference
I am confused
welcome to the club!
obj = { a: 10, b = {} }
x = {}
x.a = obj.a; // this is a copy, because a is a primitive
x.b = obj.b; // this is a reference, because b is an object
that makes sense
but why isnt it working in my scenario where I have an array of objects?
oh
it still doesnt seem to work though after removing that
actually
no, its working, some of the time
how can I do that part while keeping it a ref? with a loop and manually assigning?
you need to make everything a reference to the same object
without ever using = { ...
for example assign the object then edit the props
or use Object.assign
a = Object.assign(originalref, newProps)
a will still be a reference to the original
but the new props will be added
oh true
so they will be added to the original as well
I thought it would always make a new ref
{ ... } yes, but object.assign no
{ ... } is always a new ref, because its creating a new blank object, and then filling it
Object.assign uses the object in the first param as the base object
{ ... } is the same as Object.assign({}, ...)
assigning to a blank object
👍
do you know if its possible to manually delete something from memory? like I have some cases where I dont want to wait for gc to clean up some buffers, arrays and strings
With Mongoose,
Talking about a Schema
I have
action: {
type: String,
enum: ["log", "kick", "ban", "warn"],
required: true,
},```
Is there a way to make it fall back to e.g "log" if the value is not one of enum?
action: "log" 
action: "abc"
👉 action: "log"
There’s probably some hacky-ass way to do it but js doesn’t have any direct memory management like that, buffers are probably going to be the closest you can get
Keep in mind that if you have something that depends that heavily on performance, js might not be the proper language to choose from
If you want to manually manage memory consider a lower level language like C(++) or Rust
nope, not possible
its possible to manually run the gc using the expose gc flag in node
but thats a node-only thing (and maybe in some other engine as well)
its fine if only node
but running the gc manually does not guarantee your object will be targeted
and its not really a good idea
will setting it to null be?
Gc will always decide when to get rid of something
nope
iirc js uses reference counting right tim?
gc uses a lot of factors when deleting things from memory
including delays and timings to avoid blocking the process
so even if an object is marked for deletion, it may only be deleted later, when the timing is right
Mark and sweep algorithms my beloved c:
i believe it uses a combination of different things, including ref count yes
my current problem is that if you for example upload like a 1gb file it will stay in memory for like 15 sec after the request finished
but its up to the implementers to decide
so its pretty much an engine-specific feature
not part of the js spec
thats not how uploading is meant to be done
use streams
Are streams not a possibility for this..?
yes, obv
sometimes you do need the whole file though
why?
I need very large jsons for server management, up to 100mb
I dont think you can do that in any way with streams
json is lot really a good format for such large storage lol, cant you use a database?
its basically a ton of instructions to execute on a linux vps, like a ton a ton
there are some libs that can parse json in a stream-like manner
but if its instructions for a linux vps, isnt it something you should be able to do outside of node?
technically, yeah but its for managing multiple vps at once
for example, upload the file to disk using streams, then use shell tools to edit it
mh
wouldnt that be even slower?
it would be slower yes, but do you really need a config file to be that performant?
there are libs that can manage json files in a partial manner, without loading its entirety
What kind of instructions need hundreds of mbs of data 😭
mostly replication, aka cloning a vps (same packages, same files, same folders, same users, etc)
Why do this in node instead of rust or similar
because I still havent found a language which has a syntax I like better than js / ts
Syntax shouldn’t be more important than performance (if you need it, which here you do) unless it’s completely unusable but ok
this use case has nothing to do with performance
its all about I/O
network and disk speeds are pretty much the only factors here
I suppose, but he did say that he wanted the memory to be freed quickly instead of taking up tons of space for longer than the request needed
thats just a matter of streaming
well sure, a manual memory language will give you the ability to clear memory sooner
but you're still gonna be bloating your ram in and out
in some way
how do i fix this error with typescript TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts"
import {
Client,
GatewayIntentBits
} from 'discord.js';
import { token } from './config.json';
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
client.login(token);
are you doing node file.ts?
yes
nub
bruh
node cannot run ts files
why not
ts needs to be compiled into js
using tsc
but you can use ts-node which is a package that basically does that for you
install ts-node as a global package: npm i -g ts-node
then you can run: ts-node index.ts
https://www.youtube.com/watch?v=H91aqUHn8sE just watch this, you'll have a setup in a few minutes
Learn how to setup Node.js with TypeScript while supporting native ES modules. Use the new NodeNext option to easily interop between CommonJS and ES modules in the same project.
Full Lesson and Source Code https://fireship.io/lessons/typescript-nodejs-setup/
ok
but the correct way is to build using tsc then run the js files
usually you have an out directory for the compiled files
cannot be loaded because running scripts is disabled on this system. For more information, see
about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
ah yeah tsc is kinda dumb sometimes
Don’t use powershell
use tsc.cmd
what is tsc.cmd
where is it
dafuq
never had to do that on windows lol
just install typescript globally
npm i -g typescript
it's... a command...
this is a windows security feature that you can disable
follow the link to see how to do that
but no in visual studio code terminal
this error still persists tho
this is a windows security feature that you can disable
follow the link to see how to do that
The “Unknown file extension .ts” error occurs in ts-node occurs when "type": "module" is set in your package.json file. To fix it, run the TypeScript file with ts-node --esm my-file.ts, or remove "type": "module" from your package.json file.
Cannot find module './config.json'. Consider using '--resolveJsonModule' to import module with '.json' extension.
bruh
typescript is so buggy
thats not a bug
but it's erroring when i import config file
Its a feature.
I am new to typescript.In my project we are using typescript2, In one of my requirement i need to import json file. so i have created .d.ts file as follows
test.d.ts
declare module "*.json" {
...
I still have to see a SINGLE case where that "feature" was useful
like, a common user is very unlikely to use pshell at all
and an advanced user would fucking know what they're running, I suppose (if not they'd simply use cmd anyway)
any virus would also use cmd instead of pshell to execute scripts
bro
i can't even do if statements in ts without errors

oh wait
client.once
i meant event.once
hahahaha
ur moving to ts?
yes
thats what ts is for, it warns you of all possible things
to help you write stronger more correct code
I'd attempt a practice project before trying to migrate ur bot
id also recommend enabling strict mode in your tsconfig
anyway, a bunch of things u could do in js you wont be able to do anymore
which is good, but it'll force u out of zone of confort
bruh your saying that i'm able to do less now?
not "less", but "more correctly"
oh ok
for example you'll need to learn to use typing
what about this tho
it works in js
but ts is angry
so ```js
let a = 1
a = "test"
is no longer valid
how do i do it in javascript
a previously js project WILL NOT work in right away in ts
you'll need to rewrite it
cant u start with something simple
like a calculator or a "hello world" program
start correctly ffs
console.log('hello world')
?????????????????
also if i make a calculator don't i also need to make a website
that's too hard
ts uses static types, which means everything in ts needs to have fixed type annotations
for example, you cannot do client.a = something because client is already defined as having a set list of types that djs provides, so it detects that you are adding something that is not in the list, therefore not allowed
to do client.a = something you need to change the type of client to make room for a new custom property, there are many different ways to do that, one way is for example like this:
const client = new Client(...) as Client & { something: typeofsomethinghere }
but without eval
idek how to do math calculations without eval
hm ok
ah
that works beautifully
w
> Input first number:
< 1
> Input operation:
< /
> Input second number:
< 2
> Result: 0.5
like this
yes, but is great to start
the one and only infamous battleless
it's weird, but he's becoming a real dev now
The "proper" way to do this is to either extend the class or to add a type declaration on the client with a .d.ts file
who knows, maybe the jokes will finally end
I usually do something like ```ts
export class MyClient extends Client {
public commands: Collection<string, Something>
}
whats wrong with this tho
it works fine
no errors
first answer
jump into the world of recursive descent parsers
or RPN
or pratt parsers
or anything >:)
lmao no need for bodmas yet
https://github.com/Jwaffled/math_parser_rs rust is honestly super ideal for a beginner RD parser
just... not for battleless
he's going the right path this time
I just hope he stays till the end
the old battle wouldn't even get near TS
I won't believe it till I see it
From what I'm seeing he was just hopping on the bandwagon because we were saying how great it was
I feel it's a matter of time before he starts complaining
he complains like crazy but he slowly does accept what we say and slowly does accept changing his ways and trying new things
so he is progressing
inb4 "what's a type"
in a month it'll have been a full year since detritus got a commit :c
i type you type we type
makes me sad
rip
detritus died?
yeah
May 20th 2022 was the last commit to the beta branch
As for the master branch the last merge was September 21st 2021
it's crazy how fast time blows by
js/ts frameworks are literally rabbits in the wild
man I just wrote the most scuffed line of code I've written in a while
10 are born, only 2 or 3 stay alive to reproduce
lmao
I'm gonna torture my friend and make him javadoc everything
To be fair I've committed almost 1000 lines today alone
javadocs are easy to write but oh damn there are a fuckton of stuff to javadoc
Yeah
I think I surpassed 200 javadocs on my lib
Is there a way to count how many functions I have with intellij
this is so difficult
not using gradle or maven B)
idk for pure java, but there's probably a way
for a starter, yes, especially if you got too used to js' lenience
but it's worth the effort in the long run
const errors = {
notNumber: 'Please input a number!',
notOperator: 'Please input a valid operator!',
};
process.stdout.write('Input your first number: ');
process.stdin.on('data', (input) => {
const firstNumber = Number(input);
if (isNaN(firstNumber)) {
console.log(errors.notNumber);
process.exit();
};
process.stdout.write('Input your operator: ');
process.stdin.on('data', (input) => {
const operator = input.toString().trim();
if (!['+', '-', '*', '/'].includes(operator)) {
console.log(errors.notOperator);
process.exit();
};
process.stdout.write('Input your second number: ');
process.stdin.on('data', (input) => {
const secondNumber = Number(input);
if (isNaN(secondNumber)) {
console.log(errors.notNumber);
process.exit();
};
let result;
switch (operator) {
case '+':
result = firstNumber + secondNumber;
break;
case '-':
result = firstNumber - secondNumber;
break;
case '*':
result = firstNumber * secondNumber;
break;
case '/':
result = firstNumber / secondNumber;
break;
};
console.log('Results:' + result);
process.exit();
});
});
});
???
statically typed langs are able to catch 80% of the errors before running it
how
don't use stdin.on, use the await method I sent earlier
it'll allow a more predictable flow of code
LMAO have fun
what await method
I HAVENT EVEN ADDED FUCKING COLLISION YET
This is also only counting public methods, I have a ton of protected methods that need to be documented too
yay
write the function once, reuse it for all 3 values
on-demand function would be cleaner
fuck
that way u dont need 3 levels of nesting
you'll need something to practice with arrays too, since they're declared different too
and maps ig (this let map = {})
other than that there's likely not much before jumping to bot
oh, there are classes
but most dont use classes
I'm gonna need to decrease the quality of my javadocs if I ever want to finish this project
u need to declare types
typescript coming in clutch here
every variable needs a type
functions too
in this case you need to specify that the function will return a promise
how do i assign types
(Typescript can infer the types IF it has data to infer from)
let variable: Type = ...
so it's somewhat close to java's var
But keep in mind you don't need this for everything if you're doing something like ts let num = 5; since ts can see that num is clearly assigned a number value
if it complains about a type, you probably need one
also, avoid using : any most of the time
ok so
big thing
i need ui help
i suck ass at frontend
i have no idea how to make this look good
the colors look ass
text looks ass aswell
you need a color scheme
and i still have yet to add buttons
where can i find one
const firstNumber: number = await prompt('Input your first number: ');
still getting error
Type 'unknown' is not assignable to type 'number'.
https://coolors.co/ just found this from a quick search
ok so, prompt() returns Promise<unknown> because the user could input (in theory) anything
why the sign out button just text
Basically, you need to cast it
const firstNumber = await prompt("...") as number;
You could also validate input, which I highly suggest doing
(Since that's kind of the point of ts)
ok wtf
now when i try running my file
it opens up the video playing app
????????
brother
you can't just click on it
you have to compile it with tsc and then run it with node
you can't double click on it... it's not an executible
depending on ur IDE u can also simply click on "execute"
no
i'm doing ts-node calculator.ts
and then it's opening up video playing app
with my old code it wasn;t
did u mistakenly remap the default opening program?
try returning to the old code to see if it still happens
button is too fat
he's double clicking it with the file explorer
after we told him how to run it
it's quite hilarious
.ts is a video extension according to windows
no i'm not
as i said i'm doing ts-node calculator.ts in command prompt
tsc.cmd calculator.ts && node calculator.js
transport stream lol
import readline from 'readline';
const errors = {
notNumber: 'Please input a number!',
notOperator: 'Please input a valid operator!',
};
function prompt(input: string) {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
return new Promise(resolve => rl.question(input, ans => {
rl.close();
resolve(ans);
}))
};
(async () => {
const firstNumber = await prompt('Input your first number: ') as number;
if (isNaN(firstNumber)) {
console.log(errors.notNumber);
process.exit();
};
const operator = await prompt('Input your operator: ') as string;
if (!['+', '-', '*', '/'].includes(operator)) {
console.log(errors.notOperator);
process.exit();
};
const secondNumber = await prompt('Input your second number: ') as number;
if (isNaN(secondNumber)) {
console.log(errors.notNumber);
process.exit();
};
let result;
switch (operator) {
case '+':
result = firstNumber + secondNumber;
break;
case '-':
result = firstNumber - secondNumber;
break;
case '*':
result = firstNumber * secondNumber;
break;
case '/':
result = firstNumber / secondNumber;
break;
};
console.log('Results: ' + result);
process.exit();
})();
this is my new code btw
transport stream is a thing? lul
Likely just windows being weird
Did u try running with the command line waffle sent?
yes
it said like
blah blah blah is not a command
tsc.cmd' is not recognized as an internal or external command
Hm, did u install ts today?
wym install ts
no
If u installed with node it should've added automatically
This
After that reopen the terminal window and try again
It should now find tsc
On the code or on the terminal?
in termal
What is it saying?
You can also add the path of the executable to the known environment paths in Windows to run it globally without using the path
Cannot find name 'process'. Do you need to install type definitions for node? Try npm i --save-dev @types/node
stuff like that
Dependencies ig
Follow what it says until it finishes installing

Idk, did u do something different?
uh no
this is the new code
the old code works fine
Try running a simple console.log() file
If it doesn't work then something probably happened with tsc
Yes, ts node
yes it works
?
Windows things ig
But well, did it work as expected?
yes
Nice, now try setupping a simple ping bot
Then start writing commands as you go
Did u cast it to number?
as number
yes
casting it is not enough
const firstNumber = await prompt('Input your first number: ') as number;
const secondNumber = await prompt('Input your second number: ') as number;
case '+':
result = firstNumber + secondNumber;
break;
parseInt then
or Number()
That's a peculiarity of addition
/*- arent valid string operations
js tries to guess the best way to do operations on dynamic types
So it knows you want a numeric operation
But + is a valid string operation (concat)
wait
So it thinks you want to concat
parseInt(await prompt)
Use Number() as tim said, since you might input a decimal too
thats where you can cast it as string
Cast it at the end
Number((await prompt()) as string)
It's also worth to attempt using git too, as it's a very important tool for larger projects
but what i want to learn to do is
make it so when i commit something
it resets my project with new code
i tried once but it didn't work properly
it reseted it but not with the new code
To save to remote:
git add .
git commit -m "some message"
git push
To get the updated code:
git pull
It won't reset anything, it'll just update the project with the newly added code
i want it to do it automatically
For that you'd need to setup some kind of tool to track remote status
It's not a good idea, as it might break often
And any small change will restart the bot
pm2 likely has that feature
At least ik it can track folder changes
Did it report any error?
Go with manual git for now, at least you can ensure it doesn't update code when unnecessary
Also possible to make a bot command to do it
As node can run commands
@lyric mountain can you tell me if this thought process sounds right?
I need to make a layers system, and I was originally thinking about just using a map like you said, but the more I think about it, the more it seems like a possibility to just maintain a sorted list of entities to loop over
I was thinking that inserting into a sorted list could be O(log(n)) time too because you (I think?) could basically use a binary search for insertion
And it doesn't sound like a terrible idea
Treeset uses binary search for all operations
The map method has the advantage of not needing sorting at all, it'll at worst be 2 operations
Yeah that's fair
Thoss being map.get() and set.get()
I'm just trying to think about how to modify my ECS to handle it
But it does use more ram than a treeset as you'll be maintaining N sets, instead of 1
N being the number of layers
Another advantage is that you can easily discard most entities from collision check
If u make different layers not able to collide
Otherwise ignore this part
Yeah that's true
Nah, more like a couple kbs
Java collections are really memory efficient
Try implementing both systems, see which one performs better for your use-case
what does the backend of a website mean
A site with no backend is called a static site
why
i can write javascript code in the pages files
It's static because you get what you see
Dynamic sites might change content with or without user interaction
Like a blog
no

A purely informational site can fare well without backend
I think u should stick to playing roblox
You don't need a backend for every site
For example, a portfolio wouldn't benefit from having one
static website = server that holds html/css/js files, when website is accessed, the browser downloads those files and shows them to the user
dynamic website = server that runs a software that receives requests in real time and runs some code then responds with some html+css+js response generated dynamically based on the request type and content
whats wrong with roblox
so i do need an api

but i want my website to show the data i have
Your api would be a webserver running somewhere listening to requests
Your site would merely call it to retrieve data
an api is something different, its application programming interface, which means there is an open endpoint that provides some kind of interaction, related to or not related to the website
so do i need one to do that
Yes

You can achieve it with express if you're going with js/ts
but
i want both my bot and website to be able to access the data
but i'm using sqlite so it's a file and can only be in one folder

No prob, just have both call the api

Make the api be the only one accessing the database
so should i make the api separate from both
Optimally, yes
As you'll have a decoupled project
So if u ever need to restart the bot it doesn't take the api down
true
but
right now i collect all the data through the bot
so i will need to remove that and put it somewhere else 
but how will i do that with express
You can make an endpoint to insert data
Api doesn't necessarily need to be read-only
hm
wouldn't it be better to do it seperately tho
cus if bot down
then it will no longer collect data

Nothing u can do about that
Actually, what data are we talking about?
Is it steam data?
no
User data?
no
So what?
game data
But collecting from where?
If it's not from discord, just make the api collect it instead
The same way u did on the bot
If it's a command, make it an endpoint
Imagine your api is just like someone using a discord command
but
how will i make it collect the data
the endpoint will not collect the data itself

How does the bot do it?
Just do it the same way on the api
A bot is literally an api for discord
U can make periodic tasks on it too
You can make anything you want on the api, it doesn't need to be a request -> answer thing
Not unless you expose it as an endpoint
Code is always hidden from the end user
They just see what u show them
Just dont do shady things
for my api i don't need a domain right
er
As your site will be calling the api, so people could see your ip
but even if i have a domain, can't they see the ip anyways?
They'll only see the domain
If you use cloudflare, they'd not be able to see the ip behind the domain even
so they can see the ip?
They can see which url you're sending requests to
If it's a domain, they can use whois to find out which ip is behind it
You can make it point to cloudflare
domain -> cloudflare -> ip
So if they use whois, they'd see cloudflare dns ip
Not your real ip
The same works for any dns provider
is that easy to setup
I think so, just follow a guide
hm
Don't worry about it for now
all this seems very difficult and if i make a mistake it can end bad 
It is if you focus on everything at once
Focus on one thing at a time
First you need and api, then the site
Or the other way around, whatever works for you
Only then focus on hiding your ip
Also don't make the site public while developing, nobody needs to see an unfinished project
should I make the API with TypeScript
Up to you
TS is easier to find code errors, but takes more effort (which you save later when debugging)
I don't even know how to host a website 
i'll figure that out later
@lyric mountain turns out the treemap solution was really easy to implement and it works like a charm, thank you C:
hm
🌳
how do i even use a domain with express
You don't, you setup the domain on whatever you're using as a webserver
Like nginx or apache
you can use node directly, but you need to run it in port 80/443
which requires root
but why can't i just do it on node
when i was testing my api before i just did node index.js
Safety issues
node by default does not run on the root/sudo user
ports smaller than 1024 are protected and reserved for root/sudo users only
Also setupping ssl will be awful
so you need to either allow ports somehow or run node as root/sudo
then it will work
Nginx runs by itself
Or forward ports
It's not something u have to start everytime
In windows you'd call it "a service"
Putting another webserver to proxy his node process
It's a background process that works on its own
nginx is where is where i'm suppose to do rate limiting and stuff right
Yes
U can do it in your code aswell
i've heard of docker but don't really know what it is
But nginx can aswell
Think of it as a vm
You heard about right
It’s running code inside the vm
Handling traffic on this network layer is just stupid
is it easy to do that stuff with nginx
It takes some practice to learn to use it, but I find it much easier than apache
Wut
Fuck xml
whats nginx proxy manager
Nginx is far more annoying than Apache
GUI for nginx basically
Does nginx stuff but with web gui
Nginx can work as a redirection service, like, something to choose where to send the user to
Let's say you have 5 of the same api, each running in a different server
With nginx you can send the request to the least busy api, for example
hm ok
But don't bother about it for now
is nginx used by big companies?
Well with pretty much any common webserver
To be fair
Round robin or generally load balancing isn't something nginx exclusive
Ik
Yeah it's pretty much a more modular or modern webserver (than Apache)
i don't really wanna pay for a domain tbh 
Local tunnel?
i have one but it's for another project
Or duckdns
i could use it
Make the site first, focus on presentation later
true
The domain is useless if you don't have something to use it for
i will make the API first
with typescript
i can use express with typescript right?
Yes
ok
so since the code i use to collect data is a function
can't i just copy the function to my api project and use a cron job like i do on the bot

Ig so
Show app
You may need to do npm i @types/express if they require it, some libs do, some don't
^
what abt this tho
You can use classes, types, interfaces, etc to define the structure of an object
For example, if you wanted an object that had a property "name" that held a string, and "age" that held a number, you could represent it like so: ```ts
interface Person {
name: string;
age: number;
}
Like what
Chances are someone has defined a type for it
idek
but it's like
a long ass object thing
with text
n stuff
numbers
ips
data
parameters
all that shit from API requests that u would need
if you're getting that data from an API, they likely have documentation for what the object looks like
sounds like a lot of work
well
you don't HAVE to but that defeats the purpose of using ts
a lot more than that
Why would you have so many properties
Are you sure you're not in need of a proper data structure to manage that?
i didn't create express
Express isn't responsible for the types you serve to your users
Bruh
when someone makes a request
Express has types for that

where
Request and Response
how do i use them
import express, { Express, Request, Response } from 'express';
In your function you would have like app.get('/somePath', (req: Request, res: Response) => {...}
i think express autoatmically does that
when i added this to my code
the underline visual studio code made
disappeared
..what?
Yes
The error squiggly or the req/res dotted underline?
second one
That means VSC was making a suggestion to you, probably to add types to the function variables
If you remove the typehints on the parameters then that line will appear again
You can hover over it to see what it tells you
whats a typehints
: TypeName
but
: number is a "typehint"
Then remove the line and hover over it to see what it says
🤯
cus
It's a good thing
i wanna use typescript properly
When you have that line it means ts is complaining about something
Keep ts happy, keep your code happy
L typescript
And it begins
Endure it, it'll be good to hone your skills
Just wait until he gets to a strict statically typed language
...did you start the script
hmm
i see why
my map is empty
why is that

const endpoints = new Map();
function setEndpoints(path: string) {
const files = fs.readdirSync(path, { withFileTypes: true });
for (const file of files) {
if (file.isDirectory()) {
setEndpoints(`${path}/${file.name}`)
} else if (file.name.endsWith('.js')) {
endpoints.set(`${path.replace('./endpoints', '')}/${file.name.replace('.js', '')}`, require(`${path}/${file.name}`));
};
};
};
setEndpoints('./endpoints');
apparently this doesn't work with ts
oh wait
ends with .js
☠️
Parameter 'res' implicitly has an 'any' type.
won't start my damn api because of this
did you install @types/express?
yes
also whats up with this
import { insertGame } from '../../utils/schemas.js';```
```Module '"../../utils/schemas.js"' has no exported member 'insertGame'. Did you mean to use 'import insertGame from "../../utils/schemas.js"' instead?```

ty
typescript bro
Type 'ParsedQs[]' is not comparable to type 'number'.```

weird part is that it works in one file, but not the other
Whatever parsedqs is, you can't pass it as an argument
I should tell you where it happened
well it does
but it works here
it cannot be a number
req.query.something is of type string | ParsedQs | string[] | ParsedQs[] | undefined
those are all the possible types of req.query.something
shows 19 days
the type that you get/set in ts is just a hint, it does not affect actual code
you have to make sure that the type hints you are giving actually match the code
ok this works
Oh boy
you dont need to add as number there
because Number() automatically gives you a type number
i thought i have to make everything a type tho
oh ok
a lot of things already have types defined
for example the function Number() is already defined as a function that accepts a string type and returns a number type
hm
Could not find a declaration file for module 'better-sqlite3'
install @types/better-sqlite3
a library on npm can have types bundled with it, or not
the @types libraries are basically to add types to existing libraries that do not have types built in
a lot of developers dont bother adding types to their libs
w
so someone else does it for them and publishes it in @types
my api is now working with typescript
ah
i see
really appreicate everyone's help today 
i will continue with this tomorrow
sleepy time is now
👍
process.on('unhandledRejection', async (reason, p) => {
return errorChannel.send({
embeds: [
new Discord.EmbedBuilder()
.setTitle("New unhandledRejection encounted")
.setDescription(`\`\`\`${reason.stack}\`\`\``)
.setFooter(`${client.user.tag}`)
.setColor("#f09999")
]
})
});
process.on('uncaughtException', (reason, origin) => {
return errorChannel.send({
embeds: [
new Discord.EmbedBuilder()
.setTitle("New uncaughtExpection encounted")
.setDescription(`\`\`\`${reason.stack}\`\`\``)
.setFooter(`${client.user.tag}`)
.setColor("#f09999")
]
})
});
process.on('uncaughtExceptionMonitor', (reason, origin) => {
return errorChannel.send({
embeds: [
new Discord.EmbedBuilder()
.setTitle("New uncaughtExceptionMonitor encounted")
.setDescription(`\`\`\`${reason.stack}\`\`\``)
.setFooter(`${client.user.tag}`)
.setColor("#f09999")
]
})
})
``` why is this error handler not sending anything via the webhook?
i tried to make an error happen by removing a { it somehow doesn't even log in the console
i tried to make an error happen but it doesn't even log the events table
I'm not quite sure if you can catch these kinds of errors as they break the basic rules of the language you're programming in, the bot just won't run
Conceptually, there are 2 kinds of errors
Which are Errors and Exceptions
The latter can be caught and handled as you already know, but the former should never be caught (or be able to be) as they usually represent fatal issues that happened during execution
It includes syntax errors, running out of memory, stackoverflow, external interruption, etc
Try to ensure it doesn't happen, instead of remedying it
Btw, I noticed u have the bot automatically restart after a crash
This is very dangerous as it can lead to IDENTIFY ratelimit in case of discord outage (or crash loops)
The correct use of 'uncaughtException' is to perform synchronous cleanup of allocated resources (e.g. file descriptors, handles, etc) before shutting down the process. It is not safe to resume normal operation after 'uncaughtException'.
ok
Implement no, but outline yes
the only reason I'd see to do that though is if you are overriding another class's default types/methods
god reading through that was a pain
it was a webhook issue