#development

1 messages Β· Page 269 of 1

quartz kindle
#

drawing together

quartz kindle
#

ah i see

#

isnt it a bit overkill?

#

like

#

if you have 100 people drawing

#

you have 300 threads lel

neon leaf
#

apparently this is how its properly done

#

🀷

#

not like there is another way to really do it

prime cliff
#

Performance stonks

quartz kindle
#

lmao

neon leaf
#

ehh

#

sadly not how it works with tokio

quartz kindle
#

well idk rust so im just guessing

#

but i know too many threads = bad

neon leaf
#

I mean

prime cliff
#

Just get a better server Smart

quartz kindle
neon leaf
#

ah @quartz kindle

#

not all spawn calls go to different threads

#

Spawning a task enables the task to execute concurrently to other tasks. The spawned task may execute on the current thread, or it may be sent to a different thread to be executed. The specifics depend on the current Runtime configuration.

quartz kindle
#

ah

#

then it should be fine

#

you can then do the same thing for the pixel array

#

create a task that receives the pixel messages and updates the snapshot

wheat mesa
#

You could have a different thread process each chunk of pixels, something like that

#

That way you are never concurrently writing on the same section of the array

#

But you still benefit from concurrency on a per-line basis

neon leaf
#

welp ill look into it tomorrow πŸ’€

lyric mountain
#

ah, it's like pixelcanvas

#

when I did something similar I simply stored the operations, instead of the canvas itself

#

then simply re-generated the canvas on the clientside

#

this way u dont need to worry about concurrency or flooding your server with threads

celest monolith
frosty gale
#

out of all the messages above he decided to say hi to tim specifically

quartz kindle
#

lel

pearl trail
#

better luck next time

queen needle
#

Fittingly with this talk, how would you implement websockets for something like honk.me?

solemn latch
#

what is that? πŸ‘€

#

rip, it died before I even knew what it was

queen needle
#

I couldn't link it, but it was a chat app where you saw the typing live

#

and I've always thought what would be the best way to implement that websocket wise, because with something like a collaborative google doc there is still delay in the typing

solemn latch
#

chat apps are typically one of the first things people do with websockets, tons of guides on how to do it.

queen needle
#

Well I meant specifically that instant typing aspect, if you visit the website you can see an example of it

#

Because the first thought is, send every keystroke, but I guarantee there's a better way

solemn latch
#

Are you talking about the server side or client side?

Server side it just receives the start typing, and end typing and broadcasts it to whatever clients it needs to.

Client side it just has a timer that goes off after x time once the user stops typing and sends the event or if they send a message.

#

(or well thats how discord handles it)

queen needle
#

But i meant on there it shows what you are typing

pearl trail
#

no its not about start and end typing. if you see on the website, every character a user typed, itll be visible to the other user

solemn latch
#

Maybe its just a stream then? πŸ‘€

#

I wouldnt expect it to be handled with websockets, the overhead on that would be pretty large πŸ‘€

warped summit
solemn latch
#

Maybe they would buffer requests and make it appear as though you're seeing the live typing.
Ie, a user starts typing, buffer the first word, send it. type it the way the user typed it, buffer the next segment

solemn latch
warped summit
#

I need to give it a aesthetic look πŸ₯²

#

Ik this project is gonna blow up

queen needle
#

like a debounce effect, that displays different on the client if that makes sense

solemn latch
#

It could be per character, but it wouldnt use websockets

solemn latch
#

My mind just exploded.
TCP is handled by the os, not the browser

solemn latch
#

Looking at other protocols than websockets lead me so far down the rabbit hole.

#

I somehow ended up on graphql

lament rock
#

That is a very way out there destination on the journey

radiant kraken
#

smallest rust project

neon leaf
#

@quartz kindle got it down to 7bytes per msg for now, instead of 9
x (u16) + y (u16)
turned into
xy (u24)

action (u8) + height (u8)
turned into
actionHeight (u3 + u5)

#

height is multiplied by 4 to look better, aka 4-128 (same as before)

#

I was also thinking of maybe doing x (u13) and y (u11) since usually screens are wider, not taller

#

that would be 8192x2048 instead of 4096x4096

frosty gale
#

its the same thing

#

you import one package that package imports 50 different packages each of which has different code/binaries depending on the OS youre using which further adds to the package size

radiant kraken
#

yup

#

at least its blazingly fast in the end right πŸš€

frosty gale
#

one thing i appreciate about C++ is that packages are usually standalone unless its some big feature which realistically cant be standalone

#

i just drop it into my dependencies folder and it works

#

package systems spoil library developers a bit so they dont feel as restricted importing packages for small things

radiant kraken
#

except i fucking hate LNK2001 and LNK2019 so much

#

what caused this 😭

#

i've already used TOPGG_EXPORT in every class declaration which should expand to __declspec(dllexport / dllimport)

#

it literally says dllimport here

#

and ```cmake
option(BUILD_SHARED_LIBS "Build shared libraries" ON)

if(WIN32)
target_compile_definitions(topgg PRIVATE $<$BOOL:${BUILD_SHARED_LIBS}:TOPGG_BUILDING_DLL:DPP_STATIC TOPGG_STATIC>)
endif()
c
#ifdef _WIN32
#if defined(DPP_STATIC) && !defined(TOPGG_STATIC)
#define TOPGG_STATIC
#elif defined(TOPGG_STATIC) && !defined(DPP_STATIC)
#define DPP_STATIC
#endif
#endif

#if defined(_WIN32) && !defined(TOPGG_STATIC)
#ifdef TOPGG_BUILDING_DLL
#include <dpp/win32_safe_warnings.h>
#define TOPGG_EXPORT __declspec(dllexport)
#else
#define TOPGG_EXPORT __declspec(dllimport)
#endif
#else
#define TOPGG_EXPORT
#endif

#

@wheat mesa

#

😭

quartz kindle
#

canvas performance drops exponentially with canvas size

neon leaf
#

ah well I implemented 90% of it now, only issue is loading existing state

#

since its a whopping 67.1mb

quartz kindle
#

xDddd

neon leaf
#

takes ~13sec to download for example

#

and 1min to load

#

...

quartz kindle
#

lmao

neon leaf
#
    fetch('/history_2.raw')
        .then((res) => res.arrayBuffer())
        .then((buf) => new Uint8Array(buf))
        .then((arr) => {
            let offset = 0

            while (offset < arr.length) {
                const [ type, height, color ] = fromFormatInternal(arr.slice(offset, offset + 4))
                const x = (offset / 4) % 4096
                const y = Math.floor((offset / 4) / 4096)

                draw(x, y, color, type, height)

                offset += 4
                messages++
                bytes += 4
            }
        })```
quartz kindle
#

i wouldnt make a canvas bigger than 2k res

neon leaf
#

I mean I think itll still take ages with 2048

#

how could I "compress" this data

quartz kindle
#

the loading can be improved by ordanizing the data into a format that can be applied directly to the canvas imagedata object

#

for the size of the data itself you cant really do much except for some sort of compression like repeating pixels of the same color

neon leaf
#

hmmm

#

actually I forgot something

#

displayed resolution is 16384x16384

#

height is multiplied by 4

quartz kindle
#

lmfao

neon leaf
#

well maybe ill decrease then

#

to 1024x1024 or something

#

4.1MB

quartz kindle
#

lmfao

lament rock
#

16k is insane even in game engines

#

8k is typically seen as a max

#

and thats insane and seen as for atlases

quartz kindle
#

16384 x 16384 x 4
= 1073741824

#

that should be the size of the canvas in memory

neon leaf
#

ok it loads a lot faster now

#

1024x1024 with real res 4096x4096

#

~7s

#

impossible writing on a trackpad

#

still need to implement ws buffering

#

and make client drawings show immediately

radiant kraken
neon leaf
#

and need to properly scale the canvas

radiant kraken
#

gotta love when my http request never returns ❀️

#

@green kestrel does the bot needs to be online for dpp::cluster::request to work?

#

because when i tried m_cluster.request without the bot starting the function just never returns

delicate zephyr
#

@harsh nova

green kestrel
#

in 10.1.x you need to have called dpp::cluster::start() to run the reactor loop

