#development

1 messages · Page 95 of 1

sharp geyser
#

I don't even know basic algorithms

radiant kraken
#

skill issue

sharp geyser
#

Shut up null

radiant kraken
#

<3

#

bogo sort my beloved

hushed robin
#

update: it did not work

wheat mesa
#

Now bogo sort’s worst case time complexity is O(infinity)

sharp geyser
#

I need to learn algorithms

#

I dont even remember the ones you taught me waffle

wheat mesa
#

They’re not very hard

sharp geyser
#

My brain is small waffle

#

and my attention span is few

wheat mesa
#

Algorithms are more interesting when you have a use case for them

sharp geyser
#

true

radiant kraken
#

become rust dev and your brain will grow

wheat mesa
#

Binary search is SUPER useful

sharp geyser
#

What use cases are there in binary search?

radiant kraken
sharp geyser
#

Im sure they are used in almost everything i've used

wheat mesa
#

If you know the array is sorted, you can find an element in O(log(n))

radiant kraken
#

binary search only works in sorted arrays

wheat mesa
#

Yeah

#

It’s like searching through a dictionary irl

sharp geyser
wheat mesa
#

Wrong

#

Write everything in rust

radiant kraken
#

Based

sharp geyser
#

I don't see a reason for me to use rust

radiant kraken
#

Blazingly fast

sharp geyser
#

Serious reasons

wheat mesa
#

Graphics programming with rust looks kinda fun

sharp geyser
#

I dont do graphic related stuff rn

radiant kraken
#

Tauri looks very interesting

wheat mesa
#

It’s very good for string parsing

radiant kraken
#

looks like a good replacement for Electron

sharp geyser
#

I told you about that one

hushed robin
wheat mesa
#

Rust is like a super modern c++

sharp geyser
#

still wrong

radiant kraken
hushed robin
#

bruh

sharp geyser
#

. is not escaped

hushed robin
#

whats wrong

sharp geyser
#

. is a reserved keyword in regex

wheat mesa
#

Have you considered not using regex in a project until you understand it @hushed robin

radiant kraken
wheat mesa
#

Every beginner jumps to regex like it’s some super essential tool when in reality it’s not necessary in most situations

hushed robin
#

well

#

what would you recommend for what i'm doing then

sharp geyser
#

regex was made in the old days for a specific problem that doesn't exist anymore /s

#

idk if this is true im talking out my ass

wheat mesa
radiant kraken
#

*includes

wheat mesa
#

Fuck

#

Same thing

#

Java on the brain

sharp geyser
#

Shame on you waffle

radiant kraken
#

such method doesnt exist in js

sharp geyser
#

Yes it does

wheat mesa
#

I always forget

radiant kraken
wheat mesa
#

Contains exists for arrays doesn’t it?

sharp geyser
#

Yea, if I make it

radiant kraken
#

no

#

Arrays use includes

wheat mesa
#

Nope it doesn’t damn

sharp geyser
#

nope

radiant kraken
#

theres no contains in js

sharp geyser
#

it uses includes on both

wheat mesa
#

I hate js method names

#

Just follow Java convention 🙄

sharp geyser
#

includes is such a vague naming

hushed robin
#

but

radiant kraken
hushed robin
#

what about if they wanted to filter multiple values ☹️

radiant kraken
#

its like php using .explode()

#

pov: Array.some

sharp geyser
#

Where is fake

#

I haven't seen him around in a while

radiant kraken
#

i assassinated him

sharp geyser
#

@boreal iron ello php man

radiant kraken
#

fake literally ->explode()d

hushed robin
#

so would this be correct?
/pls|hello/i/g

wheat mesa
#

no

hushed robin
#

bruh

radiant kraken
#

learn what regex is

wheat mesa
#

(pls|hello)

solemn latch
# wheat mesa Every beginner jumps to regex like it’s some super essential tool when in realit...

I got one for you.

I have a bunch of user variables in a string, there could be 1, there could be 30

for example

"some string, wee woo <uservariable>, <someothervariable>"

currently I'm using

const variables = {
    uservariable: "something",
    someothervariable: "something else"
}


const newString = input.replace(/<(\w+)>/g, (match: string, variable: any) => variables[variable] ?? match);

👀 how do I do it without regex?

hushed robin
wheat mesa
radiant kraken
#

iirc

wheat mesa
#

For complex parsing cases you can use recursive descent parsing or Pratt parsing since they’re more practical than a giant regex too

solemn latch
#

its not a giant regex though, is it?

#

its just /<(\w+)>/g

radiant kraken
#

just use Array.some + String.includes

wheat mesa
#

I know, but this isn’t a giant solution with iterating either

#

Plus it’s faster

#

Also I find that regex is difficult to read and understand quickly

sharp geyser
#

what is w+

solemn latch
#

I have 23 variables, will that really be faster?

radiant kraken
#

words

solemn latch
wheat mesa
#

Yes

radiant kraken
#

alphabetical + numbers + _

wheat mesa
#

It’s faster but I suppose it doesn’t matter too much if you’re not doing it a ton

#

But I prefer iterative solutions and avoiding regex at all costs just for readability reasons

solemn latch
#

good to know, I'll look into that.

I think this solution should be fine, as its not done too often yeah but its good to learn better methods

wheat mesa
#

It makes it easier to remember what I wrote

hushed robin
#

but

#

if capital no match

wheat mesa
#

Just toLowerCase the string bruh

quartz kindle
#

if thats js, nothing is faster than indexOf + slice

radiant kraken
#

/i/g

sigh

sharp geyser
#

Listen to tim

#

he knows best

hushed robin
sharp geyser
boreal iron
wheat mesa
#

brotha just use .contains instead of regexes you don’t understand

radiant kraken
#

ITS INCLUDES

wheat mesa
#

FUCK

#

I FORGOT AGAIN

#

IVE BEEN IN JAVA HELL PLEASE FORGIVE ME

hushed robin
boreal iron
#

Shall I ask what's going on or not?

wheat mesa
solemn latch
#

why does it feel like the old dev channel right now?

#

👀

wheat mesa
#

You could separate by commas, and search for each string in your news to filter it

quartz kindle
#

also, its possible to use regex to find the indexes and then slice

hushed robin
#

is this correct yes or no
/(pls|hello)/i/g

boreal iron
#

No

wheat mesa
#

Even that way it would be 100x easier for your users to understand

hushed robin
#

whats wrong

solemn latch
boreal iron
#

Aren't separated by /

hushed robin
#

what about them

quartz kindle
radiant kraken
#

a few ms faster!!! 💪

hushed robin
sharp geyser
#

While this was fun

solemn latch
#

I'll look into it, thanks tim and waffle ^_^

sharp geyser
#

Ima decide on what to use for my new project

#

Cya guys

radiant kraken
#

Rust

hushed robin
sharp geyser
#

No

#

Never

hushed robin
#

thank you for the help

radiant kraken
#

Rust is always the answer

sharp geyser
#

doing backend in rust is pain for me

radiant kraken
#

skill issue

sharp geyser
#

null ima throw you off a bridge

#

:C

quartz kindle
wheat mesa
#

