#development

1 messages · Page 1439 of 1

crimson vapor
#

8 different things

gilded olive
#

Yep there is a lot

long marsh
#

Are you using SQL?

gilded olive
#

Yes

#

Postgres with an ORM

long marsh
#

I'm sure you know what you're doing; however, 8 just seems a little unnecessary

quartz kindle
#

those 8 things, whatever they are, could still be made into a transaction, if not further combined using JOINs

long marsh
#

OH

#

You're using an ORM, lol

long marsh
#

ORMs can be limited with their transaction / join abilities though.

crimson vapor
#

lmao I feel uneducated when I see these database terms

gilded olive
#

I mean the bot has to check if every message is either an automod config

#

Ofc we have put checks in place if the automod is off we return None

long marsh
#

Sounds like a join operation 🤔

quartz kindle
#

always cache hot data

earnest phoenix
#

orm is basically never seeing an sql statement ever again

long marsh
#

☝️ that too

#

Haha, that's the hope ... sometimes it doesn't pan out.

gilded olive
#

Yea one our devs implementing redis since we kinda need it

long marsh
#

100000%

gilded olive
#

peepoSnow ok ive got to go cya guys

quartz kindle
#

im happy with my sqlite xD

long marsh
#

Later!

#

lol

#

I remember you telling me about that 😄

quartz kindle
#

hahah

long marsh
#

Is there an FAQ for badges, here?

#

"Certified Developer" sounds interesting lol

#

Roles I should say, I guess.

quartz kindle
#

the certified program is currently not available

long marsh
#

GG

#

Glad you were able to get it, haha

crimson vapor
#

for caching things in memory, without redis, would you cache as a global or how would you make sure you can access it everywhere

quartz kindle
#

not sure it if was removed completely or if they plan to bring it back at some point

#

i got it like 2 years ago

quartz kindle
long marsh
earnest phoenix
long marsh
#

Cache, in this case, would probably be a singleton.

earnest phoenix
#

yup

quartz kindle
#

i usually attach my caches to the main class that runs the entire program

long marsh
#

Exactly, a singleton.

#

Just 1 instantiation of the object for cache that the entire program consumes?

quartz kindle
#

ye, also contains all methods

long marsh
#

Sweet.

quartz kindle
#

and access to subclasses

long marsh
#

I feel like that's the best way, imo.

quartz kindle
#

i do it like client.app = new MyClass() then client.app.getUser(id) for example

long marsh
#

If you guys haven't used Docker, I would highly recommend it. It makes for destroying/updating/coupling with cache really easy.

crimson vapor
#

Lmao for the program I plan to work on caching for I don’t use classes

long marsh
#

Yeah, that's a singleton - lol

#

Basically

quartz kindle
#

im not planning on dockerizing anytime soon

long marsh
#

It's definitely not a requirement.

#

Just makes things easier, for me personally.

#

I work a DevOps position currently, and I use it all day anyways 😄

quartz kindle
#

nice

earnest phoenix
#

i'd definitely recommend following oop when you can, i feel like it's way more organized and it has a better logic flow

long marsh
crimson vapor
#

How would you implement that for an express app?

quartz kindle
#

app.cache = new MyCache()
app.get("/", (req,res) => { app.cache.get(req.data) })

long marsh
earnest phoenix
#

true

long marsh
#

But, I'm not disagreeing.

earnest phoenix
#

i'm way more used to using oop since i always work with dotnet

long marsh
#

Just saying, OOP isn't the 1-all-by-all

#

.NET forces you to use OOP - doesn't it?

earnest phoenix
#

yup

long marsh
#

Like Java?

#

Yeah

crimson vapor
#

I mean my routes are i different files than my main app, to make it easier to understand

#

But I get what you mean Tim

quartz kindle
#

you should be able to access app everywhere

#

if not, req and res should have a shortcut to it, no?

#

like djs has message.client shortcuts

crimson vapor
#

it does?

#

Ik of message.client but not req.app

quartz kindle
long marsh
#

lol

crimson vapor
#

Oh that’s nice

long marsh
#

Leave it to Tim to drop some knowledge

quartz kindle
#

when in doubt, open the docs

long marsh
#

What's a doc?

#

😄

#

Oh! You're talking about StackExchange, right?

#

😄

#

Kidding, kidding.

quartz kindle
#

lmao

#

im talking about doctors

#

:^)

#

circular dependencies are kinda one of the basic things about OOP, if your classes cant access their parent classes, you're doing it wrong

crimson vapor
#

how would you implement caching? app.cache = { data: [], otherData: {} };? and I can just add and remove data from it

long marsh
#

That's the naive implementation, yep

quartz kindle
#

btw, never use this when using proxified objects or classes

long marsh
#

You can also optimize it as well

#

And, MILLION, I say naive in a non-offensive manner here 😄

#

I'm not calling you naive, of course - haha

#

Wait, maybe not use a data: []

#

Instead, it really just acts as one large map.

crimson vapor
#

I assumed you meant it as in not knowing anything about it

long marsh
#

Nope

#

I meant it as 'a super simplistic way of doing it'

#

What language, Million?

crimson vapor
#

Oh ok

#

node js

long marsh
#

Check out keyv

quartz kindle
crimson vapor
#

could you send the link

quartz kindle
#

thats my bot lul

long marsh
#

Yeah, that works too lol

#

I don't use maps within maps though.

#

I'll prepend data:

Key = user.items
Val = (from database) user.items

quartz kindle
#

ye thats another way of doing it

long marsh
#

Yeah, there's really no right or wrong answer here ... as long as you're accomplishing the goal 😄

long marsh
#

