#development

1 messages · Page 63 of 1

lyric mountain
#

remember bots can have commands added or removed at ANY time

#

or the code changed entirely

#

a "bot" is nothing more than a vessel, an interface to communicate with discord

#

the code inside is entirely hidden from the user

solemn latch
#

Your bot can join a server, create a webhook and leave.

Since the bot created the webhook it can still respond to interactions on the webhook.

You could in theory create a lot of features with that.

#

Just no guild info

crystal wigeon
#

Hey does topgg moderators dm you?

lyric mountain
crystal wigeon
#

also can i not host a GA asking people to leave a review on the bot? im just asking them to leave a review be in good or bad, not forcing any sort of number on anyone

shadow stratus
#

Well, deletions can be completely disabled or locked down. An idea for how deletions can be locked down: No channel deletions or anything else similarly destructive or kicking/banning users, can only delete messages posted by bot

surreal sage
#

I have a D.js Select Menu, I await the interaction (works fine)

After the response has been sent I show a modal, I want to reply to the modal by editing the message of the select menu and closing the modal.

modal.reply makes a new response
selectmenusubmit.update doesn't close the modal
selectmenusubmit.update "reply to this interaction has already been sent or deferred"

What method should I use?

D.js version 14.0.3

solemn latch
crystal wigeon
#

Got this DM, tryna make sure its legit

lyric mountain
#

or that ^

shadow stratus
#

Well, most scams are being done my selfbots

crystal wigeon
#

someone pls help, ty

lyric mountain
#

yes, and discord has one hell of headache on that issue

lyric mountain
#

it's a scam

crystal wigeon
#

so i can do GA asking for people to leave a review?

lyric mountain
#

topgg mods wont say "hi I am a mod"

shadow stratus
crystal wigeon
#

they shared this link

earnest phoenix
lyric mountain
crystal wigeon
#

786150805773746197

#

@rugged dawn

#

yep

#

its them ig

shadow stratus
earnest phoenix
#

Then it's not a scam, it's legit

lyric mountain
#

what if they dont want to?

rugged dawn
crystal wigeon
#

i copied their user ID, and it showed yours?

rugged dawn
#

and yeah respond to the dm ASAP please :)

lyric mountain
#

oh so it was legit

#

srry

rugged dawn
#

yeah it's me you don't have to worry

crystal wigeon
#

ah okay

#

just verifying

#

haha

crystal wigeon
solemn latch
#

/j means joking

lyric mountain
shadow stratus
lyric mountain
#

modal.reply already acks the interaction, any further edit has to be done to the message itself

#

not the hook

digital swan
lyric mountain
#

I was trying to explain, but they simply dont understand

#

gonna eat now, cya

shadow stratus
solemn latch
shadow stratus
#

I'm not exactly sure, but IDs probably aren't as easy to get in some countries

solemn latch
#

Someone who is privacy conscious probably would support protecting the privacy of users right? which is what this is for.

You're not acting as a user as a bot developer, you kind of have to forfeit some privacy when developing things with another company.

#

I cant comment on people who are not able to work with stripe, stripe doesn't support a lot of countries.
There are valid ways around that though.

Such as finding someone else who will verify the bot.

#

At the end of the day, discord has to do whats best for the platform and their users. which is the goal of the verification system.

shadow stratus
lyric mountain
#

You're free not to supply your ID, discord is free to limit your bot's reach

#

Simple trade rules

solemn latch
#

If you are really dedicated to making an application on discord without supplying an ID that can be used in more than 100 guilds at once I do think its possible, with some heavy limitations.

You could in theory make a bot that has a single command.
That command could create a channel, lock the channel so users cant send messages in it, and create a webhook.
Then on the webhook you send a message with help information, and a select menu to run something like a command.
once setup, the bot leaves the server.

Your application can still interact with the webhook, and you can still receive interactions with select menus or buttons on messages sent by that webhook.

it could scale as far as you want.

sage bobcat
#

One message removed from a suspended account.

crystal wigeon
#

Already sorted

#

Thanks

rugged dawn
sage bobcat
#

One message removed from a suspended account.

boreal iron
neon leaf
#

how do let users get params (:id) like in express with the node:http library?

#

aka recognize /lol/hello/ok as /lol/:word/ok, word = hello

lyric mountain
#

are u trying to replace express with node http?

neon leaf
#

in some ways, yes

lyric mountain
#

don't

#

there's more than a simple facade, you're in for a lot of headache trying to make an http server using raw api

neon leaf
#

I know

#

its for a school project

lyric mountain
#

well you'd use regex to extract that data

neon leaf
#

could I technically split the url into an array by / and get the params index value by that?

lyric mountain
#

that too

#

split uses regex in js iirc

#

worth to note u wont be able to get params by name if u use split

neon leaf
#

how would I know that its still the url that the user defined though?

lyric mountain
#

regex

neon leaf
#

uhh, would I just replace the params postion with ?

#

(in the regex)

lyric mountain
#

simply don't match anything after ?

#

regex doesn't need g flag

neon leaf
#

this is my current logic

#

how would I go about it here

#

because in this case it would return nothing

#

it only checks if pathname is literally in the saved urls

lyric mountain
#

reg 👏 ex

#

you need to iterate over your list to find an url that matches

neon leaf
#

how would I exactly go about implementing it though?

lyric mountain
#

do u know how regex works?

neon leaf
#

no, actually yes but no

lyric mountain
#

you need to build an expression that compares against the url

#

ignoring parts that are variables

neon leaf
#

how would I know what part is a variable though with just having the request url?

lyric mountain
#

by comparing with the url

#

you're missing the part where u iterate over each url saved in the list

neon leaf
#

would this make some sense?

lyric mountain
#

no, by far

#

you need to literally write a regex pattern to extract the variables (and their names), then check if the supplied url matches the inverse of that regex

slender wagon
#

hey guys here i am again

#