Start off with standalone rust projects at first

quartz kindle
#

:^)

radiant kraken
#

wtf death threats (at cosmic)

boreal iron
wheat mesa
#

It’s much easier if you don’t hop into some complex magic framework right off the bat

sharp geyser
#

Although if I use rust I can just bug waffle for help

#

so

radiant kraken
#

what about me wtf

quartz kindle
#

is so fun tho, i keep finding tricks to make things faster than are not obvious

radiant kraken
#

im ignored

sharp geyser
#

You will just troll me

boreal iron
sharp geyser
#

smh

wheat mesa
#

Tim is an optimization man

#

I respect it

scenic kelp
radiant kraken
#

waffle if misty asks you about rust tell him to ask to me instead ty

scenic kelp
#

have one state for parsing normal string and another state for parsing variable locations

hushed robin
radiant kraken
#

gi

latent rapids
#

How do I create my own webhook?

quartz kindle
#

there are many things in js that one thing is faster up to a certain size, and then another thing starts being faster after that size

boreal iron
hushed robin
#

should return true

#

is returning false

radiant kraken
quartz kindle
#

thats gonna be slow

wheat mesa
#

I ain’t even gonna try anymore because he doesn’t provide info on what’s wrong, what he’s inputting, what he’s expecting, and doesn’t even try to create more reasonable solutions to his problem

radiant kraken
#

who cares at least its faster by a few microseconds

quartz kindle
#

its not gonna be faster lmao

radiant kraken
#

fuck it write your own JavaScript engine and runtime

wheat mesa
#

node gyp probably has more overhead than benefits that would provide

quartz kindle
#

node addons are not fast

#

they have quite a high call cost

#

they are only good for large calculations

wheat mesa
#

It’s worth it for heavy lifting tasks like video editing or stuff like that

radiant kraken
#

based

quartz kindle
#

then compare that to 1+1 in pure js

#

:^)

sharp geyser
#

or a napi.rs addon that evaluates if a number is odd or even

radiant kraken
#

faster by a few microseconds!!! sdTroll

#

@earnest phoenix can confirm

quartz kindle
#

pure js is gonna be like 1000x faster

quartz kindle
radiant kraken
#

use Bun!!! it's faster than Node.js!!!!

#

just look at their benchmarks!!!!!

quartz kindle
#

xD

#

bun is such a meme

#

nobody talks about it anymore

radiant kraken
#

they use JavaScriptCore and Zig because they want to be quirky

wheat mesa
#

Told everyone it was a fad

#

I was right

radiant kraken
#

exactly

wheat mesa
#

Not exactly difficult to predict tho

radiant kraken
#

Node.js Killer!!!!!!

#

and then faded to obscurity

#

tbh ironically ____ killer projects will never kill the projects they intended

wheat mesa
#

Except rust

#

C++ killer

radiant kraken
#

frfr

#

Rust devs are C++ refugees

wheat mesa
#

🚀

radiant kraken
boreal iron
quartz kindle
#

bun's ideas are great tho, but the way they marketed it was terrible

radiant kraken
#

Blazingly fast!!! just look at our very real benchmarks!!!!

sharp geyser
#

I like Carbon

quartz kindle
#

they tried to make it look like bun is js-fast and not interop-fast

radiant kraken
#

Carbon is shit

sharp geyser
#

I love those job ads that say you have to have 10+ years of carbon experience

wheat mesa
#

Carbon is a great idea but it’s too young as of right now

#

I can see it being more popular in 5-10 years

radiant kraken
#

but everyone forgot about it now

sharp geyser
#

by then job ads will ask for 30+ years of experience

quartz kindle
#

lmao, bun's issues:

sharp geyser
#

discord.js bad

#

dont support it

boreal iron
radiant kraken
#

bun bad

wheat mesa
sharp geyser
spark flint
radiant kraken
#

THE RUNTIME

spark flint
#

rude !!

#

i did try bun

radiant kraken
#

wtf !!!!

boreal iron
spark flint
#

it was cool

sharp geyser
radiant kraken
#

gross

spark flint
#

but not supported by a lot of things

radiant kraken
#

good

#

L for them

sharp geyser
#

I dont even know if i have rust installed on my pc

#

I do

radiant kraken
#

good

sharp geyser
#

Gotta update it tho

scenic kelp
# solemn latch oh?
class VariableParser
{
    public string Input { get; init; }
    public Dictionary<string, string> Variables { get; init; }
    
    StringBuilder output = new StringBuilder();

    int position;

    public VariableParser(string input, Dictionary<string, string> variables)
    {
        Input = input;
        Variables = variables;
    }

    public string Parse()
    {
        ParseString();
        return output.ToString();
    }

    void ParseString() 
    {
        while (true)
        {
            if (position >= Input.Length) break;
            if (Input[position] == '<')
            {
                position++;
                ParseVariable();
            }
            else
            {
                output.Append(Input[position]);
                position++;
            }
        }
    }