I'm just using the in-memory version of it. Once my bot scales, I'll plugin a redis cluster too it; however, I will know, in the back of my mind, that it can always integrate with it whenever I want.

#

So, essentially, it'll be plug-in-play when I scale.

#

All cache is ... is just one giant map. If you look at the src, it's basically what you showed above.

#

Of course, with a lot more to it 😄

quartz kindle
#

i made a small lib that stores data in a huge string

#

xD

crimson vapor
#
// For caching
app.cache = require('./util/cache.json')```
```json
{ //cache.json
    "files": [],
    "urls": []
}``` so this is not a bad way of doing cache right
quartz kindle
#

not a bad way no, but kinda useless doing it like that, when you can simply hard code it

crimson vapor
#

true

long marsh
#

Data in a string - yikes. I don't know about all of that lol

#

Keep in mind, @crimson vapor , you're storing information in an array with that Cache.

crimson vapor
#

yes

long marsh
#

Why?

#

What are you storing?

crimson vapor
#

one second lemme grab the data object

long marsh
#

Obviously, I see files and urls

dark axle
crimson vapor
#
{
  originalName: String,
  name: String,
  path: String,
  views: Number,
  uploader: String,
  UploadedAt: String,
  lock: {
    active: Boolean,
    password: String,
  },
}```
#

file

pseudo yew
dark axle
#

@crimson vapor The password boi

long marsh
#

If you place your files into a list, they won't be easy to retrieve unless you iterate through the list.

dark axle
#

You better be encrypting that

#

Sensitive data

crimson vapor
#

its not even implemented yet

dark axle
#

@crimson vapor Wait what are you making?

crimson vapor
#

what do you think would be a better way to do this? set cache.files to a map and cache.files.set(filename, fileObject)?

pseudo yew
#

Ok back to suffering to find a way on how to get my captcha bot up-

crimson vapor
#

I am adding caching to an express server that just returns images/files

dark axle
#

@pseudo yew Aren't you hosting the bot?

quartz kindle
long marsh
#

An alternative approach to your caching could be a map:

{ //cache.json
    "files": {
        "fileId": {
            "attr": "val",
            "attr2": "val2"
        }
    },
    "urls": {}
}
earnest phoenix
#

okay so i use discordjs nodejs
my brain aint working anymore
k so. imagine if someone says *unscramble <text>
how to turn <text> into a var or a const or string

long marsh
#

That way @crimson vapor , you could have an O(1) access (big o notation) ... just 1 json pull.

dark axle
#

You just get the message that is sent and make it be a variable @earnest phoenix

crimson vapor
#

versus iterating through an array would be O(n)? idk big o notation

dark axle
#

How are you receiving the content @earnest phoenix

earnest phoenix
#

wdym with that

crimson vapor
dark axle
#

^^

earnest phoenix
#

does it also ignore the *unscramble then?

hollow sedge
#

that doesnt only get the text part guys, i think you're looking for .split()

dark axle
#

Could you be more specific and make a more descriptive exmaple on how the content you reiecive looks like and how you get it.

#

@earnest phoenix

earnest phoenix
#

i see

crimson vapor
#

alright

#

another question, what would be the difference from setting cache.files to a new Map() vs an object and doing it the way you said?

long marsh
#

1 for loop = O(n)
nested for loop for: for = O(n^2)

quartz kindle
#

need help with people who ask for help without explaining the problem

dark axle
quartz kindle
#

xD

crimson vapor
#

would there be any cpu or memory usage difference

long marsh
dark axle
#

Math.floor

#

@earnest phoenix

quartz kindle
#

.toFixed(number of decimals) in js

crimson vapor
#

alright this is a Tim question then

long marsh
#

Prob

dark axle
#

Math.floor(9.3434) would be => 9

#

Yep

quartz kindle
#

Objects and Maps are generally the same thing, but Maps support all kinds of data types as keys, while Objects only support numbers and strings as keys

#

Objects are a bit more memory efficient as well

dark axle
#

You need to parse it as an inte

#

Int*

crimson vapor
#

alright I will be using Objects

long marsh
crimson vapor
#

ty Tim

sterile lantern
#

say I have errors.json

in there it has a message.send embed function, would that work

crimson vapor
#

and Thomas

dark axle
#

@earnest phoenix Do this
${Math.floor(parseInt(si.currentLoad().currentload))}

sterile lantern
#

so in a cmd I’d do const error1 = require errors.json

#

then

long marsh
#

NodeJS is so frivolous with its rules - I'm not confident about anything in it 😄

hollow sedge
sterile lantern
#

if there’s an error it does return error1

#

would dat work

crimson vapor
#

node js doesn't respect basic math rules sadly though

long marsh
#

NodeJS doesn't respect anything.

sterile lantern
#

I don’t think it would work in a json file tho

crimson vapor
#

I don't mean the bugs with converting to binary

quartz kindle
#

the bad thing about Objects is that there is no built in way to iterate over them, you need to use Object.keys and Object.values, while Maps have .keys() and .values() as dedicated iterators, which might make it a tiny bit faster to iterate over them if you ever need to

long marsh
#

It doesn't even respect itself 😄

dark axle
#

@long marsh Typescript is Typed Javascript

hollow sedge
#

oh that makes sense

long marsh
#

TypeScript is more clear on its definitions / practices (imo) than JavaScript; however ES6 changes some of that.

sterile lantern
#

errors.json:
message.channel.send // error embed here

// cmd file
const error5 = require(errors.json) // this is an example dw
if(!haspermission)
return error5

hollow sedge
#

you know it's bad when someone who works with python says NodeJS is too flexible

quartz kindle
#

