#development

1 messages · Page 2010 of 1

boreal iron
#

That means straight copy and pasting doesn't work

#

You need to replace database with your database name

ancient nova
#

my database is called database though?

boreal iron
#

If you're running the query already in your database, you can remove it then

slender thistle
#

lmfao

boreal iron
#

The question remains... why in the world

slender thistle
#

True

#

Security!

boreal iron
slender thistle
#

Good luck bruteforcing that, bitch

boreal iron
#

Taking 5 years computing time to hash the password probably

slender thistle
#

😂 Only 5?

boreal iron
ancient nova
#

cause removing just that gives me a syntax error

#

:/

boreal iron
#
CREATE TABLE `users` (`id` INT NOT NULL AUTO_INCREMENT , `name` VARCHAR NOT NULL , `password` VARCHAR NOT NULL , PRIMARY KEY (`id`)) ENGINE = InnoDB; 
#

no begging please, I mean you really need to get into the basics of anything before working with it

ancient nova
#

gives me a syntax error

#

I'm not that dumb

boreal iron
#

which error

ancient nova
slender thistle
#

AUTOINCREMENT, no?

#

Without the underscore

ancient nova
#

without the underscore

boreal iron
ancient nova
#

you can see the error here

boreal iron
#

Use this then

#

You need to specify a length then

#

without database

cinder patio
#

lmao just switch to MongoDB to make the pain go away

ancient nova
#

okay but then where do I specify it's name?

slender thistle
ancient nova
cinder patio
#

You don't need an entire sqlite db to store several passwords and usernames

ancient nova
#

😢

slender thistle
#

Who did

boreal iron
ancient nova
#

Tim and two other people but I forgot their username

#
  var createDatabase = db.prepare(
    "CREATE TABLE `database`.`users` (`id` INT NOT NULL AUTO_INCREMENT , `name` VARCHAR(32) NOT NULL , `password` VARCHAR(64) NOT NULL , PRIMARY KEY (`id`)) ENGINE = InnoDB;"
  );
  
  createDatabase.run({
    username: "test",
    password: "test",
  });

  var getDatabase = db.prepare(
    "SELECT * FROM users WHERE username = ? AND password = ?"
  );

  response.json({ success: true });
boreal iron
#

told you to remove database my gosh

slender thistle
#

🤣

boreal iron
#

CREATE TABLE `users`

wheat mesa
#

use an ORM D:

ancient nova
cinder patio
#

As long as you're going to be storing a few passwords and usernames (I believe this is what you said earlier) a MongoDB Atlas cluster is going to be more than enough. It's lighter, and hosted on the cloud so you can change data in it anytime.

wheat mesa
#

(And easier than an SQL db)

cinder patio
#

Yeah most simple queries in MongoDB are shorter and easier to read, too

wheat mesa
#

For people who aren’t as experienced with SQL at least

ancient nova
#

I really don't wanna change that after wasting 3 hours on making sqldb even work

cinder patio
#

because it's structured like JSON

#

the queries

wheat mesa
#

Gambler’s fallacy

cinder patio
#

the data too

ancient nova
#

at this point I'd rather use RAW json client side cause I'm tired

#

ion wanna do this anymore

wheat mesa
#

like using json as a db...?

boreal iron
wheat mesa
#

Never do that

#

Please

ancient nova
#

this is the only way

wheat mesa
#

It’s not the only way

ancient nova
#

I can't use a DB cause I don't know how to

wheat mesa
#

There have been several suggestions made

cinder patio
#

You can probably get MongoDB working in ~10 minutes

wheat mesa
#

You just seem to not want to do any of them

#

Mongodb is incredibly easy to set up

ancient nova
wheat mesa
#

And their nodejs driver is intuitive

cinder patio
#

nah

wheat mesa
#

It would take you probably 20 mins max

ancient nova
#

promise me that 😦

wheat mesa
#

Promise<{ pending }>

ancient nova
#

okay you primised enough hahah

earnest phoenix
ancient nova
#

let me install that real quick then

cinder patio
ancient nova
#

it is what it is though

cinder patio
#

It's 5 min

#

login with google

#

1 click

#

Ok maybe 3

boreal iron
#

not even sure if the engine is supported by your package

ancient nova
#

the language is all messed up I'd rather take a security risk and use json instead of that

quartz kindle
boreal iron
#

what sort of engine is it then?

quartz kindle
#

sqlite uses its own engine

slender thistle
#

confusing
doesn't have time to learn

boreal iron
#

ah

#

well that's the issue then

#

do you even specify an engine then in the query?

quartz kindle
#

theres no such option in sqlite

#

db.prepare("CREATE TABLE IF NOT EXISTS users (name TEXT PRIMARY KEY, password TEXT NOT NULL)").run()

boreal iron
#

omg text

ancient nova
#

I haven't deleted the package just yet

quartz kindle
#

try it

boreal iron
#

I mean...

quartz kindle
#

but does glich use an ephemeral file system?

#

if it does, then it will randomly delete your database file

boreal iron
#
CREATE TABLE users (
   id INTEGER PRIMARY KEY AUTOINCREMENT,
   name VARCHAR(32) NOT NULL,
   password VARCHAR(64) NOT NULL
);
ancient nova
#

seems to have worked

quartz kindle
#

sqlite doesnt need varchar numbers specified

simple stump
#

How would I check if a string ends with a string with something after it?
Ex.