    void ParseVariable()
    {
        int start = position;
        while (true)
        {
            if (position >= Input.Length) throw new Exception("Unexpected end of input");
            if (Input[position] == '>') break;
            else position++;
        }

        string variableName = Input.Substring(start, position - start);
        
        if (!Variables.ContainsKey(variableName)) 
        {
            output.Append("{undefined}");
        } else
        {
            output.Append(Variables[variableName]);
        }

        position++;
        return;
    }
}
``` that's what i came up with really quickly
#

seems to wokrk

sharp geyser
#

its like 20 versions behind

radiant kraken
#

rustup update

#

ezpz

scenic kelp
#
VariableParser parser = new VariableParser("Hello, <first> <last>! It is <day>", new()
{
    { "first", "John" },
    { "last", "Doe" },
    { "day", DateTime.Now.DayOfWeek.ToString() }
});

Console.WriteLine(parser.Parse()); // "Hello, John Doe! It is Tuesday"
wheat mesa
spark flint
#

wust

scenic kelp
#

probably also faster than using regex

radiant kraken
#

wuwust

wheat mesa
#

I have multiple versions of rust on my pc

radiant kraken
#

BASED

wheat mesa
#

Even some nightly versions 😎

radiant kraken
#

Waffle <3

scenic kelp
sharp geyser
#

I guess I will use rust

#

but I can already tell ima lose motivation when using something im not confident in

wheat mesa
#

Don’t use it for your project idea misty

scenic kelp
#

why use rust then

radiant kraken
#

the compiler will spoonfeed you

spark flint
wheat mesa
#

Use something you have experience with

sharp geyser
#

Cause null is bullying me to use it

#

:C

scenic kelp
#

don't listen to him

wheat mesa
#

No

radiant kraken
#

wtf

scenic kelp
#

there's literally no reason to use it if you don't want (or more importantly need) to learn it

wheat mesa
#

Use it for fun projects until you’re confident with it

#

Then you can use it for more serious ideas

radiant kraken
#

^ this tbh

sharp geyser
#

I don't know what would be fun to mke with rust as I have no idea about its core concepts

scenic kelp
#

then don't even bother picking it up if you don't know why to

radiant kraken
#

if you dont want to work with rust

scenic kelp
#

that's the way i look at things at least

radiant kraken
#

work on your website

scenic kelp
#

if you don't get a tangible benefit from investing your time into learning it then it's a waste of time

sharp geyser
#

its not that I don't want to

#

I don't know if i do or not, but to find out I have to figure out what it excels at

scenic kelp
#

memory safe system-level programming

#

boom

radiant kraken
#

speed and performance, it's good when you want to make a c++ app without all the pain

sharp geyser
#

Without knowing the usage behind it, I hve no idea if its right fit for me

sudden geyser
#

you really don't need rust for like 95% of things

radiant kraken
#

and without all the headaches like segfaults and linker errors

scenic kelp
#

i will ALWAYS be of the belief that you should pick one language and learn it super well and pick up a couple of other ones just to cover the weaknesses of your main language

#

for me that's C# and javascript and python on the side

sudden geyser
#

yuck

wheat mesa
#

Rust is really nice for a low level language feel without all the bugs that complex memory semantics cause

sharp geyser
#

My first lang was js, but I don't really like it

sudden geyser
#

pick up the paradigm and general skills of the language rather than the language itself

scenic kelp
#

^^^^^^^^^ that too

#

you can apply those skills when learning any language

sharp geyser
#

My head hurts thinking about this stuff rn

sudden geyser
#

go back to js then

#

or python

#

which one

wheat mesa
#

Java

scenic kelp
#

:(

wheat mesa
#

😎

radiant kraken
#

Script

sharp geyser
#

no thanks

wheat mesa
#

I’m biased

#

I like Java

sharp geyser
#

we know

radiant kraken
#

Script

#

:c

sharp geyser
#

For my career path tho js wont cut it

scenic kelp
#

don't say that right now either

#

you don't know unless you're going into hardware lmfao

wheat mesa
#

Java is a good language to have under your belt for any job in the software industry tbh

#

Used in like half of all enterprise level jobs or something like that

scenic kelp
#

the thing i don't get is a lot of people will 'learn' like 40 different languages

#

there is no way companies want to see that

#

they'd much rather see you have a diverse profile of languages you know really well

radiant kraken
wheat mesa
#

I would rather master 1 language than be an intermediate in 40

#

“Jack of all trades, master of none” type thing

scenic kelp
#

java is just really well used and also a super simple language to initially pick up

sudden geyser
#

have you actually seen what companies look for in an app

#

cause they're only spending like 10 seconds reading it

radiant kraken
#

anyway gtg

#

cya

quartz kindle
#

js best lang

#

:^)

sudden geyser
#

sadistic

quartz kindle
#

String.prototype = Number.prototype (if only it actually worked)

scenic kelp
#

more = better!!

#

you can see how much experience i have because i've worked at 6 different jobs in 2 years!

latent rapids
#

Do you guys double your vote rewards on weekends?

hushed robin
latent rapids
#

Does the vote per day reset?

#

Or is it every 12 hours?

lyric mountain
#

Votes reset is dependant on the bot

#

Votes technically reset once per month tho (on topgg)

lyric mountain
#

Learn to ask proper questions

#

"it should return true" is way too vague

hushed robin
hushed robin
latent rapids
hushed robin
latent rapids
#

I know but what part of it gets reset?

hushed robin
#

wym?

#

the votes

lyric mountain
#

Only that

latent rapids
#

Every users' votes get set back to 0 or the bot's vote on the site?

lyric mountain
#

No, topgg doesn't store user votes

hushed robin
#

^

lyric mountain
#

Only the total vote count for bots

latent rapids
#

This one.

hushed robin
#

yes

lyric mountain
#

Anything else depends on what the bot developer chose to do

hushed robin
#

that resets

#

at the start of each month

latent rapids
#

Ok, it's fine I guess, I don't find the bot's vote count that useful.

lyric mountain
hushed robin
#

yes

#

well no

lyric mountain
hushed robin
#

but i'd like to

latent rapids
#

So a user can revote every 12 hours? So I can just store the timestamp of when the user voted, right?

hushed robin
#

yes

lyric mountain
hushed robin
#

what alternatives

lyric mountain
#

contains()

latent rapids
hushed robin
#

handle what?

lyric mountain
latent rapids
#

The vote webhook only gets triggered when the vote is actually valid right?

lyric mountain
#

Could've said before

latent rapids
#

Ok, I don't need to handle it then.

lyric mountain
#

You'll need a database, if that's what ur asking

latent rapids
#

I know.

hushed robin
lyric mountain
#

Then don't worry, webhook will only trigger on actual votes

#

Unless u press the test button

latent rapids
#

I don't think I have to store any timestamps. I can just store the amount of votes a user has.

lyric mountain
hushed robin
#

hm

lyric mountain
latent rapids
#

The webhook data I think has a streak.

lyric mountain
#

It doesn't

#

The only thing the webhook tells u is who and when someone voted

#

Nothing else

hushed robin
#

i don't see it on mozilla

lyric mountain
#

It'll be either contains or includes

latent rapids
#

Eh?
What is this then?

{
            "value": 1,
            "name": "Total Votes:",
            "inline": true
        },
        {
            "value": 1,
            "name": "Current Vote Streak:",
            "inline": true
        },
```I got this from the `Embed.fields`
hushed robin
#

yeah ik includes but that can only check for a single value right?

latent rapids
hushed robin
#

yeah

#

they handle it

#

that isn't an official top.gg website

lyric mountain
hushed robin
#

but it was made by one of the mods i believe

latent rapids
#

It was made by Woo.

lyric mountain
#

But writing it twice will be orders of magnitude faster than regex

lyric mountain
latent rapids
#

I know.

lyric mountain
#

Woo made it to help new devs

hushed robin
lyric mountain
latent rapids
#

I just wanna know how to make my own webhook so I don't have to rely on this site.

lyric mountain
#

See the official docs, they have examples there

hushed robin
latent rapids
#

Not really helpful.

lyric mountain
hushed robin
#

yknow what i mean

lyric mountain
#

You'll still need to think how you want to approach it tho

lyric mountain
#

What are u even trying to accomplish?

hushed robin
#

well

latent rapids
hushed robin
#

it's fine i just won't use regex

lyric mountain
#

Iirc it gives user id, auth key, timestamp and whether it's weekend or not

latent rapids
lyric mountain
#

Google topgg api, should be the first result

latent rapids
#

Neither does any of the SDKs help with that.

lyric mountain
#

How so? They show u exactly how to do it

hushed robin
latent rapids
#

I know about the docs but I wanna know how I can get the webhook from the API.

lyric mountain
#

...do you know what an webhook is?

latent rapids
#

Yes, but I don't know what to provide.

lyric mountain
#

User messages?

latent rapids
#

Like they said, I can't just slap a Discord webhook into the bot webhook.

boreal iron
lyric mountain
hushed robin
lyric mountain
latent rapids
lyric mountain
hushed robin
lyric mountain
#

There should be a field to put ur server url/ip and another to put an authentication key

lyric mountain
latent rapids
#

What is the server and IP?

lyric mountain
#

Idk, where are u hosting it?

#

The bot I mean

