#development

1 messages · Page 2004 of 1

elder wolf
#

I had to rush it because I have classes

#

well

#

that’s funny

#

im not experienced

bright hornet
#

https://sourceb.in/8ZnxdCLNWP Why i keep getting this error? I dont see any $ just one in $push

FieldPath field names may not start with '$'. Consider using $getField or $setField.```
elder wolf
#

i learned on the fly

earnest phoenix
#

mongodb is good for beginners but pg is still better

#

kthxbai

elder wolf
#

mm

#

hm

#

wait how do you guys have time for coding

#

oh

slender thistle
#

More or less it is

earnest phoenix
#

Do you think we have lives?

elder wolf
#

i have one too

earnest phoenix
#

doubt

slender thistle
#

Public bots are a hassle to get working properly with repl.it though

elder wolf
#

my English and history went down to like below 90%

#

And I need to fix that

near stratus
#

life on discord doesn't count

earnest phoenix
#

ok mine is at F

elder wolf
#

well my math and science is still 100% tho

slender thistle
elder wolf
#

why is it that anything science related is like

#

I’m doing good at it

near stratus
#

UwU
Gimme your brain

elder wolf
#

just buy salt

#

and eat more salt

#

Live off of salt @earnest phoenix

#

no u

#

no homo

#

wait not no u

#

because that means…

#

ok no u

#

I mean

#

no homo

#

not like

#

-up

#

ok

#

hm

near stratus
#

UwU

elder wolf
#

valid

#

or invalid

#

English is such a pain

#

math is great

#

English is painful

#

History

#

is

#

so

#

annoying

near stratus
#

UwU I'm a gurl
don't be rude

near stratus
#

........

civic scroll
#

stfu

elder wolf
#

America

#

but I’m Taiwanese

near stratus
#

oh

elder wolf
#

Would it be smart to like

#

find someone to code with me

civic scroll
#

also any workaround for browser api on SSG configuration

elder wolf
#

or just do it myself

civic scroll
#

or any way to know when the browser apis are available

near stratus
elder wolf
#

14 year old child with 1 month of experience coding a rpg discord bot for 1 month and burn out at the end

elder wolf
#

I’m not kidding

#

I actually tried to teach her how to code

civic scroll
elder wolf
#

uhhh… she isn’t interested in that

civic scroll
elder wolf
#

My dad threw a popcorn bag at me

#

he walked into my room

#

and threw it at me

#

dang….

civic scroll
#

the thing is

#

find motives

elder wolf
#
  1. I enjoy coding
#
  1. I want to make the bot
civic scroll
#
  1. ideas
elder wolf
#

yes

#

then u try mine

#

👍

near stratus
elder wolf
#

Huh

civic scroll
#

until xiuh and xetera

#

ANYWHO how do i know when browser loads so that its APIs are available

elder wolf
#

mm

near stratus
elder wolf
#

ur mom’s trans

civic scroll
near stratus
#

which one?

elder wolf
#

Seaman

earnest phoenix
civic scroll
#

i'm a girl too :)

#

but that has nothing to do with when browser apis are available

near stratus
civic scroll
#

is there a specific event like DOMContentLoaded

#

or

#

anything like that

#

requests takes unprecedented time

#

funni

elder wolf
#

Mm

near stratus
civic scroll
#

then i want to listen to this passively

civic scroll
elder wolf
#

@near stratus are u female

#

because if u are

#

Then I can’t ask u

civic scroll
#

that's when browser api are available

elder wolf
#

to go test the bot

#

but if your a man

#

the I can

#

then*

near stratus
elder wolf
#

alright

#

wanna go test it out

#

👍

civic scroll
#

that means the javascript is available then

#

right

near stratus
elder wolf
#

ok

#

can I send links

#

In general

#

Or no

#

is that not allowed

#

i mean

#

This channel

near stratus
civic scroll
#

@earnest phoenix that event is browser only right

civic scroll
#

i need local storage

#

wew

#

alright thanks what

elder wolf
#

is it bad that I’m coding with no experience

#

my dad tells me I’m random coding

civic scroll
elder wolf
#

but at the end of the day, it still works

near stratus
slender thistle
#

So long as you learn something

civic scroll
#

you make actual stuffs and learn how it works

elder wolf
#

I did!

civic scroll
elder wolf
#

coding?

woeful pike
elder wolf
#

building?

civic scroll
#

no

elder wolf
#

programming?

#

same thing?

civic scroll
#

designing the whole stuff

#

coding is just typing

#

no brain required

blissful coral
#

eh

civic scroll
#

momorising syntaxes ain't gonna help you in anything viable

near stratus
elder wolf
#

uh I did design it before I started

woeful pike
#

architecture is just drawing houses

#

no brain required

blissful coral
#

this

woeful pike
simple stump
#

Weird question but if I use fs to create a read/write stream, is it possible to check if the file has like a weird virus or is valid or smth. Sorry it’s a weird question but just hypothetically lmao

civic scroll
woeful pike
#

your issue is probably with the DOM not loading not browser apis

#

I meant which browser api

civic scroll
#

localStorage

#

i use that to get initial configs

woeful pike
#

localStorage is accessible as soon as your script loads

civic scroll
#

on SSG config, it's not

#

as the document is rendered on server

woeful pike
#

ok so you want to execute a script dynamically then

#

are you using nextjs?

civic scroll
#

angular HellaKek

#

alright assume i use nextjs

#

what's next

#

if i think about that, i also got thr issue when i tried to include local storage api there

woeful pike
#

you can use <Script /> to inject code before your react tree is loaded

#

which will check localStorage

civic scroll
#

"if not exists then don't call" right

simple stump
#

Okay ty.

civic scroll
#

i don't want to continously polling it

#

eg theme

#

like i don't wanna flashbang

woeful pike
#

why would you need to poll the theme

plucky imp
#

pogg

#

just finished

#

also hi xet @woeful pike i missed you too <3

bright hornet
#

what is the main problem of this?

austere surge
#

it didnt respond christmasthink

bright hornet
#

main cause?

#

on event or command?

slender thistle
#

Didn't respond in 3 seconds

plucky imp
#

somewhere

#

i had the error too

#

literally

bright hornet
#

on the event?

plucky imp
#

no

#

check your index

#

might not be loading the command properly

#

or just console log it

#
console.log(interaction.commandName, client.commands);
#

worked for me

bright hornet
#

ok ok ill try

plucky imp
#

you should see something like

#

in your console

#

iirc

bright hornet
plucky imp
#

because you aren't pulling it correctly

#

show ping command file

bright hornet
plucky imp
#

ahhhh

#

do you have intents on lol

bright hornet
#

yap

plucky imp
#

no these

bright hornet
#

aaaaaaaa

#

yep

plucky imp
#

do you have the client.commands enabled for the invite link?

bright hornet
#

yup yup

plucky imp
#

did you reinvite the bot with the

bright hornet
#

yep

plucky imp
#

ah wait

#

show index rq

bright hornet
#
const { Client, Intents, Collection } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES]});
const fs = require('fs')

client.commands = new Collection();


require('dotenv').config()

const functions = fs.readdirSync("./src/functions").filter(file => file.endsWith('.js'));
const eventFiles = fs.readdirSync("./src/events").filter(file => file.endsWith('.js'));
const commandFolders = fs.readdirSync("./src/commands");

(async () => {
    for(file of functions) {
        require(`./src/functions/${file}`)(client)
    }
    client.handleEvents(eventFiles, "./src/events");
    client.handleCommands(commandFolders, "./src/commands")
    client.login(process.env.token)

    console.log(commandFolders, client.commands);
})();```
plucky imp
#