radiant kraken
#

i see

green kestrel
#

10.1 uses a unified event loop for everything

#

which is spun up in bot.start()

#

without that, it cant make any requests

#

10.0 just launches requester threads

radiant kraken
#

i think i'll do bot.start(st_return);

#

okay it worked now!

#

wth 😭

#

oh the body just stops there??

#

@green kestrel do you have a limit on http response bodies? because i've been getting invalid string: missing closing quote errors

radiant kraken
#

here body stops at 672 bytes

#

what makes it stop at 672 bytes?? is it encoding-related? i'm not sure

#

what's wrong with the W character????

vague flare
#

Phoenixthewilld

#

Is my roblox name

radiant kraken
#

then how

#

did it just stop

green kestrel
#

but wtaf is this

#

three bar equals fif?

#

idk,.works on my machine

#

use Linux like a normal bot dev KEKW

#

10.1 hasn't been as tested on windows as elsewhere, could just be iffy there

#

real production bots aren't using windows with dpp

radiant kraken
radiant kraken
#

howwww

#

@green kestrel i rewrote my code to just this

  dpp::http_headers headers{};

  headers.insert(std::pair("Authorization", "token"));
  headers.insert(std::pair("Connection", "close"));
  headers.insert(std::pair("Content-Type", "application/json"));
  headers.insert(std::pair("User-Agent", "topgg (https://github.com/top-gg-community/cpp-sdk) D++"));

  bot.request("https://top.gg/api/bots/264811613708746752", dpp::http_method::m_get, [](const auto& response) {
    std::cout << "===BODY START===\n" << response.body << "\n===BODY END===\nSIZE: " << response.body.size() << std::endl;
    g_sem.release();
  }, "", "application/json", headers);

  g_sem.acquire();

and now it gives 2,041 bytes??? what?

#

out of curiousity i reran the executable again (without recompiling) and i got the entire body (3,746 bytes)

?????

#

i feel like this is from dpp's end onesieKEKW

#

i'll file an issue for this in the DPP repo if you want

#

i reran the executable again, and i got 3,746 bytes, and then 3,410 bytes

#

it's very much random

neon leaf
neon leaf
#

last issue is something you may see when refreshing

quartz kindle
#

the pixels are cut off?

neon leaf
#

pixels are displayed as size 4, and stored as size 1

#

so 4 pixels can be on one spot even with smallest size

radiant kraken
neon leaf
#

i think ill store both history and pixel data

#

pixel data so I can remove unused history entries

#

history so I can accurately recreate pixel data

green kestrel
#

idk why you'd send that, but that's at odds with http 1.1 and handled by dpp

#

you should only need token and content type

#

are you able to duplicate this without the top.gg api

#

if instead of top.gg API you query for example this URL... one sec

neon leaf
radiant kraken
#

i thought connection: close was mandatory for single HTTP requests done with HTTP v1.1

#

because i tried it once before and it worked

#

kinda weird that undoing this fixed it

green kestrel
#

so you are sending two

radiant kraken
#

you should've wrote it in the documentation

green kestrel
#

it might be nice to make a pr for that to stop people making this mistake

#

but there seem to be other issues with long running bots on windows, im looking into that

radiant kraken
#

cuz i thought dpp::cluster::request is very low level

green kestrel
#

that is confusing the server, i bet

radiant kraken
#

yeah that's weird

green kestrel
#

bot.request/bot.co_request create one of these and insert it into the queue

radiant kraken
green kestrel
#

something like

#

if (header.has("connection")) { ... drop that header like a mic ... }

radiant kraken
#

lmao nice

#

throw an exception?

#

or just delete it

green kestrel
#

deleting it is the least breaking change

#

isnt going to crash anyones bot

radiant kraken
#

aight nice

quartz kindle
radiant kraken
#

yea

green kestrel
#

no

#

thats the reason its a vector of pairs and not a map

#

nothing in the http spec says headers should be deduplicated, and many headers can happen multiple times

#

like cookie headers

#

admittedly, connection: close is a weird one

radiant kraken
#

interesting

#

i've yet to see code in the DPP repo that adds a Connection: close header though

green kestrel
#


From RFC2616 section 4.2:

    Multiple message-header fields with the same field-name MAY be present in a message if and only if the entire field-value for that header field is defined as a comma-separated list [i.e., #(values)]. It MUST be possible to combine the multiple header fields into one "field-name: field-value" pair, without changing the semantics of the message, by appending each subsequent field-value to the first, each separated by a comma. The order in which header fields with the same field-name are received is therefore significant to the interpretation of the combined field value, and thus a proxy MUST NOT change the order of these field values when a message is forwarded.
#

so

#

the server may reinterpret:

Connection: close
Connection: close

->

Connection: close, close
radiant kraken
#

wow i thought the problem was fixed and now bot.start(dpp::start_type::st_return); just crashes 😭

green kestrel
#

this SO post says the outcome of two connection headers is non-deterministic and depends on the server side

radiant kraken
#

how could bot.start() crash tho?

green kestrel
#

no idea

#

like i said

#

windows doesnt have much testing, wont get much testing

radiant kraken
#

dpp::cluster bot{discord_token}; discord_token here has been checked previously if it's a null pointer

green kestrel
#

nobody uses it in prod πŸ˜„

radiant kraken
#

😭

#

i guess i am one of those 0.1%

green kestrel
#

is it?

#

its an initialisation

small tangle
radiant kraken
#

same thing happens if i used ()

green kestrel
#

i cant help you without a stack trace

#

i might as well just guess and say "it was space aliens" kekeke

radiant kraken
#

how do i get a stack trace

#

there's no stack trace

green kestrel
#

use debugger

#

on a debug build of dpp

radiant kraken
#

OH WAIT

#

I REALIZED I CALLED bot.start() TWICE

#

😭

green kestrel
small tangle
#

nulllll

green kestrel
#

how exactly are you able to call it twice if its st_wait

radiant kraken
#

its st_return

green kestrel
#

lol

#

why

#

you got a loop after it?

radiant kraken
#

no

green kestrel
#

it wont work then

#

the minute the cluster goes out of scope it'll be torn down, wont wait for requests to finish

radiant kraken
#

i was ctrl-zing my test.cpp file (cuz i previously need to write it as an example for the github issue)

#

i wrote another bot.start() line and commented the older one

green kestrel
#

you might want to do this

#

before returning:

#
    /* Wait here for the webhook to complete, but we could do anything we need here */
    while (bot.active_requests() > 0) {
        std::this_thread::sleep_for(std::chrono::seconds(1));
    }
#

this may or may not do what you want, but its better to use bot.start(dpp::st_wait)

radiant kraken
green kestrel
#

ah ha

#

ok

radiant kraken
green kestrel
#

should it let you bot.start twice?

radiant kraken
#

no

#

theres no checks for it

#

just crash

green kestrel
#
    /* Wait here for the webhook to complete, but we could do anything we need here */
    while (bot.active_requests() > 0) {
       std::this_thread::sleep_for(std::chrono::seconds(1));
    }

gonna add this in a pr

#

its such a fundamentally weird thing, i never even considered it lol

green kestrel
radiant kraken
#

yippeeee

#

finally got to know that my C++ SDK is working well by testing it with top.gg's small handful of still-working endpoints

#

god why does get_bots take like 2-3 seconds to finish

green kestrel
#
GitHub

it is possible to call bot.start twice if you specify dpp::st_return
Code change checklist

I have ensured that all methods and functions are fully documented using doxygen style comments.
My cod...

GitHub

fix oof.
Code change checklist

I have ensured that all methods and functions are fully documented using doxygen style comments.
My code follows the coding style guide.
I tested that my change w...

#

first one will make sure nobody else calls bot.start twice again

radiant kraken
#

oh damn

#

you're very committed

green kestrel
#

second one is nothing to do with the http request headers, but i noticed it while looking

radiant kraken
#

lmao

green kestrel
radiant kraken
#

yeah pun intended

green kestrel
#

you mean i should be committed

radiant kraken
#

@harsh nova are you proud of me

harsh nova
#

huh?

radiant kraken
#

of my dad joke 😭

harsh nova
#

OHHHH

#

hahahha yes

#

I love dad jokes

green kestrel
harsh nova
proven lantern
#

is there a rate limit on these at mentions? it keeps going back and forth between being a valid and invalid at mention

#

here's the same message

limpid onyx
#

It's just a cache issue, whether your client has the user in cache or not

green kestrel
proven lantern
limpid onyx
lament rock
neon leaf
#

sometimes you need to send stuff to an ip with a host header because multiple sites are on it

green kestrel
#

it's set by the hostname you provide when you make the request

#

setting it a 2nd time in the header would be pointless

neon leaf
green kestrel
#

yes it is

#

the interface isn't that low level

#

if your host doesn't resolve, that's not something that's a dpp problem

amber rose
#

Does anyone use JDA wrapper?

lyric mountain
amber rose
#

Nice

#

How is the experience?

lyric mountain
#

normal, ig

#

idk what to compare against, only other I've used was d.js when I barely knew how to code

#

but being java it's a lot more pleasant to me

violet flicker
#

where can i get webhook authorization token

pearl trail
#

i wonder why the data somehow is not the same from what being logged and inserted to db

pearl trail
lyric mountain
#

but only after it's approved

violet flicker
#

Yeah thanks!

#

hey i need help with vote registration
i have set the webhook to discord webhook on top.gg

but when i vote but didn't registers it niether sending webhook
but when i manual testing !testwebhook and !testvoteapi they works fine

#

should i send code here?

lyric mountain
#

yes

quartz kindle
#

and he was never seen again

frosty gale
#

do not send the code he will steal it and make millions

frail cypress
#

hey yall, i've been relying on the query parameters when voteing, but now it looks like there is no query data passed to the webhooks? any changes or something i can work with?

humble gyro
frail cypress
#

it was working before but ig something changed and now an empty query is passed

humble gyro
#

Sorry about that -- that's most likely an issue

#

Could you send me your vote URL?

frail cypress
humble gyro
#

That's me

frail cypress
#

it should look like this

humble gyro
#

thanks!

frail cypress
humble gyro
#

will do!

quartz kindle
#

ehmahgerd its verudo-san

humble gyro
#

hello tim happ

quartz kindle
#

herro!!!

neon leaf
#

perfectly cursed, as all things should be

quartz kindle
#

nice

#

i love binary formats

pulsar marten
#

how to post shard count using python sdk ?

#

i am confused

#

post_guild_count() ?

quartz kindle
proven lantern
lament rock
proven lantern
#

it's doing it right now

#

and now it's showing up again

lament rock
#

More than likely just a client bug

#

Err actually idk how mentions are handled when under embeds

#

But when they're in the content, the mentions is definitely having the user data sent

proven lantern
#

the only difference i know between embed and content at mentions is the embed at mentions dont ping people

solemn latch
#

pings include user data iirc

#

when you send a webhook message you can disable pinging at all, so it can happen in message content too.

frosty gale
#

it looks like a caching issue, if you go on the users profiles on your client they should show up normally

#

the only reliable way for mentions to show up in embeds is to add it to the message content

primal fog
#

Hello quick question what do you think is more suited monetize option for discord bots

A) One time payment
B) Subscription

