#development
1 messages Β· Page 230 of 1
I mean HTML itself isn't complex (for me), but connecting with other ingredients is especially that I'm new at web development
yeah printf is hard to get right, but it can be used in a lot of different ways
its a fully featured text formatting tool
under the hood is it not just using a loop?
there are the sources
https://sourceware.org/git/?p=glibc.git;a=blob;f=stdio-common/printf.c;h=4c8f3a2a0c38ab27a2eed4d2ff3b804980aa8f9f;hb=3321010338384ecdc6633a8b032bb0ed6aa9b19a
https://sourceware.org/git/?p=glibc.git;a=blob;f=stdio-common/vfprintf.c;h=fc370e8cbc4e9652a2ed377b1c6f2324f15b1bf9;hb=3321010338384ecdc6633a8b032bb0ed6aa9b19a
HTML and CSS are the main parts of Next.js that I'm supposed to learn, right? I mean for sure after JavaScript itself
yuh
I can tell
lol
most of those look like they didnt get modified for years
2010 looks like the last time that file was touched
well they dont need to
its pretty much as optimized as it can get
yeah pretty hard, since its already done according to scientific papers from 50 years ago xD

its interesting how algorithms developed and discovered 50 years ago are still widely unbeatable today
mostly due to how limited hardware was back then, everything had to be the most efficient and performant possible or it would be unfeasable to even do it
general kenobi...
it forced people to think minimally while still being efficient
yeah, it forced people to be really creative and ingenious
how would i check to see if a user is in a channel? Get Guild Member doesn't seem to have it, but Modify Guild Member has it
u cant
today's developers have no sense of performance at all, everything is "just throw more hardware at it"
all members are in all channels at all the time
like what kind of channel
you can check on threads tho
even threads and vcs?
probably
forums are glorified threads
cant you check peermissions to see if the user can access the channel?
unless discord is terrible and makes people join it by default
and all you are doing is viewing it
it's like a thread, when u type u participate in it
is there anyway to remove a user from voice only if they are in a certain voice channel?
sure
sure, but u need move members perm
i have the move part working, but i just want to check before moving them
what exactly are you checking?
well, js too
nextjs uses react
and react is basically html in js
when a user leaves a lobby i remove their permissions from the lobby voice channels, but if they are in the voice channel they can still hear everything so i need to remove them. but if they are in a different voice channel i dont want to disconnect them from voice
ah you're talking about voice channels
not possible to do via rest api
only via websocket voice events
use the voiceStateUpdate event to see if they are in that channel
ifyou are using rest only sorry
like tim said not possible
dang
you have to listen to voice state events and then store that information yourself
its the only way of knowing whether a user is in a voice or not
also
when you connect to the gateway
you do receive a list of all users connected to voice channels
so that you can have a state to start with
you dont need to connect to the main gateway do ya?
since the voice gateway is separate
no its on the main gateway
ah
maybe i could connect temporally from my lambda to get that info
sure
you can even do the hack to login only the specific guild you need
you only get 1k a day
but yeah, the 1k limit will be a problem
ah, good to know
just keep the gateway session open tbh
its not worth finding a hacky way that will possibly break their guidelines
you can make it so you only recieve voice related events
i am using aws lambda