ahH

#

when using a cmd handler you want to save the cmds to a db

#

so for me i use

#
client.db = new Database();
client.commands = new Collection();
#

you only have the command setup like that if you have the event's still in the index iirc

#

do you have a interactionCreate folder?

#

or file

bright hornet
#

yes

plucky imp
#

show it to me rq

bright hornet
#

i think

#

I missed type something

plucky imp
#

try

#
async execute(client, interaction) {
    console.log(interaction.commandName, client.commands);


    if (!interaction.isCommand()) return;

    const command = client.commands.get(interaction.commandName);

    if (command === undefined) return;

    try {
      await command.execute(client, interaction);
    } catch (err) {
      console.error(
        `An error occured while executing the '${interaction.commandName}' command:`,
        err
      );
    }
  }
};
#

instead

#

i added the console log for you

bright hornet
#

its the same-

plucky imp
#

h m

bright hornet
#

this is why i dont like to join slash command

#

kidding

#

wanna learn more

#

XD

plucky imp
#

lol same im just getting into it

#

try uh

opal jay
#

hi

plucky imp
#

they have problem with slash commanD

bright hornet
#

HOLY SHIT

plucky imp
#

wass

#

i m

#

bruh

bright hornet
#

BRAH

#

OMFG

plucky imp
#

my brain just died

#

@opal jay nvm ty qt CB_heart_bounce

#

wass solved it lol

opal jay
#

:no-nitro

bright hornet
#

@earnest phoenix thanks mate

slender thistle
#

Lol this was a good laugh

opal jay
#

thats why i like to use typescript

plucky imp
#

tbh

#

@bright hornet install eslint to vsc

bright hornet
#

mygod

slender thistle
#

Just use a language where you can simply declare a public function

plucky imp
#

js is shit without eslint

#

cause eslint actually gives it formatting

#

and helps with miss types

#

jslint is depreciated

bright hornet
#

oh wait

#

still not

plucky imp
#

it only gives errors

slender thistle
#

JS is shit [...]
I agree

bright hornet
#

ah wait

#

error shows up

plucky imp
#

show error

bright hornet
#

alright bye for a moment

plucky imp
#

so i can laugh at wass

bright hornet
#
interaction.isCommand is not a function``` just some mistake coding i guess
slender thistle
#

Ho boy

plucky imp
#

probably cs wth

slender thistle
#

Is that even a method for interactions in d.js

plucky imp
#

it literally is

#

lol

slender thistle
#

I see

bright hornet
#
commandFolders is not iterable```

```js
module.exports = (client) => {
    client.handleCommands = async (commandFolders, path) => {
        client.commandArray = [];
        for (folder of commandFolders) {
            const commandFiles = fs.readdirSync(`${path}/${folder}`).filter(file => file.endsWith('.js'))
            for (const file of commandFiles) {
                const command = require(`../commands/${folder}/${file}`);
                client.commands.set(command.data.name, command);
                client.commandArray.push(command.data.toJSON());
            }
        }

        const rest = new REST({
            version: '9'
        }).setToken(process.env.token);

        (async () => {
            try {
                console.log('Started refreshing application (/) commands.');

                await rest.put(
                    Routes.applicationGuildCommands(clientId, guildId), {
                        body: client.commandArray
                    },
                );

                console.log('Successfully reloaded application (/) commands.');
            } catch (error) {
                console.error(error);
            }
        })();

    };
};```
#

this error again

#

i hate this error

plucky imp
#

tbh

#

only used cmd handlers if your advanced iirc

#

you're

bright hornet
#

so why is this js commandFolders is not iterable common showing to me

#

like what ever i code

#

lmao

#

ok

#

i forgot

#

the code const

#

ffff

plucky imp
#

lol

bright hornet
#

just re arranged client and interaction thanks guys

austere surge
#

thatll get ya

plucky imp
#

npnp

bright hornet
#

why is this error keep showing up? all good with permissions, it seems in handle command, line code:

await rest.put(
                    Routes.applicationGuildCommands(clientId, guildId),
                    { body: client.commandArray }
                );``` coming the error

PS: Its not mine
#

what console.log should i suggest to him>

earnest phoenix
#

Doesn't have the proper permissions when inviting the bot. Gotta check the application.commands thing

plucky imp
#

told ya

plucky imp
bright hornet
#

i invite the bot he created

#

the bot contains the permissions

bright hornet
#

all fixed

rocky hearth
#

can we make git, so it ignores entire project by default.
And only include the specified folders and files.?

bright hornet
#

you mean by using .gitignore?

rocky hearth
#

yeah, or by .gitinclude. If that is a thing

bright hornet
onyx silo
eternal sierra
#

need help with 2,3 and 5 guys. can anyone help me code this my assignment sucks

wooden ember
#

does any part of d.js use node-ipc? not sure what its suposed to be i just know its malware now cuz the dev made it delete everything on your pc

#

not taking any chances

earnest phoenix
#

I have mentionned 2 user and i have log the user roles id :

[
  '953700987758067814',
  '953764262172565514',
  '954455258778730586',
  '953951689407336479',
  '954171899544502303'
]
[ '953712761731448835', '954011236037713940' ]```