I feel like users are more inclined on A but B can be more profitable long term

viral wedge
#

I imagine it depends on a few factors:

  1. Frequency of meaningful updates(This more applies to game bots, I suppose)
  2. How much time did/do you spend on development?
  3. How much does it cost you to maintain?
    4.Value of the features(Does it do something original or in a better way that users will care about, that they can't find in a free bot?)
radiant kraken
#

i think veld is deprecating anything shard-related in Top.gg

amber rose
#

Maven or Gradle?

lyric mountain
#

Gradle 100%

#

I only ever use maven for publishing libs

amber rose
lyric mountain
#

I just hate xml

amber rose
#

Fr

proven lantern
prime cliff
#

vibecat Doing good progress

humble gyro
#

so based

frosty gale
#

i just realised docker is like electron but for servers

#

uses lots of storage and memory for each instance

neon leaf
#

no not really

#

cgroups are very efficient

#

~1-2mb ram overhead

humble gyro
#

you can use micro VMs for minimum resource consumption

neon leaf
#

^ lxc

humble gyro
#

adding indexes is like magic man

#

50% less db usage

acoustic bough
#

would want to know how much money you'd save by completely removing mongo from the stack

humble gyro
#

several thousands

#

unironically

coral trellis
#

mongo stinky fr

acoustic bough
#

I used to defend mongodb so much when I didn't know sql

#

now I see how much it sucks

humble gyro
#

zzz

coral trellis
#

Mongo is good for super small projects

humble gyro
#

mongo is decent for writing lots

acoustic bough
#

even at a scale of just 4,000 discord servers it's just painful

humble gyro
#

but there's a lot of better alternatives

coral trellis
#

I really wonder how you scale with it

humble gyro
#

mongo has a specific usecase

acoustic bough
#

you just dont

humble gyro
#

all of github audit logs are on mongodb

#

you just write a LOT to it

#

and read sometimes

acoustic bough
#

a timeseries database is prob still better, dunno

humble gyro
#

not all data is timeseries tho

#

like audit logs

acoustic bough
#

arent auditlogs kinda?

humble gyro
#

wdym

#

timeseries are good at aggregating

acoustic bough
#

audit logs are events that happen sequentially over time, and are usually sorted after time, so it would be practical to use timescale db or smth

humble gyro
#

yeah, but one big issue is that time-series dbs aren't really built for consistency

#

they are built for performance ingesting tons of data

#

which is great for many events, but not if you want to guarantee your data being sent

acoustic bough
#

fair I guess

delicate zephyr
#

it also depends on the time-series db

#

mongo has a time-series option

lunar junco
#

Hey why i cannot sumbit discord bot on topgg?

#

When i click sumbit it just reloads the button

#

πŸ˜ƒ

earnest phoenix
neon leaf
bitter granite
wraith ember
#

How fix the application did not respond

deft wolf
#

Respond to the interaction

neon leaf
pearl trail
#

@oak cliff morning

oak cliff
pearl trail
frail cypress
#

@humble gyro any updates on the query issue?

humble gyro
#

I've slowly been implementing it

#

has it not worked for you yet?

frail cypress
#

just now it started working

#

thank you

humble gyro
#

good to hear

#

@severe pike for u too

severe pike
#

amazing thanks, seems to be working now πŸ™‚

radiant kraken
#

me when this works

#

but this doesn't

#

am i missing something?

acoustic bough
#

doesn't seem like it

#

spelling also looks fine

radiant kraken
#

YEAH 😭

#

the top.gg api must hate people who use node.js frfr

neon leaf
#

0 is not truthy

#

it may be omitted (for some stupid js reason)

radiant kraken
#

oh 😭

#

what the fuck

bitter granite
acoustic bough
#

if user_agent.includes('node'): error()

radiant kraken
#

then how do i JSON.stringify() it without truthy?

neon leaf
#

actually try with the same number as in py

#

i think its on topggs side

#

not urs

acoustic bough
#

possible that topgg thinks it doesn't exist since 0 is falsy

#

might just me like !server_count || !shards

radiant kraken
acoustic bough
sharp geyser
radiant kraken
#

batch

#

not bash

sharp geyser
radiant kraken
#

L

sharp geyser
#

close enough

neon leaf
sharp geyser
#

batch is just bash

#

lets be real

radiant kraken
#

batch is good

neon leaf
radiant kraken
#

BATCH IS GOOD

acoustic bough
#

batch is ass

sharp geyser
#

batch is the unwanted cousin of bash

radiant kraken
#

batch is literally my first ever language

neon leaf
#

batch is painful

neon leaf
#

doesnt stop it from being bad

acoustic bough
sharp geyser
#

i'd rather learn VBScript than batch

neon leaf
radiant kraken
#

VBScript is also one of my first languages

neon leaf
#

gotta disagree on that one

radiant kraken
#

shit start ik

sharp geyser
#

I started out with python

#

then moved to js

radiant kraken
#

same

sharp geyser
#

then to C#, to rust, to c++ then finally back to C#

#

πŸ’€

neon leaf
#

batch -> js -> ts -> rust

sharp geyser
#

To truly outline my journey

acoustic bough
#

batch -> Lua -> js -> TS -> go

neon leaf
#

not for money

sharp geyser
#

py -> js/ts -> c# -> go -> elixir -> rust -> c++ -> c#

radiant kraken
#

batch -> vbs -> js (vanilla) -> py -> js (node.js) -> typescript -> c# -> c++ -> c -> rust (briefly, then gave up) -> go -> v -> rust

#

that's mine

neon leaf
#

i did nodejs before any frontend js

sharp geyser
#

I now only use c#

#

Theres no need for another language

#

C# has it all

neon leaf
#

I think im going rust + ts for life

sharp geyser
#

I will use rust if I need to use low level programming on like embedded software

#

but C# is the goat

neon leaf
#

ye all of ther c# I saw was pretty decent

#

rust is cool because of macros

#

1000 lines less for the same performance πŸ”₯

#

especially useful for parsing

#
#[derive(Deserialize, Clone)]
struct Reroutes {
    name: Option<String>,
    reroutes: HashMap<String, (String, u16)>,
}

fn main() {
    let file = File::open("reroutes.json").unwrap();
    let data: Arc<Reroutes> = Arc::new(serde_json::from_reader(file).unwrap());

    let listener = TcpListener::bind(("0.0.0.0", PORT)).unwrap();
    println!("Server started on 0.0.0.0:{} (v{})", PORT, VERSION);
    println!("{} reroutes active", data.reroutes.len());
// ...```
pearl trail
small tangle
#

is it just me or does using unwrap feel dirty derpcat

#

not like there are many other options

wheat mesa
#

Otherwise you should be handling it

sharp geyser
#

I unwrap everything

#

Cause idc if its safe or not

indigo holly
#

Any free chatbot to add on my bot?

solemn latch
#

Honestly, there is so many cheap ones right now you're better off paying the few dollars a month itll likely cost you.

scenic kelp
#

also C# has the coolest pattern matching syntax i've seen in any language yet

#

being able to do like age is >= 18 and < 25 is so cool

sharp geyser
#

Yup

#

Short hand

#

Love it

prime cliff
humble gyro
#

no

#

c# πŸ”› πŸ”

prime cliff
#

JS dosen't have >==/>= or something?

humble gyro
#

they mean the pattern matching

#
if (user is { Age: >18 and <25 }) {
   ...
}
#

idk if that is valid syntax

#

but its pretty sweet

prime cliff
#

Hu but that's just the same as user.Age >=

#

I've never actually seen anyone do it like that in C# before ik you can do object is User user but not like that

prime cliff
neon leaf
#

well

#

the difference is this is expected to be public

prime cliff
#

Ok good

acoustic bough
#

i always bind to 0.0.0.0 because it runs in a container anyway, who cares

neon leaf
#

that too

acoustic bough
#
  • I host at home wo/ portforwarding, who wants to access it?? my mum gonna hack me?
pearl trail
#

best practiceℒ️

humble gyro
prime cliff
#

I understand that but the fact that you can do is that way is too weird even for a C# nerd xD

humble gyro
#

fair lol

#

it's a .net 8 thing i think

#

so fairly new

#

its cool because you can also do stuff like

#
user is { Username: "veld", Verified: true }
queen needle
#

So it's like querying?

humble gyro
#

it is but only for in-memory data

prime cliff
#

Not querying more of a if statement structure if (user.Username == "veld" && user.Verified == true)

humble gyro
#

it compiles to effectively this in js:

"username" in user && user.username === "veld" && "verified" in user && user.verified === true
scenic kelp
#

they've changed the syntax a bit in the successive versions but

humble gyro
#

can they do that with async please

scenic kelp
#

like you used to not be able to do x is not null you had to do !(x is object)

humble gyro
#

oh fuck i remember that

#

soon C# is gonna be sql#

scenic kelp
#

x is {}

humble gyro
#
var approvedBots is select from bots where approved is true;
scenic kelp
#

can't you already do that with linq queries

humble gyro
#

only one keyword here is invalid

scenic kelp
#

ig not with full pattern matching

humble gyro
#

assigns != is

scenic kelp
#

have you ever seen someone use linq query syntax

#

like i'm very conscious it's a thing but i much prefer using lambda syntax and im pretty sure every other human on earth is the same way

#

c# needs two features and i will marry it and those are discriminated unions and blocks in switch statements a la java

humble gyro
#

with unions you mean like AnyOf<MyType, MyOtherType, Etc>?

scenic kelp
#

yeah like F# unions or rust enums

#
type Option<'a> =
| Some of 'a
| None
#

then we'll have

ParseInt
TryParseInt
TryParseIntOption

can't wait

humble gyro
#

oh hell yea

#

please give me this

scenic kelp
#

there's a proposal for it that also features like

#

A | B union types

#

which is more than i wanted originally but pLPEASE

#

c# and typescript are actually just going to be merged atp

wheat mesa
#

Types are cool but I don’t want it to get to a point where I have to be a rocket scientist to understand what type to pass into something

#

Typescript has fallen victim to that in some places

delicate zephyr
#

people just forget they exist

scenic kelp
#

yeah typescript types can be pretty disgusting but i don't think union types are terrible as a whole

#

and it should be possible to refactor the really evil types a bit

humble gyro
#

please merge it tho

#

imagine the possibilities

scenic kelp
#

they're actually gonna pull a crazy twist and merge F# with TS

#

fable is already a thing that compiles F# to JS

elfin fractal
scenic kelp
#

F# supremacy

scenic kelp
#

there's not really an easy way to do unions in C# without a preprocessor

humble gyro
nocturne dagger
#

I am trying to fetch members who have a specific role

const role1 = await guild.roles.fetch(relevantRoleIds[0]);

console.log(role1?.members);

But it seems like no one is cached, is there a better way to go about doing this?

#

I have tried just fetching members and filtering it

guild.members.fetch()

but this ends up timing out, the server has about 25k members

delicate zephyr
#

Have you got the members intent?

I'm assuming discord.js which relys on cache for fetching members roles

prime cliff
#

Yea you need members intent to fetch the entire list

nocturne dagger
unkempt aspen
#

πŸ€”

sharp geyser
#

That’s an analytics endpoint iirc

deft wolf
#

Yea, it's been down for as long as I can remember and has no effect on whether the site works or not

unkempt aspen
#

I was going to send my bot but it didn't work and I found out it was calling this api

acoustic bough
#

since it's just analytics it doesn't matter

deft wolf
#

You probably missed some required field like prefix

acoustic bough
unkempt aspen
#

I pressed submit registration but there was no notification message so I don't know if it was sent or not. But now I know that the bot is checking it.

acoustic bough
#

does smb have experience with discord bots in bun (performance wise compared to nodejs)

neon leaf
#

slower

acoustic bough
#

bleh rly

#

idk how to even properly benchmark it

#

in terms of like mps/ips

#

or average response time to messages/interactions (ignoring network ping/latency)

lament rock
#

There are some libs which support both node and bun. I'd say just setup a bot and try to run it in the same code base and yeah

lament rock
# acoustic bough does smb have experience with discord bots in bun (performance wise compared to ...

But really if you're trying to look to bun for more performance, I think you're looking in the wrong places.

I'll give an example from my own bot: A lot of libs depend on the ws package from the npm registry for gateway connection and personal experience with a bot in over 10k servers has shown that just gateway message processing can really eat cpu time. At the time, it was all on one cluster. However, Tim provided some great code for a stupid fast WebSocket impl and that gave a significant performance boost. This was before interactions were a thing. Just processing messages was baaaad. It all depends on your use case.

Really, the first place you should start is your dependency tree. Vet the code you install and run. Replace deps with more lightweight ones if you can and maybe also look into taking a different approach into how you build your bot. An example is to move away from libs that try to do it all like Discord.js and instead look into more modular libraries that can get you great mileage without having a lot of cpu and memory overhead from just lib internals. The raw Discord API really is not that bad. I'd plug the libs I maintain but not trying to get bonked

#

When I made the switch away from Discord.js, I was able to manage what data I really needed to cache in memory and the performance shifted from being the fault of libs to my own code and that helped me realize what patterns I was doing was bad for performance

earnest phoenix
#

there is some wrapper made for bun, don't remember the name though

acoustic bough
# lament rock But really if you're trying to look to bun for more performance, I think you're ...

yeah I know that I could use the discord api without djs, (or at least without the wrapper and just use djs/ws and djs/rest) but that would require me to rewrite the entire bot which is not my goal. I am pretty selective with the packages I install. From some projects bun is "just" faster, and would like to know if this also is the case if it comes to discord bots.

I currently run 12 clusters with 12,000 guilds and use 1.2-1.5gb ram (though I rn have about 350k messages in cache which I have to kill, that would fix most of the memory usage)

#

I just would like to get "free" extra performace by "just" switching runtimes

earnest phoenix
#

well you can tias

acoustic bough
#

I still would work with djs - at least the forseeable future. if I would decide to drop djs, I probably also gonna drop js as a whole

neon leaf
#

getting closer


real    0m0.169s
user    0m0.168s
sys     0m0.001s
root@remotedev:~/projects/0x7d8/bad-lang-2# time node testing/fib.js 

real    0m0.080s
user    0m0.074s
sys     0m0.008s
root@remotedev:~/projects/0x7d8/bad-lang-2# time python3 testing/fib.py 

real    0m2.858s
user    0m2.813s
sys     0m0.005s
root@remotedev:~/projects/0x7d8/bad-lang-2# ```
neon leaf
#

lets go


real    0m0.065s
user    0m0.061s
sys     0m0.004s
root@remotedev:~/projects/0x7d8/bad-lang-2# time node testing/fib.js 

real    0m0.086s
user    0m0.088s
sys     0m0.000s
root@remotedev:~/projects/0x7d8/bad-lang-2# time python3 testing/fib.py 

real    0m2.765s
user    0m2.756s
sys     0m0.009s
root@remotedev:~/projects/0x7d8/bad-lang-2# ```
#

interpreted language faster than js

#

@quartz kindle time to switch

quartz kindle
neon leaf
#

well

#

do you want to see the code

#
    let a = 0
    let b = 1
    let temp = 0

    if (#eq(n, 0)) {
        return a
    }

    let i = 2
    loop {
        if (#gt(i, n)) {
            break
        }

        temp = a
        a = b
        b += temp

        i++
    }

    return b
}

fn fib_until(until) {
    let results = []

    let i = 1
    loop {
        if (#gt(i, until)) {
            break
        }

        array#push(results, fib(i))

        i++
    }

    return results
}

let il = 0
let it = 100000
loop {
    if (#gt(il, it)) {
        break
    }

    fib_until(55)

    il++
}```
#

for python its ```py
def fib(n):
a = 0
b = 1
temp = 0

if n == 0:
    return a

for i in range(2, n + 1):
    temp = a
    a = b
    b = temp + b

return b

def fib_until(until):
results = []

for i in range(1, until + 1):
    results.append(fib(i))

return results

Run the benchmark loop

il = 0
it = 100000
while il <= it:
fib_until(55)
il += 1```

quartz kindle
#

how about using an internal timer instead?

neon leaf
#

sure wait

#

bruh my lang only has unix time

#

ill need to add ms precision time rq

#
67
root@remotedev:~/projects/0x7d8/bad-lang-2# node testing/fib.js 
66.869545
root@remotedev:~/projects/0x7d8/bad-lang-2# python3 testing/fib.py 
2892.989013671875
root@remotedev:~/projects/0x7d8/bad-lang-2# ```
quartz kindle
#

nice

quartz kindle
neon leaf
#
const start = performance.now();

function fib(n) {
    let a = 0;
    let b = 1;
    let temp = 0;

    if (n === 0) {
            return a;
    }

    for (let i = 2; i <= n; i++) {
            temp = a;
            a = b;
            b = temp + b;
    }

    return b;
}

function fibUntil(until) {
    const results = [];

    for (let i = 1; i <= until; i++) {
            results.push(fib(i));
    }

    return results;
}

// Run the benchmark loop
let il = 0;
const it = 100000;
while (il <= it) {
    fibUntil(55);
    il++;
}

console.log(performance.now() - start);```
quartz kindle
#

i can think of a few things to change but it wont show any meaningful difference

half scroll
#

want to share other ways of handling mem/compute for python

import timeit
import numpy as np
from functools import lru_cache

# Define Fibonacci Implementations
def fib_recursive(n):
    if n <= 1:
        return n
    return fib_recursive(n - 1) + fib_recursive(n - 2)

def fib_iterative(n):
    a, b = 0, 1
    for _ in range(n):
        a, b = b, a + b
    return a

@lru_cache(None)
def fib_memoized(n):
    if n <= 1:
        return n
    return fib_memoized(n - 1) + fib_memoized(n - 2)

def fib_numpy(n):
    F = np.matrix([[1, 1], [1, 0]], dtype=object)
    return (F**(n-1))[0, 0] if n > 0 else 0

# Set test value for n
n = 55

# Benchmark each implementation
results = {
    "Iterative": timeit.timeit(lambda: fib_iterative(n), number=10000),
    "Memoized": timeit.timeit(lambda: fib_memoized(n), number=10000),
    "NumPy": timeit.timeit(lambda: fib_numpy(n), number=10000)
}

# Recursive is too slow for n = 55 at high repetitions, so we run it separately for fewer iterations and n = 30
results["Recursive"] = timeit.timeit(lambda: fib_recursive(30), number=100)  # Limited to 100 runs

print(results)

results would reflect what you saw as realtime in sec

$ python3 performance.py
{'Iterative': 0.008456800016574562, 'Memoized': 0.00037169991992414, 'NumPy': 0.09832059999462217, 'Recursive': 6.185182299930602}
quartz kindle
half scroll
quartz kindle
half scroll
#

you could set it to say
@lru_cache(maxsize=128, typed=False)
where max size = how many function calls to cache
typed if different arg types should be cached seperate

#

default is maxsize=128 anyway

quartz kindle
#

so basically it just takes the function arguments and caches the return value for those arguments

half scroll
#

exactly πŸ™‚

quartz kindle
#

well thats kinda cheating

#

lmao

half scroll
#

πŸ˜‰ just offering different performance tests

slender wagon
#

i have a function that expands into multiple interactions. I need to gather that info from multiple menu's and handlers. How do you guys usually approach these as in what do you use to store the info through the different interactions

quartz kindle
#

alternatively you can have some global object/cache/db

slender wagon
#

i see, im gonna experiment a lil bit and come back if i somehow get stuck

#

thanks

half scroll
neon leaf
half scroll
neon leaf
#

I would, but this is purely for testing performance

sharp geyser
#

@scenic kelp how’s go

half scroll
#

that's kind of my point though and offering different performance tests - to show why one functionality differs so much from another

slender wagon
#

@quartz kindle

.setCustomId(`start_debate_modal_${uniqueId}`)

looking good?

#

i will have to modify my listeners tho

#

thats fine i guess

half scroll
#

get what you're saying - you were after an unbiased comparison of langs, πŸ˜… this is where I wanted to show...its kind of up to the person to know what abilities they really have

lyric mountain
#

we were comparing langs?

neon leaf
neon leaf
#

im assuming python parses the code multiple times, not quite sure why its so much slower though

scenic kelp
#

i will say the go team had some very strange design decisions

#

why the fuck did they feel the need to make x + y automatically format to x+y kiss my ass go team

sharp geyser
#

Huh

#

Bruh

wheat mesa
neon leaf
#

python doesnt jit

#

theres a seperate python runtime that does jit

wheat mesa
#

It does have some JIT

#

Pretty sure at least

#

Looks like python 3.13 has it, idk if it's used by default

neon leaf
#

pyroot@remotedev:~# python3 --version
Python 3.12.3

wheat mesa
#

Theree's probably some sort of runtime optimization causing it to be slow

#

I remember java used to have a problem with VM "warm up" times, I can't remember exactly why (I think it still does have this)

lyric mountain
#

it's just jit

#

java starts with compiled bytecode, then optimize it further as it goes

wheat mesa
#

I thought that even pre-jit java had warmup issues

lyric mountain
#

probably old issue

versed coral
#

What all is possible with the top.gg API ? I'm building a command to reward users who vote but other than that I'm not sure what I could do to utilize it more

deft wolf
#

I would use webhooks if I were you for this purpose

versed coral
deft wolf
#

Later it's up to you what you want to do with this fact. Some bots give access to commands that are unavailable without voting, others give some currency in the bot or items and the biggest bots also make vote streaks thanks to which people have a reason to vote every day to get better rewards

versed coral
#

Thank you

lament rock
#

Some of the data is missing and it stopped after 2023 because I got lazy to readd performance stats, but

#

Currently hovering at 150MB of ram usage

white gyro
# lament rock Trust me, I understand that rewriting a bot is a very daunting task but also htt...

Telling someone to rewrite their whole bot isn't great advice. Discord.js is the most well maintained library in js and they'd either use something less maintained that would get features slower (or potentially be abandoned) or essentially write their own lib.

It also shows a misunderstanding of the real issue. You can just customize the cache in discord.js - to reduce memory usage, you should disable the intents that your bot isn't using and limit/sweep the cache.

https://discordjs.guide/miscellaneous/cache-customization.html#limiting-caches

Other libs simply cache less or not at all (and you trade less ram usage for slower performance as you need to be fetch everything, and you may hit rate limits).

lament rock
# white gyro Telling someone to rewrite their whole bot isn't great advice. Discord.js is the...

I think you might not have a full understanding of the situation. Even with customization of cache, discord.js operates under a large amount of assumptions and some parts of the library simply cannot be fully bypassed. I was in the exact same situation and discord.js led me towards having a large amount of technical debt. I relied too heavily on its class system and sometimes, you can't even initialize the structures just to do rest actions without a good amount of data. Even if you literally limit the amount of data to what you'd theoretically need and use the built in Rest to make your own requests, you are basically not even using the lib at that point and are opting for internals. Just ditch the memory overhead of even importing the library. The imported string size of Discord.js already blows past what my bot's memory usage sits at during peak hours. Discord.js' approach to utilizing OOP which is what JS is known for shoots itself in the foot as you can't fully realize what you could achieve.

Your usage of the phrase "slower for performance" just because you "need to fetch everything" is such a bad take as the API actually gives you a LOT of data you'd need depending on what your use case is. You completely miss the point of trying to guide users towards making better choices just because they'd prefer to just swap runtimes and hope that magically solves all their problems. You're enabling bad choices. I would think that they would have already customized their caches which is why they'd be looking towards another runtime to fix their problems. Switching runtimes isn't just such a simple decision to make. 1.2-1.5GB of memory usage is not good by any stretch.

I also outlined in an earlier message that discord.js makes use of libs which are actually detrimental to performance. @discordjs/ws depends on ws and I have done my own tests. I've seen the before and after switching to a more lightweight ws implementation, switching to an entirely different gateway lib entirely. The CPU performance gains are nothing to scoff at.

"you may hit rate limits"
Libraries implement guards to prevent this. The only limits you'd have to worry about are the 50 requests per second globally. Even then, just cache what you actually need either in memory or in a database/object storage like Redis.

And to drive home the fact that I was hell bent on trying to maintain some semblance to Discord.js even when I was trying to migrate away from it:
https://github.com/AmandaDiscord/NEKO I wrote this before I fully gave up on Discord.js (v12) . Only later was cache customization a thing, but a global presence cache for users is still yet to be seen.
https://github.com/AmandaDiscord/ThunderStorm When I started maintaining some raw API packages, I wrote this instead of rewriting my bot entirely just so that I could avoid a total rewrite which was a waste of my time, a huge mental strain which I realized the hard way, and I ultimately stopped working on it

white gyro
#

You switched in v12 before both customizing the caching and intents were a thing so how would you know that it doesn't fix their problem? Regardless, telling someone to rewrite their entire project rather than simply use the cache controls in the library first, or if they still use message commands to switch to an entirely interactions-based bot and disable the messages intent, is a pretty wild premature "optimization" (in reality it'll probably just be a huge time sink more than anything, since all the other libraries do is less/no cache).

prime cliff
#

Both of you are right and discord.js is known to have a some memory performance issues especially at high number of servers but not really feasible to rewrite a bot if it's only in a few servers.

prime cliff
#

How much memory you using?

lament rock
lament rock
white gyro
lament rock
#

Why else would they want to make such a big decision to jump to a totally different runtime

#

You'd think they'd exhaust their options

prime cliff
#

Wait only 150mb that's actually impressive

lament rock
#

Old data, but the amount of servers never mattered

#

My bot is rather stateless

prime cliff
#

Yea figures with that amount of memory but a lot better still

white gyro
# lament rock Why else would they want to make such a big decision to jump to a totally differ...

The fact that they wanted to switch runtimes suggests that they're a beginner who doesn’t understand what’s causing the issue, as that isn't very relevant as the memory usage is due to how much data they’re caching. You should still get confirmation that they tried it before assuming.

You just seem like a disgruntled user of discord.js v12 but most of the issues you had were fixed with the new caching controls in my opinion. If you still disagree, you could do a more updated benchmark on your memory usage with unused intents removed and a limited cache before jumping to "ditch discord.js".

lament rock
#

I highly doubt that doing the tests would be worth my time as the imported string size blowing my peak memory usage is still an issue

latent marten
#

mates, maybe there is a react enjoyer here. im buildung a nextjs app with routes and somehow while prod building i get the following issue

TypeError: (intermediate value).default is not a function```

how ever, the error comes from chunks and the following lines say `at r.metadata.icon`on files like .next\server\chunks\856.js
i haven't set any metadata at all except for title within the <head> in root. i can't find any relations while searching for keywords, it doesn't matter if /upload, /users or settings, i couldn't find a pattern yet and (lol) copilot isnt that helpful. also it's my first project. my research told me i need to handle 2 files for each route: layout and page and nextjs would ask for metadata anyways. but i wonder why dev build works without errors or db issues. i can't even tell what this error means, lol
would appreciate some help :)
acoustic bough
# lament rock I think **you** might not have a full understanding of the situation. Even with ...