latent rapids
#

The site I'm using doesn't have static IP.

hushed robin
#

checking if the body of text includes one of multiple values

latent rapids
#

Or at least they don't provide one.

lyric mountain
#

Where are u hosting it?

latent rapids
#

railway.app

lyric mountain
hushed robin
#

why would that matter?

latent rapids
boreal iron
#

Man is really refusing to explain the context

lyric mountain
#

Because the approach changes depending on what u want it for

lyric mountain
boreal iron
lyric mountain
#

Since it's impossible for topgg to know where to send the info to

#

Ah yes, if it has a hostname use it

latent rapids
#

What do you mean by hostname?

lyric mountain
#

Anything that can be used to refer to ur bot address

hushed robin
lyric mountain
#

A public url for example

lyric mountain
#

If it's for user messages, I would tell u to stay away from regex

#

The answer is entirely dependant on what u want it for

hushed robin
#

well it's "user messages", not on discord though

lyric mountain
#

Ok, go on

hushed robin
#

on what

lyric mountain
#

Explaining wtf ur trying to do

#

Details are important

hushed robin
lyric mountain
#

Be more specific

#

What's the match being used for?

#

What's the rate of matches?

hushed robin
#

delete badness

lyric mountain
#

Ok, so it's for a swear filter?

hushed robin
#

💩 👉 🗑️

hushed robin
#

delete if contains one of many words

lyric mountain
#

Ok, so a blacklister

wheat mesa
#

so... then... use... includes... like... I... said... 20... times...

latent rapids
#

Where do I get public URLs I can use to get the webhook data?

lyric mountain
#

Yes, use includes on a loop

boreal iron
hushed robin
#

so

lyric mountain
hushed robin
#

i should just loop through the array of filtered things?

#

and check if it includes

lyric mountain
#

They should specify it somewhere

#

Yes

hushed robin
#

well

#

thats simple enough ig

lyric mountain
#

Yes it is

boreal iron
#

Literally anything is faster than regex

wheat mesa
#

Or even ["array", "of", "words", "to", "filter"].some(word => stringToLookAt.includes(word));

hushed robin
#

why regex exist then

wheat mesa
#

This is doable with a one liner

lyric mountain
boreal iron
#

So you should only go with it if things and pattern really get complicated

hushed robin
wheat mesa
#

It would be the same

hushed robin
#

oh

#

ok

wheat mesa
#

It's just syntactic sugar

lyric mountain
#

It is a loop, technically

wheat mesa
#

Yeah

hushed robin
#

ty guys

lyric mountain
#

For example, consider this:

wheat mesa
#

This is basically doing ```js
for(const word in arrayOfWords) {
if(stringToLookAt.includes(word)) {
return true;
}
}

lyric mountain
#

"The orange circle resembled an orange"

boreal iron
lyric mountain
#

I only want to match colors that are succeeded by a shape

#

If I searched for "orange" it'd match twice

#

Pretty bad example tbh, but it should do

boreal iron
lyric mountain
#

Anyway, regex is used when a pattern is known, but the values aren't

#

Or when you're extracting data from a text

hushed robin
#

ok

#

good to know

latent rapids
#

What if I just use an empty website created by my bot?

lyric mountain
#

Then nothing will happen

#

Topgg will send the payload to an empty site

boreal iron
#

You still need a webserver which is listening for post requests

#

aka webhooks

lyric mountain
#

Webhooks are literally reverse apis

boreal iron
#

It doesn't need to serve a site or html code etc

sudden geyser
#

me when I realize one of the most widely used editors uses regex for half its parsing

lyric mountain
#

Lmao which?

sudden geyser
#

vim

lyric mountain
#

It had to be vim smh

latent rapids
#

Yeah, I can create a webserver using flask.

#

Maybe.

lyric mountain
#

It'll do, but isn't needed if u use the library

#

Since it has it built-in already

#

But doing it though flask shouldn't be too hard either, the payload ain't complex at all

latent rapids
#

What do you mean by library?

lyric mountain
#

Topgg py lib

#

It's listed in the same site u found the docs

#

Just click on "libraries" at the left

latent rapids
#
bot.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/dblwebhook", "password")
```Oh, so this line of code creates a webhook that I can put in the `bot/webhook`?
lyric mountain
#

Yep

boreal iron
#

Keep in mind to open the port your webserver is listening to in your server firewall, as the webhook is an incoming connection

boreal iron
#

This will not prevent you from doing so

#

It can't open ports on your server for u