Now, how can put all id in the all arrays in a new array please ?
boreal iron
#

array3 = […array1, …array2, …arrayN]

sick agate
#

dependcies of dependcies

#

or just to try insall and see ( this is a joke )

#

and it doesnt

dry imp
#

d.py also contain node-ipc

earnest phoenix
#

@opaque fern @boreal iron

#
const ifRoleNoPing = client.config.noPing;
const checkMentions = message.mentions.members;
checkMentions.forEach((mentionnedUser) => {
   const arrays = mentionnedUser._roles;
   arrayWithRoles = [...arrays];
   console.log(arrayWithRoles);
});```
#

type this?

cinder patio
#

that just clones the array

neat ingot
#

whaaaadup folks!!!

#

happy saturday 😘

earnest phoenix
#

hey, is there a way to make bots create invite to a voice channel?

rocky hearth
#

are C pointers, dynamic or static?

cinder patio
#

what do u mean by static and dynamic pointers?

rocky hearth
#

idk, I hv this question in a exam

#

on, C pointers and arrays, whether they are dynamic in nature, or static

woeful pike
#

I have no idea what that question means but it sounds like the answer it's looking for is dynamic

rocky hearth
#

hmm, and arrays must be, static. As they are fixed size

woeful pike
#

I don't think this is a reasonable way to describe things

#

pointers are pointers and arrays are arrays. They're not anything by nature without context

#

classic school question written by someone who barely understands what they're teaching lolol

neat ingot
#

i'd say a pointer is static, like, it points to a specific memory location, no?

#

oh, apparently a pointer can point to either dynamically allocated, or statically allocated memory

#

so both? 😄

rocky hearth
cinder patio
#

Ok but in what ways are arrays dynamic?

woeful pike
#

if you make them dynamic

#

these qualifiers are not inherent to the thing being described but the way it's implemented

neat ingot
#

again, arrayys can be both

woeful pike
#

it's like saying a language is interpreted vs compiled

#

it depends on the implementation, not the language

rocky hearth
#

hmm, there is no context given. What r they talking about

neat ingot
#

sounds like a trick question imo

woeful pike
#

yeah idk this is why school is a horrible way to learn programming imo

rocky hearth
#

In C, a header file is a: ?

neat ingot
#

both pointers and arrays can be either static or dynamic, imo, thats the answer. as quirky said, it depends on your own implementation.

woeful pike
#

if you're not into programming already most people going through this nonsense would come out of it thinking programming is about memorizing random meaningless semantic differences

neat ingot
woeful pike
#

you could define your entire program in a header file but ofc it's about answering what the professor expects the answer to be, not the actual answer 😐

neat ingot
#

I hate that about class environments

woeful pike
#

lets pretend to do some learning

#

mm yes you get a 100% congrats on memorizing these random words I literally just made up

regal saddle
#

quirky

woeful pike
#

resource declaration file isn't an actual term like ur prof literally just made it up with the expectation that you'd know the difference between definition vs declaration and made up some other complete nonsense for C and D OMEGALUL

#

I'm so glad I dropped out man holy hell

#

unbearable

neat ingot
#

I've been doing a class on c# lately. I asked the teacher on thursday how we might return a function from a function. totally stumped her, had to google to find out there is a Function variable type, and you can use lambda expressions too.. was nice to teach the teacher for a change 😂

#

and like, imo, that shouldnt even be a hard question!

woeful pike
#

unfortunately the people who know about higher order functions are making 3x her salary working in the industry

neat ingot
#

lol yea that is likely

woeful pike
#

also kind of why I won't be considering becoming a teacher for a while

#

at least not in an educational institution. But I have other problems with formal education not just money

rocky hearth
#

This one must be easy.

  int a = 20;
  printf("%d%d", ++a, a++);
neat ingot
#

lol

#

that 20-20 vision

lyric mountain
#

21, 21 actually

neat ingot
#

yea, but theres no such thing as 21-21 vision 😄

rocky hearth
#

hehe, u both wrong

neat ingot
#

what? lol

lyric mountain
#

How so?

rocky hearth
#

I checked, and I did it correct in my exam.

#

its 2220

neat ingot
quartz kindle
lyric mountain
#

22 only if ur compiler is having a seizure

#

++a returns 21

quartz kindle
#

wait

lyric mountain
#

a++ too

quartz kindle
#

does python evaluate variables right to left?

rocky hearth
#

its not python, its C

cinder patio
#

dats not python

quartz kindle
#

oh that C

lyric mountain
#

Definitely compiler issue

quartz kindle
#

does C eval variables right to left?

rocky hearth
#

there's printf in python too?

rocky hearth
lyric mountain
#

C compilers are famous for weird processing order

#

Like 5 - 2 * 2

rocky hearth
lyric mountain
#

Some compilers show different results

#

That was a running joke lately on reddit

trim perch
#

yeah cause they have shit specs

quartz kindle
rocky hearth
quartz kindle
#

just noticed print and assumed py

rocky hearth
#

hmmm

neat ingot
#

thats valid in py~ semicolons

lyric mountain
#

Semis in py?

#

Doesn't it throw a syntax exception?

slender thistle
#

Semis in Py are valid

rocky hearth
neat ingot
#

^ py trash for college

rocky hearth
#

so can u write multiple instruction, in single line?

slender thistle
#

Yes

earnest phoenix
# lyric mountain Doesn't it throw a syntax exception?

Semi-colons are valid in Python, although they're completely omitted when they're transpiled, Python only has optional inclusion while JavaScript for example, has optional exclusion, as it tries to place the missing semi-colons for you on transpilation

neat ingot
#

ooohh, did not know that ❤️

lyric mountain
#

Now I'll make sure to include semis in every single python code I write

slender thistle
#

Piss off

spark flint
rocky hearth
#

the term arguments and parameters doesn't mean same thing in C, right?

lyric mountain
#

Argument usually means input

#

While parameter is a value passed to a function

#

Usually

rocky hearth
lyric mountain
#

?

#

No, like, when u use a bot command !!help command command is an argument

#

Or mv /home/folder /usr/folder

#

Both paths are arguments

boreal iron
rocky hearth
#
    // C code
    int sum(int a, int b) {
      return a + b;
    }
    // error: too few arguments to function ‘sum’
    printf("%d", sum(2));

Can that error also be called, error: too few parameters to function ‘sum’ in any other compiler?

lyric mountain
#

Don't think so

#

At least not in any C-based langs

rocky hearth
#

My teacher has taught us, that argument and parameter means same thing. pandasad

cinder patio
#

Both refer to the same thing. It's just that the values you're passing are called arguments

boreal iron
#

Similar discussion could be started about function and method

#
 @media (max-width: 959px)
{
  .visible\@m
  {
    display: none !important;
  }
}
#

I swear css is pissing me off

#

firefox and edge, both show the selector @ a window width of 959

#

fuck that shit

rocky hearth
boreal iron
#

escaping @

lyric mountain
#

When did u discover @ means "at"?

boreal iron
#

what?

#

what has the naming to do with my issue?

lyric mountain
#

Nothing

boreal iron
#

Stop confusing me... or I might begin to talk about py, Java and Brazilians

trim perch
#

that's a good thing

#

less elephants, more coffee

boreal iron
#

It's really funny but max-width really seems to be buggy in media queries

#

At least in firefox and edge

#

max-width of 959px should include 959px but doesn't

#

it stops at 958px

#

min-width however doesn't have that issue

woeful pike
#

so it's implemented as [min, max)

boreal iron
#

that's actually a damn annoying issue

woeful pike
#

it's pretty common for ranges to be implemented this way though

#

Math.random works the exact same way

#

python range() too

boreal iron
#

But a max-width of 959 should include 959...
I mean a max container width of 959 for example, also let's the container expand to exactly 959, not 958

#

So... that's not really consistent tbh

#

I mean I'm working with min-width instead now but still... a little bit confusing why max-width for media queries is being threatened different than a common container max-width

neat ingot
#

I like to threaten all my elements equally 😛

boreal iron
#

I mean think about when you look at this:

@media (max-width: 960px)
{
  .visible\@m
  {
    display: none;
  }
}

@media (min-width: 960px)
{
  .visible\@m
  {
    display: initial;
  }
}
woeful pike
#

you really shouldn't be using max-width by itself anyways imo

boreal iron
#

Yeah... I'm not doing it but still it's not really consistent imo

woeful pike
#

it is pretty consistent. Ranges are often implemented min inclusive max exclusive shrug

boreal iron
#
.visible\@xs, .visible\@s, .visible\@m, .visible\@l, .visible\@xl
{
    display: none;
}

@media only screen and (min-width: 320px)
{
    .visible\@xs
    {
        display: initial;
    }
}

Doing it like that now...

woeful pike
#

the way god intended

boreal iron
#

yeah, I see

#

I was working in the past with max-widths only

woeful pike
boreal iron
#

But I see that doesn't make sense tho

woeful pike
#

media queries encourage thinking in mobile-first

earnest phoenix
#

what? Mobile support? Nah b

boreal iron
#

Well yeah I'm not really a frontend guy but at least I'm enveloping freerealestate

woeful pike
#

also why are you reinventing the wheel with utility classes

earnest phoenix
#

REIMPLMENTEING

#

LMFAO

woeful pike
#

implementing it as a square this time

#

if you need this there's always tailwind

earnest phoenix
#

pin this lolololol

boreal iron
woeful pike
#

what framework

boreal iron
#

UKit

#

oops

#

Ulkit

#

It's only for the content tho, not the layout

#

Because I like to do anything myself tbh, I dont really like frameworks

woeful pike
#

I've hated every css framework so far that has opinionated css instead of just making writing css easier for me

boreal iron
#

Well yeah I'm weird when it comes to using frameworks, I really like to do anything myself, which means it takes like forever to build a fundation of utility stuff you would already have when using a framework

#

🤷‍♂️

#

Guess I'm making my life way harder than I would need to...

#

But I'm very satisfied with the results of the entirely new build

wooden ember
# wheat mesa lmfao what

the author thought it would be cool to use it as a platform to protest the war in Ukraine so it copies an anti war text document to your desktop, which on its own isn't that bad, however it also replaces all the files on your pc with text files filled with heart emojis. its supposed to only do that on pc's with russian ips but its not very good

wooden ember
earnest phoenix
#

I have mentionned 2 user and i have log the user roles id :

[
  '953700987758067814',
  '953764262172565514',
  '954455258778730586',
  '953951689407336479',
  '954171899544502303'
]
[ '953712761731448835', '954011236037713940' ]```