wdym js doesnt respect math lmao

sterile lantern
#

would that work;-;

#

${error5} maybe

dark axle
#

Is the type of "si.currentLoad().currentload"?

long marsh
quartz kindle
#

you cant in js either xD

hollow sedge
#

lol

crimson vapor
#
[] == 0 // true
0 == "0" // true
"0" !== [] // false```
long marsh
#

👀

#

What do you mean?

sterile lantern
#

can some1 see my inquiry above

long marsh
#

I thought you could, lol

quartz kindle
#

you can with many things, but not with numbers

long marsh
dark axle
long marsh
#

But, the point still stands 😄

quartz kindle
#

xD

long marsh
#

Interesting.

#

No errors though, how about dat

#

Python would raise a value error so quick 😄

quartz kindle
#

you cant with strings either

hollow sedge
#

yeah

crimson vapor
#

objects are cool though

dark axle
#

@earnest phoenix Can you console log si.currentLoad().currentload

crimson vapor
#
a.b = 1
a { b: 1 }
a.b 1```
#

nice

dark axle
#

And see what it returns

quartz kindle
#

you can do this tho :^)

dark axle
#

Yep that's why

long marsh
#

Because that makes sense

crimson vapor
#

is that because a is a Number instance and b is a property

#

the Number has a value of 5 but a property b of 10

dark axle
#

Make sure you're getting the correct value @earnest phoenix

long marsh
#

But, assigning a brand new property to an object outside of its original instantiation basically breaks the laws of physics coming from an OOP language 😄

dark axle
#

Check on how you did it on the embed.

sterile lantern
#

if I have fsreadDir on command folder, if I add sub folders in it will it still read those folders

long marsh
#

Objects are just so closely related to maps in JavaScript (imo) ... in other languages .. that's not the case at all.

#

In fact, really, any other language 😄

dark axle
#

You probably misspelt something or did not implement it correctly @earnest phoenix

quartz kindle
#

js has classes for everything, but literal definitions such as numbers, strings, objects and arrays, have special rules in them that dont allow you to access their underlying instances, however you can still do new Number, new String, new Object or new Array, and it will work the same way, but this time give you full access

crimson vapor
#

how do you delete the property of an object

quartz kindle
#

delete obj.prop

crimson vapor
#

oh

long marsh
quartz kindle
#

ye

dark axle
#

@earnest phoenix Can I see how you do it on the embed.

long marsh
#

Sorry, I'm sure you knew that - just reiterating for anyone else that's curious.

crimson vapor
dark axle
#

Send a snippet of the code or a screenshot

crimson vapor
#

ok sad no response

#

nice and groovy error

quartz kindle
#

i said literal as in, you literally write them in your code instead of instantiating a class for it

long marsh
#

Ahhhh

crimson vapor
long marsh
#

My fault

quartz kindle
#
a = [];
b = new Array();
long marsh
#

Yep yep

hollow sedge
#

million-are-you-a-computer?

quartz kindle
#

they are the exact same thing but follow slightly different rules

crimson vapor
#

well I am supposed to be

dark axle
#

@quartz kindle Lmfao

hollow sedge
#

lol

long marsh
#

Are they the exact same thing, Tim?

crimson vapor
#

but app is not defined ig

long marsh
#

I trust your judgement; however, they seem different 🤔

quartz kindle
#

they are, or at least they are supposed to be

long marsh
#

One seems like a primitive while the other is an Object representation of the primitive.

dark axle
#

@crimson vapor Define app.

long marsh
#

But, that's just me eye-ballin' it

#

And I don't know shit about NodeJS 😄

quartz kindle
crimson vapor
#

I typed app instead of req.app

long marsh
#

Are we certain that's valid? Is there inheritance at play here?

#

what if a == b?

#

well, I guess not

#

They'd be two different memory addresses 🤔

quartz kindle
#

(await s1.currentLoad()).currentload.toFixed(2)

#

for 2 decimals

long marsh
#

Idk - Javascript comparisons confuse me

quartz kindle
dark axle
#

@earnest phoenix Make a Variable named Auslastung and make it equal to the awaited currentload Then try to console log it
I think you just need to await it

long marsh
#

"When in doubt, triple equals"

pseudo yew
#

Hi guys I'm new to djs and I made my own starter code is it ok if you guys correct it? Or do I test it first?

crimson vapor
#

how would I get the amount of values in an object

#

Object.values(object).length?

quartz kindle
#

ye

dark axle
#

There you go

quartz kindle
crimson vapor
#

realistically Object.values().length is the same as Object.keys().length correct?

quartz kindle
#

yes

crimson vapor
#

ok

quartz kindle
#

Object.keys() would kinda be semantically more correct i think? who knows

earnest phoenix
#

,

#

oops

earnest phoenix
#

i'd assume it would be faster

#

The moment when objects don't have a length property so you gotta cast them to an array, pepega

crimson vapor
#

is an array not just a fancy object?

dark axle
#

@earnest phoenix Lmfao

long marsh
#

Not technically

#

An array is an object.

quartz kindle
#

an object is a fancy array xD

crimson vapor
#

o

quartz kindle
#

and both are fancy hashmaps

earnest phoenix
#

Array is an object data type, not everything in JS has a unique type

#

js
types
proceed to laugh

#

[] == []

long marsh
#

You know, more on that, is an array an object 🤔

earnest phoenix
#

false

long marsh
#

Or is it a primitive?

quartz kindle
#

an array is an object

crimson vapor
#

I assumed an array was just an object where "0" was the first value and "1" was the next

quartz kindle
#

there are a few diffences between arrays an objects in v8 tho

earnest phoenix
#

The moment when both arrays and object has the type of object but has different constructors

long marsh
#

Constructor overloading, eh

quartz kindle
#

under the hood, most objects are c++ hashmaps in v8
however arrays are not

long marsh
#

It really depends on the language ,tbh

quartz kindle
#

arrays have different c++ constructions depending on length and data size

long marsh
#

I believe Java's primitive types are objects themselves.

#

At the base of all data structures are objects.

earnest phoenix
#

Java should have just been renamed to just object

long marsh
#

LOL

#

Kinda true, though.

quartz kindle
#

jobject

long marsh
#

job

#

Just call it jOB

quartz kindle
#

jon

#

java object notation

long marsh
#

lol

#

Screw it, going back to C

#

No.

#

Assembly.

#

No.

#

Bytecode

earnest phoenix
#

Nah mate

queen needle
#

woah woah woah

quartz kindle
earnest phoenix
#

We going back to binary

long marsh
#

Is bytecode not the same thing 🤔

#

HOLEY DOUBLE ELEMENTS!

#

lmao

earnest phoenix
#

I'm not sure if there's a difference between them

quartz kindle
#

xD

long marsh
#

The elements of which are the holiest of holes.

queen needle
#

when i see tim voltrex thomas or cry talking in here and im in here its the same thing has a kid sitting at the adult table

earnest phoenix
#

Holy double elements, quite interesting

quartz kindle
#

a holey double element is used when you create an array with floating point numbers and empty holes, like this: [34.252,,,234.235235]

long marsh
#

OH

#

That makes sense, though.

#

Would the empty 'holes' be filled?

#

Abstractly, I mean

quartz kindle
#

pretty sure it stays the same

#

even if you eventually fill the holes, the underlying data structure will still be a sparse array

long marsh
#

Ah, interesting.

crimson vapor
#

Okay I have fixed the bug and now my caches are maps

dark axle
#

Just get a shovel

long marsh
#

Well, I can't speak for voltrex or tim or cry .. I guess

crimson vapor
quartz kindle
#

im the kid thats always sitting in weird ways at the table

earnest phoenix
#

Bruv

queen needle
#

i mean that in a way that i understand the gist of what yall are saying but i dont understand anything pass that

sharp thicket
long marsh
#

I'm the kid that is trying their hardest to fit in with the others kids; however, due to my own paranoia, I end up not saying anything and inadvertently being marketed as a 'weird' kid.

#

facts

quartz kindle
#

who needs to fit in, just be proud of your own uniqueness :3

dark axle
#

Im the kid that is not on the list cattocry

sharp thicket
#

Can you move to a general chst

#

Chat*

long marsh
#

You right.

earnest phoenix
#

Imagine if tim was the kid that's sitting behind the class then when he gets angry and this shit appears in real life, you know shit is serious

crimson vapor
#

who needs to fit in, just get more than 50 stars on a gh repo and you are now popular so people will start copying you to be normal

#

change the normal

sharp thicket
#

@quartz kindle why eo you spend so muxh time helping ppl here?i rlly think they should make you like a helper role 🤣

quartz kindle
#

lmao

sharp thicket
#

Do*

crimson vapor
#

Tim should get a Tim role

crimson vapor
#

anyone that is very knowledgeable and respectful should get a Tim role

quartz kindle
#

because it makes me feel better about myself :^)

earnest phoenix
#

Petition to give tim, Certified developer but tim role

queen needle
#

tim should get a top.gg role because without him this would die and we all know it

sharp thicket
#

Yes i wanna sign that

#

Gimmie

quartz kindle
#

lmao

earnest phoenix
#

Yo wtf

#

Loggers

quartz kindle
#

can i trade the role for donators and patreons?

sharp thicket
#

Can we stoo breaking rules tho

#

Let move to general

#

Lets

crimson vapor
#

therefore its fine

sharp thicket
#

Lol

#

Ok

earnest phoenix
sharp thicket
#

Yes

earnest phoenix
#

Lemme say this

queen needle
#

lol

crimson vapor
#

yes

#

or

#

#ask-tim

quartz kindle
#

i mean, at that point why not just join my server lmao

crimson vapor
#

you have a server?

queen needle
#

each question costs one patreon

earnest phoenix
#

Wait you got a server?

quartz kindle
#

yes lol, the support server for my bot and my libs

earnest phoenix
#

Give link

crimson vapor
#

yes

#

either send here or dm

solid tide
#

can yall dm me please

crimson vapor
#

by the way, if someone asks for a link to something, is it considered self promo if you send it?

earnest phoenix
#

First we decancer your username

quartz kindle
#

BpeedKh

crimson vapor
#

ty

earnest phoenix
#

The entire DBL heading to join tim's server

#

May lord help us

sharp thicket
#

Lol

solid tide
#

can yall dm me please

sharp thicket
#

Why

quartz kindle
#

why do you want a dm?

solid tide
#

i need a friend

sharp thicket
#

Sure

quartz kindle
#

this is not the place for that lol

sharp thicket
#

Tim whats ur bots name

crimson vapor
#

well it is if you contribute to the conversations in a helpful way

#

what are the chances that he is trying to grab the ip from the db?

sharp thicket
#

-bots @tim

gilded plankBOT
#

tickNo User not found

weary ore
#

Hey guys, how would a economy bot work with mongo dB/quickmongo
any reference guides

hollow sedge
#

What is quickmongo

sharp thicket
#

Tf

crimson vapor
#

Is there a way for a js library to tell if someone is using a user token?

weary ore
crimson vapor
#

oh

#

you can make schemas

earnest phoenix
#

Wrapper for a wrapper?

crimson vapor
#

LOL

weary ore
#

idk

#

lol

hollow sedge
#

Yeah what

#

Its a beginners MongoDB thing

weary ore
#

probaly

#

like how would a buy n sell command work with mongodb

crimson vapor
#

well a buy command would decrease a variable and a sell command would decrease a variable

sharp thicket
#

Save money for a user then change it whenever u need to

hollow sedge
#

It calls itself a MongoDB wrapper but one of its dependencies is mongoose LOL

crimson vapor
#

so all you need to do is create schemas with the id as the user's id

#

and add a balance property

weary ore
#

i have a profile schema

crimson vapor
#

so add a balance property

#

and there should be a way to update it

#

im not quite sure since I only use basic features of mongoose

weary ore
#

lol thats why im asking

lapis forge
#

Hi, i have my bot that can post to mongodb for prefixes and im not sure how to read from the database or to read it from just the API. Im not that great with mongo and to get it from the API i need to get the guild id from client.guild.id. Im using DJS commands too

sharp thicket
#

schemaName.findOne()

#

If ur using mongoose that is

#

Idk any other libs

crimson vapor
#

same

#

and I use updateOne() with the same input

sharp thicket
#

I dont think thats a good idea

weary ore
#

i have a way to update the balance $inc

sharp thicket
#

Check if anything is there first

slim umbra
#

dont use mongoose

#

its supersuper slow

crimson vapor
#

if false djs should just destroy the client

slim umbra
#

bc mongo is not a relational db

#

so dont use a lib that attempts to make it one

sharp thicket
slim umbra
#

afaik it does

#

eris doesnt tho

sharp thicket
#

If ur hosting ur bot locally u can just remove that part??

slim umbra
#

well why

crimson vapor
#

what

#

why would anyone want to remove that

slim umbra
#

yeah

sharp thicket
#

Self bots

crimson vapor
#

it should be obfuscated

slim umbra
#

unless u think ur funny making some shitty selfbot

slim umbra
sharp thicket
#

Yea

slim umbra
#

obfuscating a oss lib thats on gh

weary ore
#

so when a person buys it adds it to the user profile right?

slim umbra
#

thats some stupid shit

crimson vapor
#

they should obfuscate a whole chunk of code

#

to prevent breaking discord tos

slim umbra
#

its very easy to bypass lol

#

obfuscating it would be stupid

crimson vapor
#

!==

#

right?

earnest phoenix
#

Doesn't matter

crimson vapor
#

oh

#

nvm

earnest phoenix
#

undefinded

#

Spell error

crimson vapor
#

that too

#

why not

slim umbra
#

oh my

crimson vapor
#

thumbnail.source || "link"?

#

well

crimson vapor
#

you're right it would be a string

#

???

slim umbra
#

yes lol

#

valid js

crimson vapor
#

I mean whats it

#

ik its valid

slim umbra
#

nullish coalescing

crimson vapor
#

node not the right version?

queen needle
#

isnt that node 14 syntax

earnest phoenix
#

Those are only available in Node.js v14+

slim umbra
#

yeah

#

yeah upgrade to 14

#

its the latest lts

earnest phoenix
#

Use n or nvm

crimson vapor
#

what does ?? do?

slim umbra
#

i showed u

crimson vapor
#

I mean

slim umbra
crimson vapor
#

in english

#

I saw you use it

#

but im not quite sure

slim umbra
#

nullish coalescing

#

so

#

if

#

a in a ?? b

#

is !a = true

#

a ?? b = b

crimson vapor
#

ok

#

do we say yes or no?

earnest phoenix
#

You shouldn't go for the latest

crimson vapor
#

since its not wrong but its not right

earnest phoenix
#

Use LTS

slim umbra
#

yeah 15 has been annoying for me

quartz kindle
#

how so?

#

because of npm v7?

slim umbra
#

yeah it was doing weird stuff in package-lock

#

and on other versions of node npm got confused

crimson vapor
#

what is package-lock even?

slim umbra
#

yes i use npm i apologize in advance

misty sigil
#

so do I

quartz kindle
#

well i use npm as well lol

earnest phoenix
#

Well it's because of the yarn stuff support or whatever

#

The package-lock formats were changed

sterile lantern
#

so say u generate a premium code
db.set(premium, code)

#

but what if I run the generate again

quartz kindle
sterile lantern
#

it will replace the existing premium code

crimson vapor
#

oh

slim umbra
#

oh my r u using quick.db

sterile lantern
#

yes

#

y

slim umbra
#

u didnt install node 14 my friend

#

u installed 15

sterile lantern
#

wdym?

#

oh

#

not me nvm

slim umbra
#

okay

crimson vapor
#

npm i canvas

quartz kindle
#

so you can use package-lock to make sure the exact same versions are installed elsewhere and ensure everything works, instead of installing the latest versions

crimson vapor
#

iirc

slim umbra
#

npm rebuild

crimson vapor
#

oh

slim umbra
#

dont use quick.db tho

#

its kinda terrible

quartz kindle
#

npm rebuild

queen needle
slim umbra
#

why the fuck

weary ore
#

if i create a structure file would that be better for a economy bot

earnest phoenix
#

Ah yes, we're iterating through many errors

slim umbra
#

uh u didnt install node properly

queen needle
#

yeah you should use mongo or sql

quartz kindle
#

node node index.js

slim umbra
#

lmfao

quartz kindle
#

wat

slim umbra
#

mongo or sql

#

oh

#

i didnt catch that lmfao

earnest phoenix
#

lol

slim umbra
#

nvmnvm

quartz kindle
#
for(let error in errors) {
  Tim.plsFix(error)
}
slim umbra
#

ignore that

earnest phoenix
#

This guy tried to make his process 2 times faster by doing node node <file>

queen needle
#

node node node

slim umbra
#

the one thing he didnt realize is

#

that hes using node so it only goes slwoer

quartz kindle
#

if you have 32 bit windows, just install it twice so you get 64 bit

crimson vapor
#

voltrex its not 2 times faster, its ^2 times faster

earnest phoenix
crimson vapor
#

because its not 2 node its node * node

sonic lodge
#

node index.js not node node index.js

earnest phoenix
crimson vapor
#

I do

#

a little

queen needle
#

voltrex speaks javascript

earnest phoenix
#

I speak Node.js

crimson vapor
#

doesnt know math

earnest phoenix
crimson vapor
#

knows code

#

:bigbrain:

slim umbra
quartz kindle
#

i only know math until 7th grade

crimson vapor
#

oof

earnest phoenix
sterile lantern
#

does quick.db have a insertOne function

queen needle
#

no

slim umbra
#

dont use quick.db

sterile lantern
#

oof

slim umbra
#

thats my answer

earnest phoenix
#

Those are mongodb methods

queen needle
#

use mongo

sterile lantern
#

y it’s easy to use

queen needle
#

so is mongo

slim umbra
#

its also slow

sterile lantern
#

mongo is

#

complicated

quartz kindle
#

npm cannot install node lol

earnest phoenix
#

npm i n -g

#

n <node version>

slim umbra
#

literally every database is easy to use depending on ur dedication to read documentation

solemn latch
#

quickdb is easy until you need some real features

summer torrent
#

npm is node's package manager lmao

sterile lantern
#

So if I generated a code

#

It’s set to “premium_code, code”

#

But if I generated another code

sudden geyser
sterile lantern
#

It overrides the existing code

queen needle
#

it would be a different thing in database

quartz kindle
#

it doesnt matter if you use 14 or 15, dont fret over it lol

sterile lantern
#

oh really??

#

bruh that’s epic

crimson vapor
#

json db is the best

sterile lantern
#

JSON??

#

LOL

crimson vapor
#

yes

queen needle
slim umbra
#

oh my top.gg dev chat just makes me cryy

earnest phoenix
#

Imagine not using file database system

sterile lantern
#

aight thanks

crimson vapor
#

fs.readFile('db.json', (data, err) => {})

#

best code for db

sterile lantern
#

also does better sqlite 3

#

have a

#

web system?

queen needle
earnest phoenix
#

Sarcasm level here is off the charts

quartz kindle
#

web system?

sterile lantern
#

so you can view your DB on a website

quartz kindle
#

no

#

you have to code that yourself

sterile lantern
#

oof rip

slim umbra
#

braincells are like below the charts here

queen needle
#

wait brain cells exist here?

slim umbra
#

reload webstorm terminal

quartz kindle
#

lol

earnest phoenix
#

🗿 There is no, "brain cells"

slim umbra
#

needs the latest bash or zsh source

#

(assuming ur not epic enuf to use fish)

quartz kindle
#

i need to wash my brain cells in the shower now

crimson vapor
#

are you sure?

#

I will code you guys the best db code you have ever seen

earnest phoenix
#
for (let brainCell of Tim.brainCells) {
await brainCell.wash(3); // Be sure to clean it 3 times
}```
sterile lantern
#