reinstalling postgress

lyric mountain
#

can probably be done with split + loop tho

slender wagon
#

any tip before i am finished?

lyric mountain
#

configure cache size

slender wagon
#

to what

lyric mountain
#

...to whatever resources your server has

neon leaf
#

make sure to not allow external postgres user login

slender wagon
#

am i gonna need this all

lyric mountain
#

postgres comes with default settings, which obviously isn't optimized for ur server

lyric mountain
slender wagon
#

so no admin4?

lyric mountain
#

pgadmin is for managing the database, technically not needed but enable it if u want a gui

slender wagon
#

can i run that in localhost if i don't install pgadmin

lyric mountain
#

pgadmin is a manager, not the database

#

the database will run regardless of what u install

slender wagon
#

yes yes but can i run some sort of manager on localhost

lyric mountain
#

there's no "on localhost"

#

it's either local or remote

slender wagon
#

i can't explain i saw some other guys they had something very similar to pgadmin

#

but it wasn't it

#

it was simple

#

running on localhost

#

basically not an app

lyric mountain
#

ops

#

fuck amazon let me copy the image

slender wagon
#

lmao

slender wagon
#

well i am gonna install it again an this time let's hope it does the job

#

yes i am aware

lyric mountain
#

pgadmin doesn't do anything other than present a visual interface for the CLI

#

having it or not won't influence how postgres work

slender wagon
#

gotchya

neon leaf
lyric mountain
#

[A-Za-z0-9]+ will match a word

neon leaf
#

ah

#

nvm

lyric mountain
#

but u cant include : nor / in the match

neon leaf
#

why?

lyric mountain
#

so put () around the word pattern

#

because those aren't part of the name of the variable

#

those are boundaries

neon leaf
#

ok, I am now a bit confused how to continue

#

I mean, I got a regex that matches var names ut what to do with it?

lyric mountain
#

now u invert that regex and compare against the url

#

it'll compare anything but the variables

neon leaf
#

how do I invert it?

lyric mountain
#

(?!pattern)

neon leaf
lyric mountain
#

try doing it with split + loop tho, it'd probably be easier for u

#

split by / and iterate over each part

#

split both template and input urls btw, not just input

#

if both have the same array length, continue, else stop cuz they cant be equal

neon leaf
#

🤯 it makes sense

lyric mountain
#

after that it's just comparing template[i] with input[i]

#

if template starts with :, save the current input index as a property

#

else compare if both are equal

neon leaf
#

is this kinda correct before I continue?

sage bobcat
#

One message removed from a suspended account.

neon leaf
#

its not in a try it state yet

lyric mountain
#

don't split many times

#

save the split result to a const and use it

neon leaf
#

I can only put actualUrl outside the loop though, right?

#

actually, I can just store most of that in the urls json

brave raptor
#

Bro, use BDScript

#

Easy af

neon leaf
#

why would I use bdscript to make a web server

brave raptor
#

Oh

lyric mountain
#

bdscript 💀

brave raptor
#

I thought u r making bot

brave raptor
lyric mountain
#

nah, just "yet another bot builder"

#

which end up to be constrained af and usually, harder to deal with than if u just used normal programming

lyric mountain
# neon leaf

u dont need the regex anymore if ur looping with split

clever shuttle
brave raptor
#

Why lol?

clever shuttle
#

that's like so basic

neon leaf
brave raptor
lyric mountain
#

it's because bot builders don't have a good rep around here

clever shuttle
#

💀

opaque acorn
#

Somebody know how to avoid root perms in Termux?

brave raptor
#

Btw u cant

opaque acorn
brave raptor
#

3.6gb only

neon leaf
#

how do I know which template to use? Do I put that in my other loop?

lyric mountain
#

template is the stored url

#

input is the url ur testing

neon leaf
#

so input = reqUrl.pathname?

lyric mountain
#

yes

#

I think

neon leaf
# neon leaf

with stored url you mean what I showed in that screenshot? (array)

lyric mountain
#

yes

neon leaf
#

but I need to uh w- its stored under /userinfo/:username but I dont know that its there

#

because there are many urls

lyric mountain
#

you'll iterate over each url

neon leaf
#

ah so your code snippet just goes in a for loop with every url that has params?

lyric mountain
#

with every url

neon leaf
#

why every?

#

and wouldnt just checking for lenght result in /userinfo/:username and /userdata/:username being the same?

lyric mountain
#

yes, that's why u also check each param

lyric mountain
neon leaf
#

ok, imma just not ask questions and copy the code snippet first

lyric mountain
#

pay attention to it, dont simply copy blindly

neon leaf
#

like this?

lyric mountain
#

u forgot to return vars

#

if the inner for completes, then it's a match

#

nvm

#

well, just return var after u have a match

neon leaf
#

seems to be loading infinitely now

lyric mountain
#

it shouldn't be

#

also ur not supposed to change iterator variables

#

simply use for (... of ...)

neon leaf
#

these are my logs,

lyric mountain
#

and the first two variables are useless

lyric mountain
#

are u sure that's a school project?

neon leaf
#

it just means the server now runs

neon leaf
#

ok, it works now, atleast it responds

#

for some reason the loop isnt executing at all though

lyric mountain
#

probably because ur prefixing the url with /

#

told u how to do it, now it's ur turn to solve that

neon leaf
#

no like, the actual loop isnt running, the upper one

#

I dont understand why

#

urls:

    '/lol': {
      hasParams: false,
      array: [Array],
      type: 'GET',
      code: [AsyncFunction (anonymous)]
    },
    '/lol/:username': {
      hasParams: true,
      array: [Array],
      type: 'GET',
      code: [AsyncFunction (anonymous)]
    }
  ]```
loop:
lyric mountain
#

did u try printing what urls is?

neon leaf
#

yes, the thing in the upper part of the message

lyric mountain
#

that's a print result?

neon leaf
#

yes

lyric mountain
#

well then, it's because you're returning

neon leaf
#

even

  console.log(e)
}```
doesnt work
lyric mountain
#