Now, how can put all id in the all arrays in a new array please ?
wheat mesa
# lyric mountain Chaotic good

Meh, I disagree, just because you’re Russian doesn’t mean you support the war (in fact I’m pretty sure the majority of Russians don’t, they just can’t say that or they’ll get arrested)

near stratus
earnest phoenix
#

yes !

boreal iron
#

Got already answered

earnest phoenix
#

The problem is that I get this when a user mentions users (there can be 1 or 10), how do I select all the arrays and their values ​​and put them in one and the same array :

// ANTI PING
const ifRoleNoPing = client.config.noPing;
const checkMentions = message.mentions.members;
let arrayWithRoles;
checkMentions.forEach((mentionnedUser) => {
     const arrays = mentionnedUser._roles;
     arrayWithRoles = [...arrays];
     console.log(arrayWithRoles);
});```
earnest phoenix
boreal iron
#

array.length

boreal iron
#

You overwrite array each iteration

earnest phoenix
#

He count the value in all arrays, so 8 roles and not 1 for 1 array

boreal iron
#

You gotta define it outsite your loop if you wanna push the arrays inside the loop to it

earnest phoenix
#

i have already defini outside loop

#

check

#

Ok i .push()?

boreal iron
#

You don't push anything to it.

#

You overwrite it each iteration

#

VAR = VALUE

#
const roles = [];

for(const mention of message.mentions.members) roles.push(mention._roles);
lyric mountain
#

He does what HE believes is right, even tho it causes more harm and anarchy than necessary

#

If it WAS right it'd be neutral good

sudden geyser
#

It's not good for Russians

lyric mountain
#

Alignment doesn't consider others point of view

sudden geyser
#

All it does is hurt them because Putin is too busy trying to imperialize Europe to restore the empire

#

This little incident is not what's going to make someone in Russia or Belarus say "you know what, fuck Putin!". It's what's going to make him say, "you know what, fuck javascript!"

lyric mountain
#

...

#

I'm not saying it's right, nor that it'll have any effect at all

#

Just that according to alignment chart, he'd be chaotic good

#

"good intention, terrible implementation"

sudden geyser
#

then yes, I agree

quartz kindle
#

nobody would ever consider themselves evil

#

everyone believes what they are doing is good

ancient nova
#

can anyone tell me what "something ? like : this" would be called?

quartz kindle
#

ternary operator

lyric mountain
#

Bolsonaro is chaotic evil

ancient nova
lyric mountain
#

He doesn't care, all he wants is shit on the fan

quartz kindle
#

but even he still thinks that hes right, and that his views are good

wheat mesa
#

kuuhaku is there a java framework or something I should use that's similar to swing for GUIs, or should I just stick with traditional swing

ancient nova
#

"like" is true and "this" is false right?

wheat mesa
#

(preferably easy to use)

quartz kindle
ancient nova
#

nice

#

ty

lyric mountain
boreal iron
#

aka. shorthand if

lyric mountain
#

You can customize any component btw, just extend 'em

sudden geyser
#

How about JavaFX

lyric mountain
#

And can't get much easier, swing is very intuitive

ancient nova
#

if "this" checks for "true"
then this one is "false" : "true" ??

lyric mountain
#

A friend of mine tried to make his graduation project in jfx

#

May he rest in peace

sudden geyser
#

I wouldn't try making any UI in Java

lyric mountain
#

Intellij has an integrated ui editor

sudden geyser
#

gets cancerous very quickly when combined with imperativeness

quartz kindle
sudden geyser
sudden geyser
#

oh wait I misunderstood

ancient nova
#

I suppose answers are static

lyric mountain
#

There're netbeans and eclipse (?) too, but they're shitty

ancient nova
#

I just got kinda confused because the inital opertation checks for the boolean as well

#

maybe that's just my bad practice

split hazel
sudden geyser
#

yeah that makes it easier but I doubt it's any better to actually write and maintain

quartz kindle
#

the answers can be anything, just like in an if

cinder patio
#

then it's both

quartz kindle
#

as long as they are a one-liner tho

sudden geyser
#

compared to other ecosystems at least

split hazel
#

I find quantum computers very interesting

wheat mesa
#

schrodinger's bit

split hazel
#

bros gonna have to enroll in uni just to get access and play around with a quantum computer 💀

lyric mountain
#

Idk, java is very open on how you approach something

#

But I do agree it's more complex than say, react native

#

A thing I like is that you're not forced to have a single file for all ui stuff

#

You can split into multiple files

sudden geyser
#

isn't that true of every ui framework though

ancient nova
cinder patio
wheat mesa
#

I think java would be a nice language for UIs since it's class based

ancient nova
#

in my case I think it's better and more compact

lyric mountain
#

Just for the sake of responsiveness remember to keep the main thread exclusive for the UI

wheat mesa
#

easy to split components and such into multiple classes

lyric mountain
#

I once made the mistake of processing in main thread

#

Whole ui was more sluggish than a rock

sudden geyser
#

you don't need classes for uis

wheat mesa
#

oh yeah I forgot that's a thing you need to do

sudden geyser
#

react trying to pull out of that

wheat mesa
#

no wonder my webhook thing was so shitty

#

lmao

#

wondered why it froze after each operation when POSTing to the dapi

#

I'm gonna fix that because that's something I couldn't figure out

quartz kindle
wheat mesa
#

never really done GUI apps too much

lyric mountain
wheat mesa
#

yeah

lyric mountain
#

Wrong reply

#

Anyway

sudden geyser
#

can you get away with putting the ui on its own thread think

lyric mountain
#

Ye

wheat mesa
#

use main thread for UI, spawn a thread (only once obviously) for the other operations..?

sudden geyser
#

so the main thread's purpose is to manage other threads

lyric mountain
#

It's better than the other way around

wheat mesa
#

ah ok

lyric mountain
#

UI u only create once, that way you save on verbosity for other stuff

ancient nova
# quartz kindle depends on the situation, its not a rule

yep, just don't say doing something like this:

commandArray.push(availableCommandsArray.forEach(e => e !== undefined ? Prefix + e : ""));
``` is worse than doing
```js
for (var int in availableCommandsArray) {
    if (availableCommandsArray[int].includes(".js")) {
        commandArray.push(Prefix + availableCommandsArray[int].replace(".js", ""));
    }
}
``` because they're essentially the same and I'd say the first one is easier to read
lyric mountain
#