let str = "Hello! I am char982734662 asdf 34ih23";
let str2 = "i am something with char12345678 idk";
if (str.endsWith("char" + something)) {
  // true
}
if (str2.endsWith("char" + something)) {
  // true
}
ancient nova
#

how can I display it as a json though?

quartz kindle
#

also doesnt need an id autoincrement, it has a hidden rowid column

boreal iron
#

while in his case the name as KEY makes more sense I guess

ancient nova
#

the table I mean

slender thistle
simple stump
# slender thistle I'd reckon you need to know what the something is first

I guess I'm kinda looking for the situation in which I don't which stumps me. Cause if I have:

let str = "something char";

I could just do:

if (str.endsWith("char")) return true;

But I'm looking for the case in which I don't know what anything after that character is. However, I don't want to use includes cause I'm looking for the case that there's something similar to:

https://myurl.com/search=?some+search&key=token

Token could be a random set of characters, but I want to check if the URL ends with some+search

boreal iron
ancient nova
quartz kindle
boreal iron
#

without specifing probably based on the rowid ASC by default

quartz kindle
#

you need to use something like includes or indexOf

simple stump
#

okay. thank you!

quartz kindle
#

that detects strings in the middle of another string

boreal iron
#

without specifing probably based on the rowid ASC by default

ancient nova
#

list everything to a json

quartz kindle
#

db.prepare("SELECT * FROM users").all()

ancient nova
#
  createDatabase.run({
    username: "test",
    password: "test",
  });

result
{
username: "test",
password: "test",
}

boreal iron
#

you get your result, then do with it what kind of stuff you need to do

ancient nova
#

TypeError: Expected first argument to be a string

quartz kindle
#

what is createDatabase?

ancient nova
#

from reading the docs I thought that's how you add to the database?

quartz kindle
#

thats only for creating the table, you dont use that for anything else afterwards

lyric mountain
ancient nova
#

oh

lyric mountain
#

encoding: whatever works

boreal iron
ancient nova
#

then how do I add to the database?

boreal iron
#

by inserting

quartz kindle
#

db.prepare("INSERT INTO users (name, password) VALUES (?, ?)").run("username", "password")

ancient nova
#

think I may finally be getting the hang of it

boreal iron
#

why is it confusing? you need to make a request to your database anytime you wanna do something

lyric mountain
#

INSERT INTO users (name, password) VALUES (?, ?) this is the actual sql

#

it'll do exactly what you read

boreal iron
#

insert -> query database to insert my values
select -> query database to select my search
delete -> query database to delete some rows

#

etc.

lyric mountain
#

it'll insert into users (in columns name and password) the values ? and ?

ancient nova
lyric mountain
#

it's structured in english

ancient nova
#

and I get the errors which I don't even know the cause of TypeError: Expected first argument to be a string

#

like is it not a string?

#

I just added into it

lyric mountain
#

what did u put?

boreal iron
#

You first argument is an object

#

Not a string

#

See the correct verison

lyric mountain
#

sql isn't like mongo where you pass objects left and right

boreal iron
#

So the error message is totally accurate

lyric mountain
#

it works in text

#

you need to tell your database what to do

lyric mountain
#

as you'd if you had a human secretary of some sort

ancient nova
#

RangeError [ERR_HTTP_INVALID_STATUS_CODE]: Invalid status code: { success: true }

#

getting a different kind of error now though

lyric mountain
#

like imagine you come to your secretary and say {username: "test", password: "test"}

#

they'd call the police

boreal iron
#

that error has nothing to do with sql

ancient nova
boreal iron
#

only thing you can actually blame sql for are the error messages

ancient nova
#

DELETE FROM users (name, password) VALUES (?, ?)

#

why does this give me a syntax error....

lyric mountain
#

no values

ancient nova
#

I do

lyric mountain
#

think about it, it makes no sense

boreal iron
#

DELETE FROM users WHERE name = ?

ancient nova
#

var removeDatabase = db.prepare("DELETE FROM users (name, password) VALUES (?, ?)");
removeDatabase.run(
"username",
"password"
);

lyric mountain
#

think about how it'd sound if you were talking to your database

boreal iron
ancient nova
#

WHAT I WROTE SOUNDED... OKAY?

ancient nova
lyric mountain
#

"Hey, could you please delete from users name and password values ? and ?"

boreal iron
#

it deletes the row which has a name column mathcing your string

#

*matching

lyric mountain
#

against "Hey, could you please delete from users where name is ? and password is ?"

#

first one sounds like someone during a stroke

boreal iron
#

kuuhualwagabanke stop dude, laughing my ass off

lyric mountain
boreal iron
#

should have expected this

lyric mountain
ancient nova
#

var getCertainUserFromDatabase = db.prepare("SELECT * FROM users WHERE name = ?").run(username);

#

okay I hope this works

#

it didn't give me an error but instead of showing me the password it gave me this {"changes":0,"lastInsertRowid":0}

#

...

lament rock
#

synchronous file i/o MiyanoDisgust

west moth
#

I wonder where the lightning bot is voting

lyric mountain
#

since you're not updating/deleting/inserting, only retrieving data

lament rock
#

prepared statements

#

always use prepared

#

unless you're writing 100% of the sql

ancient nova
lyric mountain
#

or something like that

#

press ctrl + space to see available functions

lament rock
#