it shuts down after every request
yeah lambdas dont support keeping ws open
yea then I can only say abandaon this idea or swap to something else, unless you can find a way to keep the ws open
it doesn't even wait for background stuff to finish so you need to await everything
yeah, i think i'll just remove them blindly
lel
you can deafen them via the rest api yea
but only in the channel
but you wont be able to again tell which channel they are in
thats not a thing afaik
double dang
they are already connected. i tested and i can still hear
normal voice
ah well
nothing much you can do besides blindly deafen them
or blindly remove them
server deafen if they leave the lobby
just to be safe
lel
Honestly this will be virtually impossible to do effectively without the gateway
blindly deafening them is a bad idea as well
same with removing them
what if i give the other members MOVE_MEMBER permissions in the channel.
then they could remove them manually perhaps
or is MOVE_MEMBER not even a channel level perm
let me see
nope, not at the channel level
perhaps i give members this permission in the channels
if two users have this permission can they deafen each other?
or only if the other member doesn't have the permission
Yes they can server deafen each other other and undeafen themselves
so they could deafen the member that leaves the lobby, but they could also troll each other
hmmm
@quartz kindle I have a question about memory
If applications use memory, and they typically use a certain amount, and if you have multiple applications open, how does another application know an address is taken by a currently running application and not to touch it?
Is it some sort of like "This is strictly reserved, you better not touch it" and if so, how does it communicate that
Idk if this is an appropriate question to be asking right now or if ima confuse myself, but I was curious
the OS is in charge of managing that
Hm I see
i dont know the details, but the OS allocates blocks of memory and assignes a process id to them
the program itself does not know anything about memory besides what the OS tells it
Ah I see okay
That makes sense
I thought the program itself was handling the memory
but that makes more sense the OS allocates it for it
what the program sees is "virtual memory", which basically means the memory that the program thinks its using
virtual memory is an arbitrary number that often doesnt make much sense
some times the program has a virtual memory of several times more than the amount of ram
π
thats what the program thinks its available for use
Thats kind of crazy
when the program actually wants to use it, the OS will manage that, check if its available, howmuch is available, put parts in ram, parts in swap if needed, take away unused ram from other apps, etc
oh thats cool
So thats why you see applications sometimes go from using more ram to using less
the OS also makes a lot of memory "mapping", for example the app wants 50mb, the os gives it a block of 50 mb, from address X until address Y
but the OS then maps this to random places that the app doesnt know about
for example addresses from X until X+5000 will be in X location in ram, then from X+5000 until X+10000 will be in another location in ram, then the rest in swap
the actual physical location of data in ram can be anywhere, can be fragmented, split in pieces and other stuff
but the app will never know about that, it only sees a block of ram
when you try to access parts of memory you shouldnt, in low level languages two different scenarios can happen (correct me if im wrong about this tho)
either the invalid area you access is still inside the physical locations of memory that belong to the same app, you get random garbage data or undefined behavior
if it happens to be outside of the physical locations that belong to the app, then you get a hard failure, access violation errors, segfault, etc
sounds correct
I know until you give a definition a value it will hold garbage data
if you do
int main(void)
{
int n;
printf("%i\n", n);
}
it will have garbage data
any memory allocation will hold garbage data by default, because it would be expensive to constantly write zeros whenever areas of memory are freed
yea
so it only writes zeroes when explicitly requested
ye
iirc if you try to write something out of bounds of your allocated memory, it will segfault tho
at least in C (from what I saw)
ye
it doesn't even return garbage data, it just segfaults
how memory is allocated is a whole other field of study, actually, and much of it is still being developed today
you have a bunch of new-ish allocators out there, like mimalloc, jemalloc, tcmalloc
with different tweaks and strategies to read/write to ram faster
but its a very complex field
because fragmentation is a big problem
the gist of the issue is basically like this
if you have an array of size 10, and indexes 1-6 are used by one program, then 7-10 are used by a different program
then you close program 1, and free indexed 1-6
then start a new program that requires 7 spaces
you have 1-6 free, but its not big enough to write 7
so you need to fragment it?
Where it takes up those 1-6 spaces so its not wasting memory
but then it takes up 1 space in another?
so you either make the array bigger and write 11-18, and leave that 1-6 unused, making the program use more memory than it should
or you fragment it, and make it slower
yeah
so fragmenting is slower
whch makes sense
because now it has 2 blocks to read/write from
now repeat this process over thousands and millions of times as computers open and close processes
and you have a real chaos in your ram
is fragmenting how its normally done rn?
most allocators allocate in fixed blocks
for example even if the program needs only 90 bytes, it will alocate a block of 256 for example
but then the allocator has multiuple block sizes
For what reason
called "arenas"
that seems like a waste of memory
so if a program needs 900 bytes, instead of multiple 256 blocks, it will use one larger 1024 block
a different arena
and then plays around with these different block sizes, like a puzzle
like tetris
although fixed size blocks are less memory efficient, the performance advantages are very important

Right ima put a stop in that for now
I think my brain might explode if I take any more information in
Byte alignment is a big deal
for example if you didnt have fixed predictable block sizes, whenever you write and delete, a large part of time would be spent trying to calculate how big are the holes left between blocks and how to fill them efficiently
which would lead to worse performance and much worse fragmentation
its my phone number wdym
I'm calling you
I think he didnβt pick up
lets phone ring

why did papa johns pick up
totally does not work there

:^)
there isnt one
π
Html is html, the only constraint is that you can't use script on topgg
And <embed>
Anything else is fair game
discord.html
discord.css
top.css
unwrapping is good right?
// check if the command is a modal command
if modal_commands.contains_key(body_parsed["data"]["name"].as_str().unwrap()) {
let res = modal_commands.get(body_parsed["data"]["name"].as_str().unwrap()).unwrap();
return Ok(
Response::builder()
.status(200)
.header("content-type", "application/json")
.body(res.to_string().into())
.map_err(Box::new)?
);
}```
so long as you know it wont be an Err or None sure

let command_name = body_parsed.get("data")
.and_then(|data| data.as_object())
.and_then(|data_map| data_map.get("name")
.or_else(|| data_map.get("custom_id"))
.and_then(|v| v.as_str())
);
fixed
i have no idea how the pipe works in rust
the pipe character
thats just how you do lambdas
// scope
}```
yea thats a lambda buddy
all {} does is make it allow you to do multi line
the stuff between the || is the properties the function returns
and you are able to do stuff with it
ofc
{} is how you scope things
fn main() {
let a: i32 = 2;
{
let b: i32 = 3;
println!("{a}");
}
println!("{b}")
}
I do not like the mockery
isn't that function parameters
what
that outputs the full tree, as expected
since {} denotes JS expression within JSX element
its the stuff from the previous function
the parameters is the data from the last function
let command_name = body_parsed.get("data")
.and_then(|data| data.as_object())
.and_then(|data_map| data_map.get("name")
.or_else(|| data_map.get("custom_id"))
.and_then(|v| v.as_str())
);
ah there we go
|data| is whats retruend from get
its whats returned from get bro
yes I know
yes,,,I know
just tell me that's a callback
i'm from js land
I mean