are u sure it's really entering wherever that code is?

neon leaf
#

hmm, half of the code works now

#

oh yeah, because I used in

#

this works

                e = urls[e]
                console.log(e)
            }```
wheat mesa
#

e = urls[e] pepowot

#

Imagine seeing this in Java

#

ConcurrentModificationException would like to know your location

surreal sage
#

I have a value that can be 0 to 1
If it's 0.6 I want it to be 0.4, if it's 1 I want it to be 0 If it's 0.3 I want it to be 0.7, get me?

#

What's the math

lyric mountain
#

still a fucked up habit tho

lyric mountain
surreal sage
#

I see, thanks

molten halo
#

Hello im trying to simply download files from my url with nodejs
When i try
file = fs.readFileSync("./x.pdf")
and res.send(file)
And when i go this slash it works but it download without extintion i mean it just downloads x not x.pdf i need to rename it how cna i fix it?

lyric mountain
#

first of all, readFileSync reads a file, it doesn't "download" anything

#

second, what is res? the answer can change drastically depending on what that is

lyric mountain
#

💀

neon leaf
#

how can I get the put body of the request and forward it to the custom function to use?

lyric mountain
#

req.body

neon leaf
#

I am talking about node:http

#

req.body is undefined

lyric mountain
#

read the docs

neon leaf
#

since when does node:http have docs

lyric mountain
#

since eniac was built

neon leaf
#

is this it?

lyric mountain
#

no, those are headers

neon leaf
#

cant really find anything else

lyric mountain
#

keep searching

neon leaf
#

do I have to use res.on('data', (d) => { console.log(d) })?

lyric mountain
#

that'll just print the request itself

neon leaf
#

I have now went trough every body word on the page and found out how long my post body is

lyric mountain
#

did u try pressing ctrl + space after typing .?

#

if ur using an IDE* it should show u all the possible attributes

  • text editors aren't ides
neon leaf
#

Ok, lemme cut it down, do I need to use a function? aka cube?

lyric mountain
#

cube?

neon leaf
#

aka method

lyric mountain
#

please dont call methods "cubes"

#

and no, I don't think so

#

read the last part

wheat mesa
#

I have never heard of a method being called a “cube” before 💀

neon leaf
earnest phoenix
#

@neon leaf
https://nodejs.org/docs/latest-v18.x/api/http.html#httprequesturl-options-callback

In a successful request, the following events will be emitted in the following order:
'socket'
'response'
'data' any number of times, on the res object ('data' will not be emitted at all if the response body is empty, for instance, in most redirects)
'end' on the res object
'close'

You need to listen to the data event of the response to get the body of the request, concatenate the data, and finally use it's final value

#

Although you shouldn't really use the built-in node:http (or node:https) to make such requests because it's not easy to work with and are very low-level as mentioned, you should just use an existing high-level HTTP client such as Undici or Node-Fetch

neon leaf
#

but how can I send the data to a user defined function? Because its an Event it can also take 1 sec and not be sent

lyric mountain
earnest phoenix
#

Ah, not sure why exactly the built-in modules are needed instead of dependencies but fine

earnest phoenix
neon leaf
lyric mountain
#

I'm getting worried for american IT students

earnest phoenix
#

That's a very ambiguous request from a teacher, but if it can be pretty simple then I guess that's not too bad

#

Teachers try not to give you the most random or ambiguous shit ever, or place weird constraints challenge

lyric mountain
#

new Promise(stuff)

#

dont remember if js uses diamond notation

neon leaf
lyric mountain
#

on("", e => new Promise(stuff with e))

#

tho aren't events async already?

earnest phoenix
# neon leaf how would I make that a promise?

You can create a promise using the global Promise constructor and then place the event inside of it, it gives you two methods to control the promise's state, resolve to resolve the promise, reject to reject the promise; an example of this would be:

let body = '';

<Response>.on('data', (data) => {
  body += data.toString();
});

await new Promise((resolve) => {
  <Response>.once('end', resolve);
});
#

That promise will resolve only when all the data has been collected, which is when the end event is emitted, so then you can use the body variable in this case, as it holds all the data

neon leaf
#

where would I need to put that? it currently results in infinite loading

quartz kindle
#

in a function

#

you can create a promise using the new Promise() constructor, and a function that returns a promise is the same as an async function

#

so put it in a function and return the promise

#
function bla() {
    return new Promise(...)
}
#

then you can do await bla() elsewhere

#

inside the promise you can process the http response, collect the data and resolve it once the stream ends

earnest phoenix
#

x

hidden gorge
#

does anyone use electron?

wheat mesa
#

don’t ask to ask, just ask

hidden gorge
#

@royal portal

wheat mesa
#

Just so you know, you can’t magically require something from electron and expect it to work

#

There is no such thing as app in electron

#

You have to create a variable called app, I presume you’re looking at an online tutorial that omitted that step

quartz kindle
#

there is actually, according to the docs

#

but using .then there makes no sense

#

the electron official example shows app.whenReady().then(...)

#

not app.on("ready")

wheat mesa
#

Why would they export app tho

#

I remember having to create that a while back when I tried doing electron

#

Ig I forgor

solemn latch
wheat mesa
#

I think I just got confused because I normally don’t see lowercase global vars being exported from libraries and frameworks

hidden gorge
#
const Discord = require("discord.js");
const fs = require('node:fs');
const path = require('node:path');
const { Collection, Events } = require('./config.json');
const client = new Discord.Client({
    ws: {
        properties: {
            $browser: "Discord iOS"
        },
    },
   intents: 32767,
});


client.commands = new Collection();```
ocean jay
earnest phoenix
quartz kindle
#

you're trying to load Collection from a json fille

ocean jay
#

o

#

thanks!

earnest phoenix
#