Discord could troll a lot of bot devs by changing the ID field to "DROP TABLE users;"

quartz kindle
#

when using a js library to a database system, you need to know what is what

#

1 thing is the library interface/api

#

the other thing is the database interface/api

#

better-sqlite3 itself has the following api:
database.prepare(SQLITE API HERE).get/run/all

#

.get() gets one value from que query
.all() gets all values from the query
.run() runs the query without returning any value

#

use .run() for anything that does not return a value, like inserting and deleting

#

use .get() for anything that returns a single value, like select WHERE

#

use .all() for anything that returns multiple values

ancient nova
#

I assume you'd do .get()

#

but all it returns is
{"busy":false,"reader":true,"readonly":true,"source":"SELECT * FROM users WHERE name = ?","database":{"name":"database.db","open":true,"inTransaction":false,"readonly":false,"memory":false}}

#

instead of the actual json

#

which is extremely confusing

quartz kindle
#

everything inside prepare(...) is not better-sqlite3, its the sqlite3 database api

ancient nova
#
  getCertainUserFromDatabase.get(username);```
quartz kindle
#

everything outside .prepare(...) is not sqlite3, its specific for the better-sqlite3 library interface

ancient nova
#

maybe something is wrong but I don't think I can debug it

lament rock
#

what are you logging

#

the result of get or getCertainUserFromDatabase

quartz kindle
lyric mountain
#

also var

ancient nova
#

I want to get the json from where name = the username variable

#

what exactly am I doing wrong then?

ancient nova
lament rock
#

log the result of get() instead of the prepare(…)

quartz kindle
#

you need to log the .get()

#

not the .prepare()

ancient nova
#
  var getCertainUserFromDatabase = db.prepare("SELECT * FROM users WHERE name = ?");
  response.json(getCertainUserFromDatabase.get(username));
``` like this? I'm confusing what do you mean by log?
lament rock
#

console.log

ancient nova
#

oh that worked

#

cool

lament rock
#

also, what is response.json

#

is this an api?

near stratus
lament rock
#

fun

ancient nova
#
  var getCertainUserFromDatabase = db.prepare("SELECT * FROM users WHERE name = ?")
  let databaseResponse = JSON.parse(getCertainUserFromDatabase.get(username));
  response.json(databaseResponse.password);
ancient nova
#

nevermind I don't need to parse it

#

but it finally worked

#

now to actually integrate the api into my app is gonna be a pain

quartz kindle
#

you dont need json parse

#

better-sqlite3 always returns objects

ancient nova
#

why can't I get the password now?

quartz kindle
#

password: databaseResponse.password

ancient nova
#

thanks

near stratus
#

"translate" ?? MegaThonk Thonk

quartz kindle
#

pseudocode to js i assume

near stratus
quartz kindle
#

someone come here and kill my internet

lament rock
#

compile your js to bytecode

quartz kindle
lament rock
#

god damn

boreal iron
#

haha Tim

#

suffer the consequences of moving to your current location, Sir

#

you really need Star Link I guess

quartz kindle
#

do you have any idea how fucking expensive starlink is?

#

lmfao

boreal iron
#

ik

#

then release your payed api !!!

quartz kindle
boreal iron
#

dunno about portuguese dollars

quartz kindle
#

thats basically

#

100 usd per month

#

500 usd for equipment

boreal iron
#

yeah so... world wide the same price

near stratus
boreal iron
#

lol you can setup it your own

lament rock
#

Wish I could get paid 2500 to screw in some nuts and bolts

quartz kindle
#

can we build our own antenna + dish and hack into the starlink signal?

#

like they do in the movies

#

lmao

boreal iron
#

lol

lament rock
#

probably got some weird key system tied to subscriptions to decrypt the signal

boreal iron
#

I swear Tim's using his poorness as excuse for anything

civic scroll
#

[SayuriPseudocode2JSComplERR] Not enough context data given.

ancient nova
#

@boreal iron how does this look?

cinder patio
#

That won't work

ancient nova
#

how come?

cinder patio
#

The code inside the req callback will be executed after the rest of the code

#

so getResponseFromAPI will be undefined

ancient nova
#

that means I have to resolve it?

cinder patio
#

outside of that function

ancient nova
cinder patio
#

Put all the code inside the callback or use promises

#

you don't

#

I can clearly see the rest of the code using the variable

civic scroll
#

so the if hits first

near stratus
# civic scroll `[SayuriPseudocode2JSComplERR] Not enough context data given.`
import { Pseudo } from "sayuri"

Pseudo.eval(`
define async function onMessage(message: DiscordMessage)
    get message.Mentions.Roles.First -> roleId
    await call discordFetch(guildId) -> data
    data.users filter (roles in user has roleId) foreach user:
        call sendMessage(user.name)

when command.IsUsed -> call oneMessage(...params)
`)
civic scroll
#

solution: use Promise resolve

civic scroll
cinder patio
#

no

civic scroll
cinder patio
#

What does req return

ancient nova
#

the json file this returns

civic scroll
#

@ancient nova wrap this thing inside an async function

cinder patio
#

No but does it return a Promise or no

#

Sayuri you're not helping

civic scroll
#

so it returns void

ancient nova
ancient nova
deft orchid
#

yes

cinder patio
# civic scroll callback-based

how do u know req doesn't return a promise... many APIs return a promise if a callabck isn't provided, and if a callback is returned they don't return anything but run the callback