I'm not just trying to switch runtimes because it's the holy grail that will fix ally issues - it won't. My biggest issue isn't even memory, even with 1.5gb ram usage (I have a fix for that by limiting cache sizes to 0 and using keep over limit to only store what I need). My point rather is CPU utilization/CPU usage. things like parsing hundreds to thousands of gateway message takes time and resources, which another runtime may be better at. Bun is generally perceived to be faster, and I only really wanted to know if this would also be the case with djs (as bun may be slower than nodejs under certain conditions).

#

it's just not feasible to rewrite the entire bot with another library. If I was about to do this, I would drop JavaScript entirely for Golang or C++

lament rock
# acoustic bough I'm not just trying to switch runtimes because it's the holy grail that will fix...

As things stand with discord.js, I don't believe switching runtimes would have any meaningful impact like you think it would. At best case, you should have your gateway clustered across multiple machines and only ingest what messages you actually need at your workers. And ideally replace the gateway backing. the ws package is pretty bad for CPU performance at scale as I mentioned. I don't know how feasible it is to do this in @discordjs/ws, but Tim helped me write a slimmed version of a WebSocket and also an etf reader/writer

white gyro
#

The difference of bun is really negligible at best it does have faster package install but you can just use pnpm. But you can simply switch to an interactions-only bot then you will only process the interactions you will receive and not the "hundreds of thousands of gateway messages"