latent rapids
#
# The port must be a number between 1024 and 49151.
bot.topgg_webhook.run(5000)  # this method can be awaited as well
```I need to open this somehow?
lyric mountain
#

Most "automatic" hosts already give u a port to use

latent rapids
#

How do you even open a port.

boreal iron
#

In this example 5000 (tcp) needs to be opened

lyric mountain
#

Just see which port it gave u

boreal iron
#

Depends on your system, os etc

lyric mountain
boreal iron
#

Or service yeah

lyric mountain
#

Railway app

latent rapids
#

railway.app doesn't provide me any port.

lyric mountain
#

Well, that's complicated then

#

You'll need one to be able to listen to incoming requests

vocal canopy
#

I'm using mongoose, and recently when fetching a document inside a collection, the response is very very slow, this just started happening today the document contains an array of 10,000 objects, is it because the number of items?

latent rapids
#

Do you guys double your rewards on weekends?

hushed robin
latent rapids
hushed robin
latent rapids
#

Oh.

#

I'll just make my own.

sharp geyser
#

Sunday can't be considered weekend

#

its the beginning of the new week

#

Friday is also not the end of the week

#

Saturday is the true end

hushed robin
#

well 🤷

rustic nova
#

Especially Java

sharp geyser
#

Lmfao

sharp geyser
rustic nova
#

And ESPECIALLY ones where the datetime related settings are set to private

sharp geyser
#

not Monday to Friday

wheat mesa
rustic nova
#

Hell yeah

hushed robin
#

why is school monday to friday then

sharp geyser
#

Because they can't make you go school 6 days out of 7

#

Thats immoral

hushed robin
#

the weekend is only a day? 🤨

sharp geyser
#

Although I am sure some countries dont give no fucks

#

Yes but then you only have 1 day off

#

That would be hell and inefficient

tulip socket
#

Hey, I need to make the bot listen to incoming server requests, any way i can make this possible?
(Python)

sick agate
#

yes

radiant kraken
#

imagine only wanting to be spoonfed

hushed robin
radiant kraken
#

i've just said Array.some + String.includes

hushed robin
#

ok but how does that explain anything

earnest phoenix
#

Explains that you need to turn on more than 2 braincells and search on Google or similar how Array.some works, as well as String.includes, with examples if needed and then use again a few braincells to put them both together to get your final solution.

sharp geyser
#

That expects too much out of your average top.gg member krypton

hushed robin
earnest phoenix
#

Might just go back to hibernating

sharp geyser
#

ong

#

I might just block out discord servers entirely and just talk to a few people

compact pier
#

How can I optimize large images?

#

the images size are >20mb

#

and I want to have a good quality

quartz kindle
#

a website?

compact pier
#

I looked for cdn but it is too expensive

#

a backend server would be too complicated

#

I dunno where to host those images

#

😢

lament rock
#

added last.fm scrobbling to my bot and that was the absolute worst thing I've experienced when it comes to docs. If you want to retain your sanity, do not read last.fm docs

earnest phoenix
radiant kraken
#

no matter the difference

#

if its less time then its faster 😎

earnest phoenix
#

Definitely worth learning an entirely different language that's probably 10x harder than what you're already using!!!!!

quartz kindle
#

most people use screen resolutions between 720p and 1080p, displaying images bigger than that in those screens will make no visual difference

#

and even if you have 4k screen, 20mb is still too big, you can have 4k images much smaller than that

#

@earnest phoenix btw, why is DataView so slow to inatantiate?

#

its literally faster to copy a buffer into another buffer that already has a dataview attached than creating a new dataview on the buffer

lyric mountain
#

that said, 20mb makes me think they're using png instead of jpeg, which is not really necessary

earnest phoenix
#

webp ftw

lyric mountain
#

there's that too

earnest phoenix
#

It's the purpose of the format, so I'd use that

#

Hosting? Honestly you can just make a github repository lmao

earnest phoenix
# quartz kindle its literally faster to copy a buffer into another buffer that already has a dat...

That's because DataViews are much more complex internally compared to just Buffers which are just ArrayBuffers internally, DataViews provide a direct interface to the data and the buffer to be modified in however you want, meanwhile Buffers don't provide as much control as DataViews

Here are implementations:

DataView: https://chromium.googlesource.com/v8/v8.git/+/refs/tags/11.2.207/src/builtins/builtins-dataview.cc

Buffer: https://chromium.googlesource.com/v8/v8.git/+/refs/tags/11.2.207/src/objects/js-array-buffer.tq (the object) | https://chromium.googlesource.com/v8/v8.git/+/refs/tags/11.2.207/src/builtins/arraybuffer.tq (the actual ArrayBuffer implementation)

#

Note that Buffer itself is not an API provided by JavaScript engines themselves, it's an API provided by the runtimes like Node.js, which is an ArrayBuffer internally as mentioned

earnest phoenix
#

🦀

quartz kindle
#

while buffer and uint8array holds actual, much larger, data

#

in my benchmarks they break even at around 13kb in size

#

meaning its faster to copy 13kb of data from one arraybuffer to another arraybuffer than it is to instantiate a DataView on one arraybuffer

#

which doesnt make much sense to me

#

also, TypedArray.byteLenght is very slow to access, about 10-20x slower than TypedArray.length

#

is it a getter that calls native code?

quartz kindle
#

also, pls expose bigint raw bytes in js :^)

earnest phoenix
# quartz kindle which doesnt make much sense to me

It's unrelated to the data itself, the interface is the one that takes the most time to instantiate because it attaches itself to the array buffer directly, which takes time as it does multiple checks and whatnot to do so, you can see from the implementation

earnest phoenix
lyric mountain
#

u need to do something inside the loop, else it'll get inlined

#

also, run 2 separate scripts, to prevent jit from kicking in

earnest phoenix
lyric mountain
#

ah

#

but what abt jit?

earnest phoenix
#

Barely any different in that regard

quartz kindle
#

same thing on 110

#

and DataView

#

compared to copying

#

even worse with small buffers

quartz kindle
#

in node 19 performance is same as in chromium

#

not sure which version it started, but it seems i did indeed find another regression xD

earnest phoenix
#

Tim the regression finder in unstable builds

quartz kindle
#

:^)

#

so where do i report this, or who/when/where did made the last changes to typedarrays?

earnest phoenix
quartz kindle
#

yes, tested in 19.7

earnest phoenix
#

I'm not exactly sure if this should be reported to V8 or Node.js because this is intertwined with both, try opening an issue about it in https://github.com/nodejs/node/issues for a heads up

GitHub

Node.js JavaScript runtime :sparkles::turtle::rocket::sparkles: - Issues · nodejs/node

quartz kindle
earnest phoenix
#

Then it's a V8 issue, but I have no idea from which V8 version that regression started from, you can compare Node.js v18 and v19's V8 engine versions

quartz kindle
#

why doesnt google use github

#

google git is so damn confusing, i cant find anything

earnest phoenix
quartz kindle
#

like some nightly chromium test build that includes the latest v8

#

also, how to see v8 version from chrome?

#

or is it implied from the chromeversion, like v110 = v8 11.0?

earnest phoenix
# quartz kindle is there no way to test 11.2 without manually building it?

We don't provide pre-built binaries for V8 due to significant resources needed to compile so many release tags, and the fact that pretty much nobody uses pre-built binaries as we provided them before, because building from source allows you to configure it in many ways to make it much more compatible, so building it from source is your only option

earnest phoenix
quartz kindle
#

11.0.226.16

#

so the issue is still present here, but idk when it started

quartz kindle
#

@lament rock yo, i pubished the etf thingy, if you want to give it a spin

sharp geyser
#

Woah a finished project ?

#

Tim hasn't made one of those in ages

quartz kindle
#

indeed

#

lmao

#

its not really finished tbh, there are still things it can be added

#

but should work for using with discord

wheat mesa
#

Those are some impressive performance benchmarks

quartz kindle
#

thanks, i sold my soul for them

#

:^)

wheat mesa
#

Roughly 6x faster than the fastest etf encoder on that list

#

Damn

rustic nova
#

Tim

#

Make an optimised java

lyric mountain
#

nah, a straightforward swing would suffice

next storm
#

Idk why my bot is occupying high amount of ram, like it has an uptime of 42 hours now, and it has occupied around 3gb ram.
Is there any way to reduce this amount and have a control on it?

sudden geyser
#

would be good if you could figure out what is taking up much of the ram

#

think node has some snapshot tool

#

could also check if you have some sort of caching

rustic nova
#

Inb4 cache

rustic nova
#

Unsure if djs supports it right now

#

But forums are essentially threads so these would not be hard to implement

hushed robin
#

in v14, yes

#

not supported in v13 yet though

sharp geyser
#

It is ?

#

<ForumChannel>.threads.create() should do the trick

hushed robin
#

oh

sharp geyser
#

Same thing yea

low moat
#

You can ignore this:
Hello it's only once in a blue moon I come over here and reach out for help, I tried reaching out to stackoverflow but one person responded and were awfully rude about it and didn't even help so I have come here as my last resort.

My monkey brain cant uncover this problem:
I may be a bit slow but I have tried many times using guides, youtube tutorials, google searches etc. etc. to make a discord button that is attached to this motherfucking embed but my god what ever i try is failing due to the search or guide being either out of date or doesn't work with my command handler (im pretty sure that's the issue anyways).

const { MessageActionRow, MessageButton, MessageEmbed } = require('discord.js');

module.exports = {
    name: 'client',
    description: "Check to see how Nonay is holding up!",
    showHelp: false,

    execute({ client, inter }) {
        const commands = client.commands.filter(x => x.showHelp !== false);

        const button = new MessageButton()
            .setLabel('Click Me')
            .setStyle('PRIMARY')
            .setCustomId('exampleButton');

        const row = new MessageActionRow()
            .addComponents(button);

        const embed = new MessageEmbed()
            .setColor('#0CEC1D')
            .setAuthor(client.user.username, client.user.displayAvatarURL({ size: 1024, dynamic: true }))
            .setTitle('📑 Client Info')
            .setDescription("``Nonay Client Ver``\nv3.4.9\n\n``Client Performance``\nExcellent\n\n``Client Discord.js``\nv14.2.0\n\n``BETA Whitelist Commands``\ncontroller, update, filter, console")
            .setFooter('Powered by Nonay', inter.member.avatarURL({ dynamic: true }));

        inter.reply({ embeds: [embed], components: [row] });
    }, };```

