#development

1 messages · Page 1960 of 1

split hazel
#

comes with a built in display, pretty awesome stuff

proven lantern
#

these are like $10

split hazel
#

is that a breadboard

proven lantern
#

yeah

split hazel
#

what for tho

#

i really have no clue about any of this stuff

#

school really been lacking

proven lantern
#

you can make led light do things

wheat mesa
#

aliexpress things that are hella cheap are often sketchy

cinder patio
#

A lot of components on aliexpress just don't work when I get them

#

I know from experience

split hazel
#

sus

wheat mesa
#

My friend ordered a 1080 ti from aliexpress about 7 years ago when I told him it was a scam, when it came in the mail it was a broken 1030 GT lmfao

#

Actually that was probably about 5 years ago thinking about it

#

Still, before the GPU shortage

split hazel
#

lol oh dear

cinder patio
#

Uh yeah it's aliexpress

cinder patio
#

Like, cents

split hazel
#

i'll probably go with a raspberry pi pico to start off with

cinder patio
#

one dollar

wheat mesa
#

Just be prepared for things to come in not as you expect them to if you order tech from aliexpress

#

It’s a gamble sometimes

split hazel
#

i can probably take a gamble with a £8 product lol

#

problem is idk if i'll be able to even get it to work

#

it looks like a custom modified arduiono/pico