A huge tip for swing is, enable opengl

sudden geyser
#

When designing UIs, I've found it better to try getting the processing out of the UI/component/etc. For example, a user component shouldn't have logic to fetch from your database; it should just accept some data about the user (i.e. a map/user class) and display it.

#

Give the fetching for someone else to handle.

lyric mountain
quartz kindle
sudden geyser
#

plus it saves you when you already have the data since you won't just fetch it again

ancient nova
lyric mountain
#

When I first started on swing lambda wasn't really a thing yet

#

But man

ancient nova
#

also what do you mean by wrong? they both work fine

lyric mountain
#

Swing + lambdas are so fckin sweet

sudden geyser
#

what does it look like?

quartz kindle
lyric mountain
#

Compared to having to write a whole class inside it

#

Life before lambda was terrible

ancient nova
#

same with the first one. it just checks if E isn't undefined instead of the extension but it can be easily changed

sudden geyser
#

Ah you talking about stuff like this

Runnable r = new Runnable() {
  public void run() {
    // ...
  }
};

vs. this:

Runnable r = () -> { /* ... */ };
quartz kindle
lyric mountain
#

Ye

quartz kindle
#

.push(something.forEach()) is the same as .push(undefined)

lyric mountain
#

Java lost most of its verbosity after lamba came

#

Which is a good thing

sudden geyser
#

no you still got a ton of verbosity

#

just a little some less

lyric mountain
#

Little is exaggerating

ancient nova
#

I'm confused

quartz kindle
#

you're confusing forEach with map and filter

sudden geyser
#

how about now?

ancient nova
#

so how would you attempt to write such script?

lyric mountain
#

Having to work with runnables/functions/consumers was awful when u had to write it constantly

ancient nova
#

using map and filter, let's say

lyric mountain
#

Always repeating the same thing every line

sudden geyser
#