if needed i can run this command and try and find the error again
deft wolf
#

What exactly doesn't work?

#

Because the command itself looks to work, there is nothing in it that could not work

low moat
#

but either way i cant get to the bottom of it due to my inability to solve errors

#
D:\Nonay\nbot\commands\other\client.js:11
        const button = new MessageButton()
                       ^

TypeError: MessageButton is not a constructor
    at Object.execute (D:\Nonay\nbot\commands\other\client.js:11:24)
    at module.exports (D:\Nonay\nbot\events\interactionCreate.js:15:17)
    at Client.emit (node:events:513:28)
    at InteractionCreateAction.handle (D:\Nonay\nbot\node_modules\discord.js\src\client\actions\InteractionCreate.js:81:12)
    at module.exports [as INTERACTION_CREATE] (D:\Nonay\nbot\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
    at WebSocketManager.handlePacket (D:\Nonay\nbot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:352:31)
    at WebSocketShard.onPacket (D:\Nonay\nbot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:481:22)
    at WebSocketShard.onMessage (D:\Nonay\nbot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:321:10)
    at WebSocket.onMessage (D:\Nonay\nbot\node_modules\ws\lib\event-target.js:199:18)
    at WebSocket.emit (node:events:513:28)

Node.js v18.7.0```
#

i swear some developers must be screaming at their monitors right now and yelling at me because its right there

earnest phoenix
#

You have migration there

#

e.g.

// v13
const button = new MessageButton();
// v14 
const { ButtonBuilder } = require('discord.js');
const button = new ButtonBuilder();
low moat
#

well it was going great but its flopped now

D:\Nonay\nbot\node_modules\@sapphire\shapeshift\dist\index.js:76
    throw this.error;
    ^

ValidationError: Expected the value to be an object, but received string instead
    at ObjectValidator.handle (D:\Nonay\nbot\node_modules\@sapphire\shapeshift\dist\index.js:1182:25)
    at ObjectValidator.parse (D:\Nonay\nbot\node_modules\@sapphire\shapeshift\dist\index.js:142:88)
    at EmbedBuilder.setAuthor (D:\Nonay\nbot\node_modules\@discordjs\builders\dist\messages\embed\Embed.cjs:42:37)
    at Object.execute (D:\Nonay\nbot\commands\other\client.js:20:14)
    at module.exports (D:\Nonay\nbot\events\interactionCreate.js:15:17)
    at Client.emit (node:events:513:28)
    at InteractionCreateAction.handle (D:\Nonay\nbot\node_modules\discord.js\src\client\actions\InteractionCreate.js:81:12)
    at module.exports [as INTERACTION_CREATE] (D:\Nonay\nbot\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
    at WebSocketManager.handlePacket (D:\Nonay\nbot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:352:31)
    at WebSocketShard.onPacket (D:\Nonay\nbot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:481:22) {
  validator: 's.object(T)',
  given: 'Nonay'
}

Node.js v18.7.0```
earnest phoenix
#

ValidationError: Expected the value to be an object, but received string instead

#

setAuthor

#

Ctrl+F on the migration guide

low moat
# earnest phoenix https://discordjs.guide/additional-info/changes-in-v14.html#messagemanager:~:tex...

thanks bro, one last question that should be more simple

if 'interaction' is not defined is that an intents issue?

the error im getting:

D:\Nonay\nbot\commands\other\client.js:33
        const collector = interaction.channel.createMessageComponentCollector({ filter, time: 15000 });
                          ^

ReferenceError: interaction is not defined
    at Object.execute (D:\Nonay\nbot\commands\other\client.js:33:27)
    at module.exports (D:\Nonay\nbot\events\interactionCreate.js:15:17)
    at Client.emit (node:events:513:28)
    at InteractionCreateAction.handle (D:\Nonay\nbot\node_modules\discord.js\src\client\actions\InteractionCreate.js:81:12)
    at module.exports [as INTERACTION_CREATE] (D:\Nonay\nbot\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
    at WebSocketManager.handlePacket (D:\Nonay\nbot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:352:31)
    at WebSocketShard.onPacket (D:\Nonay\nbot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:481:22)
    at WebSocketShard.onMessage (D:\Nonay\nbot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:321:10)
    at WebSocket.onMessage (D:\Nonay\nbot\node_modules\ws\lib\event-target.js:199:18)
    at WebSocket.emit (node:events:513:28)

Node.js v18.7.0```
earnest phoenix
#

No, that means it's not defined

#

E.g

console.log(x); // x is not defined
let x = 1337;
console.log(x); // x is defined
low moat
earnest phoenix
#

What kind of old code do you copy from CS_pepehmm

low moat
#

well actually

#

now that i think of it

#

i ran it through ChatGPT-3

#

and its out of date and ended training in 2021

earnest phoenix
#

yoikes here we go

low moat
#

so it doesnt know about discord v14

low moat
lyric mountain
#

the time you save from cloning/cheating almost always come to bite you back later on

earnest phoenix
#

in worse

earnest phoenix
#

instead use ```const message = await interaction.reply({ embeds: [Confirm], components: [Buttons] })

const collector = message.createMessageComponentCollector({ time: 15000 });```

low moat
#

so i guess im trying everything now

#

even with ur code

#
D:\Nonay\nbot\commands\other\client.js:39
        const message = interaction.reply({ embeds: [embed2], components: [row] })
                        ^

ReferenceError: interaction is not defined
    at Object.execute (D:\Nonay\nbot\commands\other\client.js:39:25)
    at module.exports (D:\Nonay\nbot\events\interactionCreate.js:15:17)
    at Client.emit (node:events:513:28)
    at InteractionCreateAction.handle (D:\Nonay\nbot\node_modules\discord.js\src\client\actions\InteractionCreate.js:81:12)
    at module.exports [as INTERACTION_CREATE] (D:\Nonay\nbot\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
    at WebSocketManager.handlePacket (D:\Nonay\nbot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:352:31)
    at WebSocketShard.onPacket (D:\Nonay\nbot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:481:22)
    at WebSocketShard.onMessage (D:\Nonay\nbot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:321:10)
    at WebSocket.onMessage (D:\Nonay\nbot\node_modules\ws\lib\event-target.js:199:18)
    at WebSocket.emit (node:events:513:28)

Node.js v18.7.0```
earnest phoenix
#

hol up

#

your not using slash commands?

#

are you using slash commands or not

lyric mountain
earnest phoenix
#

@low moat So Basically Interaction can be used only for slash commands

#

if your not using slash commands

#

send me a sample of one of your commands

low moat
#
const ms = require('ms');
const { MessageActionRow, MessageButton, EmbedBuilder, ButtonBuilder, ButtonStyle, ActionRowBuilder } = require('discord.js');
const { ApplicationCommandType, ApplicationCommandOptionType } = require('discord.js');

module.exports = {
    name: 'client',
    description: "Check to see how Nonay is holding up!",
    showHelp: false,

    execute({ client, inter }) {
        const commands = client.commands.filter(x => x.showHelp !== false);

        const row = new ActionRowBuilder()
        .addComponents(
            new ButtonBuilder()
            .setLabel('Up to Date')
            .setStyle(ButtonStyle.Success)
            .setDisabled(true)
            .setCustomId('exampleButton'),

            new ButtonBuilder()
            .setLabel('Check for Updates')
            .setStyle(ButtonStyle.Danger)
            .setCustomId('Check BETA Whitelist Perms')
        )

        const embed1 = new EmbedBuilder()
            .setColor('#0CEC1D')
            .setTitle('📑 Client Info')
            .setDescription("``Nonay Client Ver``\nv3.4.9\n\n``Client Performance``\nExcellent\n\n``Client Discord.js``\nv14.2.0\n\n``BETA Whitelist Commands``\ncontroller, update, filter, console")

            const embed2 = new EmbedBuilder()
            .setColor('#0CEC1D')
            .setTitle('📑 Client Info')
            .setDescription("Button Pressed")

        inter.reply({ embeds: [embed1], components: [row] });

        const message = interaction.reply({ embeds: [embed2], components: [row] })

        const collector = message.createMessageComponentCollector({ time: 15000 });
    }, };```

this is the entire shit show
low moat
earnest phoenix
#

Oh

#
const { MessageActionRow, MessageButton, EmbedBuilder, ButtonBuilder, ButtonStyle, ActionRowBuilder } = require('discord.js');
const { ApplicationCommandType, ApplicationCommandOptionType } = require('discord.js');

module.exports = {
    name: 'client',
    description: "Check to see how Nonay is holding up!",
    showHelp: false,

    execute({ client, inter }) {
        const commands = client.commands.filter(x => x.showHelp !== false);

        const row = new ActionRowBuilder()
        .addComponents(
            new ButtonBuilder()
            .setLabel('Up to Date')
            .setStyle(ButtonStyle.Success)
            .setDisabled(true)
            .setCustomId('exampleButton'),

            new ButtonBuilder()
            .setLabel('Check for Updates')
            .setStyle(ButtonStyle.Danger)
            .setCustomId('Check BETA Whitelist Perms')
        )

        const embed1 = new EmbedBuilder()
            .setColor('#0CEC1D')
            .setTitle(':bookmark_tabs: Client Info')
            .setDescription("``Nonay Client Ver``\nv3.4.9\n\n``Client Performance``\nExcellent\n\n``Client Discord.js``\nv14.2.0\n\n``BETA Whitelist Commands``\ncontroller, update, filter, console")

            const embed2 = new EmbedBuilder()
            .setColor('#0CEC1D')
            .setTitle(':bookmark_tabs: Client Info')
            .setDescription("Button Pressed")

       const message = await inter.reply({ embeds: [embed1, embed2], components: [row] });

        const collector = message.createMessageComponentCollector({ time: 15000 });
    }, };```
#

use this

#

instead of the above

#

did it work?

#

@low moat

lyric mountain
# low moat tiny bit

I'd recommend learning more about js before attempting a bot, else you'll struggle a lot keeping it alive

deft wolf
#

^^^

lyric mountain
#

besides, your code cannot possibly work

#

first because interaction is supposed to be inter, second because you cannot reply twice

earnest phoenix
earnest phoenix
#

check at the bottom

lyric mountain
#

u forgot to add embed 2 to the reply

earnest phoenix
#

oh

lyric mountain
#

also I'm not sure but, doesn't reply need to be awaited? since it's an api action

earnest phoenix
#

ahem

#

i do have that in my own code

lyric mountain
earnest phoenix
#

forgor to put here

deft wolf
earnest phoenix
lyric mountain
#

lul ik

earnest phoenix
rustic nova
lyric mountain
#

it's just ironic that the entire bot stats is hardcoded

earnest phoenix
#

he has to manually update it KEKW

low moat
#

excellent

#

💪

low moat
#

like the aim of the game is to crash/over heat the bot (not actually obviously)

lyric mountain
#

you should really take your time to study how d.js works (and js in general)

#

it's much more efficient than doing corrective programming

low moat
lyric mountain
#

you don't have 1 hour everyday?

#

heck, even 30 minutes

low moat
#

yk what i dont have? the dedication

#

i have short attention span i cant sit there and focus

#

i am professional unfocuser

lyric mountain
#

well, you'll struggle a lot then, programming is all about focusing and entering a "lock-on" state

#

typing is just a side-effect

wheat mesa
#

If you don’t care about trying to learn to program then why are you trying to program anything

#

At that point you’re just wasting your time

low moat
#

i never said i didnt care

#

i just said i simply dont have the focus required

wheat mesa
#

Then you don’t care

lyric mountain
#

it's a sisyphean task in the end, until it gets so unmaintainable that it requires complete rewrite

#

I mean, it also happens with every other programmer, but we try to delay it as much as possible

low moat
wheat mesa
#

I’m not saying that

#

I understand that adhd makes it difficult to focus, but it seems like you preemptively blame adhd before even attempting to study a bit

#

It’s okay if you lose focus, by trying a little bit each day you can get better at it

lyric mountain
#

there are games that teach programming (or just logical thinking), they were made specifically for people with focus issues

wheat mesa
#

You shouldn’t think that you can’t do anything because you have adhd, you can definitely learn stuff even if it’s just 5 minutes a day that you’re focused on it

lyric mountain
#

heck, I learned programming playing gmod

wheat mesa
#

Making things that you’re interested in doesn’t require as much focus because you’re having fun

#

If you think of it less as a task and more as an enjoyable activity, you’ll learn a lot

final tinsel
wheat mesa
#

I am not blaming adhd

final tinsel
#

no i was impersonating you

#

silly goose

wheat mesa
#

I am saying that always assuming you are incapable of doing something that requires focus is going to set you back

final tinsel
#

🦆

wheat mesa
#

You never know until you try

#

And like I said it’s okay to lose focus even if you only get a few minutes in a day

#

A few minutes a day is still a LOT better than no minutes a day

earnest phoenix
#

basically

#

To learn programming

#

You need to get your hands dirty with projects and exercises that get harder with time

lyric mountain
#

keywords are "get harder with time"

#

people often jump into hard/complex projects from the get-go and give up because "programming is too hard"

earnest phoenix
#

Failed to make an OS when learning C - programming is definitely too hard

radiant kraken
#

@wheat mesa TIL if let [..] in Rust is a thing

wheat mesa
#

Oh you didn’t know that?

radiant kraken
#

i didnt know that .. also works in if lets

#

god i don't find the point behind &literal in Rust ```rs
let next = *text.get(i + 1).unwrap_or(&0);

#

like why &0 😭

lament rock
quartz kindle
#

without &, 0 will feel lonely. with & makes it look like there is someone else with him

earnest phoenix
wheat mesa
#

Probably gets thrown away in compilation

#

Or maybe even allocates memory for it temporarily though that would be kinda dumb

earnest phoenix
#

Yeah that's pretty stupid, you would be hit with an error if you try to do that in C/C++

#

I guess Rust maintainers wants it to be some kind of undefined behavior or something

quartz kindle
#

its in their docs

#

so basically yes, its a temporary value

earnest phoenix
#

Weird Rust semantic, I don't think any other programming language out there that allows you to manage memory manually allows that

#

But ¯_(ツ)_/¯

quartz kindle
#

thats why rust is the next big lang

#

:^)

earnest phoenix
#

Oh yeah, definitely :^)