what is your definition of a callback
like js callback, gets called after the operation is complete
because you can do something like
Box::pin(async || {})
eg.
.then
I wouldnt necessarily call that a callback
in the Future case
If you are working with future sure
but in general a lambda is just a function inside of a function
usually you'd return something inside them as well
I mean truthfully thats what lambdas are
ask @radiant kraken
all a lambda is just a fn inside a fn that returns something
No idea
@civic scroll what is it
we were discussing lambdas
no, but usually you find them being used as such
some languages like python and javascript lets you define lambdas top-level
we are talkin bout rust
2.as_pipe()
| append(3, 4, 5)
| reverse
| add(3)
| product;
then sure you can only define lambdas inside functions
Ive yet to see a lambda in rust not be defined in a fn
or use a function pointer for functions that accept lambdas as parameters
a lambda outside fn is just a fn
it's just that you can't do dn inside fn so you use lambda
they can have a name
ive never seen a lambda have a name
as variables
and in my heart
the pointer gymnastics 
pointers can suck the soul outta me
in js it's called (async function amogus() {})
+win32 api
killer combo
i love the win32 api tbh
(async () => {})();
i dont get the hate
you dont use it
they are just functions
yk what i hate
they don't show the docs in rust
cope
so i have to go to ms website, and then convert c++ types to rust equiv
read the C documentation π
at least c docs has docs
thats not that hard tbh
and i can access them without internet
a lot of C++ types exist in rust in some shape or form
extra hassle
also the fact that they only have online docs means i'm completely lost when without an internet connection
do you lose internet connection often
yes
ima write my applications in electron 
fuck this
π
ima write my applications in C
fuck this

jokes aside i am addicted to SDL π

Anything persistent I would say yes.
Now if its just config stuff then don't bother
JSON is fine
Thanks
Also, is there a Next.js guide that I may as a beginner to web development?
But uh, without HTML and CSS knowledge it seems to be impossible
And I should also learn routing as well
This is where I start to get a little harsh.
I 100% do not recommend whatso ever using a framework before actually knowing html and some css
Using a framework without such knowledge will leave you clueless.
You will be forced to not only
- Learn HTML
- Learn the framework itself & CSS (if you want to do so)
It's better to focus on one, then do the other.
HTML is something that can quite literally take you a week or two to learn.
Of which you can do while workin on your bot.
You yourself said its not urgent to have a dashboard, so take your time and don't overwork yourself and take on more than you can handle.
CSS is something you can learn as you use the framework though, so I am mainly just saying learn html
Ah thank you so much
Now I can give you some resources on learning html
As well as some other resources for when you get to nextjs
I'd really appreciate it
Thoug hyour best resource for netjs will be the docs
nextjs*
Its were I learned html
As for component libraries choose 1 and use it
It has pre-made components for you that will help in your development
top.gg uses chakra + tailwindcss + nextjs
Wow, I'm really thankful
mantine.dev is really good as well tho
the community behind it is nice too
Choose whichever one you think will fit your site
mantine is also natively customizable
idk bout chakra
Not a problem
tailwindcss removes like 80% of your need to write your own css
You'll still need to write your own css in most cases
but tailwind is definitely a big helping hand for the more mundane / common tasks
NO!
π
π
count me in

together we eat user's RAM
"unused ram is wasted ram"
I
agree
is there a reason why drag and drop doesnt work here? i remember doing something similar with a label before and it worked fine
<input type="file" name="file" id="file" multiple hidden bind:files={$formFiles} />
<div class="w-full p-4">
<label
class="flex h-fit w-full cursor-pointer items-center justify-center rounded-lg border border-accent border-opacity-15 bg-base-300 p-4 duration-200 hover:border-opacity-25"
for="file"
>
<div class="flex flex-col gap-2 text-center">
<div class="flex w-full justify-center">
<CloudUpload class="text-primary" />
</div>
<h1 class="text-lg font-semibold">Click or drag and drop to upload</h1>
<p class="text-sm">Max: 1GB per file</p>
</div>
</label>
</div>
maybe the div that holds tht text is the problem
it has no idea where the actual input is
so its just opening hte file in the browser
input tag for the file is outside the div
responding to the chat from 5hours ago
techincally lambdas and callbacks are not necessarily the same thing, for example array.find(() => {}), thats a lamdba but not technically a callback
but someasyncfunction("xyz", response => {}) thats a lamdba and a callback
iwassleepingok
I like sleep
too bad itβs 7am and I just woke up after a solid 4.5 hours
have you ever messed with SRT?
i havent slept yet
:D
like subtitle files? lmao
subtitles.srt
so, SRTP
its for video/audio transport for live streams
No
well sure
but they call it srt
π
Ik its confusing
the official team behind srtp calls it srt
so I dont want to hear it