but you still need functions/consumers today in signatures for example

lyric mountain
#

But u don't need to write it fully

#

It can be resumed to parameters and an arrow

sudden geyser
#

well it is less, so yes

quartz kindle
lyric mountain
#

Instead of writing ```
new Consumer<String>() {
public void accept(String arg) {
// code
}
}

#

U only write ```
arg -> {
// code
}

ancient nova
# quartz kindle

okay, I guess you're right, though in that case how would forEach function?

lyric mountain
#

This in swing, where everything uses such methods, is a huge jump

quartz kindle
sudden geyser
#

and I assume lambdas can do a lot more, like take N amount of arguments

quartz kindle
#

the same way you cant do const result = for(...) {}

ancient nova
sudden geyser
#

probably not an arbitrary amount, but more than using bi/tri/etc.

ancient nova
#

instead of push, foreach and filter

lyric mountain
#

They can, you just need to write a functional interface that allows N arguments

ancient nova
#

hopefully that makes sense

quartz kindle
lyric mountain
#

In my bot I wrote a NConsumer

quartz kindle
#

if all you want is remove undefined items, just use filter

ancient nova
quartz kindle
#

also depends if you want to push arrays, or push the items from inside the array

ancient nova
#
availableCommandsArray.filter(e => e !== undefined); //Filter undefined values.
availableCommandsArray.filter(x => x !== null) //Filter null values.
availableCommandsArray.filter(e => e.indexOf(".js") !== -1); //Filter out files that are not type ".js".
#

for that I already done filter

quartz kindle
#

you can combine all those into 1 filter

ancient nova
#

but that's after I pushed the objects

ancient nova
quartz kindle
sudden geyser
ancient nova
#

"e => e" automatically removes undefined and null values?

quartz kindle
#

e && something = return something if e exists, aka if e is not 0 ""null undefined NaN etc

lyric mountain
wheat mesa
#

is there a way to make a component span multiple rows/cols in a gridlayout

sudden geyser
#

so yes

ancient nova
#

I don't suppose you have anything to remove
const customCommandArray = [];
undefined from pushing an empty array?

quartz kindle
#

back to the previous question

#

commandArray.push

#

do you want to push the whole array, or the items from inside the array?

lyric mountain
#

There are a lot of nice tricks u can do in java, I'm still learning some each time

ancient nova
#

basically what I done in that script above is have an array called commandArray with commands that are builtin and customCommandArray which are commands outside the script which are found in a different folder called in later in the script execution, once that is done, I filter them and push them into the "commandArray" to function as normal commands, afterwards customCommandArray is cleared since I haven't found an use for it other than comparing arrays

sudden geyser
#

A lot of the recent additions in Java have come from functional programming, so I'm happy to see them

#

The biggest thing I'd like to see is project loom becoming a thing

#

Would get rid of the need for the kind of async you see from many languages today

ancient nova
#

what I'm doing is probably not the smartest, however this is how I execute the scripts themselves