Also what in the hell are you doing at the first part, looks like something from Yandere Dev

#

The infamous if else chain

hidden gorge
#

oh wait i am

lyric mountain
#

messages = messagefetch

earnest phoenix
#

Yeah, although it seems like they're doing it so it becomes undefined if it's not the levels they've specified

#

It's better for them to just use a switch statement

radiant kraken
#

or an if (... === ... || ... === ... || ...)

earnest phoenix
#

The second one is yikes... Isn't a good idea in this case but yeah the array one would work better

radiant kraken
#

just throw it in prettier

#

bam readable code

earnest phoenix
#

It's not "faster" at all

radiant kraken
#

how

earnest phoenix
#

You're literally doing comparisons, just like the comparisons internally done by %Array.prototype.includes%, not any better

#

A switch statement should be the same performance in this case

radiant kraken
earnest phoenix
#

Well yes because you're working with an object that implements arrays rather than just literals

radiant kraken
#

not blazingly fast 😔

wheat mesa
#

Technically includes is slower even if it’s the same code because you have to advance the stack pointer to a new location 🤓👆

earnest phoenix
#

@radiant kraken @wheat mesa actually did a million iteration benchmark and it seems like the %Array.prototype.includes% approach is faster than the if (... === ... || ... === ...) approach

#

Although my offered approach, the switch statements are the fastest :^)

wheat mesa
#

I feel like v8 purposely makes your code slower just to prove that using the built in api for everything is faster 😉

earnest phoenix
#

Oh no our tricks are exposed! DogKek

wheat mesa
#

Blazingly tricky

#

Where’s my v8 Halloween update with a fake segfault to scare me

earnest phoenix
#

That's the spirit, it's secret so it would be scary

surreal sage
#

this isn't ts or js right?

#

(not my code)

wheat mesa
#

This is… what the fuck

#

It’s SUPPOSED to be javascript, but either it’s a joke or that person genuinely has no idea what they’re doing

surreal sage
#

I def think it's the second

#

Guy said he moved from py

wheat mesa
#

And judging from the fact it seems like a roblox script, I’m going to assume they are 12 years old and trying to become a script kiddie

#

That’s python mixed into javascript for literally no reason and no explanation

surreal sage
#

They wish js-py combos exist I suppose

#

2 very different languages

surreal sage
wheat mesa
#

Highly doubt that an automated bot is not against their tos tbh

surreal sage
#

Well their API docs are wide open, discussions about self bots n api on their own forums

#

Automatic group ranking bots etc

surreal sage
wheat mesa
#

But yeah if it’s just for API stuff it’s probably fine

surreal sage
#

It's getting the group rank of a player

wheat mesa
#

I remember laughing at that shit in middle school

surreal sage
wheat mesa
#

So more like 5 years now

hidden gorge
#

@wheat mesa from the looks of its uses roblox api to get the rank of the user of a group and sends it back to the bot

surreal sage
#

I saw that shit like 2-3 years ago

#

"sends back" is not really a thing but technically yes

hidden gorge
surreal sage
wheat mesa
#

Sends back is correct enough

surreal sage
wheat mesa
#

API request -> response

surreal sage
#

^

#

Ain't a web socket shrug

hidden gorge
#

basically saying

rank = random shit code here

console.log(“shitty api response here”)

surreal sage
#

GET = READ
POST = WRITE
DELETE = DELETE 😒

#

PATCH = Frequently used to overwrite/update shrug

#

Unnecessary info 😃

wheat mesa
#

You make a request, the server sends back a response

surreal sage
surreal sage
#

Which characters besides numbers have the lowest bit value?

wheat mesa
#

Wdym?

#

Like ascii values?

surreal sage
#

I believe so

wheat mesa
#

\0

#

The null terminator char

#

Most commonly used in memory to signify the ending of strings

surreal sage
#

text character*

wheat mesa
#

Then it’s !

surreal sage
#

abcde etc

wheat mesa
#

Ok hold on

surreal sage
#

I'm optimizing a script in a language that does not have memory features like JavaScript

#

Trying to have variable addresses tiny

#

(lua)

#

capital A?

wheat mesa
#

A character is going to take up the same amount of memory no matter what

surreal sage
#

.

#

Skeeter = Better?

#

shorter*

wheat mesa
#

No

surreal sage
#

Double language autocorrect

wheat mesa
#

Most languages either use 1 byte or 2 bytes for characters

#

1 byte supports all standard ASCII values, 2 is used for Unicode

solemn latch
#

I assume js uses two?

#

Or is it smart

wheat mesa
#

Depends on the character I’m sure, v8 might pack the memory if it fits in an ASCII value or something like that

solemn latch
#

I wouldn't be surprised if its dynamic. I wouldn't be surprised if it's not.

wheat mesa
#

Yeah

#

Could go either way

#

Or classic 8 byte string pointer 🧌

earnest phoenix
#

It's actually dynamic, V8 is very aggressive on picking the type appropriate for a JavaScript value

wheat mesa
#

Figured so

surreal sage
#

Eh what I was planning would do little to no change at all

#

Maybe a thousandth of a millisecond

wheat mesa
#

Character value does not change the amount of memory it takes up unless it is a non ascii character

#

In which case it would likely use twice the amount of memory

surreal sage
#

World of programming nooo

wheat mesa
#

It’s not too difficult to think about

#

Characters are represented as numbers

#

Numbers take bits to represent

#

The English alphabet fits all within one byte

#

(Each character, that is)

#

But since there are more than 256 characters in the world, a 2 byte standard called Unicode exists

#

Which can store 65536 unique values (technically more because of encoding or something like that, idk)

#

Tim is gonna come in and blow my mind

quartz kindle
#

the js language spec represents all characters as utf-16, so 2 bytes per char, but js engine implementations do their own thing under the hood to improve efficiency

#

speaking of which, utf-8 is surprisingly petty inefficient memory-wise