but anyways
have you ever looked at or used it
its UDP
RTMP is a TCP-based protocol which maintains persistent connections and allows low-latency communication.
SRT is UDP tho
ye
RTP typically runs over User Datagram Protocol (UDP). RTP is used in conjunction with the RTP Control Protocol (RTCP). While RTP carries the media streams (e.g., audio and video), RTCP is used to monitor transmission statistics and quality of service (QoS) and aids synchronization of multiple streams.
there is also RIST, ARQ, Zixi
SRT seems like the most likely one to use tho
im just trying to wrap my head around it
π
All the services that offer live streaming capabilities with protocols like SRT are like 40$ a month for shit features
some even 200$
Absolutely bogus
Wtf
also, my bad,you were right
they are indeed different things, although similar
apparently browsers dont support it yet tho
SRT is supported in the free software multimedia frameworks GStreamer, FFmpeg, OBS Studio and in VLC free software media player
In March 2020, an individual Internet-Draft, draft-sharabayko-mops-srt,[1] was submitted for consideration to the Media OPerationS (MOPS) working group of the Internet Engineering Task Force.
yeah webRTC uses RTP not SRT
Who said anything about webrtc?
i've tried without it its the same thing unfortunately
its the only way to do audio/video streaming in browsers
oh really?
I mean
there is HLS and DASH
and RMTP
but those are limited
HLS is apple only for the most part
and DASH has no apple support

and HLS/DASH and RMPT have high lat
i guess HSL/DASH use websockets or something
yeah RTP is used in the webRTC api in browsers
honestly dk if ima pursue this
it sounds very very costly to even get up and running
so many fucking acronyms

welcome to programming
havent you heard there is an acronym for everything
programmers are lazy
wait webrtc is js 
not js my enemy
Honestly fixing to make a mock youtube using bunny.net
fixing to steal youtube's userbase ong fr
the browser api is js yes, how else are you gonna use it in a browser
udp has no security
Oh you have a corrupt packet? Damn alright you're cool go ahead on in
nah, udp is the doordasher that throws the food through the window
quic has the entire ssl https stack embedded
lmao
and I still eat it
it might not all be there
but its yummy
yeah a lot of error checking and bouncing back and fourth
that has a devestating impact on performance
also not to mention UDP can basically also send some packets in parallel since it does no error checking
it can route packets across different network paths at the same time and when they arrive at the destination they will be reordered
yeah its unordered so in case of failure it doesnt need to wait for the queue to resolve
its like a shotgun, fires multiple packets for multiple streams and connections at once
i was looking at the new webtransport api, looks quite interesting
sad to see nodejs being so behind tho, they still dont have a working quic socket nor http3 support
i dont think node even has http 2 support
its basically the standard now and way superior to http 1.1
performance improvements too
oh wait looks like they do now
ill switch my app to use it then
but i have to make sure my nginx server also uses http 2 otherwise if the backend server uses a different http version and frontend server uses something else it can cause a http smuggling vulnerability
ah nginx doesnt allow the inconsistency in protocols anyways so thats good
@civic scroll https://chibi.takiyo.us/pbcztYcLn434.png π₯ this project is not even half way done
what the fuck