if (commandArray.indexOf(answer) > -1 && customCommandArray.indexOf(answer.replace('-','')) > -1) {
eval(fs.readFileSync(`./customcommands/${answer.replace('-','')}.js`, "utf-8"));
}
``` (they are taken from both arrays and compared, to know which one is custom and which one isn't)
quartz kindle
ancient nova
#

if they are I'll probably add a filter and a warning not to do that - in the script execution

quartz kindle
#

you showed this code commandArray.push(availableCommandsArray.forEach(e => e !== undefined ? Prefix + e : ""));
if we ignore the forEach issue, and assume you're using filter here, this code will push the entire array as a single item, into commandArray, meaning no matter how many commands you have in availableCommandsArray, after pushing, commandArray will only have 1 item in it

#

the fundamental difference being:
commandArray.push(availableCommandsArray) which pushes the entire thing as a single item
vs
commandArray.push(...availableCommandsArray) which pushes each item from availableCommandsArray as a separate item, into commandArray

ancient nova
spark flint
#

project @proven escarp

lyric mountain
#

Also one thing I fckin loved in recent updates is pattern-matching switch

sudden geyser
lyric mountain
#

Idk how I lived without it

lyric mountain
sudden geyser
#

Loom basically adds green threads to the language.

lyric mountain
#

What are green threads?

sudden geyser
#

They're like OS threads but managed by the language instead.

#

Here, the JVM.

lyric mountain
#

Wait, so actual threads?

sudden geyser
#

They're much smaller and have better performance

#

So you can have millions of them running concurrently in your app

lyric mountain
#

I wonder if executors will switch to that when it becomes a thing

sudden geyser
#

Pretty sure they will

#

Executors can schedule the system themselves if they want

lyric mountain
#

That'll be awesome

#

Another thing I'm holding my breath for is type casting in switches

#

It'll come on next release

sudden geyser
#

A better description:

Project Loom's mission is to make it easier to write, debug, profile and maintain concurrent applications meeting today's requirements. Threads, provided by Java from its first day, are a natural and convenient concurrency construct (putting aside the separate question of communication among threads) which is being supplanted by less convenient abstractions because their current implementation as OS kernel threads is insufficient for meeting modern demands, and wasteful in computing resources that are particularly valuable in the cloud. Project Loom will introduce fibers as lightweight, efficient threads managed by the Java Virtual Machine, that let developers use the same simple abstraction but with better performance and lower footprint. We want to make concurrency simple(r) again! A fiber is made of two components — a continuation and a scheduler. As Java already has an excellent scheduler in the form of ForkJoinPool, fibers will be implemented by adding continuations to the JVM.

From: https://cr.openjdk.java.net/~rpressler/loom/Loom-Proposal.html

proven escarp
sudden geyser
split hazel
sudden geyser
#

But JS isn't concurrent

split hazel
#

a million threads in a single thread isn't either

lyric mountain
#

And some other stuff, but I don't remember

#

Just read the next jdk release notes

lyric mountain
split hazel
#

if I read that correctly green threads mean virtual threads on a single thread

lyric mountain
#

It doesn't create "threads in threads"

split hazel
#

which allow you to do multiple things on a single thread

#

thread seption

sudden geyser
split hazel
#

so what is the benefit

lyric mountain
#

No object holding an instance if I got it right, and it isn't capped by the runtime

sudden geyser
# split hazel so what is the benefit

The benefit is you get to run many tasks concurrently that aren't bound by OS threads, which are expensive and usually much harder to use. Plus, since they're just threads, you don't run into issues like promises where you can only use promises from promises, which propagate up your application

woeful pike
#

imagine being able to await the completion of async tasks in a blocking way

#

feelsjsman

sudden geyser
#

I think Haskell has something like that

woeful pike
#

I mean basically any language that implements coroutines does no?

#

except js seulgizoom2

lyric mountain
#

And python

woeful pike
#

python has this too

lyric mountain
#

Really? Wasn't python mono-thread?

woeful pike
#

you manage your own event loop in python so you can block the main thread while waiting for coroutines to run to completion

sudden geyser
#

no, this part:

you don't run into issues like promises where you can only use promises from promises, which propagate up your application

I haven't seen many languages provide this: not JS, Python, Java, Kotlin, etc.

woeful pike
#

isn't that just going from Promise<T> to T

#

I'm sleep deprived maybe I'm just missing the point

sudden geyser
#

Yeah, but usually you can only go that way by blocking or unwrapping it in a promise

#

Like .then

woeful pike
#

I vaguely remember seeing this article but I don't think I read it

#

thanks

lyric mountain
neat ingot
#

for what language?

lyric mountain
#

Java

#
Object num = 10;

if (num instanceof Integer n) {
	System.out.println(n * n); // will print 100
}
spark flint
#
const express = require("express")
const app = express()

const bodyParser = require('body-parser');

app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(bodyParser.raw());

app.post("/status", async function(req, req) {
        console.log(req.body)
})

app.listen(5005, () => {
        console.log("online")
})``` returning `undefined` ![sus](https://cdn.discordapp.com/emojis/825311789457211422.webp?size=128 "sus")
sudden geyser
#

you can think of it like typescript where saying, if x is type T, x is T

spark flint
#

OH
WAIT

#

FUCK

#

i did req,req not req,res

#

fuck me

sudden geyser
#

try duck programming next time IruSmile

atomic kindle
spark flint
#

hi akshit

atomic kindle
#

don't traumatize this channel KEKW

wheat mesa
#

This might be a stupid question @lyric mountain, but how do I separate UI and computation? For context, I'm sending a request to discord through a webhook, and I want my UI to update instantly without freezing for the duration of the request

lyric mountain
#

var exec = Executors.newSingleThreadExecutor()

wheat mesa
#

on every request?

lyric mountain
#

No

#

Save that as final somewhere

#

Also, there are more thread pools

#

Choose the one best for ur case

#

If ur processing amount is small SingleThreadExecutor is fine

wheat mesa
#

yeah it's just one POST request

lyric mountain
#

Then u can submit tasks with exec.submit(() -> do stuff here)

#

If u need to retrieve the result (like js' await) save the returned future to a variable and use .get()

#

The other pools are newFixedThreadPool(thread amount) and newForkJoinThreadPool(thread amount) iirc

#

Just type Executors. and press ctrl + space

wheat mesa
#

thanks!

#

best thread pool name

lyric mountain
#

Kekw

stiff dust
#

how can i check message attachments first file type image/gif/video/text file

lyric mountain
#

Btw remember to shutdown ur thread pool on exit

#

Else the process will hang there indefinitely (unless u use System.exit(0))

#

And u can name ur threads

wheat mesa
#
x-ratelimit-reset: 1647719857
x-ratelimit-reset-after: 2
``` what's the difference between these two? Is the first the unix timestamp when the ratelimit gets reset, and is the 2nd the amount of seconds until the ratelimit gets reset?
#

(discord)

quartz kindle
#

probably yes

crimson pike
#

anyone knows how to get users speaking on vc with discordjs voice

wheat mesa
#

ngl these swing layouts are annoying I don't understand them agh

sudden geyser
#

show pls

wheat mesa
#

currently I've got this with a flow layout

#

which isn't terrible

#

but adding anything to this is going to be a pain in the ass

#

I should probably not be using a flow layout because the Current name thing could change in length

#

but it's the simplest I could make it

wheat mesa
#

ok fake you caught me red handed

#

but one thing you can't shit on is java lambdas

#

beautiful

craggy pine
#

In mysql, I'm trying to gather the sum of entries match a string. Easy enough.
I would like it to return 0 if a string is not matched since it'll be checking this via a forloop of specific titles that a user can potentially have.
I found this SELECT COALESCE (SUM(card_anime), 0) FROM cards WHERE card_anime = "Chobits" and if chobits exists, it should print out the total sum of each "chobits" entry however I am returning 0 each time.
This is what my db looks like, am I using the query incorrectly? https://scs.twilightgamez.net/M5NVg.png https://scs.twilightgamez.net/kcORj.png

plucky imp
#

poggggg

#

slash commands are so useful bubs @earnest phoenix

#

keep up the good work AG_PixelHearts

boreal iron
plucky imp
#

yeah but i didn't know they were this good

#

i just though they were flashy but omg

sudden geyser
#

what's your favorite feature?

earnest phoenix
plucky imp
boreal iron
craggy pine
craggy pine
plucky imp
craggy pine
#

meany

plucky imp
#

ghostie_angry he's already busy find your own bubs

sudden geyser
plucky imp
#

it's so cooL

craggy pine
sudden geyser
#

So the X used /...?

plucky imp
#

a b c d e f g

#

h i j k l m n o p

boreal iron
#

If you just wanna get the count why would you select all columns?

craggy pine
#

well true honestly.

#

I can just change * to card_anime

boreal iron
#

Or simply without selecting any column

#

SELECT COUNT(*) FROM cards WHERE card_anime = ? AND user_id = ?

craggy pine
#

Wait.

#

COUNT is a thing..

boreal iron
#

result[0] is your count then

#

You can also select and count at the same time

#

For example

craggy pine
#

But will it do what SUM does where if the match doesn't exists at all it'll throw a mysql error

boreal iron
#

You can also assign own column names to easier use the result

#

SELECT COUNT(*) AS sum FROM cards WHERE card_anime = ? AND user_id = ?

#

result[0].sum would be your amount then

craggy pine
#

Got it, but I go back to the question:

boreal iron
#

I don't get what you mean by sum here?

#

Do you wanna sum up a column of all matches?

craggy pine
#

it does not, it returns 0 which is what I need

#

Esencially, it's a collectable system that'll show in this particular code, 0 / total

plucky imp
#

i'm bored

craggy pine
#

but with SUM when it matched a string the user didn't actually own it would error out. It look like using COUNT it returns 0 if it doesn't find anything which is good

plucky imp
#

time to code bottums

boreal iron
#

Either I don't get what you mean or it's literally too late...

craggy pine
#

I mean it doesn't matter either way.

#

It works \

boreal iron
#

I feel like you wanna group results?!

craggy pine
#

I do not

#

I literally just want the total amount the users owns of the column anime_cards

#

count works fine

boreal iron
#

yeah that's exactly what count is made for

craggy pine
#

I've just seen SUM the first time looking for this solution so I wasn't aware of COUNT

boreal iron
#

getting the actual count without return and selecting any column to save ressources

#

and to speed up the query (in theory)

craggy pine
#

very handy

boreal iron
#

SQL is just... exciting

#

Excluding the error messages

craggy pine
#

agreed

boreal iron
#

Also try to use single quotes for strings

#

Never ever double quotes, nowhere

craggy pine
#

i dont normally.

boreal iron
#

Just regarding that

craggy pine
#

Ah that was in my actually db itself

dry imp
craggy pine
#

code i dont

boreal iron
dry imp
#

u ew

boreal iron
#

Stop making me vomit, please

dry imp
craggy pine
boreal iron
#

ok kids sql lesson over, now gimma your money, please

craggy pine
#

💰

oak cliff
#

I'm going to be learning sql soon

lament rock
#

DELETE FROM topgg WHERE mod = 1;

sudden geyser
#

Remove mod = and we'll be good

lament rock
#

DROP TABLE topgg;

boreal iron
#

was already waiting for somebody to write it

lament rock
#

yw

earnest phoenix
#
function addfield(value, field) {
embed.addField(value, field, true)
}
addfield("Hi", "Bye")
``` will something like this work?
#

all my knowledge represented in some lines be like

lyric mountain
#

No

#

Unless that's a class-specific function

#

Else embed will be undefined

earnest phoenix
#

oh

lyric mountain
#

Since js is so ooga booga u can just add that function to the embed class itself no?

craggy pine
#

I believe you can do something like...

#
function addfield(embed, value, field) {
embed.addField(value, field, true)
return embed
}
addfield(embed, "Hi", "Bye")
#

Pass the embed into the function and return it with new added field

earnest phoenix
#

I'm adding fields repeteadly in a command so a snappier way will be more readable and better

earnest phoenix
craggy pine
#

well no

#

You can do something like let newEmbed = addfield(embed, "Hi", "Bye")

lyric mountain
craggy pine
#

since u return it, newEmbed is the embed will the added field

lyric mountain
#

Builders return themselves

#

So u can chain

earnest phoenix
#

ok

craggy pine
#

may have to await the function. shrug

boreal iron
#

I better don’t ask why you would ever need that

earnest phoenix
#

i agree

boreal iron
#

I was referring to his embed field function

wheat mesa
#

seems longer than just using the builder normally

earnest phoenix
#

idk myself why I would need that

#

maybe to not repeat the same process many times

boreal iron
#

Well just think about it

#

embed.addField(value, field, true)

#

You can directly add the field instead

craggy pine
#

You can do that with all things you wish to add to the embed. Description, title ect. It's also a way to edit it aswell. Fields are an array so embed.fields[index]

earnest phoenix
#

yeah

#

have that

boreal iron
#

embed.fields.push({ name: "title", value: "value", inline: true });

#

totally up to you... I will never get why people are using those ugly builder tools

plucky imp
#

wtf

#

@earnest phoenix stop being so flash before your pc fries

plucky imp
#

f r i e s

#

as in

#

explodes

earnest phoenix
#

oh

#

after debloating it's smooth with these 4 apps open

#

90% cpu and memory but well, it works at least

plucky imp
#

4 apps???|

#

wtf

earnest phoenix
#

discord, vsc and edge

#

windows update and defender takes all

#

What is the difference between using put and post?

#

They both seem to mean the same effect of creating a resource

sudden geyser
#

PUT is for updating, while POST is for creating.

#

For example, PUT to update a user's name, while POST to create a user.

#

Although I'd recommend you also check out PATCH

wheat mesa
#
public class Paddle extends JComponent {
    private int paddleX, paddleY;
    private int paddleWidth, paddleHeight;

    public Paddle() {
        this(0, 0, 50, 200);
    }

    public Paddle(int paddleX, int paddleY, int paddleWidth, int paddleHeight) {
        this.paddleX = paddleX;
        this.paddleY = paddleY;
        this.paddleWidth = paddleWidth;
        this.paddleHeight = paddleHeight;
        setForeground(Color.BLACK);
    }

    @Override
    public void paintComponent(Graphics g) {
        Graphics2D graphics = (Graphics2D)g;
        graphics.drawRect(paddleX, paddleY, paddleWidth, paddleHeight);
    }

    @Override
    public Dimension getPreferredSize() {
        return new Dimension(paddleWidth, paddleHeight);
    }
}
``` I have this for a custom component, but for some reason my `getPreferredSize()` method cuts off the rectangle unless I make it return a dimension longer than the actual width and height of the component, anyone know what I'm doing wrong?
#

(For context, this is how it gets cut off)

woeful pike
#

oh wait

#

I'm looking at the wrong thing nvm

wheat mesa
earnest phoenix
sudden geyser
#

They don't exactly do the same thing.

#

When using PUT, you need to provide the whole resource.

#

It also has some properties you're meant to uphold, such as it being idempotent (meaning, providing the same resource body multiple twice won't change the result)

#

Often it's easier to just support PATCH

sage bobcat
#

One message removed from a suspended account.

quaint rampart
#

anyone know how to make a nginx webserver load discord embeds faster? i cant really find anything in the config that can make it faster im trying to make my screenshotting site just a little faster cuz it takes like 5-10 secondsto load an embed

pulsar sierra
#

where can i find this?

quartz kindle
craggy pine
lyric mountain
wheat mesa
#

Yeah I figured after I changed it by 1 pixel and it got fixed lol

#

btw do you know how to make a custom component respond to key presses?

lyric mountain
#

That's a tricky question

#

Ik text input does have KeyPress event

#

Idk if it's available for non-input components

#

It is possible, I just don't know how

wheat mesa
#

interesting

#

I was going to create a pong game