#

but i think it was done purposefully to be faster to encode/decode or something

#

there are a lot of wasted bits

#

also fun fact, these are all the different string types in v8

#

as voltrex said, very aggressive

lyric mountain
#

And people say java has long names

quartz kindle
#

🤦

lyric mountain
#

I don't acknowledge that dev

#

Tf is that

quartz kindle
#

that, my friend, is java

lyric mountain
#

No, that's swing

wheat mesa
#

technically part of the jdk!

lyric mountain
#

Swing is a terrible interface api, but it does represent Java

#

They just added it to the jdk bcuz fuck it

wheat mesa
#

swing is honestly.... interesting

#

java deserves better than swing

desert kindle
#

guys

lyric mountain
#

I'm still waiting for a decent gui lib to pop, feels like everyone accepted swing as is

wheat mesa
#

yeah

#

even intellij didn't want to bother fucking with a new gui lib

#

literally built their entire ide in swing

desert kindle
#

I can't quite understand how functions work with Promises in js I just started learning a day ago

wheat mesa
#

A little bit of an advanced topic for a beginner, but basically they're part of the async api built into javascript

lyric mountain
#

Well then don't start from the middle

#

Start from the base basics

wheat mesa
#

Yeah

wheat mesa
#

Promises are a little bit complex

lyric mountain
#

Damn does noone start with a calculator or hello world nowadays?

desert kindle
#

I didn't know they were ok thx

desert kindle
#

bruh what guide should I watch

lyric mountain
#

None

wheat mesa
#

None of them

desert kindle
#

I think this isn't in proper order yeah

wheat mesa
#

Don't get stuck in tutorial hell

desert kindle
lyric mountain
#

Pick a goal, break it into smaller parts and complete until you finish the whole thing

quartz kindle
desert kindle
#

in python yes

#

idk about js

quartz kindle
#

probably the same

#

promises are the same thing as a callback

radiant kraken
#

Dunning Kruger effect moment

quartz kindle
#

promises are like tasks in py afaik

#

or futures, or whatever its called

#

i dont really know py

desert kindle
#

I understood promises

#

But

#

if I don't understand how I can make an async function return a promise in js

quartz kindle
#

two ways

desert kindle
#

Fine, where can I learn them, if it's not too hard for a beginner ig

quartz kindle
#
async function bla() {} // this function automatically returns a promise, because its an async function
function abc() {
  return new Promise(...) // this function explicitly returns a promise
}

// both are equal
await bla()
await abc()
bla().then(...).catch(...)
abc().then(...).catch(...)
lyric mountain
#

Beginners will choose the biggest, badassest looking bucket to carry the most water at once

#

They struggle to carry the full bucket tho, making them trip and fall down the mountain

radiant kraken
#

imagine using a bucket

#

just drink it directly

#

ezpz

desert kindle
#

Why would you need a bucket

#

just use your hands 💀

wheat mesa
#

You’re trying to use the bucket right now

#

Lol

lyric mountain
#

Slow and steady, a code a day keeps the insanity away

desert kindle
radiant kraken
#

*a line of code a day keeps insanity away

lyric mountain
#

Ah yes

quartz kindle
#

then im pretty insane already

desert kindle
#

is there like any website that teaches you java

quartz kindle
#

tons

desert kindle
#

Through application

lyric mountain
#

Lmao buddy, that's a funny beginner mistake

desert kindle
#

and not just reading/watching

lyric mountain
#

Don't call js java

quartz kindle
#

probably

desert kindle
#

javascript

#

js

#

mb

quartz kindle
#

these days you can find everything

lyric mountain
#

I don't recommend tutorials because you get dependant on them

radiant kraken
#

every indian website

quartz kindle
#

js is one of, if not the, most popular language at the moment, so yeah you will likely find tons of practical js guides/courses

lyric mountain
#

All languages are the same, what you need is to know the logic

quartz kindle
#

i never used any, but i heard people recommending codecademy and udemy

desert kindle
radiant kraken
#

Rust

lyric mountain
#

Start breaking it up, "Ok, how will I make the map?"

desert kindle
lyric mountain
#

Well...

quartz kindle
#

js is the same lol

#

if not easier

lyric mountain
#

Python is a snake in macaroni disguise

desert kindle
quartz kindle
#

im pretty sure js is easier than python

radiant kraken
#

indentation moment

lyric mountain
#

It feels easier, but can snowball very easily if u make mistakes frequently

desert kindle
#

do you know python?

lyric mountain
quartz kindle
#

not fluently, but i've seen a lot of things in python that doesnt exist in js

lyric mountain
#

But unless you focus on smaller parts, you get overwhelmed

wheat mesa
#

imo, python is a terribly designed language and should only be used for scripting, not full on projects

lyric mountain
#

I always make a snaker when starting a new lang

desert kindle
radiant kraken
desert kindle
lyric mountain
#

Because it involves async, collections, oop, arrays, keyboard integration and random generators

radiant kraken
#

unless you code using notepad

lyric mountain
#

So u get a soup of concepts in a single project

quartz kindle
#

js doesnt care about indentation

radiant kraken
#

also operator overloading

quartz kindle
#

js sync/async concepts are simpler and straight forward, python has more options for different kind of things

#

python has better threading tho

#

threading in js is pretty limited

desert kindle
#

decorators shouldn't be an issue at all

radiant kraken
#

@earnest phoenix decorators in ECMAScript when

lyric mountain
desert kindle
#

python seems more logical, but if you mess something up at a moment your whole thing is messed up with it

lyric mountain
#

Sleep(millis) freeze the application itself, not the thread

quartz kindle
#

lmao

lyric mountain
#

It's a fuckin global sleep

quartz kindle
#

doesnt python also have a global sleep?

radiant kraken
lyric mountain
#

Who was the psycho that thought that'd be a good idea

desert kindle
lyric mountain
#