anyone know why I'm suddenly getting "Unknown Interaction" all of a sudden? Ihadn't been getting this error and I hadn't change anything in this game in days https://pastes.dev/kF5LSpngwy
or is discord having issues
if you have nginx you dont need http2 on node
http2 on node is only for exposed node
for reverse proxy you always use http1 on the node side
does the error show which line its coming from?
Error handling button interaction: DiscordAPIError: Unknown interaction
at RequestHandler.execute (C:\Users\Maurice\Desktop\Click War Bot\node_modules\discord.js\src\rest\RequestHandler.js:350:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async RequestHandler.push (C:\Users\Maurice\Desktop\Click War Bot\node_modules\discord.js\src\rest\RequestHandler.js:51:14)
at async ButtonInteraction.reply (C:\Users\Maurice\Desktop\Click War Bot\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:103:5)
at async InteractionCollector.<anonymous> (C:\Users\Maurice\Desktop\Click War Bot\commands\clickwar.js:216:25) {
method: 'post',
path: '/interactions/1255909767121993891/aW50ZXJhY3Rpb246MTI1NTkwOTc2NzEyMTk5Mzg5MTphcWtlZFlmRFVHZXpmRHlNZG1TYXNHTk1GZTNwU25ucUZwRUpoYWxvYmI2M1ZhRTlqSmR3OUw2Y0ZiZ0ZSQUNCZ3J2MnQwM3c4YTFrMkxrcDI0MWxZdkQyQW00QUFjNzU5a3RpeGNNajBFVWxTbnRXVUlxWlJEQ09EbFZpcDNITw/callback',
code: 10062,
httpStatus: 404,
requestData: { json: { type: 4, data: [Object] }, files: [] }
}
C:\Users\Maurice\Desktop\Click War Bot\node_modules\discord.js\src\rest\RequestHandler.js:350
throw new DiscordAPIError(data, res.status, request);
^
is that line 51? collector issue?
line 216
} else {
is line216
but like, it's been working fine
what would cause this error back to back suddenly?
it's even working fine right now, but another server was trying to play it and it keeps giving this error
the issue is around here
what stands out there are database calls
try to measure the performance of those database calls to see if any of them is taking too long to run
for example ```js
const now = performance.now();
db.prepare(...)...
console.log("db call took", performance.now() - now);
okay let me see
measure both the SELECT and the UPDATE calls
ok let me try this
@quartz kindle I know you're pretty good with optimizing... any suggestions with this game?
for now check the db performance first
ok checking now
never done this before so i might need help understanding what it means lol
db call took 107.32210000000487 ms
db call took 66.494200000001 ms
db call took 66.3698000000004 ms
db call took 83.01440000000002 ms
db call took 66.33860000000277 ms
db call took 75.017399999997 ms
db call took 57.91610000000219 ms
db call took 91.50990000000456 ms
db call took 58.16370000000461 ms
db call took 74.50089999999909 ms
db call took 72.31900000000314 ms
db call took 93.3015000000014 ms
db call took 57.8237000000081 ms
db call took 0.23990000000048894 ms
db call took 68.00229999999283 ms
db call took 0.21350000001257285 ms
db call took 0.25480000000970904 ms
db call took 74.02300000000105 ms
db call took 66.75149999999849 ms
db call took 0.2253000000055181 ms
db call took 0.1809999999968568 ms
db call took 75.06379999998899 ms
db call took 86.00079999999434 ms
db call took 0.2260999999998603 ms
db call took 75.33370000000286 ms
db call took 56.0792999999976 ms
db call took 90.80819999999949 ms
db call took 85.12979999999516 ms
db call took 66.20199999999022 ms
db call took 0.21630000000004657 ms
db call took 0.1895000000076834 ms
db call took 0.2614999999932479 ms
db call took 93.70009999998729 ms
db call took 0.20129999998607673 ms
db call took 84.42829999999958 ms
db call took 0.359599999996135 ms
db call took 103.84169999998994 ms
db call took 0.19209999998565763 ms
db call took 0.28629999997792765 ms
db call took 0.2327999999979511 ms
db call took 0.25310000000172295 ms
db call took 0.21400000000721775 ms
db call took 0.27600000001257285 ms
db call took 0.18780000001424924 ms
db call took 0.19709999999031425 ms
db call took 0.2415999999793712 ms
db call took 71.24220000000787 ms
db call took 72.88229999999749 ms
100ms is a long time
can you check which of them is taking 100ms? the update or the select one?
also, can you show your db.js?
yes let me add the logging and see
add this: ```js
db.pragma('journal_mode = WAL');
anywhere in the file, as long as its after new Database and before module.exports
what does this do
enables WAL mode (write ahead logging)
WAL mode allows the db to not need to wait for an update to be completed before the program continues
it writes the update instantly to a separate file, and then merges the updates in batches later on
yeah
ok added
check the performance again
ok
UPDATE db call took 32.26290000000154 ms for player ID: 1117213227110125698
UPDATE db call took 0.14159999997355044 ms for player ID: 814054114316386335
UPDATE db call took 0.0864000000001397 ms for player ID: 1229242651145146409
UPDATE db call took 0.1294999999809079 ms for player ID: 1156988549359489104
UPDATE db call took 0.13659999999799766 ms for player ID: 366347830232612884
UPDATE db call took 0.07029999999213032 ms for player ID: 1177659669725057045
UPDATE db call took 0.0712000000057742 ms for player ID: 1147203522765529170
UPDATE db call took 0.17170000000623986 ms for player ID: 1143606182280433834
UPDATE db call took 0.12950000001001172 ms for player ID: 1198737757393137745
UPDATE db call took 0.1394000000145752 ms for player ID: 1199880202554191932
UPDATE db call took 0.07639999999082647 ms for player ID: 1186751910984822936
UPDATE db call took 0.07859999997890554 ms for player ID: 1144065440881070172
UPDATE db call took 0.12149999997927807 ms for player ID: 1137732601910673449
SELECT db call took 0.13010000000940636 ms for player ID: 1199880202554191932
UPDATE db call took 0.19289999999455176 ms for player ID: 1143606182280433834
UPDATE db call took 0.13659999999799766 ms for player ID: 1117213227110125698
SELECT db call took 0.11160000000381842 ms for player ID: 1186751910984822936
SELECT db call took 0.0921000000089407 ms for player ID: 366347830232612884
UPDATE db call took 0.20980000001145527 ms for player ID: 1137732601910673449
UPDATE db call took 0.21479999998700805 ms for player ID: 1177659669725057045
SELECT db call took 0.10970000000088476 ms for player ID: 1229242651145146409
SELECT db call took 0.0953999999910593 ms for player ID: 814054114316386335
SELECT db call took 0.1080999999830965 ms for player ID: 1143606182280433834
SELECT db call took 0.1245000000053551 ms for player ID: 1147203522765529170
UPDATE db call took 0.1870000000053551 ms for player ID: 1137732601910673449
SELECT db call took 0.10140000001410954 ms for player ID: 1177659669725057045
SELECT db call took 0.09799999999813735 ms for player ID: 1156988549359489104
SELECT db call took 0.13159999999334104 ms for player ID: 1137732601910673449
SELECT db call took 0.0918999999994412 ms for player ID: 1117213227110125698
SELECT db call took 0.09010000000125729 ms for player ID: 1156988549359489104
SELECT db call took 0.1309000000183005 ms for player ID: 1147203522765529170
SELECT db call took 0.094600000011269 ms for player ID: 1117213227110125698
UPDATE db call took 0.31989999997313134 ms for player ID: 1147203522765529170
looks much better, everything is under 1ms
would that have caused an unknown interaction error?
not directly, but the unknown interaction error happens when you take too long to respond
discord only gives you 3 seconds
and those 3 seconds do not account for the time it takes for the event to travel until your pc and be executed by your code
so when responding to interactions, performance is very important
imagine it takes 1 second from discord to your pc, then another 1 second from your pc to discord
then would mean your code only has 1 second left to use
sometimes when the internet is slow or congestioned, 100ms from a slow db call can make it or break it
but most times a healthy internet connection wont take more than 200-300 ms for a full round trip, so realistically your code should have around 2.5 seconds of processing time, most times
but even the fastest code will run at that error every now and then, because when the internet really craps itself and the event takes more than 3 seconds just to reach your pc, theres literally nothing you can do about it
ahh ok i see what you're saying
even if you deferReply?
deferReply comes between the arrival of the event and your code
so if your code is slow, defer will save it
if the arrival is slow, it wont make any difference
fair enough
my rule of thumb is to always deferReply if I am doing anything that takes longer to process
like db calls
ye
cuz db calls while fast, never know what might happen and it takes longer than usual
deferReply saves you a bit there
I think it gives you an extra 10s right?
but with sqlite its not really needed, because sqlite (better-sqlite3 specifically) is not actually async, and its as fast as any other sync code (avg 0.1ms )
but yeah it depends on how you use it, inefficient queries can make it very slow
15 minutes
ye
Didn't think it was that long
thats the maximum validity of an interaction token

as long as the db calls are fast its fine to keep it as is
fast meaning less than 5ms
prices.map((x) => {
switch (x) {
case "Bieden":
return 1;
case "Gereserveerd":
return 1;
case _:
return x;
}
});```
hey guys, i come from a more functional background like haskell and java, are we allowed to use wildcards in js such as above usecase?
in reality, i can just do default i think, but i guess i always wanted to know this \0/
In order to use Next.js, what I need to know is JavaScript, HTML & CSS, the framework itself and React.js, right?
I think I started getting with HTML, however I have zero React.js experience
Nextjs is somewhat different, you don't really need to learn react first before nextjs.
So it would work to learn Nextjs itself right?
Yeah.
But I'd make some basic html/css pages first just to understand the basics of it.
Like figure out what your home page will look like with just raw html and css.
Then once you feel a bit comfortable you can start to learn nextjs.
Nextjs has a tutorial that's probably pretty good(its been rewritten since I learned)
https://nextjs.org/learn
Just remember its not a race to learn these things.
No matter what it will be frustrating and hard.
Even if you only use html css and js.
I really appreciate all the help you've provided me, it will prevent me from hesitating before asking questions in the future

case default
default is the wildcard
if all the others fail it goes there
it handles the default case
you can however use switch(true) if you want more advanced cases
π
interesting
then you'd be using conditionals as the case statements
honestly never thought of that
π
ye
it kinda defeats teh purpose of using switch in the first place, but its there as an organizational option
like a glorified if else
yeah i realised that, although its a bit inefficient
true
nginx has to do additional processing instead of being able to sort of pass the request through
and parsing of http 1.1 which is slower
honestly I need to learn how to use nginx better
cuz I swear most of my problems come from nginx
π
yeah but if you want full passthrough, then node would need to handle ssl, and it will probably be much slwoer that way
actually yeah ssl probably gets rid of any performance benefits youd get with http 2
darn encryption
not only gets rid of them, it sends them into negatives :^)
nginx still has to manhandle the request
nginx subrequests β€οΈ
btw Angie supports http3 to upstream
(nginx fork)
ive heard about http3 but i heard a large portion of services still havent migrated to http2 so theres not much point supporting
so dont know what it is
is it quic?
http over quic, yes
React.js is what we use for routing right?
Wsg
Oh
I've never used react itself, so I'm not entirely sure
probably for the best
With all the recent drama with react... probably
At least they're working on a compromise.
I hate react partly due to how messy it can get at the hands of someone who doesn't care
i have a feeling were going to see the end of TCP
since http 3 is based on udp
they may redesign it on the network layer
why did they fork nginx anyways
it has the potential to replace tcp in most cases yeah
you mostly only use tcp if you need all packets to always be in order
angie was forked by russian nginx developers who were fired for being russian
i see
is there an equivalent for function compositions in js?
I loved the haskell $ operator
it was actually a precendence operator, but it allowed you to do:
f $ g x instead of f(g(x) )
there is function composition in js yes, but there isnt any specific operator for it
ive heard that nginx also has a paid version so they want to keep some good features behind their enterprise paywall which some open source devs dont agree with
yeah some of its features were made free in Angie
as well as in Tengine, the chinese alibaba nginx fork
Tengine has been maintained since 2011 apparently
and they hardcoded many nginx modules for performance
and use a modified ssl lib
Nextjs has its routing built on top of react's app router
It just allows you to do dynamic routing with like slugs and nested routing much easier
propose you have something like this kind of layout
src
--app
---[user_id]
----index.jsx
---index.jsx
nextjs automatically routes that as
example.com/
example.com/user_id/
i might give it a try as well
[user_id] is a folder btw
its important to note teh [] that denotes it as a "slug"
2 months last commit and project was started around 2 years ago
im not certain about future updates and maintenance
you can even do something like
So it makes it a lot easier, like I don't need to script it for every single route and just make the folder like this?
src
--app
---[user_id]
----settings
-----index.jsx
----index.jsx
---index.jsx
settings being another folder
folder names get turned into route names
It does it automatically for ya
indeed
Now, you can use the page routing which is slightly different (not recommended)
The app router is so much more pleasant to use π
the App Router is the new standard in nextjs, they offer support for both as of right now to prevent a breaking change (backwards compatability)
Eventually they will require you to use only the app router afaik
A lot of sites still use the page router
I'd bet most do.
If they were to outright remove it those sites would break
.jxs is used for XML, which is a programming language as well right?
Thanks π
I just think of jsx as javascript and html combined.
jsx is not XML
So it's pretty much nothing new right?
Not really
a few syntax changes
Only thing to note is
you can use {} to embed js into the html
and the result of that js will be displayed in the end
for example
function Home() {
const todo = ['Make Apple Pie', 'Do the dishes', 'Clean the yard'];
return (
<>
<ui>
{ ...todo.map((t) => <li>t</li>) }
</ui>
</>
)
}
module.exports = Home;
I think thats how that works I have not used js in a while
But thats the rough idea
So it's pretty much what I would use for like component reactions (such as button click) and etc in case I would need to use JS modules
pretty much
JSX gets rid of the need of having
.html files and .js files
it combines it all into one
its a react specific thing
or at least, react uses it the most
Oh, and it's also used by Nextjs right?
Indeed
Nextjs is built ontop of react
its a framework for a framework so to speak
:p
It just adds neat functionality to react that saves time from implementing it yourself
Wow, it made everything more clear for me
Thank you a lot again, I really appreciate it much
Not a problem!
Idk man
you might need to tweak it some more /j
Also Im sorry
but 600 for a damn controller
you got to be out of your damn mind
At that point save up another 300 and buy a decent pc

Sony is already porting some of their exclusives to pc anyway
xbox been had it because windows
So like, why even buy a console anymore π
and failing miserably at that
everything would work fine if they didn't insist to force psn account
I mean, its fair
All your PSN account is just a sony account
Ubisoft requires an account to play their games
no one complains
ubisoft isn't blocked in a ton of countries like psn
primary reason people complained was because some people couldnt access psn
also sony is infamous for having data as secure as a wet cardboard
usually Ubisoft is the one that shit like that happens to
To be fair its wet cardboard with a small volt of electricity running through it :D
More annoying than secure
we literally had to shove sony away from helldivers so they didn't reduce their playercount by 50%
π
Didn't helldivers have an issue where not everyone could play it?
Like people spent 60+ on it and turns out they couldnt even play it
psn integration wasn't working properly at release, so they made it optional

but then sony demanded that it became required, so people who bought the game couldn't play anymore cuz they couldn't make an account
I mean usually studios behind games for playstation is not the worst
I mean Ghost of Tsushima was amazing
then the refund wave was so big that steam removed the game from store until it was resolved
the game went from overwhelmingly positive to overwhelmingly negative in less than a week
Is it sony blocking the countries or the countries blocking sony?
iirc it's sony that's choosing what countries they want to support
probably currency value reasons
Like just support the countries you aren't being blocked in
but then sony nuked their playerbase, so idk if it's about money
I can almost guarantee you the money they "lose" in those areas with lower currency value is mute to what they make everywhere else
probably not even 1%
why??
the preprocessing behind it was fucked up as well cuz i received data in literally 10 fucking different types or something
one batch are strings, other gives prices up to fucking 100 decimals, the other has negative values 

nah i ain't an internet nerd
you should be
lol
i was wondering why my uploads were failing
turns out nginx has a default upload limit of 1mb per file
thats a very useful default
going to push that baby to 1gb
you cant match url params in nginx?
what in the 2000s web design
One message removed from a suspended account.
should i have 1 database for all purposes or different databases for specific purposes?
usually 1 database is enough as long as you have multiple tables and link them together.
i would use multiple databases if you have distinct distinct features that don't have any correlation, parting it would not be needed but in reality it would be safer
i gotcha
so i created a game with its own currency and that database keeps track of games played, games won, currency, basically game data
but i also have a βschedule postβ command thatβs used everyday by a mod, and i donβt want it to be deleted everytime i have to restart the bot
Hey guys Ik youve already heard this a lot but I wanna know how do big bots scale ?
Iβm sure they not using something like djs right
Do I need to use discord api to like register ws? And scale? How do I shard
And stuff
idk the specifics but im sure they all use their own sort of library
So not every js bot uses djs you are right.
Some of them use their own version of djs or make their own library
I'd say using djs is fine up until big bot sharding
That's when I suggest looking to other avenues whether that be making your own library, or even porting over to a more memory efficient language that has a smaller footprint
Thatβs all fine but like how am I supposed to connect to ws and shard and stuff?
Is there discord apis
Iβm assuming so
Well of course there is
or else you wouldnt be able to make bots
You'd connect via the gateway
Tyty
When it comes to the term bandwidth in streaming videos (VOD specifically) how exactly is it impacted? I really hope its not entirely based on the size of the video being streamed e.g if a video is 50gb then it takes 50gb of bandwidth to stream it.
afaik unless the system change the quality (lower bitrate, lower resolution), it'll stream it 50gb, like plex instance
element name???
How to add a message a timed component listener?
π what are you trying to do?
Well, when the bot sends a message with a button component, I want it to seek for any interactions for a certain amount of time
Sorry if I couldn't express it well
In discord.js it's called collectors
For some reason I thought it was a nextjs question π
Aw sorry yes
Ah, I'm learning HTML yet π
Tho I think I started getting with it
I found the documentation about collectors thanks
also look into the awaitMessageComponent methods, better than collectors for 1 use
MANAGE_MESSAGES gives you access to bulk delete and regular delete.
Special note on bulk delete: You cannot bulk delete messages older than 2 weeks
Like
Deleting channel
And making channel in same position
At same time
Which permission is required for that
MANAGE_CHANNELS and MANAGE_PERMISSIONS
Manage permissions?
Why that?
So you can add permissions to the channel�
When creating a channel you can set any permissions, its not technically needed iirc
No
It's not feature
That editing permission of channel
It just creates not edits
If the channel has any special permissions or overrides, it might be desirable to put them back
no?
if the channel you delete has special permissions, the new channel will not have them
No
No
.......
No
Which permissions should i use?
ie, if someone would do nuke on our moderators channel, if it was deleted and created without new permissions everyone could see the new mod channel π
If your intention is to recreate the channel you do need to set permissions.
But, when creating the channel afaik you can set any permissions without manage permissions.
menage a chanel
I don't want
That permission should be change
It would be default
Like when we create new channel
None of changes
Then only managechannels required?
yes
I personally wouldn't use any bot that doesn't offer that feature, but if it's for personal use only then what do I care
yes
Okk
Thanks
@quartz kindle thought youd find this interesting https://lyra.horse/blog/2024/05/exploiting-v8-at-openecsc/
A beginner-friendly journey from a memory corruption to a browser pwn.
do note the function theyre exploiting isnt real, its just a prototype function made for a CTF to show how you can potentially break out of the V8 engine and do RCE with vulnerable v8 code
i dont understand most of it since i dont thoroughly understand v8 and that would take too much time anyways but its pretty interesting
no wonder it takes ages to get a single patch into the V8 engine
a single mess up could mean RCE in millions of browsers just by running some js
dayum
pretty impressive
interesting to see how unbreakable js looks like from the surface, but how under the hood its hanging on a thread of carefully written cpp validations
@earnest phoenix https://discord.com/developers/docs/topics/permissions
Thenks
Youβre welcome
its also interesting to see js makes a differentiation between arrays