civic scroll
cinder patio
civic scroll
#

^

cinder patio
#

Exactly you gotta ask more questions

#

you're just making them more confused

ancient nova
#

req is the request npm

civic scroll
#

request?

ancient nova
#

yep

cinder patio
#

that's deprecated use something else

#

using deprecated HTTP libs opens u up to vulnerabilities

civic scroll
#

just https.get

cinder patio
#

plus AFAIK request doesn't have a promise API which is just unacceptable in this day and age

civic scroll
#

or use undici

#

axios also has promise api iirc

ancient nova
#

although I still prefer request

cinder patio
#

then use node-fetch

#

request is outdated

ancient nova
#

I'm more accustomed to it

civic scroll
#

i use http

cinder patio
#

the difference is minimal

civic scroll
#

or https

#

i work more in low-level stuffs

ancient nova
civic scroll
#

but all those are callback-based

cinder patio
#

Then you gotta suffer the consequences

#

you lazy

civic scroll
#

so alright, you wanna wrap those in a function

#

async

#

for the callback specifically

ancient nova
#

Failed: FATAL ERROR HAD OCCURRED
Reason: TypeError: Cannot read properties of null (reading 'success')

#

looks like it can't get the json file from the website

ancient nova
#

why though

ancient nova
#

my entire thing is asynchronous

cinder patio
#

You have to understand that software always evolves and if you aren't bothered to rewrite sections of your code, then it'll become unmaintainable in the near future

#

That doesn't matter when you're using callbacks

civic scroll
cinder patio
#

you have to put the ENTIRE code after the callback inside the callback

civic scroll
#

no need

cinder patio
#

yes need.

#

Unless you promisify the function which is probably the best thing they can do

ancient nova
#
            req(`https://transparent-speckle-door.glitch.me/checkPassword?username=${Username}`).then(r => {
                getResponseFromAPI = r.body;
            });
``` how about this?
cinder patio
#

but why not use node-fetch at that point

civic scroll
#
async function request(params)
{
    return new Promise((resolve, reject) =>
        req(..., (res, err) => {
           if (err) reject(err);
           resolve(res);
       });
}
cinder patio
#

Yes so why not use node-fetch then

#

they'll still have to change all the code

ancient nova
#

typing req is muscle memory at this point

civic scroll
#

then in async funtion

...
const dat = await request(...);
if(...)
...
ancient nova
civic scroll
earnest phoenix
quartz kindle
#

@_@

civic scroll
ancient nova
civic scroll
#

no

quartz kindle
#

dafuq is a constant function

civic scroll
#

fuck your arrow functions

cinder patio
ancient nova
#

:<

quartz kindle
#

you mean a function expression? like const req = function () {}? it doesnt really matter lol

cinder patio
#

If it did you wouldn't have this problem

civic scroll
civic scroll
#

WHAT

#

then do it???

#

man i'm losing steam

#

also for the love of god, learn how the javascript event loop works

#

thank you

slender thistle
#

lmao Sayuri is losing his shit

ancient nova
# civic scroll then do it???
            const request = async (params) => new Promise((resolve, reject) => req(..., (res, err) => {
                if (err)
                    reject(err);
                resolve(res);
            }))
civic scroll
#

remove the async

#

reduntdant

ancient nova
#
           const request = (params) => new Promise((resolve, reject) => req(..., (res, err) => {
                if (err)
                    reject(err);
                resolve(res);
            }))
``` better?
civic scroll
#

right

#

wew

ancient nova
#

lol sorry for the madness caused

civic scroll
#

then in the other async function, you await this function call

#

be sure to use try catch

boreal iron
civic scroll
#

else it would throw an exception

#

@ancient nova remember
synchronus code gets executed first
then callbacks
then resolved promises

cinder patio
#

man just use node-fetch lmao

ancient nova
#

request4life

civic scroll
cinder patio
#

not really... it's not certain when a callback is going to be executed, depends on the method

#

javascript doesn't decide how fast the request is going to be made

civic scroll
# ancient nova NO

then you better back your data up before your computer gets hacked by chance

#

vurneralbility is never good

ancient nova
civic scroll
cinder patio
#

it's not maintained

ancient nova
#

also I just noticed the syntax isn't right on this

civic scroll
#

you run the bot on your pc

ancient nova
#

const request = (params) => new Promise((resolve, reject) => req(..., (res, err) => {
^ returns a synatx error
if (err)
reject(err);
resolve(res);
}))

civic scroll
#

replace the ... with something else

#

duh

ancient nova
#

oh

#

jesus christ my brain is melted at this point

cinder patio
#

take a break

civic scroll
#

@ancient nova a cleaner way
(res, err) => err ? reject(err) : resolve(res)

civic scroll
#

take 5 minutes, go get a glass of water

cinder patio
#

You've been talking here for 3+ hours

#

constantly

boreal iron
civic scroll
boreal iron
#

that's what she usually does

ancient nova
#

god save me

cinder patio
#

Probs from request?

#

What sends an error like this

#

Oh it's probably ur own custom thing

#

is it?

ancient nova
#

it's just a custom error handler but it mostly returns original errors

civic scroll
#

I TOLD YOU TO USE TRY CATCH DIDN'T I

quartz kindle
#

@_@²

civic scroll
#

sorry

#

capslock was on

ancient nova
#

why does it matter ?

cinder patio
#

😭 ur code is definitely spaghetti I can smell it from here