slender wagon
#
 console.log(price)
      await DiscordUser.findOneAndUpdate({ discordId: user.discordId }, { $inc: { cips: -price } }, { new: true }, async (err, doc) => {

so something weird is happening whenever i try to remove lets say 2 cips the function removes 4 instead as if it is running 2 times

split hazel
#

aliexpress looks like ebay and wish combined

lyric mountain
#

Mmr should be based in average skill level, not winner/loser

#

You need to calculate mmr based on the match

proven lantern
#

each match calculates an elo for the team in the specific versus type. ie 2v2.
it also calculates an elo for the team in all versus types like 2v2v2, 2v2v2v2 etc.
it also calculates an elo for each player individually for that versus type

lyric mountain
#

but what if someone intentionally lose games to elo boost someone?

proven lantern
#

i'm thinking of this scenario. there are 10 people doing 5v5s. they play a game and then record the result to get updated elo scores. then they balance the teams again and play.

#

rinse repeat

worn sphinx
#

How to make v12 to v13 in repl

earnest phoenix
sacred plover
#

..

twin kettle
#

what a user should have permission to be able to warn ?

spark flint
#

Possibly

#

IMO

sudden geyser
#

moderate members

solemn latch
#

tbh, it should be if the member can manage the other member.

#

and whatever permission you want, manage messages makes the most sense to me, as anyone who can delete messages probably should be able to warn for those deletions.

spark flint
#

^

#

my thoughts exactly

sharp saddle
#

can anyone tell me if python is better than javascript?

spark flint
#

Well thats a hard judgement to make

#

Each programming language has its primary uses and each has its advantages and disadvantages

sharp saddle
#

what advantages and disadvantages of python?

quartz kindle
#

advantage: it works
disadvantage: its python

spark flint
#

listen to tim

#

he is smart

earnest phoenix
quartz kindle
#

precisely because its bad that we love it

earnest phoenix
#

i know

quartz kindle
#

you can do tons of bad cool things with it

#

like jsfuck

solemn latch
#

I like doing bad things with js

sudden geyser
#

or write an operating system in it

#

JS has been stealing our developers

#

Now if you want to write anything good it has to be in JavaScript

#

sadge

quartz kindle
#

js to native compiler

sudden geyser
#

exists

quartz kindle
#

nobody will use c/c++ anymore

proven lantern
split hazel
#

javascript job stealer

wheat mesa
#

anyone have recommendations on a request lib, or should I just use node-fetch

proven lantern
#

use axios

spark flint
#

^

#

axios is good

wheat mesa
#

alright thanks

short pilot
#

can you edit an attatchment?

#

i'm trying to upload a png and then edit the image later on

boreal iron
#

v2.5.x

#

Which isn’t an esm module and still receives some updates, sometimes

lament rock
#

use the built in http module

#

All the others are bloat

#

Only one where I can disagree on being bloat is centra

#

Something minimal is good

sudden geyser
#

and it's a backend project, so size itself wouldn't be a concern

lament rock
#

because simple http requests don't require that much space

sudden geyser
#

but most requests aren't simple

lament rock
#

I have never made a complex http request that goes beyond simple headers and json body

#

im sorry

sudden geyser
#

hit send too early

#

damn keyboard

lament rock
#

wonder if I should be scared

sudden geyser
#

fear nothing

#

In non-trivial applications, I've found that it's not just "I hit this page and keep appending data to this string and parse it to json when I'm done", it's "I need to append and parse this data, parse and verify these headers, and recreate many features http libraries do for me, like cookies, streaming, and the happy path of error handling."

#

I get wanting a library that does just what it needs to do, but not sinking down back into net or http modules

lament rock
#

cookies are a pain, I can agree, but streaming isn't hard considering the http lib streams just the body and handles header parsing which is why I've grown quite keen to it. Beyond that, I don't see a need for huge libs if its for proprietary APIs or even stuff like Discord since Discord is relatively sane. Not saying I'm insane enough to operate with Discord on the socket level, but

#

I guess it's helpful to know I mostly just operate with proprietary software unless it's something outside my scope

#

I could do raw net.Socket communication which I've had to do before (major pain), but not that much of a masochist

#

if you need everything major libs offer, I can agree with node-fetch since it's a similar api to webjs, but for me, I don't need all of those features which is why I would be more inclined to recommend lightweight solutions

#

I've had to deal with debugging axios before as well and I hate it.

Turns out that not many http libs support shoutcast/icecast

bronze socket
#

how to link files in js?

earnest phoenix
earnest phoenix
lament rock
#

this just looks like Promisified built in http lib

bronze socket
#

how can i link it??

lament rock
#

..// is not a valid path string

#

../

earnest phoenix
#

light mode

pale vessel
#

Keep crying

earnest phoenix
#

@woeful pike quick question: how did you make the colors thingy for dislike.gg that lets you change the background and text and everything
I assume it's using chakra's colorScheme prop somewhere but where

#

react dev tools won't show me the onclick listener for the anchor ftw buttons

flat copper
#

how can i make image cirlce in canvas

lament rock
#

use alpha masks

solemn jolt
#
const { Client } = require("discord.js");
const client = new Client()
try {
  client.login(_token);
} catch (error) {
  console.log(`${_token} Remove this token in token list;`)
}

I want to know if the token is invalid but i get an error in the console how I can remove the error if the discord bot token is invalid

solemn jolt
#

i do it but the login is dont work

#
const { Client } = require("discord.js")
  try {
    const cllient = new Client();
    cllient.login(botTOKEN)
    return res.send({ error: true, message: "The token is valed." });

  } catch (err) {
    return res.send({ error: false, message: "The token is invaled." });
  };
#

i do this but if the token is valed or no the log well be valed

#

i do this but when i use return the return is dont work

#
const { Client } = require("discord.js")
const cllient = new Client();
cllient.login(botTOKEN).catch(err => { return; })
console.log("test")
#

by this if the token is valed or no in the console i get test

#

i use this code but if the token is valed or no the console well be work

#

ok thank you

#

i well get this error and restart the website when the token is invaled

#

im working in a website that just by puting config the bot well be online the the code and you can edit it by dashboard

#

i well put every code that i now and some of then you can use it by free some of them by premium

#

i just want to create something to now if the discord bot token is valed or no

#

😂

#

damn, how i dont think about it xD

civic scroll
#

iirc the login method doesn't return anything at all

pale vessel
#

It returns a promise of the token provided

#

You'd have to await it to catch the error

solemn jolt
civic scroll
civic scroll
#

also there are event emitters in the brower api too

solemn jolt
civic scroll
# solemn jolt how

model: user send data to server
server uses that information to create a capsule that said bot run
catch output from that and send back

civic scroll
solemn jolt
civic scroll
#

you sure wanna read 1.5k lines of code

#

wait did you understand what i said

#

💀

solemn jolt
civic scroll
#

you made the website, so there must be a server to send it off

pale vessel
#

It returns a promise

civic scroll
#

isn't it void

#

what

pale vessel
#

Nop

civic scroll
#

am i outdated on the api again

split hazel
solemn jolt
pale vessel
#

what did you change?

civic scroll
#

if that's the case then

<client>
.login(<TOKEN>)
.then(data => {....})
.catch(e => {...});
#

then you are confined to do inside the { } since async works different from synchronus code

#

also may i see the error?

solemn jolt
#

i create this in post i just want to now if the token is valed or invaled

solemn jolt
pale vessel
#

did you or did you not await the promise

civic scroll
#

what did you send before the client login?

pale vessel
#

it'll send a response but then it errors so it'll send another response

#

that'll trigger another error

solemn jolt
civic scroll
#

can i see create.js at line 39?

pale vessel
#

okay

#

Await the promise or your catch block will be useless

civic scroll
#

use callbacks Trolled

solemn jolt
#
app.post("/bot/create", global.checkAuth, async (req, res) => {
  const {
    botTOKEN,
    botID,
    ownerID,
    coowners,
    prefix,
    website,
    supportID,
    supportLOG,
    embedCOLOR,
    statusNAME,
    statusTYPE
  } = req.body;
  let data = await db.findOne({ id: req.user.id });
    const cllient = new Client();
 >>>   await cllient.login(botTOKEN).catch(err=>{
    return res.send({ error: true, message: "The token is valed." });
})
return res.send({ error: true, message: "The token is invaled." });
})
solemn jolt
pale vessel
#

why did you remove the try catch

#

:/

civic scroll
#

headers hmmm

pale vessel
#

you just made this more complicated

civic scroll
#

modify headers error

solemn jolt
civic scroll
#

lemme take a look

solemn jolt
pale vessel
solemn jolt
#

i do it

#

look at it

pale vessel
#

that code is different

civic scroll
#

remove the return

#

just res.send

#

and that's it

pale vessel
#

it's not the return, res.send({ error: true, message: "The token is invaled." }); will still run regardless the token is valid or not

civic scroll
#

do not return a value

pale vessel
#

that causes the error

pale vessel
#

Actually, hmm

solemn jolt
#

im try now

civic scroll
#

flaz

solemn jolt
#

1 sec

pale vessel
#

Why is the token valid if it errors?

civic scroll
#

the code sent response twice

#

after the body is already sent, it returns a value again

pale vessel
#

yeah since the second res.send() is outside the catch/then

civic scroll
#

that's why it has header error

solemn jolt
#

i get eror again

civic scroll
pale vessel
#

yeah

solemn jolt
#

ok i well try this

civic scroll
#

actually

#

remove the async / await

pale vessel
civic scroll
#

using callbacks made that useless

#

if we use callbacks then we can safely delete the async / await keywords in this case

solemn jolt
#
app.post("/bot/create", global.checkAuth, async (req, res) => {
  const {
    botTOKEN,
    botID,
    ownerID,
    coowners,
    prefix,
    website,
    supportID,
    supportLOG,
    embedCOLOR,
    statusNAME,
    statusTYPE
  } = req.body;
  let data = await db.findOne({ id: req.user.id });
  const cllient = new Client();
  await cllient.login(botTOKEN)
    .then(() => res.send({ error: false, message: "The token is valed." })) // success
    .catch(() => res.send({ error: true, message: "The token is invaled." })); // error
})

i do this now im wait for deploy

civic scroll
#

that usage is useless

solemn jolt
#

ok

#

it work

#

thank you

civic scroll
#

@solemn jolt also grammar error
"valid" and "invalid"

solemn jolt
civic scroll
solemn jolt
earnest phoenix
#

Can I do this in a few lines? (functions...) ```js
db.add(silver_${message.author.id}, 1);
db.set(giantt_${message.author.id}, true);
db.set(archers_${message.author.id}, true);
db.set(minions_${message.author.id}, true);
db.set(arrows_${message.author.id}, true);
db.push(common_${message.author.id}, "Giant");
db.push(common_${message.author.id}, "Archers");
db.push(common_${message.author.id}, "Minions");
db.push(common_${message.author.id}, "Arrows");
db.add(cards_${message.author.id}, 4);
db.push(all_${message.author.id}, "Giant");
db.push(all_${message.author.id}, "Archers");
db.push(all_${message.author.id}, "Minions");
db.push(all_${message.author.id}, "Arrows");

db.set(deck1_${message.author.id}, "Giant")
db.set(deck2_${message.author.id}, "Archers")
db.set(deck3_${message.author.id}, "Minions")
db.set(deck4_${message.author.id}, "Arrows")

split hazel
#

you could do this all in one line if you really wanted to but you screwed up your database layout

earnest phoenix
#

db is deat

split hazel
#

but yeah you can make a function

earnest phoenix
#

example?

#

oh with forEach?

#

you can use example db.set(`deck_${message.author.id}', { giant: dataone, gianttwo: datatwo //and whatever })

#

yeah but I already made it like that...

#

dont db.push(`common_${message.author.id}`, "Giant"); db.push(`common_${message.author.id}`, "Archers"); db.push(`common_${message.author.id}`, "Minions"); db.push(`common_${message.author.id}`, "Arrows");

#

just use db.push(`common_${message.author.id}`, { giant: "Giant", archers: "Archers", minions: "Minions" })

#

like that

earnest phoenix
split hazel
#

honestly just rewrite it completely otherwise this is gonna plague you

#

delete the database and start over

earnest phoenix
#

yes

#

it would be better to arrange everything

#

If you are using SQLite, delete and recreate the db

split hazel
#
db.set(message.author.id, {
   decks: [
      ['giant', 'baby dragon', 'zap spell']
   ],
   arena: 2,
   xp: 1935
});```
something like that
raw nest
#

Does docker-compose automatically create a stack when building? Because I have 1 service with docker-compose and it automatically creates a stack... there's no explicit mention in the file for creating a stack..:/

boreal iron
earnest phoenix
#

¯_(ツ)_/¯

boreal iron
#

But it would make sense for to use one for this use case

split hazel
#

quickdb is good for small starter projects if you have no idea about databases

#

i like the idea of it i even used it in one of my bots with some modifications because its so simplistic and doesnt have you worry about stupid schemas

earnest phoenix
#

I recommend xen.db module

split hazel
#

and theres no unreliable database connection to a foreign server going on

earnest phoenix
boreal iron
#

"unreliable connection" pfff

split hazel
split hazel
#

they even use the same library

earnest phoenix
#

yea lmao

boreal iron
#

Unsuccessful requests gotta be cached and queued, Sir!

split hazel
#

and error spams

boreal iron
#

You’re doing something wrong then

#

I’m using my centralized database for many years now without issues except if I need to update/restart the server freerealestate

#

_Go and and concentrate on developing your OS instead of dealing with database connections _

split hazel
#

stupid

#

didnt ask for your experience

#

on a clustered server with multiple connections

#

sometimes mysql just shits itself and goes "bye bye" to the connection

#

redis despite the heavy load actually behaves itself

#

not one connection drop from redis

boreal iron
#

Also use MariaDB and OracleShitQL

earnest phoenix
#

shitQL

boreal iron
#

They at least try to fix issues

earnest phoenix
#

i like mariadb

boreal iron
split hazel
split hazel
boreal iron
#

Then suffer the consequences! spongery

split hazel
#

now fuck you

boreal iron
split hazel
#

im scared even thinking on how im gonna implement the usb driver

#

where tf do i start

#

theres this dickhead on the forum that loves usbs to the point where he wrote a book about them and made the book his pfp

#

so sad

#

and when i asked for some vague steps he said "there are none:) good luck"

boreal iron
split hazel
#

lmao he's like 40

boreal iron
#

Uhh the last one was unexpected

split hazel
#

all the people there that are active are grown men with wives and kids

#

like brain

#

the forum started before i was even born

boreal iron
#

Don’t forget his tortoises

#

Yee that reminds me of some comments on PHP net

#

Which existed before me and some are still helpful

split hazel
#

the php forum sounds even worse

#

most of these php forums are very old

boreal iron
#

I didn’t mention the word forum

split hazel
#

comments and net insinuate a forum

boreal iron
#

Ok go develop you USB driver!!!1!

split hazel
#

oh and on the os forum someone got angry and called an active member an "elitist forum troll"

#

the use of language there is amazing

boreal iron
#

lmao

#

Ok gotta do some things now…
Damn sun is shining into my eyes, can’t go on sleeping until bed time

earnest phoenix
#

Can anyone help me to move to postgreSQL from 0?

split hazel
#

what is 0

earnest phoenix
#

from zero

boreal iron
split hazel
#

am i not understanding something here

boreal iron
#

Go back to OS development if you can’t handle your life anymore KEKW

split hazel
#

😠

boreal iron
#

:P

#

I’m sorry I had a good amount of sleep

#

That usually doesn’t happen often

surreal sage
#

Here's a challenging question

If I had a set of rows & columns like this:

1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6

And a empty array

I want to push to that array like:

{
    col: 1,
    row: 1
}``` for each.
#

col 1
row 1

col 1
row 2

etc

sudden geyser
#

sounds like a matrix would be helpful

#

Or even just a line split

surreal sage
#

The whole thing starts with columns: 200, rows: 200

#

Oh wait

#

columns * rows

sudden geyser
#

So it becomes

[1 2 3 4 5 6]
[1 2 3 4 5 6]
[1 2 3 4 5 6]
[1 2 3 4 5 6]

And when you go to iterate over the arrays from top to bottom, you have your row, so you'll just iterate on that inner array for your column

surreal sage
#

for loop

#

dk

#

Lunch flyshed

surreal sage
#

Back to the same thing

#

It's so hard to explain

split hazel
#

real programmers do not take lunch breaks

#

they eat and code

wheat mesa
#

real real programmers eat mongodb collections off of the floor for lunch

sudden geyser
#

and the realest vomit it out right after

split hazel
#

thats called bulimia

sudden geyser
#

should've come with relations

raw nest
#

I have an express api which is only accessable via localhost and my app has a domain with SSL. But when I make a request I get CORS errors... but I can't put my api on https... help? 😅

modest maple
#

well what is your cors error?

raw nest
#

like how?

modest maple
#

ill take that as a no

raw nest
#

I just have app.use(cors());

#

yes I have that...

modest maple
#

scroll down

#

#readthroughthepagebeforecopypasting

raw nest
modest maple
#

have you actually read the "Configure Cors" sections mmLul

raw nest
#

The default config is *

modest maple
#

help

#

idk then

raw nest
#

#readthroughthewholepagebeforesayingsomething

modest maple
#

mmLul got me there

raw nest
#

xD but no problem man 🤝

modest maple
#

but then again I dont have CORS issues

raw nest
#

then you maybe have one more security leak than me

modest maple
#

Hey I just said i didnt have CORS issues not that I didnt have cors lul

#

but gl

#

thats a real JS moment

raw nest
#

xD it's alright, thanks tho

raw nest
sudden geyser
#

CORS is always a bitch

round cove
#

CORS with js is easy to handle if you're using express.

raw nest
round cove
#

Ah.

cosmic forum
#

Hello, does anyone happen to have a consistent algorithm for picking a random item from an array? (JavaScript)

split hazel
#

generating a random number between 0 and element count - 1

#

and using that as an index

cinder patio
#

Math.floor(Math.random() * arrayLen)

split hazel
#

if you want each item to be unique there are a couple ways of achieving that

#

either keeping track of already generated indexes or removing elements which can be quite slow

feral aspen
#
const { readdirSync } = require("fs");

module.exports = async bot => {// Slash Commands
    const commandsArray = [];

    const slashload = dirs => {
        const slashcommands = readdirSync(`./src/slashcommands/${dirs}/`).filter(d => d.endsWith('.js'));

        for (const file of slashcommands) {
            const slashpull = require(`../slashcommands/${dirs}/${file}`);
            bot.slashcommands.set(slashpull.config.name, slashpull);
            
            commandsArray.push(slashpull.config);
        };
    };

    bot.on("ready", () => bot.application.commands.set(commandsArray.flat()));
    ['bughunting', 'economy', 'fun', 'image', 'information', 'management', 'music', 'settings', 'social', 'utility'].forEach(x => slashload(x));
};

Am I doing something wrong as it is not setting the commands. I waited one hour, re-added the bot, yet still.

earnest phoenix
feral aspen
#

OHH.. that made sense.

#

My bad, thank you!!

earnest phoenix
#

You're welcome

spark flint
#

How would I make an anti raid bot with Discord.py? I’m trying to make a feature that checks how many users join at once, and prevents mass mention spam etc

earnest phoenix
split hazel
#

difficult to make a good detection system

#

should also add manual threshold configuration

spark flint
#

Yeah

split hazel
#

i would also suggest machine learning but you need lots of data for it to start figuring out decent values

#

such as taking into account the size of the server and rate of messages

spark flint
#

I have 2k user ids and evidence saved in one db and 5k+ in another

#

That could be enough KEKW

split hazel
#

not that kind of data

spark flint
#

Ah ok

split hazel
#

quite difficult to gather too

#

but yeah with a sufficient algorithm it will do a decent job

feral aspen
earnest phoenix
#

That can happen when both the global and guild commands diverge, it's better to keep one of them instead of both

boreal iron
#

This can also happen if you register commands multiple times, even if that “should” replace the old ones

earnest phoenix
#

They're not registered globally at all when you register them to a specific guild, it can be the cause of you registering them globally before without notice and then attempting to register them to a specific guild

#

No I literally register them to a guild and they still pop up globally

#

I've tested this before, never experienced that behavior, maybe you're doing something wrong probably registering them globally somewhere without notice then attempting to do that, registering slash-commands to a specific guild has an entire different endpoint than registering them globally for an application, that can be the cause

boreal iron
#

You did something wrong then

split hazel
#

how tf do you get assembly compilers and linkers onto windows

#

an os developer cant live without nasm and ld installed

spark flint
#
async function createuser(email, username, username, discriminator) {
    
}```
#

wait

#

fuck

#

ignore that, i'm stupid

cinder patio
#

ok

split hazel
#

ok

spark flint
#

yep its because i put username twice

split hazel
#

ok

#

theres probably a more serious issue underlying though

#

such as a skill issue

sudden geyser
#

what if we just

#

made usernames not unique or require combinations

earnest phoenix
#

what if people can have the same username just not discrims if a username with that discrim already exists

boreal iron
#

Wut?

#

English - skill issue pandasad

earnest phoenix
#

What is confusing about what I said

#

If username + discrim already exists (them as a pair) then another user can't have that username discrim pair they have to either choose a new discrim or a new username

boreal iron
#

Yes that’s how it works… and? freerealestate

sudden geyser
#

to disambiguate users

#

and also to leach money off people who want to set it to 9999

lyric mountain
#

discord discriminating wtf?

earnest phoenix
boreal iron
#

Most important stuff in 20212

earnest phoenix
#

If you dont have nitro in 2022 you lame

#

even tho mine is fixing to run out

boreal iron
#

I know I’m lame… I’m old you know

#

Is it just me or is my avatar different (again)?

#

Thought that old default logo got replaced with the new one?
Or is it just an issue on this phone?

sudden geyser
#

looks the same on my screen

slender wagon
#

ok so i am working on my vps and i am using pm2

#

whenever i try to run my bot with pm2 it throws an error of mongoose TextEncoder is not defined

#

but if i run the file manually it works just fine

boreal iron
sudden geyser
#

that's wack

winter pasture
#

Weird, seeing the new on on iPhone app, desktop web and Canary 🤷‍♂️

spark flint
#

same

boreal iron
#

Weird… it’s the discord app on iOS just on a different phone

#

Wtf

spark flint
#

but when i click its there

boreal iron
#

Hmm… that’s the issue with a client you can’t control

boreal iron
#

On a different phone it’s actually the current default style

#

Both discord app versions are the same

#

Most be some sort of caching issue then I can’t control on the mobile app

lyric mountain
wheat mesa
#

Doubt it, probably just a caching issue

boreal iron
#

Yee ignore the Brazilian men freerealestate

quartz kindle
#

fake 007

boreal iron
#

Oh no… another Brazilian men

quartz kindle
#

br br br huehuehuheuheuheu gibe me money please

boreal iron
#

I’m poor myself oldEyes

quartz kindle
#

i report you

earnest phoenix
#

What license makes it so you can't inspect element a chrome extension?

sudden geyser
#

none

earnest phoenix
#

Then how do I do it?

sudden geyser
#

you don't

earnest phoenix
#

?

sudden geyser
#

by license, I assume you mean permissions the user can do

#

like if they redistribute your software

earnest phoenix
#

Oh okay

#

I thought a specific one can make it so inspect element is disabled on the extension

#

If it's not in the license, how do I do it?

sudden geyser
#

You probably can't accomplish it even through an extension

#

or any settings (unless the user enables it, of course)

#

or any permissions/license

earnest phoenix
#

Weird, I thought I saw many extensions have it so they disabled inspect element on it

craggy pine
#

Why would something like

fs.readdir(`${__dirname}\\..\\commands\\

Goto the proper directory in windows but not linux?

Error: ENOENT: no such file or directory, scandir '/home/miyuka/Desktop/Nyu/src/library\..\commands\
Basically go up a directory from library into the folder "commands"

quartz kindle
#

because windows uses \

#

linux doesnt

pale vessel
#

Just use / on both, windows supports it

craggy pine
#

right linux uses / not \

earnest phoenix
#

you could use sep from path

#

it uses whatever separator from what operating system the code is being ran on

#

makes it easy for testing and production use so you dont gotta keep changing it

uneven scaffold
#

Hi, I just threw an ID in discord to confirm my bot. But do I need my bot open for my boot to be approved?

uneven scaffold
#

and how can i make dashboard on my bot or are you have simple template with bot

wanton walrus
#

My assumption is you would code the dashboard, and I would also assume that you would want the bot to be online for verification

#

I don't think anyone here or elsewhere would just magically decide to give you a cut and paste web dashboard that connects to your bot

lament rock
#

anyone know any obscure UnityCS optimization tips?

earnest phoenix
#

dont be yanderedev Im kidding, I hope you enjoy messing with unity tho :)

lament rock
#

Ofc

#

No absurd if chains

earnest phoenix
#

lol

#

Also, pretty sure updating everything in the Update method is not a good idea

#

At least not how he was doing shit, which is one of the reasons the game lagged at 1fps no matter how good ur pc was mmLol

lament rock
#

Just recently started making use of caching some calculations and GetComponent<T> calls on methods that get called more than once.
Big bump, but looking for some micro optimizations since I need to hit a 90fps target

earnest phoenix
#

Mmm well I haven't used unity that much so I can't really give you any tips, but I do hope you enjoy it

lament rock
#

Enjoy is a stretch of the imagination as is with any language

earnest phoenix
#

If you end up making a game i'll gladly play it :p

lament rock
#

Nothing serious. Just games within a game

earnest phoenix
#

My first game with unity was a cube maze

earnest phoenix
lament rock
#

Not roblox tho since roblox is lua

#

and not unity

#

but sure

earnest phoenix
#

It was a joke

#

I like the concept tho

#

I do wonder how roblox made it possible to make all those games tho 🤔

#

They obv used lua but that can't be the only thing

#

Like I wonder how they made the launcher and roblox studio.

lament rock
#

Their game engine is pretty strong for being based on lua, but it's their own lua iirc where they made some optimizations

earnest phoenix
#

Its luau yea

#

But I am curious if the launcher is also made in lua

#

if so I didn't know you could use lua like that

lament rock
#

Unlikely. Probably a native app or even an electron app since it's easier to just embed a webpage into a container

#

The launcher's performance isn't fantastic, so I'd be willing to bet it's in electron

earnest phoenix
#

Mmm yea

#

So if that is the case, then all the games are basically just webpages

lament rock
#

I'm just pulling shit out of my ass. I know nothing

earnest phoenix
#

Well yes

#

But it does make some sense

pale vessel
#

flex 💪

#

justify-content: center

slender thistle
#

Apply the centering to the container element and make sure its width is... wider than its children

cold sparrow
#

can anyone help me with lavalink?

drifting coral
#

i have this error coming on the terminal from the past 8 hours

crude oar
drifting coral
#

It’s been almost 9 hours

#

What can I do to get it fixed

crude oar
#

@drifting coralcontact to that web owner

#

😂

modest maple
frosty valve
#

what api version does discord.js v12 use?

modest maple
#

probably v8 at best

frosty valve
#

and that isnt shutdown yet?

#

cause I am getting 404's from /users

#

oh nvm. Figured it out

earnest phoenix
#

upgrade to detritus or v13 🙏

frosty valve
#

well, its an outdated handler. ¯_(ツ)_/¯

proper goblet
#

can a webhook trigger a bot command (discordpy)?

earnest phoenix
proper goblet
#

ok

#

so i have to use on message event right?

earnest phoenix
#

if you use commands with a prefix such as ;ping maybe you can do smth

proper goblet
proper goblet
#

my code:
prefix : a.

@bot.command()
async def ping(ctx):
    await ctx.send('Pong')```
earnest phoenix
#

i don't use python

proper goblet
#

ok

earnest phoenix
#

perhaps you're blocking bots from using the commands

#

(webhooks are technically bot users)

earnest phoenix
#

wdym appends sideways

#

the image is rotated?

#

screenshot pls

#

wait i think i see the problem

#

the flex-direction is row by default

#
flex-direction: column;

will make it append at the bottom

earnest phoenix
#

What kind of host would one need for an OCR discord bot?

split hazel
#

what is an ocr bot

earnest phoenix
#

I don't plan on using an API. But if I find a good one I might

split hazel
#

I would say anything basic would work

#

there are also libraries which do this for you and they're not very heavy

earnest phoenix
#

Oh okay

split hazel
#

pov you're under the age of 15 making your first discord bots

wheat mesa
#

POV you didn’t read the OR MORE after the 1 week message pinned in #support

earnest phoenix
#

POV it is multi purpose bot

tawdry oracle
#

How can i cluster a djs bot? i dont know much about clusters in bots

split hazel
#

asking that question most definitely means you dont need it

#

but it depends what approach you want to take

tawdry oracle
#

i think i need it, thats why im asking here first

modest maple
#

mmm Doubt

tawdry oracle
#

When shoud i start to cluster then?

#

im at 340k

modest maple
#

guilds?

tawdry oracle
#

yup

modest maple
#

which bot?

tawdry oracle
#

not mine, im working in passing it to java and we are slow, the bot needs other way to distribute work thru cores in typescript, is called kena

compact pier
#

anyone know why componen doesn't change after the state is changed?

split hazel
#

i'll take your word for it

#

so is the bot written in typescript or java

modest maple
#

What does the bot do?

tawdry oracle
#

will be in java soon, but we need to cluster it in typescript

split hazel
#

you generally cluster the bot in the same language you made it in

modest maple
#

I think they mean they're rewriting to java

#

but atm it's in typescript

tawdry oracle
#

yup

split hazel
#

in that case clustering depends on the language and the support that discord library has

tawdry oracle
#

its using djs@latest and typescript

split hazel
#

there arent any great clustering modules for discord.js but i did see some new ones pop up

tawdry oracle
split hazel
#

kurasuta sucks

#

its very buggy and no longer supported

#

at your supposed scale i would recommend you write your own clustering library but java might have some ones available

tawdry oracle
split hazel
#

well clustering isnt a popular task

#

most bots that need clustering write their own library

tawdry oracle
#

true

split hazel
#

and there arent many of those

#

what are you rewriting it in

#

jda?

tawdry oracle
#

yup

#

its a little bit of a pain but we are a big team

modest maple
#

Litterally never heart of kena or why you need a big team but err, generally it's just a case of spining up kubernetes and some stateful sets and just declaring clusters that way

tawdry oracle
#

Well thank you both! i will ty it all

split hazel
#

kubernetes scales automatically right

#

but the shard count generally needs to remain constant

modest maple
earnest phoenix
#

its for your ts version

compact pier
#

How i can wait for every step 1 second?

cinder patio
#

you need to await the swap function call

compact pier
#

but after the first loop

#

it just stop

sharp saddle
#

someone help me with Reactjs?

sudden geyser
#

don't ask to ask please

#

just ask 🙌

sharp saddle
#

ok

#

lmao

#

im trying loop a json object... but is not working

#

code class Dashboard extends React.Component { constructor() { this.radios = data.radio } render() { return( <> {data.radio.map((r, i) => { return(<> <div data-index={i}> <p>{r.name}</p> </div> </>) })} </> ) } }

sudden geyser
#

Well in your constructor you're setting this.radios to data.radios

#

But we don't know where data is coming from

#

You'd use the value you assigned in your render method

#

So you shouldn't be using data.radios, but rather this.radios

#

As that's what you've saved for the class instance.

#

Though, the inner fragment (<>) is concerning

sharp saddle
#
import data from './json/radios.json'```
sudden geyser
#

Can you really import JSON like that?

#

Normally you'd read and parse a file like that

sharp saddle
#

idk

#

now works :D

fresh shoal
#

plz

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

quartz kindle
#

wat

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

quartz kindle
#

you have to import dicksword

sage bobcat
#

One message removed from a suspended account.

quartz kindle
#

import "dicksword"

#

or if god has abandoned you, then you have to explicitly import it from god

#

import "dicksword" from "god"

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

quartz kindle
#

tfw https://dickswordapp.com/ is actually a thing

sage bobcat
#

One message removed from a suspended account.

spark flint
#

its a discord bot so idk why its deciding to look at Microsoft.ZuneVideo

split hazel
#

probably telling you you arent using some optional extensions or something

spark flint
#

oh ok

lament rock
#

Zune Video and Zune Music are the internal names of the built in video player and music player in Windows respectively

spark flint
#
output.forEach(entry => {
  const member = message.guild.members.cache.get(entry.user)
  embed.addField(`${loopNum}.`, `${member.user.username}#${member.user.discriminator} (Level ${entry.level})`)
  loopNum++
})
sudden geyser
#

Just so you know, forEach passes a second parameter of the index

spark flint
#

wdym

sudden geyser
#

Anyway, is the error coming from entry.user or member.user

spark flint
#

well i logged member

#
GuildMember {
  guild: <ref *1> Guild {
    id: '822979643589787688',
    name: 'Jessicord',
    icon: '124e1fac8737a6d73dc1f10bcc8d236a',
    features: [ 'THREADS_ENABLED_TESTING' ],
    commands: GuildApplicationCommandManager {
      permissions: [ApplicationCommandPermissionsManager],
      guild: [Circular *1]
    },
    members: GuildMemberManager { guild: [Circular *1] },
    channels: GuildChannelManager { guild: [Circular *1] },
    bans: GuildBanManager { guild: [Circular *1] },
    roles: RoleManager { guild: [Circular *1] },
    presences: PresenceManager {},
    voiceStates: VoiceStateManager { guild: [Circular *1] },
    stageInstances: StageInstanceManager { guild: [Circular *1] },
    invites: GuildInviteManager { guild: [Circular *1] },
    scheduledEvents: GuildScheduledEventManager { guild: [Circular *1] },
    available: true,
    shardId: 0,
    splash: null,
    banner: null,
    description: null,
    verificationLevel: 'LOW',
    vanityURLCode: null,
    nsfwLevel: 'DEFAULT',
    discoverySplash: null,
    memberCount: 5,
    large: false,
    premiumProgressBarEnabled: false,
    applicationId: null,
    afkTimeout: 300,
    afkChannelId: null,
    systemChannelId: null,
    premiumTier: 'NONE',
    premiumSubscriptionCount: 0,
    explicitContentFilter: 'DISABLED',
    mfaLevel: 'NONE',
    joinedTimestamp: 1638229505447,
    defaultMessageNotifications: 'ONLY_MENTIONS',
    systemChannelFlags: SystemChannelFlags { bitfield: 0 },
    maximumMembers: 250000,
    maximumPresences: null,
    approximateMemberCount: null,
    approximatePresenceCount: null,
    vanityURLUses: null,
    rulesChannelId: null,
    publicUpdatesChannelId: null,
    preferredLocale: 'en-US',
    ownerId: '768615938055471116',
    emojis: GuildEmojiManager { guild: [Circular *1] },
    stickers: GuildStickerManager { guild: [Circular *1] }
  },
  joinedTimestamp: 1641091823125,
  premiumSinceTimestamp: null,
  nickname: null,
  pending: false,
  communicationDisabledUntilTimestamp: null,
  _roles: [ '833147140683202560' ],
  user: User {
    id: '471409054594498561',
    bot: false,
    system: false,
    flags: UserFlags { bitfield: 64 },
    username: 'big.bun',
    discriminator: '6969',
    avatar: 'a_54d448ed90a8f64758d5507c49761e58',
    banner: undefined,
    accentColor: undefined
  },
  avatar: null
}```
sudden geyser
#

Well, there's a user, so maybe it's entry

spark flint
#

entry.user returns user id

sudden geyser
#

That's interesting. The error says otherwise, however, so it does concern some undefined value.

sharp saddle
#

what is wrong?

don't return nothing.

{this.data.radio.map((r, i) => {
       if(this.id === r.id) {
       return(<>
       <Link to={"/app/player/" + r.id}>
       <img id="radio" src={r.img} width="100"/>
       <div class="overlay"><div class="text">
        <FA name="play" />
       </div></div>
       </Link>
       </>)
       }
     })}```
sharp saddle
#

all page

spark flint
#

works for me

#

clear cache

sharp saddle
#

...

#

in my website?

spark flint
sharp saddle
#

what the heck

spark flint
#

clear cache

sharp saddle
#

oh yeah...

#

shit

#

but...

#

@spark flint

lethal hare
#

hi folks, im getting ready to switch my bot to using slash commands, what would be the best way to go about it?

#

its on quite a lot of servers and i dont want people to be confused

wheat mesa
# spark flint wdym

Btw he’s saying that you don’t have to have a loop counter, since forEach passes the value and the index of the value of whatever you’re iterating over

#

things.forEach((thing, index) => ...

spark flint
#

loopNum is unrelated btw

wheat mesa
#

Oh

#

Doesn’t entirely seem like it since you use it in your forEach loop

#

But I suppose if you need it to be incremented for later use that makes sense

boreal iron
#

Not before asking a related question...

cold sparrow
#

can anyone help me with lavalink?

boreal iron
earnest phoenix
#

Is it possible to fetch all the users in a role and only show the ones who are online (online)

#

Ik how to fetch all the users in a role, but can you make it so they only show if they're online?

boreal iron
#

I assume this requires the privileged presence intent

#

But sure, why not...

#

<guild member>.presence.status

#

I mean... I would call both online and dnd as online

earnest phoenix
#

They want all online members in that role

#

Filtering is probably what you'd wanna do

boreal iron
#

spoonfeeding

#

is what we don't do

earnest phoenix
#

How the hell is that spoonfeeding

#

All you need to do is tell them to use a filter

boreal iron
#

That's the logical consequence after reading what I wrote, yeah

earnest phoenix
#

What if they didn't know filtering was possible

#

You can be helpful while not telling them exactly what to do at the same time

boreal iron
#

Instead of arguing and guessing wildly wait until he responds.

earnest phoenix
boreal iron
#

I mean feel free to create the filter snipped for him then...

earnest phoenix
#

I wasn't saying make code for him, but telling them that a filter would be a good option to use here is very helpful then just telling them how to get the status

#

That at least gives them something to google to figure out on their own

#

Hi i need help for my discord bot.
I would like to make command say with url, sample:

Ezermoz:
?sayurl

My bot:
https://boturl.xxx/say/the text

I make this with :
req.params.tagid but when i put "\n" or other caracthere they dont work

Module used : express, quick.db, discord.js

boreal iron
#

what? You wanna add the command parameters the user enters to an URL or..?

#

say whatever is the text to https://boturl.com/say/whatever/is/the/text

#

?

lament rock
#

Very ambiguous

boreal iron
#

You gotta split your parameters then and use join() to them to your URL
In other words replacing any sort of whitespaces by a /

#

The result should be URL encoded if special chars can be used

#

If not removing them with a regex filter

boreal iron
#

*replace them

earnest phoenix
#

because I don't really understand

#

But your solutions is good

boreal iron
#

const query_string = <content the user enters>.split(/\s+/g).join("/");

Concat query_string to your URL after

boreal iron
#

Wtf where did my quotes go waitWhat

#

That does not replace special chars

#

You need to URL encode the query_string if required

split hazel
earnest phoenix
boreal iron
#

encodeURI(query_string);

#

And you need to learn the basics of JavaScript

earnest phoenix
#

😭 🤣

#

Iam not pro

#

Sorry

boreal iron
#

Those are basics of the language tbh

earnest phoenix
#

Yeees😳

boreal iron
#

As I said if the user is not allowed to use special chars you need to remove them then

#

May I ask you what’s the reason to add random content the user enters to your URL?

#

just to know

earnest phoenix
#

Idk

#

I test

boreal iron
#

Alright

split hazel
boreal iron
#

spam - ban - kthxbb

#

Fuck Nitro

sudden geyser
#

quit staring at me

proven lantern
#

how would i do the math to find out how many combinations there are for a 5v5 match? i dont think this is right

sudden geyser
#

5!

proven lantern
#

is that it?

#

very close to 126

#

120

#

hmmm

sudden geyser
#

It's shorthand for 5 * 4 * 3 * 2 * 1

proven lantern
#

finding the combination count uses factorial

#

its something like
n!/total!

sudden geyser
#

confuzzled

#

5! is the total amount of combinations there could be

#

So wouldn't that be your answer?

#

Like how 3! only has 6 possible combinations

proven lantern
#

i found this

#

n! / r! * (n - r)!

#

weird

#

i think that's what the choose function does

#

but choosing a 5v5 out of 10 is different than choosing 5 out of 10

#
vs
player6, player7, player8, player9, player10```
would be the same as

```player6, player7, player8, player9, player10
vs
player1, player2, player3, player4, player5  ```
so i think it's divided by 2
lyric mountain
sudden geyser
#

for combinations ! is usually wanted

lyric mountain
#

ye

sudden geyser
#

applied math was worth this moment

proven lantern
# proven lantern

i think the division of factorials removes duplicates that you dont want counted

#

5! is permutations right?

proven lantern
sudden geyser
#

then give it set behaviors

#

so the order of a collection doesn't matter

proven lantern
#

all possible different teams that could be made from a 5v5 match

lyric mountain
#

idk if other languages have that, but at least in java u can have lists with different orders be equal to each other

#

as long as the content is the same

proven lantern
#

those are Sets right?>

#

idk

sudden geyser
#

js has them btw

proven lantern
#

i just want a math function

lyric mountain
#

just generate a hashcode from all objects within it

sudden geyser
#

but why support that

#

lists are ordered usually

lyric mountain
#

cuz order shouldn't matter, content is more important

#

that said, there are also ways to check order + content

sudden geyser
#

that's weird

lyric mountain
#

black text + black bg = nono

proven lantern
#

yeah

#

i'm testing your monitors

split hazel
#

all those equations but not one bitch

proven lantern
#

wouldn't it be combinations divided by 2 to get possible teams?

boreal iron
proven lantern
#

i dont even have the equations

#

i'm trying to find out the equation to find the number of possible team pairings for a 5v5 match

earnest phoenix
#

Looks complicated

boreal iron
#

5v5 match - 25 combinations

#

But you’re probably speaking about something completely different, right?

proven lantern
#

maybe, idk

#

is n squared your formula?

wheat mesa
#

What you’re looking for is a permutation, unless order of your teams matter

boreal iron
#

I literally have no clue what you’re actually talking about

wheat mesa
#

Combination takes into account order

#

Permutations don’t

proven lantern
#

ohhh

#

i had that backwards

boreal iron
#

Just combinations by factors n

#

?

proven lantern
#

i need caffeine

wheat mesa
#

Oh wait

#

I got it backwards

proven lantern
#

mmkay

#

i still need caffeine

wheat mesa
#

Been awhile since I did this stuff in school

#

My memory isn’t great mmulu

boreal iron
#

How many combinations has the alphabet (26) with a factor of 2 n letters, which would be 26x26 …
Is that what you need?

#

If n would be 3, it would be 26x26x26 or 26^3

proven lantern
#

i'm looking for how many unique sets of 13 by 13 letters could you make

boreal iron
#

Without repeating combinations it would be 26x25x24

#

13 digits longs out of just 13 letters?

proven lantern
#

13 letters want to make a team to fight 13 other letters, but those letters cant form the same team and fight the same other team again.

boreal iron
#

That would be 13^13 if I understand you right

proven lantern
#

that seems too high

boreal iron
#

Combining 2 possible letters with each other out of 13 letters would be 13x13 or 13^2

proven lantern
#

only teams of 13 are valid

#

13v13

#

or 5v5

boreal iron
#

We must be speaking about 2 different things

#

Or you speak Spanish which I do not freerealestate

proven lantern
#

let's say you have 10 people playing a game that has 2 teams

#

that would be a 5v5

boreal iron
#

Yeah

proven lantern
#

how many different match offs could you do before you needed to do the same match off. ie the same team is matched off against the same other team

boreal iron
#

In theory at 1st 5 then 4 then 3 then 2 then 1

#

So 5x4x3x2x1

proven lantern
#

but that grows too fast

#

maybe that's right

#

i need to wake up more

boreal iron
#

Without doing the same match again it’s what I wrote above if I understood anything correctly

#

With repeating matches it would be 5^5

proven lantern
#

yep, without the same match. and if one team has been on team A against another team on team B then they wont face off again as team B vs team A

boreal iron
#

Oh that’s what you mean, like a winning tree

#

Dunno the exact word in en for it

proven lantern
#

yea

#

me neither

boreal iron
#

Something like that?

#

Oh no

#

That’s winner vs winner

#

My bad

proven lantern
#

there is a loser bracket too

boreal iron
#

It has

proven lantern
#

but i still think that misses some combinations

boreal iron
#

It’s just not on the screenshot

proven lantern
#

there would need to be a new loser bracket created for every round

#

maybe

boreal iron
proven lantern
#

hey

boreal iron
#

But that would be something totally different to what you explained KEKW

#

Or at least what I understood

proven lantern
#

but these are fixed teams of 2

boreal iron
#

It’s just an example I found lol

#

To make sure we’re actually talking about the same shit

proven lantern
#

why is math so tricky

boreal iron
#

m__e__th

#

Fuck markdown

proven lantern
#

maths

#

all the maths

boreal iron
#

Why tf doesn’t this work

#

m_e_th

#

works here

#

W__t__f

#

Yes… fuck markdown for real

boreal iron
# proven lantern why is math so tricky

You literally moved from 5v5 games which would be 5 games for each team to combinations to something different when you started speaking about to include looser brackets etc.

#

That’s a wild transition

proven lantern
#

i was trying to tie that back to what i was talking about

boreal iron
#

If nothing helps, take a pencil, draw it on a paper and you will may see how it is

#

no jokes

proven lantern
#

10 choose 5 gets me the number of unique teams of 5 that can be made from 10 players

#

but those teams need to be on opposing sides so i should take this and divide by two

#

that's my best guess now

boreal iron
#

So not games anymore…
The number of teams (5player in one team) 10 players can do?

proven lantern
#

step one is to find all unique teams

#

or maybe it's not needed to find it idk

fallen holly
#

i'm connecting my bot to mongoose db Will everything i do will get stored in the db cus i’m only doing it just for ranking and maybe couple other thing

fair axle
#

How can I do this with .map() function?

const list = ["a", "b"]

Expected Output: [{"a": 1, "b": 1}]
proven lantern
proven lantern
#

you cant do that with map, you need reduce

#
["a", "b"].reduce((acc, l) => ({...acc, [l]:1}), {})
sudden geyser
#

It's weird that the output has to be an array wrapping the object has the actual work applied

boreal iron
#

Which is totally nonsense but possible KEKW

proven lantern
#

this works too js ["a", "b"].map((l,i,a) => a.reduce((acc, l) => ({...acc, [l]:1}), {}))[0]

#

but

#

idk it's hacks

#

just use reduce in the first place

boreal iron
#

Im sure it can be shorter than what I wrote

#

Just but parsing the template string directly

proven lantern
#

that still makes an array of maps instead of one map object with all the keys

#

array -> map

boreal iron
#

There we go

#

const array1 = [1, 4, 9, 16]; const map1 = array1.map(x => JSON.parse({"a":${x}})); console.log(map1);

proven lantern
#

im not sure what's happening there

#

but map function returns an array

boreal iron
#

Isn’t that what he wants?

#

A map filled with objects?

sudden geyser
boreal iron
#

Test which one is faster, I bet mine is

#

As it creates one array only

proven lantern
#

one map with all the keys

#
const list = ["a", "b"]

Expected Output: [{"a": 1, "b": 1}]```
boreal iron
#

Oh the keys are his array items

#

I didn’t got that one

#

But still only requires a small change of my code

sudden geyser
proven lantern
#
const arrayWithOneMap = [["a", "b"].reduce((acc, l) => ({...acc, [l]:1}), {})];```
boreal iron
#

Hold on

boreal iron
#

Be careful before blaming me

sudden geyser
#

faster

#

but the first one I tested would've been faster if you passed the function rather than an anonymous function wrapping it

#

aka instead of .map(x => JSON.parse(x)), do .map(JSON.parse)

boreal iron
#

Shh I’m driving… let’s be realistic

#

I’m faster than Ben

#

That’s all what matters

proven lantern
#

hey

#

it doesn't have the right output though

#

so it get the wrong answer quickly

#

nice

boreal iron
#

My gosh

#

But still only requires a small change of my code

proven lantern
#

i'm not doing it

boreal iron
#

const array1 = [1, 4, 9, 16];
const map1 = array1.map(x => JSON.parse(`{"${x}}": "1"`));
#

There’s you little change

wheat mesa
#

my question is why would you even make a design like this in the first place notlikenoot

proven lantern
#

it's good for taking a list of user ids and turning that into a map

#

then you have a map which is faster than an array

proven lantern
proven lantern
#

it's a good pattern

wheat mesa
#

...maps are faster than arrays?

#

Since when

proven lantern
#
array.find(a=>a.name === "me")
map["me"]```
lyric mountain
#

Maps are always O(1)

sudden geyser
#

I'd rather use an update key function.

Object.keys(playerIds.reduce(assoc));
wheat mesa
#

I haven’t really done too much with time complexity, my brain was stuck on ooga booga c++ performance

#

Forgot that in js everything is an object

proven lantern
#

isn't java the same

lyric mountain
#

Java has primitives

proven lantern
#

Object is the parent

#

oh yea

#

and they made those wrappers

lyric mountain
#

Yep

proven lantern
#

int vs Integer

wheat mesa
#

Other than that everything is an object in Java too pretty much afaik

lyric mountain
#

Chad superior objects vs sussy orphan types

wheat mesa
#

I like the c# approach where “primitives” are technically structs and therefore have methods

#

Always found primitives kind of annoying in Java (specifically when dealing with generics)

lyric mountain
#

You get used to it

#

In c# they're wrapped basically, so that's why they work

wheat mesa
#

Yeah