what other DBs are similar to quick.db

#

and actually use a website

queen needle
#
this.544676649510371328_bal = 50```
sterile lantern
#

to store stuff

slim umbra
#

i use scylla in prod and its pretty great

solemn latch
#

quick db doesnt use a website does it 🤔

sterile lantern
#

no

#

that’s why I’m asking

#

if there’s anything similar to quick db but uses a website

queen needle
#

cant you see your database with mongo?

slim umbra
#

but i dont think u have enuf braincells to comprehend cql or scylla as a whole

solemn latch
#

well, if you want it to use a website, like an api? i would build something myself 🤔

sterile lantern
#

hm

#

k

quartz kindle
#

if you just google "web dashboard for XYZ database" you will likely find many options

sterile lantern
#

ya that’s what I mean

#

hm

crimson vapor
#

rethinkdb

sterile lantern
#

kk

quartz kindle
#

keep in mind that quick.db is not a database, its a database wrapper, so you wont find anything if you search for "dashboards for quick.db"

sterile lantern
#

how does rethink db work

slim umbra
#

thumbnail?.source

#

oh wait

quartz kindle
#

thumbnail?.source should work then

slim umbra
#

that url doesnt seem to exist lol

#

just tested and

#

its not parsing as json

#

so thats ur problem

quartz kindle
#

it works for me

#

so what is the problem?

crimson vapor
#
const fs = require('fs');

const DB_PATH = 'data.json'

function readDB() {
  try {
    return JSON.parse(fs.readFileSync(DB_PATH));
  } catch (err) {
    throw "An error occured when reading from the DB.";
  }
}

function writeDB(data) {
  try {
    data = JSON.stringify(data);
    fs.writeFileSync(DB_PATH, data);
    return true;
  } catch (err) {
    throw "An error occured when writing to the DB.";
  }
}

function saveDataToDB(type, key, value) {
  let data = readDB();
  data[type][key] = value;
  writeDB(data);
  return true;
}```
#