ancient nova
#

it shouldn't do that + try catch looks ugly

civic scroll
#

"why does exception handling matter", you asked

ancient nova
cinder patio
civic scroll
ancient nova
#
/** DEPENDENCIES */
const express = require("express");
const app = express();

/** DEFAULT */
app.use(express.static("public"));
app.get("/", function (request, response) {
  response.sendFile(__dirname + "/views/index.html");
});

/** IMPORT DATABASE */
//const db = require('better-sqlite3')('database.db'/*, options*/);
const Database = require("better-sqlite3");
const db = new Database("database.db", { verbose: console.log });

/** GET PASSWORD */
app.get("/checkPassword", function (request, response) {
  response.setHeader("Content-Type", "application/json");

  if (!request.query.username)
    return response.send(`Query "username" cannot be empty.`);
  //if (!request.query.password)
  //  return response.send(`Query "password" cannot be empty.`);

  const username = request.query.username;
  //const password = request.query.password;

  //var createDatabase = db.prepare("CREATE TABLE IF NOT EXISTS users (name TEXT NOT NULL, pass TEXT NOT NULL)")
  //createDatabase.run();

  //var insertDatabase = db.prepare("INSERT INTO users (name, password) VALUES (?, ?)");
  //insertDatabase.run(
  //  "Zero",
  //  "Root"
  //);
  
  /*var removeDatabase = db.prepare("DELETE FROM users WHERE name = ?");
  removeDatabase.run(
    "username"
  );*/

  //var getDatabase = db.prepare("SELECT * FROM users")
  //getDatabase.all();
  
  var getCertainUserFromDatabase = db.prepare("SELECT * FROM users WHERE name = ?")
  let databaseResponse = getCertainUserFromDatabase.get(username);
  
  if (!databaseResponse) response.json({success:false})
  response.json({success:true,password: databaseResponse.password });
});

/** PORT APP */
const listener = app.listen(process.env.PORT, function () {
  console.log("Your app is listening on port " + listener.address().port);
});
``` here's the API for exmple
cinder patio
#

You can use .catch

ancient nova
#

looks sorted

civic scroll
#

if you don't catch the error, how can you notify the user?

ancient nova
ancient nova
cinder patio
#

Template literals strings without any templates inside them too

civic scroll
quartz kindle
cinder patio
#

this looks ok but

#

That's like 70 lines

civic scroll
#

use let instead

cinder patio
#

In the grand scheme of things it probably looks a lot worse

civic scroll
#

yes

#

i would agree

ancient nova
#

nope

#

it looks nice and sorted -_-

#

i'll insist on it because it does

civic scroll
#

you don't want unhandled stuffs hanging around

#

not funny

ancient nova
cinder patio
#

It might look good but that doesn't mean it doesn't have messy logic

#

and potentially wrong

civic scroll
earnest crane
#

PUTOS PUTOS PUTOS

cinder patio
#

Like using request with a wrapper function to handle promises, instead of just using node-fetch... Still looks pretty, but it's wrong

wheat mesa
#

Handling all unhandled promise rejections can be useful when you don’t want the program to crash, but in reality you should be catching promises that have a chance to fail in the first place

civic scroll
#

^

cinder patio
#

Also you can use .catch instead of try/catch

#

you don't have to use try/catch

wheat mesa
#

(On promises only)

civic scroll
#

i don't want stinky callbacks

#

also how do i throttle async requests

#

seems like they are all executed almost simultaneously

quartz kindle
#

you want to execute them sequentially instead of concurrently?

cinder patio
#

What's the point of using promises then 🤔

quartz kindle
#

use a queue with await

ancient nova
#

            let getResponseFromAPI;
            try {
                getResponseFromAPI = await resolveRequest(`https://transparent-speckle-door.glitch.me/checkPassword?username=${Username}`);
            } catch (e) {
                getResponseFromAPI = null
            }

            if (getResponseFromAPI != null ? getResponseFromAPI.success == true && getResponseFromAPI.Password != undefined ? Password == getResponseFromAPI.Password : false : _password == "Zero" && _username == "Zero") {
             }
``` but I'll just leave it at that, if there's an error, name it null and go back to the hardcoded password lmfao
civic scroll
#

apparently executing 120+ calls at the same times

ancient nova
#

I know I just wasted few hours of my life here and I want to cry

civic scroll
#

!= undefined

#

i want to die

ancient nova
sage bobcat
#

One message removed from a suspended account.

cinder patio
#

Also all those == comparisons ew

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

ancient nova
quartz kindle
#
const getResponseFromAPI = await resolveRequest(`https://transparent-speckle-door.glitch.me/checkPassword?username=${Username}`).catch(() => null);
if(getResponseFromAPI && getResponseFromAPI.success) {
  const password = getResponseFromAPI.Password;
}
cinder patio
#