acoustic bough
#

I use pnpm - I need the gateway (at least until http events release)

lament rock
#

And as a word of advice, dont use the gateway to receive interactions

delicate zephyr
#

they've built it in a way to allow not just experience devs to use it but everyone

#

after about 8-9k servers depending on your usage, can use way more memory than any other lib even with cache customizations

#

at the end of the day it falls on your experience and your willingness to learn honestly

acoustic bough
#

my current solution

#

should kick out at least 300k messages out of my cache

quartz kindle
acoustic bough
#

I fear that djs breaks if I dare to call
reply on a message that's not cached anymore

#

wouldn't at all surprise me

quartz kindle
#

it wont break because of that

#

messages is something you can safely set to 0

acoustic bough
#

will test it anyway before pushing to prod

quartz kindle
#

as long as you're not replying to a message from a delete event

acoustic bough
#

oh yeah no lol

#

even with 500 it's way better than my current 34k per cluster lmao

quartz kindle
#

isnt the default 200 tho?

#

the limit is per-manager, not global

acoustic bough
#

no idea

quartz kindle
#

each channel has its own manager

sharp geyser
#

ima manage u

acoustic bough
#

oh wait is message manager per channel?

quartz kindle
#

yes

acoustic bough
#

oh

#

ok

#

makes sense