I hate delphi, but it pays me so I have to tolerate it

radiant kraken
desert kindle
quartz kindle
#

there is a very clear separation between sync code and async code, when you start going for async code, some things are indeed handled differently

radiant kraken
#
await new Promise(res => setTimeout(res, Number.MAX_SAFE_INTEGER));

bam global sleep

quartz kindle
#

its still an async sleep, so non-blocking :^)

wheat mesa
#

indentation controlling scope is unclear and causes issues that are easily solved with explicitly used curly braces

radiant kraken
#

smh js

quartz kindle
#

also, timeouts dont support max safe integer

#

timeouts are limted to 32bits

lyric mountain
#

Wait

radiant kraken
#

0xFFFFFFFF then

lyric mountain
#

What...what's the size of js "ints"?

radiant kraken
#

8 bytes afaik

desert kindle
# wheat mesa no

well in python, you can write a whole function that can be very long in two lines

quartz kindle
#

everything in js is doubles

radiant kraken
#

they use double

lyric mountain
#

Holy

quartz kindle
lyric mountain
radiant kraken
#

triple datatype when

desert kindle
quartz kindle
#

they will tell you you're either crazy, or your code was minified

lyric mountain
#

I bumped at that thing once, always thought int would go to full Fs

desert kindle
#

why do you guys always put the '}' in a new line

lyric mountain
#

But that'd be for uint

#

YES

radiant kraken
#

unsigned >>> signed

quartz kindle
#

since js was made for the web, minified js is pretty normal

#

but nobody codes in minified js lol

#

they just minify it after its done

radiant kraken
#

I do

lyric mountain
#

I know someone who does

quartz kindle
lyric mountain
#

"single char variables to save space"

quartz kindle
#

lmao

desert kindle
#

How much "js" do you need to know before going into bot developping in js

radiant kraken
#

100% js

lyric mountain
#

Enough to know what ur doing

quartz kindle
#

there are lots of people here who made bots with zero js knowlege lmao

#

they learned along the way

lyric mountain
#

U don't need to go internal, but u need to be familiar with the lang

radiant kraken
#

or even zero programming knowledge

desert kindle
quartz kindle
#

general programming/logic knowlege is more important that knowing the actual language syntax imo

#

because syntax is easy to learn if you know the concept of what you want to do

wheat mesa
#

I think that anybody asking for advice on where to start on js needs to learn the syntax though tbf

radiant kraken
wheat mesa
#

Because I see way too many people in here with "how do I fix this" and it's a basic SyntaxError

wheat mesa
#

or people making command handlers and not understanding how parameters are passed in js

desert kindle
lyric mountain
#

It's true

desert kindle
#

I found out it was

lyric mountain
#

If you learn programming, you automatically can use any language

radiant kraken
lyric mountain
#

But if u learn a language, u get stuck to it

#

Languages are just different flavors of 1s and 0s

desert kindle
quartz kindle
#

but if you learn both, you become a god

#

learn programming and learn a single language in depth

radiant kraken
desert kindle
#

you would just type and find words, click those words and view what they return

radiant kraken
quartz kindle
#

rusty

desert kindle
#

etc until you know the whole damn language

#

Prehistoric way of learning a language

lyric mountain
#

You don't need to memorize the words, that's what google's for

#

U just need to know what you need to do X

#

Then u search for it

desert kindle
#

bruh

desert kindle
quartz kindle
#

software engineers in 2022:
googles how to split a string (because they forgot the syntax)

radiant kraken
desert kindle
#

in python it's quite easy

quartz kindle
#

a method to split a string

radiant kraken
#

it splits

lyric mountain
#

In python it's reversed

#

Oh wait, that's join

#

Iirc

radiant kraken
#

python being stupid as usual

desert kindle
#

bro

radiant kraken
desert kindle
lyric mountain
#

", ".join(arr)

desert kindle
quartz kindle
#

wat

radiant kraken
#

.join !== .split

lyric mountain
#

Ik

quartz kindle
#

you cant join a string

lyric mountain
#

I remember one was inverted

quartz kindle
#

you join an array lol

lyric mountain
#

In python it's the inverse

#

Join is a string method

#

That joins an array

radiant kraken
#

why would they do such a thing

#

it's such a shit way to implement .join

quartz kindle
#

"a.b.c".split(".") = ["a","b","c"].join(".") = "a.b.c"

lyric mountain
#

Did u see how to write a main method already?

radiant kraken
#
if __name__ == "__main__":

sdForgor

lyric mountain
#

That's python without noodle disguise

desert kindle
#

super().innit()

#

oops

desert kindle
quartz kindle
#

so in python you do ".".join(["a","b","c"]) ??

lyric mountain
#

Yes

desert kindle
quartz kindle
#

what the fek

lyric mountain
#

Check the docs if u don't believe lul

quartz kindle
#

what about split? is it ".".split("a.b.c") ?

lyric mountain
#

Split is normal

desert kindle
#

what?

quartz kindle
#

ah

desert kindle
lyric mountain
#

Also iirc, no switch-cases

quartz kindle
#

py doesnt have switch?

lyric mountain
#

Lemme check

quartz kindle
#

isnt switch like, as basic as an if?

lyric mountain
#

Nope, no switch

#

Only elif

quartz kindle
#

even C has switch

lyric mountain
desert kindle
#

they're all defined

#

Exactly

#

functions are very easy to define

wheat mesa
#

yet another reason why python is a terribly thought out language

lyric mountain
#

Java mobile app developer 💀

desert kindle
wheat mesa
#

feels like someone had the "wonderful" idea of making a language entirely controlled by whitespace and then just threw in the rest of the features as an afterthought

lyric mountain
#

Turing complete YAML

quartz kindle
#

lol

wheat mesa
#

even the most basic things like lambdas are terrible syntax

#

lambda x:

#

you have to literally do that

#

so disgusting

#