(...or MongoDB but you're stubborn as hell)

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

slender thistle
#

Our friend is stubborn on using (note: not learning) SQLite

civic scroll
#

== comparisions are unsafe given unknown types

civic scroll
#

not yet

sage bobcat
#

One message removed from a suspended account.

ancient nova
#

:<

quartz kindle
#

sqlite is bae

slender thistle
#

I love Postgre honestly

ancient nova
#

@quartz kindle suggested sqlite3 and people agreed

#

I spend like an hour JUST trying to get that thing installed

civic scroll
#

haha

#

funni

#

for my case they are raw JSON data

#

so

old cliff
#

is there a way to partially bind a function in js?
for example I only want to bind the last argument of a function

sage bobcat
#

One message removed from a suspended account.

civic scroll
#

well, absolute path xml requests let's go

sudden geyser
#

Your databases bore me socialcredittroll

cinder patio
#
const bound = (...args) => something(...args, last);
civic scroll
#

yeah

#

that

quartz kindle
#

el em ef ay ow

sudden geyser
#

Actually I think bind only does the front

cinder patio
#

hmm seems like if you pass null to bind you can skip over arguments

old cliff
ancient nova
#

if you don't believe me try yourself

old cliff
#

ill try doing something else

sudden geyser
#

But what you're talking about is known as currying

quartz kindle
#

i like curry

cinder patio
sudden geyser
#

omg same

cinder patio
#

and pass the new function instead

old cliff
cinder patio
#

I'm not sure what's going on in that pic to be fair

#

10 is not the answer I expected

sage bobcat
#

One message removed from a suspended account.

ancient nova
#

well it did for me

cinder patio
#

It all depends on how fast ur PC is

#

oh glitch

#

yeah that explains it

quartz kindle
cinder patio
#

bruh

#

so null + 10 is 10??

quartz kindle
cinder patio
#

And people are complaining about other stuff... this is the true issue with JS

#

null

old cliff
#

@radiant kraken kek

quartz kindle
#

kek

radiant kraken
#

im tired of it

#

yes yes my name is null aka the js keyword i get it

cinder patio
#

yeah so you can't skip over parameters

#

I read the docs wrong

old cliff
cinder patio
#

Use the code I sent u then

old cliff
#

already implemented something else

#

but thanks

cinder patio
#

🤔 What other solution is there to this

ancient nova
#

this can't be the fault of request

#

it works with other APIs just not mine

civic scroll
civic scroll
#

check in Promise callback

ancient nova
#

how come???

civic scroll
#

positional params wrong?

ancient nova
civic scroll
#

both err and res are undefined?

ancient nova
#

just used the function you gave me, but modified to a constant function

const resolveRequest = (params) => new Promise((resolve, reject) => req(params, (res, err) => {
    if (err) reject(err);
    resolve(res);
}))

then used the thing Tim wrote to assign the json to a variable

const getResponseFromAPI = await resolveRequest(`https://transparent-speckle-door.glitch.me/checkPassword?username=${Username}`).catch(() => null);
#
if (getResponseFromAPI && getResponseFromAPI.success && Password === getResponseFromAPI.password) {}
``` also this to do the first primary check
civic scroll
#

Username is an object?

ancient nova
#

it's a variable

civic scroll
#

i mean the data type of it

#

is it a string

ancient nova
#

it's a string

#

CLI readline varable = _username which gets appended to Username = _username;

civic scroll
ancient nova
civic scroll
#

log them then

#

i thought you already did

ancient nova
#

give a sec

civic scroll
#

possibly it went to the catch block

ancient nova
#

both return undefined @civic scroll

civic scroll
#

also you just defined a varible

#

so ofc it returned undefined

quartz kindle
#

youre logging resolve, not res

#

@_@

ancient nova
#

...sorry

pine nova
#

💀

civic scroll
#

no

#

i'm dumb

#

didn't read the code

stone bloom
#

Hello!

civic scroll
#

that's why tim is my one and only code linter / quality checker 🤝

civic scroll
quartz kindle
#

downgraded to a linter

#

x_X

civic scroll
ancient nova
#

logging variable itself returned null

stone bloom
#

I literally just walked in

civic scroll
#

null

#

then an error must has happened

quartz kindle
ancient nova
civic scroll
#

@ancient nova
.catch(console.log)

ancient nova
#

give me second

latent jay
#

When is downtime done???

civic scroll
latent jay
#

Sorry

quartz kindle
ancient nova
#

so large it didn't even fit on my CLI

lyric mountain
#

console

civic scroll
# ancient nova

looks like you didn't explicitly request it to be application/json mime type

#

so it sent you html

civic scroll
ancient nova
civic scroll
#

yes

#

wait

#

what api are you using

cinder patio
civic scroll
#

request?

ancient nova
#
{
  url : https://transparent-speckle-door.glitch.me/checkPassword?username=${Username},
  method :"GET",
  headers : {
    "content-type": "application/json",
  },
  json: true
}
#

like this?

civic scroll
#

no

ancient nova
civic scroll
#

oh

#

so

cinder patio
#

Looks right

ancient nova
#

alright so should I try it?

civic scroll
cinder patio
#

yes

#

You have json: true so why doesn't request set that header automatically

civic scroll
#

i dorgor

cinder patio
#

ya know unless it completely ignores that and you made it up

ancient nova
#

I didn't have any of those options before

civic scroll
#

check its overloads

ancient nova
civic scroll
#

check in your IDE by hitting Ctrl Shift Space while thr cursor is in function's parenthesis

bronze fractal
#

Why can't I vote bot ya ka

civic scroll
ancient nova
#

also

civic scroll
#
  1. not reading pins issue
ancient nova
#

used the options still didn't give me json

civic scroll
#

stop using var please

ancient nova
#

why...

#

actually nvm you told me

civic scroll
#

let is also 3 characters

ancient nova
#

it never gave me a issue

lyric mountain
civic scroll
#

name collisions

#

wasted memory

ancient nova
#

okay okay I changed it to let

civic scroll
#

or even worse, mem leaks

ancient nova
#

don't have to list everything

ancient nova
#

but

#

let's fix the api

civic scroll
#

but "var is sexier"

#

💀

lyric mountain
#

most IDEs don't really allow u to even write var without throwing a ton of warning at u

ancient nova
#

I have never in my life said or even thought that lmao

civic scroll
ancient nova
lyric mountain
neat ingot
ancient nova
#

really now

#

okay let me try

neat ingot
#

which icon is better?

ancient nova
#

2nd

lyric mountain
#

neither

neat ingot
#

rip lol

lyric mountain
#

tf is that texture?

civic scroll
#

also i dropped request 2 years ago

civic scroll
ancient nova
lyric mountain
#

feels like you threw those icons on a federal highway at monday

ancient nova
#

I can try node fetch ig...

lyric mountain
#

then picked them up after an entire 40°C summer

civic scroll
ancient nova
#

okay

neat ingot
lyric mountain
#

KEKW please do it

neat ingot
lyric mountain
#

what is the first supposed to be btw?

neat ingot
#

a D

lyric mountain
#

oh is that ur rpc thing?

neat ingot
#

lol yea

lyric mountain
#

2nd def

neat ingot
#

but it looks trash in the app as the activity icon 😢

cinder patio
#

2nd better

lyric mountain
#

I'd change the background color for the icon to #1F1B24

cinder patio
#

I'd also remove the border on those inputs, or at least make it lighter

neat ingot
civic scroll
cinder patio
#

still, looks kinda weird when they're this dark

civic scroll
#

you should look at the error

ancient nova
#

it either returns null or sends the entire body instead of the json

neat ingot
cinder patio
#

EEh I'd remove the preview border

civic scroll
#

@ancient nova

cinder patio
#

make the box more rounded

#

like discord

civic scroll
#

but i used node-fetch

cinder patio
#

since that's what you're mirroring

lyric mountain
civic scroll
cinder patio
#

and give it a box shadow

ancient nova
civic scroll
neat ingot
#

it has a box shadow, at the bottom, but yea, it could be a little more rounded

ancient nova
civic scroll
#

use latest then

#

then you handle in the then callback so you just gonna await the request

ancient nova
civic scroll
#

what

ancient nova
#

... I already had nodefetch installed, plus I also had it defined and never used it in the script

#

PPLEASE

#

KILL ME

cinder patio
#

"clean code"

civic scroll
#

funni

quartz kindle
#

🔫

lyric mountain
#

average js coder

cinder patio
#

"unused variables"

civic scroll
#

take a look at that

#

though i can optimise it, it's the code from more than a year ago KEKW

civic scroll
#

yeah

#

back when idk how event loop works

#

fine days

cinder patio
#

u don't really need to know how it works in order to use promises

quartz kindle
#

but did you ever do eval(fs.readFileSync()) instead of require? :^)

ancient nova
civic scroll
ancient nova
civic scroll
ancient nova
quartz kindle
civic scroll
#

man you call in terminal

ancient nova
civic scroll
#

i did in discord

#

but now they remove message intent

ancient nova
civic scroll
#

planned to do a terminal REPL eval

proper spindle
#

When it will come back

civic scroll
#

then halted

ancient nova
#
            let getResponseFromAPI = await fetch(`https://transparent-speckle-door.glitch.me/checkPassword?username=${Username}`).then(async out => {
                getResponseFromAPI = await out.json();
            })