quartz kindle
#

:^)

#

@earnest phoenixbtw, there is pretty much only one thing left that node has that is faster than browser/v8 alternatives

#

text encoding/decoding

#

pls make TextEncoder/TextDecoder faster kthxbye

#

just copy the node:string_decoder source code, ezpz

earnest phoenix
#

i still hate somehow something called rsx exists

earnest phoenix
#

Expect these changes in Node.js v20 after we release it and mark it as LTS, we might backport these changes to the older versions but that's unlikely

lament rock
#

Might be considered breaking since even performance numbers are to consider

quartz kindle
#

ayyy

#

im trying to get rid of Buffer and use only Uint8Array with DataView, text encoding/decoding is the only thing i still need Buffer for

lament rock
#

Why Uint8Array when Buffer extends Uint8Array

quartz kindle
#

browser compatibility

#

dont wanna check if typeof Buffer !== undefined everywhere lol

#

and DataView's methods are faster than Buffer's, its just painfully slow to instantiate

lament rock
#

Funny how they deprecated BufferConstructor

quartz kindle
#

lies

#

also compared v18 to v19.7 and no difference

sharp geyser
quartz kindle
#

@earnest phoenix also please for the love of god make TextEncoder.encodeInto accept start index

#

look at this crap

#

literally half the speed because i have to use subarray instead of start index