harsh nova
#

Making my own "library" for my webhook bot and can strongly recommend doing that if you can. It's fun

sharp geyser
#

They made it per channel?

quartz kindle
#

it's always been per channel

sharp geyser
#

I never bothered looking into it

#

but thats cool

quartz kindle
#

you set the limits for a single MessageManager object, and every single Channel has its own instance of MessageManager

acoustic bough
#

there is also guild message and dm message manager but I think I can ignore it if I set a message manager

quartz kindle
#

they all extend MessageManager

acoustic bough
#

but ok will def set a lower max then

#

but the default 200 explains why a cluster is always at the 33k messages for me

harsh nova
#

Nonetheless a really fun project

pearl trail
#

haha yeah, better than having no project

sharp geyser
#

They used to be a lot easier for newbies to follow but now its jumbled with a bunch more jargon than needed.

harsh nova
#

Wish everyone had the quality of docs that Microsoft does

sharp geyser
#

I hate ms docs as well tbh

#

😭

#

Sure they are good

harsh nova
#

Oh really? Always been good for me

sharp geyser
#

but I swear to learn one concept you have to follow 3 hyperlinks

#

only to be sent back to the beginning

harsh nova
#

Kinda the opposite of discord. They tell you that you need to send something to some certain route but don't link what exactly you need to send so you have to dig for it