python is just trying to be unique in areas that it shouldn't

#

that's my opinion

lyric mountain
#

Lambda as in, equivalent to x -> { }?

quartz kindle
#

at least it isnt js thats being hated on this time :^)

wheat mesa
#

Yeah

lyric mountain
#

Lmao

desert kindle
#

Yes

wheat mesa
#

Also they made it too beginner friendly

#

Probably the #1 choice for beginners, which is an awful idea imo

desert kindle
wheat mesa
#

Since it's so much different than every other language out there

lyric mountain
#

Snake disguised as a noodle

quartz kindle
#

but there is something that only PHP has and nobody else

#

die()

#

:^)

lyric mountain
#

Explode()

quartz kindle
#

lmao yes

desert kindle
#

now that I see the difference

#

I just wanna do

desert kindle
lyric mountain
#

Any c-like lang is a good starter

#

Cuz u learn the majority of the syntaxes

desert kindle
#

POV u start with C++

quartz kindle
#

but today thats mostly not the case anymore

#

js engines are stupid fast

#

js still gets some hate for its dynamic type system

#

from people who love static types

#

but now there is also typescript so they dont complain anymore

lyric mountain
#

I mean, js suffers a lot from what java suffers nowadays

#

That is legacy support

#

Both langs had a dark past, but can't forego it cuz backwards compat

desert kindle
#

each language has its own fields of usage

quartz kindle
#

python also has this issue where compatibility completely breaks on every single python version

wheat mesa
#

python also has this issue called speed

desert kindle
#

C# and C++ are mostly used for scripting in making games

lyric mountain
#

Python sacrificed it's ancestors to have a fluent language

quartz kindle
#

lmao

lyric mountain
#

Except it didn't work as expected so now all ancestors are dead and descendants are weirdos

quartz kindle
#

a lot of langs became popular because something big pushed them

#

for example C# started being used by game engines

#

js has always been used in the web

#

these things keep pushing the lang forward

#

the use case made the lang, almost literally

#

actually literally for js

#

python was very popular for writing shell scripts

#

php for servers

#

every single webserver had to have php

wheat mesa
#

python is good for scripting, but people try to make it into an all purpose language that it just isn't

lyric mountain
#

Fun when u learn what php means

quartz kindle
#

poop haha poop

wheat mesa
#

professionally hated programming

desert kindle
#

I wonder how much knowledge you have once you've learned python, javascript, C, C++, C#, LUA, HTML/CSS and json

lyric mountain
#

Html 💀

#

Well, programming is programming regardless of language

quartz kindle
#

i never got into python because i dislike the indentation system

#

never got into lua either because never needed it

lyric mountain
#

U get more proficient in those langs, but your overall programming knowledge improves globally

desert kindle
wheat mesa
#

But I'm by no means an expert

lyric mountain
#

Except if u refuse to improve your technics, that is

quartz kindle
#

json is like dead easy lol, its not even a language, just a storage format

wheat mesa
#

Yeah json is just key:value

desert kindle
quartz kindle
#

well you included it with the others

wheat mesa
#

another language I hate: lua

#

sorry not sorry

quartz kindle
#

you just hate brazil

lyric mountain
#

Me when I tell my gf she's number 1 in my priorities array

quartz kindle
#

racist

desert kindle
lyric mountain
#

Lua devs: ❤️
Other devs: 💀

radiant kraken
desert kindle
#

IdkLua

radiant kraken
#

roblox cringe

lyric mountain
#

Read with my other msg

#

It'll make sense

quartz kindle
#

included as in something important worth learning

wheat mesa
lyric mountain
#

Arrays start at 1 in lua

lyric mountain
#

But 0 in almost any other language

desert kindle
wheat mesa
#

I'll make it 1 in my language

lyric mountain
#

Except delphi, because delphi starts at 0 or 1 depending on context

wheat mesa
#

to fuck with people

lyric mountain
#

Fuck delphi

wheat mesa
#

and I'll just make 0 return null and not an error

#

the benefits of making your own language is that you get to do as much trolling as you wish to

quartz kindle
radiant kraken
desert kindle
wheat mesa
#

yeah

#

"beginner friendly"

desert kindle
#

Bruh what

#

That's so messed up

desert kindle
#

at this point

lyric mountain
#

I used to make mods for starbound, funny when I figured I had to use <= instead of < for indexed loop iterations

quartz kindle
radiant kraken
#

everything is binary moment

#

it's what makes me love C

#

i love pointer arithmetic so much

wheat mesa
#

I'd like C if it had a little bit more informative errors

radiant kraken
wheat mesa
#

It's just a bit too primitive for my tastes

#

I'm lazy

radiant kraken
#

that's called Rust

wheat mesa
#

exactly

quartz kindle
#

i dont like pointers, i like bitwise tho

radiant kraken
#

i like pointers

#

cant live without em

desert kindle
#

gotta sleep my eyes heavy asf rn

#

bye

lyric mountain
#

But can u make a rose in other languages? ++i++--<<0

quartz kindle
#

working with bits is so awesome, you can come up with new data formats and compress the shit out of things

lyric mountain
#

In groovy u can

wheat mesa
#

Friendship ended ❌ with C compiler
Me 🤝 rust compiler

quartz kindle
radiant kraken
#

based

#

ilysm waffle

wheat mesa
#

❤️

quartz kindle
#

im gonna make 2 new libs with some code i made for my serializer lul

wheat mesa
#

it's actually fun yeah

#

coming up with bytecode formats is really fun

lyric mountain
radiant kraken
#

just learned about bit-masking recently and i was like how did i not use this earlier

quartz kindle
#

utf56 string compression and variable length float to binary

lyric mountain
#

Utf what?

wheat mesa
#

it's like creating your own encrypted messages

quartz kindle
#

utf56

radiant kraken
#

i love making my own binary files

quartz kindle
#

actually

#

its utf5/utf6

#