rate my code

quartz kindle
#

a solid 5/7

crimson vapor
#

why 5?

#

why not 8

boreal iron
slim umbra
#

kinda shit bc functional code node oop

keen drift
#

Hey, anyone provisioned Flannel, Calico, Canal or Weave networking plane before for a cluster?

quartz kindle
#

both me and doge told you what to do

#

thumbnail?.source || "fallback url"

slim umbra
#

i mean we've said it tons of times now

#

fucking read or get out

crimson vapor
#

unless thumbnail.source is a string "undefined"

earnest phoenix
#

A solid ineffienct/efficient

crimson vapor
#

how would you improve my code?

quartz kindle
crimson vapor
#

oh

#

a meme

slim umbra
#

just like ur code

quartz kindle
#

want a json db competition?

#

lmao

slim umbra
#

yesyes

earnest phoenix
#

No tim, don't make me eval

slim umbra
#

need to see the pinnacle in speed

queen needle
#

voltrex has entered the chat

crimson vapor
#

oh

#

so perfect?

sterile lantern
#

how would I make it so the bot checks if a premium code is in the DB and not claimed

slim umbra
#

oh god

#

sigh

queen needle
#

object with a boolean or something

slim umbra
#

hes using quick.db

queen needle
#

you can still set objects

crimson vapor
#