``` is this legal to do?
civic scroll
proper spindle
#

Sorry

neat ingot
#

I made the border radius closer to discord, but i think im gonna add the border back around the preview. doesnt look right to me without it lol

ancient nova
#

nice

#

let's hope it'll work

civic scroll
#

but

#

no need for that

#

you can

ancient nova
#
const fetch = require('node-fetch');
              ^

Error [ERR_REQUIRE_ESM]: require() of ES Module
``` wat
civic scroll
#
const res = await fetch(...).then(data => data.json());
cinder patio
civic scroll
ancient nova
civic scroll
#

man

#

i use typescript

civic scroll
ancient nova
#

I had an older version installed

#

before lol

civic scroll
#

Oct 2020

ancient nova
#

give me a second

#

I made a backup I can restore to see which version I used

#

used version v2.6.1

#

this one seems to work with require ig

#

I wonder why the newest one doesn't

#

the dilema, can you at least you import with require?

lyric mountain
ancient nova
#

it still doens't work even after downgrading how come

civic scroll
#

2.6.1

#

commonJS module

civic scroll
ancient nova
#

can you use both require and import in one script ?

#

if so I can just change node fetch to import

lyric mountain
#

require is just a method as any other

cinder patio
#

just switch to typescript

#

ez

ancient nova
cinder patio
#

time for a rewrite

ancient nova
#

meaning?

#

no error but still doesn't work

cinder patio
#

there's no require in ESM modules

neat ingot
cinder patio
#

ESM modules get imported asynchronously so they cannot work with require

ancient nova
cinder patio
#

yes

#

you can't

ancient nova
#

require(someotherscript)
import 'this' from some otehr

ancient nova
civic scroll
ancient nova
#

lmao

civic scroll
#

just

#

use typescript

#

:D

slender thistle
cinder patio
#

Use typescript and you'll have both :p

neat ingot
#