sharp geyser
#

yup

frosty gale
#

they send you to some random article filled with a dump of irrelevant information that you need to scan through to find what you need

sharp geyser
#

Yup

latent marten
earnest phoenix
#

it's like 20 something by now

latent marten
earnest phoenix
#

ah yeah v15 had some changes i'm not a fan of

wheat mesa
#

Aaaaaaand support scam

#

@zinc fable hi

zinc fable
#

tyty

latent marten
#

tbf, this is my very first react project and wasnt able to build prod at all. it was weird since dev worked without any issues. after a whole day i figured i have to use standardexports

#

(still not working, but new errors at least :>)

surreal sage
#

i love seeing

#

nameservers propogate to my ns

#

but then they went back to the registrar ns

sharp geyser
#

So something I still have not been able to wrap my head around is keeping state that the user is logged in on the frontend.

What I mean by that is, auth is handled on the backend in my aspnet api using microsoft's Identity and OpenIdConnect libraries, the frontend makes a request to an endpoint that calls the signin function to these libraries that redirects you to the oidc auth page of my auth server then back to the frontend on successful auth. The problem is that a cookie is saved on successful auth with all the information about the user, but its a signed cookie and encrypted so I can't use it on the frontend I would have to request the user info from the backend.

The problem I see with that is stale data, the data i'd save to state from the userinfo endpoint could become stale in the event they update something about their user, my idea was to call a mutation whenever something is updated (by mutation I mean a function that updates the state locally that fetches the user info endpoint to update this "stale" state).

I also think I may be overthinking this and there is a better solution to keep track of this state on the frontend, because all I really need to do is be able to keep track of the user info so I can use it when querying for things from the backend.

prime cliff
sharp geyser
#

Yes I know, thats what I was referring to when saying "hitting a userinfo endpoint"

#

I am using react

#

I plan on using a state library like zustand or something

prime cliff
#

There should be state stuff in react that you could look for it's a very old framework

sharp geyser
#

Yea but its not as good as an external lib

#

zustand gives me more features to work with that'd be more beneficial

prime cliff
sharp geyser
#

yes I know of it

#

but thats component specific and its harder to saturate that amongst numerous components

#

so a state library is better since it makes it easier to access state anywhere

prime cliff
sharp geyser
#

Right but this still doesnt solve what I perceive is the root problem

#

Keeping the userinfo up to date on the frontend.

prime cliff
#

How important is it to keep the userinfo?
You could just set a background timer every 15s to update or just refetch the userinfo when doing crucial tasks.

#

Either that or you switch your front-end to a server side rendered app

sharp geyser
#

I guess its not super important

#

The only real thing I would need is their user ID which I know will never change, everything else is just info like their name, email and roles they have

#

I can fetch it again in cases I need to check if they have permission to do something in case they did get a new role added to em

#

I know their name and email will almost never change in my use case

prime cliff
#

Well you would need to check permissions server-side anyway so that's not a good point xD

sharp geyser
#

Well yea

#

honestly I dont think I will ever need to refetch user info

#

Thinking more about it

#

None of it is important to the frontend except their ID

#

Should I keep track of their access token in state as well or nah?

prime cliff
#

That's already in the cookie?

sharp geyser
#

hm fair

prime cliff
#

Or jwt whatever way you do it

sharp geyser
#

I was only asking because the frontend would need a way to authenticate it but I guess that wont matter since the Identity library does that already iirc

prime cliff
#

Yea oauth stuff should just redirect the front-end to auth on the backend

sharp geyser
#

πŸ‘

prime cliff
#

Best case is you shouldn't really trust the front-end for user/security stuff because it can be manipulated or browser console changed

sharp geyser
#

Yeah

#

Well thank you builderb

prime cliff
#

Np i'm not the best with web either but i'm doing a server-side blazor app

sharp geyser
#

Yea once it comes to front end I’m a fish out of water

prime cliff
#

You could take some ideas from this and implement 2FA stuff πŸ˜„

sharp geyser
#

Luckily my auth server handles all that

#

I just need to make api calls and it does the rest

prime cliff
#

Ah you doing a self hosted auth like keycloak/authentik or just standard oauth stuff with google/discord

sharp geyser
#

I’m using a self hosted auth server

#

It’s called zitadel

#

It handles different forms of auth between multiple providers or can be used as a local auth provider with email and password

#

Or a combination of both

#

It’s rather neat

neon leaf
#

@quartz kindle I think its now possible to write a discord bot in my language


fn handleconn(connection) {
    let data = tcp#readstr(connection)
    let head = array#get(string#split(data, "\n"), 0)
    let parts = string#split(head, " ")

    array#pop(parts)

    let method = array#get(parts, 0)
    let path = ""

    let i = 1
    loop {
        let part = array#get(parts, i)

        if not (part) {
            break
        }

        path = string#concat(path, part)
        i++
    }

    io#println(method)
    io#println(path)

    tcp#write(connection, "HTTP/1.0 200 OK\n")
    tcp#write(connection, "sus: ok\n")
    tcp#write(connection, "\r\n")
    tcp#write(connection, "Hi sir, from bad-lang\n")
}