earnest phoenix
# quartz kindle also compared v18 to v19.7 and no difference

I think you're benchmarking in a non-realistic way, our benchmarks showed very high performance improvement rates
https://github.com/nodejs/node/pull/45803#issuecomment-1353832681

GitHub

simdutf provides a faster way of providing utf8 operations with SIMD instructions. @nodejs/undici team was looking for a way to validate utf8 input, and this dependency can make it happen.
Edit: I&...

neon leaf
#

whats the best tool for automatic api docs with laravel? I found rakutentech/laravel-request-docs but it seems to only be erroring, Error: Call to undefined method ReflectionUnionType::getName()

earnest phoenix
quartz kindle
#

its a few years old tho, maybe opinions change

earnest phoenix
#

Yeah that's why I'm saying that, lots of things have changed since that time so it's better to give it a shot again

quartz kindle
#

is whatwg the right place for it?

earnest phoenix
quartz kindle
#

the actual implementation comes from v8 tho right?

#

or is this something that is done by a third party addon?

earnest phoenix
#

V8 does not implement additional web APIs, Node.js does

quartz kindle
#

i mean TextEncoder and TextDecoder

#

in browsers

#

they are not done by v8?

earnest phoenix
#

Ah, yeah those are implemented by V8

#

Though V8's codebase pretty much has no sign of the TextEncoder/TextDecoder implementations, so I have no idea on that regard to be completely honest

#

There's a high chance Chromium itself implements them instead of V8

quartz kindle
#

hmm

quartz kindle
#

not v8

earnest phoenix
#

Hmm yeah

sharp geyser
#

ICU sounds like a hero squad name

lyric mountain
#

Hero: ICU (I see you)
Power: can see anyone from anywhere regardless of distance or line of sight

gleaming bolt
#

I was analyzing the "ActivityType" of discord.js and I noticed that the invisible doesn't exist anymore, is there any way to set the invisible status in the bot?

lyric mountain
#

invisible does exist, but most libs no longer list it

gleaming bolt
#

hm...

lyric mountain
#

since it only makes sense for yourself, for everyone else you'll have the status "offline"

gleaming bolt
#

do you know what type it is?

radiant kraken
#

like ```rs
let something = *troll();

#

or ```rs
let something = func(&yes());

gleaming bolt
#

I gave a console.log on the "ActivityType" and received only

Playing: 0,
Streaming: 1,
Listening: 2,
Watching: 3,
Cistom: 4,
Competing: 5

radiant kraken
earnest phoenix
#

I said nothing about pointers, let alone a null pointer

#

But it seems like they actually make it a temporary value that has an identifiable address unlike C/C++

radiant kraken
#

you can see this everywhere in the Rust docs, since most arguments take a reference (or borrowing), instead of a value

quartz kindle
gleaming bolt
#

:V

quartz kindle
#

invisible is a status

gleaming bolt
#

but formerly, in older versions, you could set bots status to invisible

#

Is this no longer possible?

#

I want to set bot state, like: idle, invisible, online

quartz kindle
#

what dont you understand?

#

activity type is one thing
status is a different thing

gleaming bolt
#

c.c

quartz kindle
#

this is activity

Playing: 0,
Streaming: 1,
Listening: 2,
Watching: 3,
Cistom: 4,
Competing: 5
#

this is status ```
online
idle
invisible
dnd (do not disturb)

gleaming bolt
#

ok

quartz kindle
#

for status you use client.setStatus or client.setPresence({status:})

#

for activity you use client.setPresence({ activities: [] })

gleaming bolt
eternal osprey
#

hey guys in java i have a question about interfaces.

#

I still don't fucking understand why i should use them

#

imagine i want to get the price of all sorts of products yeah

#

I hvae different classes for each product

#

I can then create an interface like: void Interface test {
double getPrice();
}

#

now i n all classes i must define this fucking price again....

#

why would i bother using an interface then? Because i could define the double getprice without the interface?

lyric mountain
#

I think we gave u a pretty good example last time

eternal osprey
#

yes i know i still didn't get t

lyric mountain
#
public interface Walkable {
  public void walk();  
}
public interface Human implements Walkable { ... }
public interface Dog implements Walkable { ... }
#
var walks = new Walkable[]{new Human(), new Dog()};
#
for (Walkable w : walks) {
  w.walk();
}
#

basically, so you can have a common method signature, allowing u to reference them by the interface, instead of the specific classes

eternal osprey
#

huh isn't var walks an array of interfaces now?

lyric mountain
#

yes

#

it can hold any class that implements it

eternal osprey
#

Why would that be needed because 1 interface can be used in multiple classes if it gets implemented

lyric mountain
#

show me how would you put Human and Dog in a single array

#

and call walk() from each entry

#

that'll make u understand the reason

rustic nova
#

You might need to look into inheritance/interfaces before understanding it

rustic nova
#

New to me