but utf56 for short

radiant kraken
#

it makes me feel that i've created my own language that everyone sees as gibberish

wheat mesa
#

misleading lol

lyric mountain
#

AH OK, I thought it was 56 bits per char

quartz kindle
wheat mesa
#

you could do some serious compression if you created a character format meant exclusively for storing english characters and punctuation and nothing else

quartz kindle
#

thats basically what i do

radiant kraken
#

pov: ASCII

quartz kindle
#

but with a dictionary

wheat mesa
#

Not even ascii

lyric mountain
#

Ain't that windows-something encoding?

wheat mesa
#

less than one byte per char

radiant kraken
#

oh wait

wheat mesa
#

you'd only need what, 4 bits per char? or would it have to be 5

quartz kindle
#

my utf5 is a dictionary-based encoding where the user can set a list of 30 characters they use, and those 30 characters will use 5 bits each

wheat mesa
#

4 bits = 32 combos

#

26 letters

#

damn, wouldn't work

#

you'd need 5 bits

radiant kraken
#

numbers tho

lyric mountain
#

Byte rounding tho

wheat mesa
#

unless you don't have about punctuation

#

and numebrs

#

yeah

radiant kraken
#

what about huffman coding

quartz kindle
#

huffman and rle are more traditional compression things, they run through your bytes and put repeating patterns into a dictionary

wheat mesa
#

I’ve figured it out

#

Change human language to be more compressed

#

The best way of compression for computer scientists, no work needed!

lyric mountain
#

Ain't that jap/chinese?

wheat mesa
#

No lmao

lyric mountain
#

Kanjis takes only 16 bits

wheat mesa
#

They have massive amounts of unique characters though

quartz kindle
#

chinese is the most compressed language

lyric mountain
#

And can represent whole words

radiant kraken
#

morse code

lyric mountain
#

Sometimes even sentences

quartz kindle
#

they have single characters for everything you can think of

radiant kraken
#

ezpz

wheat mesa
#

The sentences are compressed but since they’re character based languages, wouldn’t it end up taking more space in the long run?

lyric mountain
#

Nope

#

Kanjis replace whole words

quartz kindle
#

the number of characters are much lower

lyric mountain
#

Not characters

wheat mesa
#

Although I suppose 2 bytes for a whole sentence as opposed to 1 byte for each character is a massive trade off

radiant kraken
#

how many kanji chars are there

lyric mountain
#

Also their alphabets are syllabaries

#

Like, no A B C, but Ka Ke Ki

wheat mesa
#

I’ve always been curious though since I don’t know how character based languages work, but how do you come up with characters for new words?

lyric mountain
#

So all words are half the size of a regular word

#

Except for A I U E O

#

Which are single characters

radiant kraken
#

also N

lyric mountain
#

Forgot that one

#

There's also the extension character which I don't remember the name

#

Other than that, 1 char per 2 chars

quartz kindle
radiant kraken
#

imagine a chinese keyboard

lyric mountain
#

It's a normal keyboard, but they use autocomplete for everything

#

I had a jap keyboard

radiant kraken
#

i know, but imagine

wheat mesa
lyric mountain
#

2

wheat mesa
#

106k doesn’t fit in 2 bytes

lyric mountain
#

They take 16 bits per char

radiant kraken
lyric mountain
#

They're made of combinations

#

Like emojis basically

wheat mesa
#

Ah

quartz kindle
#

utf16 encodes those characters as surrogate pairs, meaning two 16bit special chars make up one 4byte character

#

utf8 can encode them as 3 or 4 bytes individually

radiant kraken
#

utf8 most based encoding tbh

#

i see why it's everywhere and for a good reason

lyric mountain
#

The only encoding to defeat mysql

quartz kindle
#

utf8 could be much more efficient

#

but for some reason they decided to make it that way

radiant kraken
#

it's already good enough imo

quartz kindle
#

yeah

#

a 4 byte utf8 character can only hold 21 bits

#

11 bits are wasted

radiant kraken
#

utf21 when

#

we have utf32 but not utf21

quartz kindle
#

lmao

lyric mountain
#

Utf64 tho

quartz kindle
#

utf32 is a massive waste of space for almost all use cases

#

unless your language uses 4byte characters exclusively

radiant kraken
#

but it's blazingly fast 🔥 🚀

#

it's like Rust

lyric mountain
#

Btw, another fun thing that happened st my job

quartz kindle
#

well true

radiant kraken
#

who cares if your program is huge, at least it's fast™️

lyric mountain
#

We recently updated firebird to 4

#

Did u know firebird now uses int128 for calculations and timestamps?

#

Now, did u EVER see a language that fuckin supports int128?

radiant kraken
#

Rust

quartz kindle
#

doesnt C and C++ support it?

radiant kraken
#
u128 i128
#

very limited support

lyric mountain
#

C supports everything

radiant kraken
lyric mountain
#

But fckin, wasn't int64 enough?

radiant kraken
#

no

quartz kindle
#

nothing is ever enough for you

radiant kraken
#

can't wait for int4294967296

lyric mountain
#

What even is the max value for int128?

#

U could store the number of atoms in earth

radiant kraken
#

twice that of int64s

quartz kindle
#

2^128 (over 3.40 × 10^38)

radiant kraken
#

actually not just twice

radiant kraken
#

my ints kept overflowing

quartz kindle
#

the range is 0 through 340,​282,​366,​920,​938,​463,​463,​374,​607,​431,​768,​211,​455

radiant kraken
quartz kindle
#

Quadruple precision floats can also represent any position in the observable universe with at least micrometer precision.

radiant kraken
#

but you still get 0.3000000000001 when you try to add 0.1 with 0.2

quartz kindle
#

yes

radiant kraken
#

why can't there be math-accurate floats

quartz kindle
#

but this time

#

its 0.300000000000000000000000000000000000000000001

radiant kraken
#

that's even worse