loop {
    let connection = tcp#getconn(listener)

    thread#launch(handleconn, connection)
}```
#

tcp streams work now

neon leaf
#

some perf fixes later

quartz kindle
#

why is the slowest 16 seconds lmao

neon leaf
#

not sure

#

but I need to do a lot more optimizing

quartz kindle
#

xD

neon leaf
#

variable lookups are still very expensive

quartz kindle
#

you're using rust right?

neon leaf
#

yes

quartz kindle
#

nice

neon leaf
#

mainly this is the issue

#

it runs on each lookup instead of each scope

solemn latch
#

15.2 was a really good update

#

the error page updates are ugly af though πŸ‘€

queen needle
#

what?!?! I love the new error pages

#

this is very funny however

neon flicker
#

Hello, I had asked the same question in 2024 and now I would like to ask it again in 2025, do you think even skilled programmers will lose their jobs due to the rise of AI technology?

lyric mountain
#

no

#

not even unskilled programmers will

neon flicker
# lyric mountain not even unskilled programmers will

Well, my opinion at this point is that it possibly can replace people who've chosen computer science just because they thought they would make much money for free and are not willing ti stay updated against any updates in the field/industry

lyric mountain
#

not really, AI has a major flaw when it comes to anything: it cannot create

#

besides, non-programmers rarely can explain exactly what they want, AI would have a hard time figuring out

neon flicker
#

You got such a good point, you still need to know how to program in order to provide the AI service decent prompts

lyric mountain
#

yep, there's even a comic for that

neon flicker
#

Aw lol

wheat mesa
#

AI can replace people the day that clients know how to describe exactly what they want

#

Aka never

#

Not to mention that AI inbreeding is going to fuck over the quality of LLMs soon enough

solemn latch
wheat mesa
#

Companies that are replacing juniors with AI will find themselves in deep shit 5 years down the road when they aren't creating senior developers that actually do a good chunk of work

neon flicker
frosty gale
wheat mesa
#

LLMs are just predicting the next token in a sequence of tokens. Their quality is based almost entirely on the data they are trained on. Without good training data, you get poor output.

lyric mountain
wheat mesa
#

When you have a bunch of these "AI developers" making shit and training the newer LLMs, it starts to hurt their quality because the AI developers make terrible quality code which gets fed to the training data of the newer LLMs

#

You reduce your "genetic diversity" so to speak, just like inbreeding irl

lyric mountain
#

AI is training on AI generated content

frosty gale
#

i want to see some more research and tests in this area, how much is the quality of LLMs impacted by generating & adding predictions back into the training set, also across different models

queen needle
frosty gale
#

technically if you raise the temperature and adjust the token prediction algorithm you can come up with completely new sentences not seen in the training set

wheat mesa
#

I think that more people are going to have to work on knowing what code is good and what code is bad to feed to LLMs for them to produce better quality responses... aka software engineers...

neon flicker
#

Besides that, it sounds way too utopic to have AI handling everything

queen needle
#

so like approve and decline but for code feeding llms lmao

lyric mountain
wheat mesa
#

Not to mention that these models are fundamentally flawed; they don't "think". Even the reasoning models aren't "thinking", there is just some clever tricks used to make it appear that way

neon flicker
lyric mountain
#

where they start making stuff up leading to incorrect or straight up unrelated answers

frosty gale
lyric mountain
#

huh

#

the hell google lmao

#

actually where tf did google take that from

frosty gale
lyric mountain
#

I meant the kid game where you gather everyone in a row and one side whisper a phrase to the next, propagating till the last player

wheat mesa
#

telephone game lmaoooo

lyric mountain
#

usually the message will be completely unrelated to the original

frosty gale
#

just "telephone" too apparently

lyric mountain
#

here we call it "telefone sem fio"

humble gyro
solemn latch
#

the middleware update might be useful to you too.

deft wolf
limpid onyx
#

finally node.js runtime in middleware πŸ™

solemn latch
#

Helps with nextauth

queen needle
#

I'm confused on what that adds to next.js middleware

acoustic bough
#

you being able to use nextjs middleware on nodejs

slender wagon
#

question, if i want to quickly check if a channel id matches another id. Would i rather use a json file to match it or a query on my postgres?

#

the question would be which one is faster

acoustic bough
#

would use some KV for smth like that

frosty gale
#

is there a date limit to how far you can read messages in a channel in a bot?

#

as in be able to get the messages for an entire channel

#

planning to export a channels messages which i use for notes offline

acoustic bough
#

you can get everything

#

100 messages at a time (per request)

lyric mountain
#

the rule is that ids within a specific domain cannot overlap, but they aren't unique globally

#

so 2 channels cant have the same id, nor 2 guilds, but those channels can share the same id as the guilds

slender wagon
#

i am sorry for the confusion

#

i have a forum in my server and this forum has posts. Now i have a bot that creates posts and it only grants access to certain people.
My question would be which way would be the best and fastest way to store an id and compare it with the channel id. That way i can delete messages of users that aren't allowed to post in that forum post

#

I'm doing all of this because discord doesn't give you a way to limit permissions on forum posts

wise burrow
lament rock
#

If it's something like a ticket system or something where it's your bot's mechanisms that decides who can use it, I'd have two tables in pg. One that describes necessary info on the forum post channel and then another table to describe who has access to it.

If you only need to store user ID and channel ID, you can have just 1 table and then create an index in that table off of channel IDs. No pkey.
For instance, the table could just have two columns which is the user ID and channel ID. Then you
SELECT user_id FROM posts WHERE channel_id = $1 and since the channel ID is the indexed column, it'll be stupid fast to return all of the users who have access to channel_id.

If you do need more info wherein you'd need 2 tables, your query might look more like
SELECT post_access.user_id FROM posts INNER JOIN post_access ON posts.channel_id = post_access.channel_id WHERE channel_id = $1
In this case, you should index channel_id on post_access and pkey channel_id on posts or however else you wanna pkey it

sharp geyser
#
  Assembly 'Mercatus.Database' with identity 'Mercatus.Database, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'Microsoft.EntityFrameworkCore, Version=9.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' which has a higher version than referenced assembly 'Microsoft.EntityFrameworkCore' with identity 'Microsoft.EntityFrameworkCore, Version=9.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

What the fuck does this mean. No where am I using EFCore 9.0.0.0

#

Unless its a dependancy issue where one of my deps is using it

#

Its what I thought it was

#

well thats fucking annoying since the latest package only uses 9.0.1

#

and all my other EFCore packages use 9.0.2

#

Downgrading everything to get it to work is too much of a hassle

sharp geyser
#

Fixed it, luckily only had to downgrade Design and Tools and it did all the other deps itself

prime cliff
#

Portainer vs my project, it actually looks pretty nice now

lucid vessel
#

I sent my bot for verification... but it didn't appear in the logs, and a few days have already passed... what should I do?

ancient shale
lucid vessel
ancient shale
languid dragon
#

Anyone know of any (working) embedded-able embed visualizers? preferably for TS/NPM
ping if reply

sharp saddle
sharp saddle
# sharp saddle

I mean, I read several docs, and I didn't understand anything

weary drum
#

who can help me add bots to my discord server

prime cliff
#

bruh

warm halo
#

a

quartz kindle
#

b

neon leaf
#

c

deft wolf
#

d

vocal knot
#

e

solemn latch
#

f

zinc fable
#

z

solemn latch
#

-warn @zinc fable

lucid vessel
#

Is there any place that can guide me on integrating votes with my bot's system? (Such as rewards, for example.)

lucid vessel
latent marten
#

broskis. i am working at my very first react project and for days i wasnt able to build. i've tried literally everything and even bought 20$ cursor subscription. i've head problems with nextjs's metadata and always problems with the favicon.ico
claude 3.5 and 3.7 looped into a fix hole, until i realized bruh, i have 2 favicons.ico, renamed the wrong one and vuala
dunno if i wanna cry or hug the world lol

frosty gale
#

ai is very clutch but you cant trust it to do anything significant for you without handholding

frosty gale
#

is the intel cpu hetzner has that bad to the point where the amd variant costs more with less ram lol

quartz kindle
#

the amds are epyc 7002

frosty gale
#

im a bit torn between the x86 and arm variant, i heard the arm machines are much faster on hetzner

#

but some of the projects i want to have on there have libraries that may not work well with arm64

#

i'll try compile them for arm and see how that goes because ill get much more out of the server if i go with arm

quartz kindle
#

im on the epyc one rn

#

the CPX11

frosty gale
#

it looks good but im quite a bit pissed about half the ram

quartz kindle
#

afaik the other one used to be the same ram

#

did they increase it recently?

#

i remember 4gb ram being 7+ bucks not 4

frosty gale
#

this is all i see atm

#

or i can go balls to the walls with the more expensive AMD plan

#

yeah not a good start trying to compile one of my main rust projects for arm

#

probably because its trying to link my X86 libraries

latent marten
frosty gale
#

@quartz kindle i think the threads i was looking at were when hetzner had ancient intel cpus

#

it looks like they are much better now

#

the amd one looks worse in this comparison(?)