make premium codes an object and add code: boolean default to false

#

set to true when used

sterile lantern
#

o

slim umbra
#

quick.db does objs

#

wut

crimson vapor
#

or just remove

sterile lantern
#

isee

crimson vapor
#

does it not?

#

WHAT

sterile lantern
#

u can do db.set(code, false)

earnest phoenix
#

🗿

sterile lantern
#

oh ik what to do

slim umbra
#

it does

crimson vapor
#

ok good

slim umbra
queen needle
#
let premobj = {
code: "bleh",
claimed: false
}
db.set(`prem_${premobj.code}`, premobj)```
crimson vapor
#

@quartz kindle what else should I add to my db code?

#

sorry if you were typing

sterile lantern
#

let pcode = db.fetch(code)
if(pcode === claimed) return msg.send(already claimed)

crimson vapor
#

and need to stop your thought

sterile lantern
#

that’s a horrible piece of code but just an example

crimson vapor
#

yea

earnest phoenix
#

Well not a strict equally comparison, just access the property

sterile lantern
#

hm so if someone entered the code as args 1, would I just do db.set args 1, claimed ?

#

example once again

#

if it’s a valid code ofc

queen needle
#

if you use something like i sent you could do js if(db.fetch(`prem_${args[0]}`).claimed === true) return <message>.channel.send("no")

earnest phoenix
#

You want to overwrite the previous document?

#

=== true is redundant

queen needle
#

no u

earnest phoenix
crimson vapor
#

yeah

slim umbra
crimson vapor
#

especially if it was set to a string for some reason

earnest phoenix
#

Tim is writing the entire bible in 3 different ugandan languages

queen needle
#

his code will fix every problem ever

quartz kindle
#
const fs = require('fs');

class JSONDB {
  constructor(file) {
    this._file = file;
    try {
      this._data = JSON.parse(fs.readFileSync(file, "utf8"));
    } catch(e) {
      this._data = {}
      fs.writeFileSync(file, "{}", "utf8");
    }
  }
  get(key) {
    return this._data[key];
  }
  set(key, value) {
    this._data[key] = value;
    try {
      fs.writeFileSync(this._file + "-temp", JSON.stringify(this._data), "utf8");
      fs.renameSync(this._file + "-temp", this._file);
    } catch(e) {
      throw "An error occured when writing to the DB: " + e;
    }
  }
}
#

lmao

slim umbra
#

thank god atleast its oop lmao

queen needle
#

what is oop?

quartz kindle
#

object oriented programming

opal plank
#

old outdated programming

quartz kindle
#

out of poo

opal plank
#

fuck, cant beat that one

#

you win

#

gg

#

oily oil poo

stoic moon
#

How do i get it to show nsfw servers?

earnest phoenix
opal plank
#

what now?

stoic moon
#

the website

opal plank
#

define it

crimson vapor
#

oop based json db

slim umbra
#

wrong channel my friend

crimson vapor
#

hmm

slim umbra
#

wrong website too probs

quartz kindle
stoic moon
#

top gg

opal plank
#

u cant show nsfw in top,.gg

stoic moon
#

sort by most users

earnest phoenix
opal plank
#

its against the rules iirc

crimson vapor
#

Tim you should add different collections

stoic moon
#

this website

crimson vapor
#

then upload it to github

#

we can have a json db competition

crimson vapor
#

best json db gets a vote for their bot

earnest phoenix
#

Well tim never lost a competition so there's no point

opal plank
#
import jsondb from 'jsondb'```
#