@lyric mountain I do think i like this bg color for the icon better

cinder patio
#

most likely yeah

#

but I don't know how you'd access it

slender thistle
#

As in, can I do those imports in my functions that get called often? Or is there another way?

ancient nova
#

I've been here since like 11:00 I don't wanna spend another 4 hours rewriting everything to typescript

#

just please tell me why node-fetch doesn't even work

neat ingot
#

typescript scares me 😭

cinder patio
ancient nova
#

guys can you jsut try

#

requesting json

neat ingot
#

true, root

ancient nova
#

and tell me what works

neat ingot
cinder patio
#

but yeah they are most likely cached

ancient nova
#

HOW?

#

HOW

#

HOW

neat ingot
#

LOL

ancient nova
#

please bro

#

tell me

#

I've been here for so long

#

:<

neat ingot
#

i started writing my bot in 2019...

ancient nova
#

tell me

#

please

neat ingot
#

lmao

ancient nova
#

there's subtle differences

civic scroll
#

check if type in your package.json is module

cinder patio
#

You started working on your bot in 2018 and still don't know some basic concepts of the language you're programming in 😭

ancient nova
ancient nova
#

js isn't the only one

neat ingot
#

wait what?

quartz kindle
#

lmao

civic scroll
#

jack of all trades, master of none

wheat mesa
#

Started mine in august 2020

ancient nova
#

well it's better to know many than master one

wheat mesa
#

Not really

civic scroll
#

started in aug 2020

neat ingot
#

color me curious... what other languages do you know?

ancient nova
#

can you build a game in javascript, no

neat ingot
#

yes

wheat mesa
#

Yes

neat ingot
#

i have an entire game engine

wheat mesa
#

You can

ancient nova
#

a bad game

neat ingot
#

no

ancient nova
#

can't do much in js

civic scroll
wheat mesa
#

???

neat ingot
#

its actually really nice lol

ancient nova
#

;-;

cinder patio
#

People can learn a lot in a month... it all depends on the person

wheat mesa
#

That is the most upside down logic I’ve ever heard

civic scroll
#

funni

ancient nova
#

can you make a 3D game with raytracing and support for every platform in JS?

wheat mesa
#

I’d say it’s infinitely more useful to master one or two languages than know a little bit of 20

ancient nova
#

no

cinder patio
#

probably

neat ingot
#

i literally only use js now cause it can do almost everything 😄

ancient nova
#

you cannot

wheat mesa
#

Yes you can lol

cinder patio
#

You can on the browser

neat ingot
#

there are 3d libs for js yes

civic scroll
#

Unity compiled to WebAssembly

neat ingot
#

quite a few

ancient nova
#

okay but you can't make an application

wheat mesa
#

Yes you can

ancient nova
#

2014

quartz kindle
#

browser supports webgl

neat ingot
#

i literall am ~ in node electron

wheat mesa
#

Electron

ancient nova
#

it switched to c#

wheat mesa
#

Lmfao

cinder patio
#

electron

civic scroll
wheat mesa
#

React native

civic scroll
#

funni

ancient nova
#

ok ok I give up

civic scroll
#

also fun fact

wheat mesa
#

Discord is made in either electron or react native I believe

cinder patio
#

electron

civic scroll
#

discord is a js app

neat ingot
#

discord is made in electron, so is vs code

civic scroll
#

sorry for shattering your dreams

#

but js is much more powerful now

#

than what it used to be

cinder patio
#

the question is SHOULD you use js

neat ingot
#

you can also easily turn webpages into mobile apps

quartz kindle
#

have you guys checked out ultralight?

civic scroll
neat ingot
civic scroll
#

my phone is at 9%

civic scroll
#

oh

neat ingot
#

0o

civic scroll
#

thought discoed theme

civic scroll
neat ingot
#

render html to a bitmap 0o

cinder patio
#

Looks promising

quartz kindle
neat ingot
#

its super quick

civic scroll
#

should not be wrong if ver 2.6.1

civic scroll
cinder patio
ancient nova
neat ingot
#

ahh yea, ive seen a few projects that use live2d. i went for dragonbones armatures instead, but i wrote a converter for live2d/spriter/dragonbones to go from any to another 🙂

cinder patio
#

I guess if you make $100K annual revenue you wouldn't have a problem to pay for the subscription license lol

ancient nova
#

only difference is the discord related modules

cinder patio
#

but I still don't like it

quartz kindle
#

yeah the licensing is not that nice

ancient nova
#

guys

#

I have

#

finally

#

managed to

quartz kindle
#

but the project seems to have a lot of potential

ancient nova
#

make it work

neat ingot
#

yea, overall they havent sold me on a download 😄

quartz kindle
#

it had tons of issues last time i tried it tho

civic scroll
ancient nova
#

it's enough to make a grown man cry

civic scroll
#

your code is enough to make me cry

ancient nova
#
            let getResponseFromAPI = fetch(`https://transparent-speckle-door.glitch.me/checkPassword?username=${Username}`)
                .then(res => res.json())
                .then(out => getResponseFromAPI = out);
``` only reason node-fetch didn't work was because I didn't resolve it first
#

and yes, I didn't use var in this one

cinder patio
#

bruuuuh

#

use await

#

.then(out => getResponseFromAPI = out); this is not how it's done

ancient nova
#

it does work tho?

cinder patio
#

you sure?

quartz kindle
#

lmao