done

sudden geyser
#

JSONDB => JsonDB

opal plank
#

actually i can top it up

#
import pg from 'pg';

cuz postgreSQL, if you using any other database, you doing it wrong

quartz kindle
#

i mean, what would the criteria be?

#

performance?

#

being less bad than others?

slim umbra
#

dont use pg use pg-native

crimson vapor
#

how quickly the db corrupts

#

more points the more writes

slim umbra
#

well thats easy then

#

just write atomically

#

and ur safe

opal plank
#

pg > pg-native

quartz kindle
#

which is basically what i did

crimson vapor
#

yes

slim umbra
opal plank
#

every

crimson vapor
#

so anyway

slim umbra
#

the fact that pg-native is faster?

opal plank
#

their libis better

crimson vapor
#

we should still have the competition

#

anyone else want to make a json db

slim umbra
quartz kindle
crimson vapor
#

ok

opal plank
#

they actually have properly written types than the garbage attrocity they did in postgres

interface PromiseReturns {
[key:string]:any

}```
#

fucking lazy pricks

#

i remember they did this shit 3 or 4 times

slim umbra
#

ah well ur a genius whose using ts 🤯

opal plank
#

its a hell to write interfaces when they do this garbage

quartz kindle
#

btw how would you add jsdoc to a native library?

slim umbra
#

u dont lmao

opal plank
#

it should be able to import jsdocs

quartz kindle
#

i can write a typings file

#

but idk how to jsdoc it xd

opal plank
quartz kindle
#

unless you can put the jsdoc in the typings?

slim umbra
#

u probs can just put it in the types yeah

opal plank
#

it should import them just fine tim

#

lemme double check

#

it looks like the usual imports

#

either import at top of your code or simply
index.dt.ts

quartz kindle
#

i'll look into it later then, i didnt even publish the lib yet

opal plank
#

tim 100% making a nsfw bot

earnest phoenix
#

Wait, what lib

opal plank
#

d.js 2

quartz kindle
#

nothing much, just a remake of an existing native lib but using N-API instead of NAN

opal plank
#

nhentie api, man of culture

quartz kindle
#

lmao

opal plank
earnest phoenix
#

🗿

opal plank
quartz kindle
#

i've been using the existing native lib for a few years now, and it works well, but it has some weird bugs

#

mine works perfectly

opal plank
#

thats what i say about the main library for twitch

#

though i cant say mine works perfectly as its possibly a flag trigger for internal twitch spam

quartz kindle
#

xD

#

i contributed a lot to the existing one, but icba anymore

#

i basically PRed all the latest major updates by myself

opal plank
#

tim needs to colab with me

#

just saying

#

ts vs js mashup

quartz kindle
#

lmao

crimson vapor
#

wait does data corrupt with writeFileSync?

opal plank
#

reading? no

quartz kindle
#

i'll make the js libs, you turn them into ts

opal plank
#

writing is issue

#

sounds like a deal

earnest phoenix
#

mmLol Collaboration with tim, loggers moment

quartz kindle
opal plank
#

its not like to turn them into ts its as simple as changing the extension and adding types, cuz all the transpilation is done with ts

crimson vapor
#

so realistically your way of making a tmp file prevents that right

quartz kindle
#

yes

crimson vapor
#

ok time to make a git repo

quartz kindle
#

because a rename operation is Atomic

opal plank
#

boom

quartz kindle
#

its fully done by the operating system, and not by the node process

earnest phoenix
#

I wonder where tim finds these logics from

#

Pretty interesting

quartz kindle
#

i read a lot of random stuff on the internet

#

xD

earnest phoenix
#

Tim's search history must be interesting

opal plank
#

you write lib, i port it to ts, deal

quartz kindle
#

lmao

slim umbra
#

is tht default vsc theme

#

ew

opal plank
#

is that some skid complaining about my code while they dont even know async properly?

earnest phoenix
#

Changes extension
Woah wtf, magic

opal plank
quartz kindle
opal plank
#

is that leaking guild ids?

#

bean, reported

crimson vapor
#

but its like

#

a user not a bot

quartz kindle
#

its this guild

#

lmao

opal plank
#

oh

crimson vapor
#

anyway how do you make npm modules?

opal plank
#

rip lmao

earnest phoenix
#

Mods would get banned if they try to ban tim

crimson vapor
#

yeah

#

Tim is too powerful

earnest phoenix
#

That's how life works

opal plank
quartz kindle
crimson vapor
#

no I mean how do I make it so I can require my code in another place

#

sorry I didn't say what I meant

quartz kindle
#

you module.exports it from your main file

crimson vapor
#

o

opal plank
#

then simply require()

#

or import and use es6 modules if you fancy and need an extra monocle

#

🧐

quartz kindle
#

damn englishman

opal plank
#

shits so fancy i need 2 monocles

#

named exports

#

aliases

earnest phoenix
#

Life changes when you discover JS module exports

opal plank
quartz kindle
#

my life changed when i understood js prototypes

crimson vapor
#

what do you mean

#

your life changed

civic relic
#

hello

crimson vapor
#

aren't prototypes what every instance has access to

quartz kindle
#

ye, and once you understand them, you can essentially hack anything in js

opal plank
crimson vapor
#

oh

opal plank
#

no

#

not THAT hack

#

its not as cool as you think

#

you just add methods and change functions

crimson vapor
#

lol

earnest phoenix
#

Prototype pollution

opal plank
#

and other extras bits, like hacking NASA and the FBI, but those are less important

crimson vapor
#

^

quartz kindle
#

lmao

#

the entire djslight lib is prototype pollution

earnest phoenix
#

Spaghetti

#

Yum

#

Where's the lamb sauce

quartz kindle
#

i drank it

opal plank
#

i dont like that comma in there nor that comment, .prototype. the fuck out of it

crimson vapor
#

is there any way for me to set a constant in a package without using classes

quartz kindle
#

wat

crimson vapor
#

english hard when I just add words, you know

opal plank
#

why am i listening to Phao while talking here?

slender thistle
#

My life changed when I knew JS existed

opal plank
#

to worse?

slender thistle
#

Yup

opal plank
#

saw that coming from a mile away lmao

crimson vapor
#

so I have a constant DB_PATH how would I change that normally without using classes?

opal plank
#

Ts is the promised land shiv, im telling you

slender thistle
#

I did want to finish that message with "for the worse" but couldn't be assed to

opal plank
#

its py without the nuinsences

slender thistle
#

I need to learn TS

quartz kindle
opal plank
#

you do

sudden geyser
crimson vapor
#

String.prototype.reset = function() { return this = "" }

#

best code

opal plank
#

tim

slender thistle
#

My medicine is Python and I'm high

earnest phoenix
quartz kindle
crimson vapor
#

o