#development
1 messages · Page 118 of 1
That is not how it works at all
no
brooooooooooooo
it's javascript's runtime
you guys are so confusing
Nodejs is an engine that implements the javascript specification that is defined by the EMCA committee and a bunch of people
i don't get how you make a language out of nothing
it'll be hard to explain as he thinks js = coding
javascript ≠ node.js
there is always an abstraction layer below
js is a language, english is a language, stone carving is a language
cus it is
To be fair, its a complex idea.
The funny part is how everyone tries to explain it and everyone explains it differently. No doubt they don't understand shit anymore...
tl;dr: it's a language, nothing more than a way to explain things
Ok so @hushed robin how do you think a computer works
(I just want to gauge an understanding here)
you seem to be likely trolling yho
On a nanoscopic level, everything in your CPU is a very complex circuit run by billions of little transistors
It's all electricity
yup
bro how am i trolling
And some of the things in your computer take that electricity, and use it as meaning
i don't know how computers work internally bruh
For example, your RAM is basically billions of little switches that are either on or off depending on the signals they have been sent
billions?
yeah
physical?
yes
yes
1gb of ram = more than 1 billion bits, aka 1+ billion little switches
black magic of the computer industry
We spend incredulous amounts of money as a society researching how to make things small, that's how
one transistor is 13 nm (correct me if wrong), which is just a few atoms wide
isn't the latest tech 5 nm? nowadays
👀 we're below 13nm now right?
ah yeah, 5nm then
bruh
yeah
a cpu is a lattice of billions of very tiny transistors
because physics don't allow
The diameter of a gold atom is 0.144 nanometers
we are messing with the psychics enough
So yeah, our transistors are a mere few hundred atoms wide
if they go any smaller quantum shenanigans will start messing things up
what will mess up
Technically the quantum world starts applying at the nanoscopic scale so yeah
that's too complex for u to understand, don't try to go too deep in that yet
ok
yeah
but basically things at atom scale don't work like we know it
M1s are 5nm, currently 2.5nm being a sort of experiment and 2nm probably soon a thing if not already
they start doing things that they shouldn't
just wait until you take a physics class and learn that all matter is a wave 😉
but it just doesn't matter until you get into a small scale
Could go as small as 0.2nm theoretically but not realistically
at 0.2nm the cpu will simply start teleporting things around
Actually IBM already has 2nm, my bad
not the same as physics, chem is more about how atoms interact than the quantum world

makes sense, it's IBM
Ok so to get back on track, everything is an abstraction on top of other things. C is an abstraction on top of assembly, C++ is an abstraction on top of C, Javascript is an abstraction on top of C++, and it goes up and up
Fundamentally everything in your computer is being processed due to the laws of physics
So languages don't really "exist", they are implemented on top of other smaller things
very impressive
To be fair we did discover the electron roughly 130 years ago, that's a super impressive transition
(We discovered electricity before then)
hm
Let's just say that scientists are very smart
Yet Electron is still a wacky framework
I still wonder how we thought mixing ingredients to make something together
well
by mixing them
trying and seeing
Back to the topic though, javascript is simply a standard made by people saying "Hey, javascript should look like THIS.", then it is the job of people like Voltrex working on javascript engines to conform to that standard and make it work
“Hm let’s mix eggs, flour, other ingredients” “oh look it’s a cake”
i mean
i don't really get this still
but
What don't you get
how javascript made of nothing
Ok I'll walk you through the compilation process
JavaScript is just a syntax
(And behavior)
yup
meh not really
Engines, made out of code, interpret that syntax according to the JavaScript standard and make your computer do stuff
i don't understand much i don't think i will understand this process
When you run a JS code, you use the engine that was coded in, e.g. C++, and give it some file to read, interpret and act accordingly
Step 1: Look at the file the user has written
Step 2: Take those strings the user has written, and convert them into "Tokens"
Step 3: Take those tokens, and "parse" them into a tree-like structure that represents a flow of code
Step 4: Do compiler magic that isn't important for you to know right now and turn that tree-like structure into instructions for the engine to execute
Step 5: Execute these instructions in the engine
Step 6: You're done, yay
Oh oh, wait, I know how I can explain
Code is just a "letter" u write to the engine
To tell it what to do
It's like we chatting in this channel
cus my bot is on node.js but what about a website
IntegerProperty value1 = new SimpleIntegerProperty(0);;
IntegerProperty value2 = new SimpleIntegerProperty(0);
IntegerProperty value3 = new SimpleIntegerProperty(0);
IntegerProperty value4 = new SimpleIntegerProperty(0);
DoubleProperty total = new SimpleDoubleProperty(1.0);```
```java
public void createSegments(){
TextField[] array = new TextField[4];
for(int index = 0; index < allValues.length; index++){
TextField textField = new TextField(null);
array[index] = textField;
root.add(textField, 0, index);
Label label = new Label();
label.textProperty().bind(Bindings.concat(Bindings.format("%.4f", allValues[index].divide(total))));
label.setMinWidth(200);
label.setMaxWidth(200);
root.add(label, 1, index);
}```
hey so this will ofcourse show NaN as it tries to create a doubleproperty for a division with a 0. Is there any way to fix this? And upon startup actually showing 0.0000 instead of fuck NaN
you have to learn html & css
Also on another note, this is a super cool visualization of size (Our transistors are around 10 * 10^-9 meters)
and framework maybe
I would never get something like that implanted in my head
yeah no
No matter how superhuman it made you
i would
I do not trust someone else with that power
being super smart would be fun
i also wonder why
there are no other smart animals on earth
why are only we smart
dolphins, dogs, monkeys
To be fair, smartness is inversely proportional to fun
👀
it's different tho
The more intelligent you are, the more you see the world is boring
Completely off topic for this channel though lmfao
no not really imo
but they are not as smart as humans tho
JavaScript, html
development-and-philosophy
i am much smarter than a dog
not even philosophy 

you sure?
yes

that doesn't make them not intelligent
my dog can eat his own shit
also you know that dogs take orders from humans all the time right
yeah
they may not understand what is being said, but they recognize the sound you make
and what action comes with it
but they only recognize the sound and the action to do with it
they don't actually understand anything
that doesn't make them not intelligent
you'd be surprised to know that there are other species with forms of communicating with each other
dolphins are super smart
well yah
so are birds
but are their languages as complex as a human language?
probably more complex given that we can't fully decipher them ourselves
what thee hellll
I don't see how that doesn't make them intelligent though
wait someone actually doing swing correctly????? wtf
because
Is a human language even complex? How do you define something for the entire humanity for it to be considered complex.
more complex = smarter
complex is relative
That's just speculations and random talk based on what you think and know.
yes
I bet you don't understand the languages at a low level that computers use, that doesn't make computers intelligent and humans unintelligent though
cus why has another animal not learned it?
it is javafx
they don't have very large interconnected communication ways
Speaking japanese may be complex for you but not for a Japanese born human. Does that make the Japanese born human less smart just because they talked the language this their birth? Highly doubt
no but
if i really tried i could learn Japanese
if another animal really tried they coudln't learn it
But it wouldn't be as easy for you as a native speaker
every foreigner i have listened to trying to spell my name had issues
for some reason that NaN only appears when my initial values are 0
Off topic for this channel either way at this point. Also being an endless loop of the same sentences over and over.
true cus u don't understand
well, you're dividing are you not
i haven't coded in awhile
yessir
actually from the look of it you might be dividing NaN by 1
i wanna make website but too hard and other things are boring so i'm not quite sure what to do 
i logged both values seperately and it worked fine, only problem is that .divide() doesn't allow 0.0 as input as the result elseis NaN
since your fields are empty initially it might be setting the value to NaN
I am using the built in javafx properties, this is not really about doubles.
Just check if the value is 0 then?
do you know how binding works? i can';t just manually change it because once i bind it it's set
Mathematically dividing by 0 isn't defined, so NaN makes sense there
What is your intended result?
well, if i startup the priogram i wanna see 0.0000
From what I'm seeing online, you can define your own model class for this
That way you can control the binding behavior
Instead of being stuck with whatever default behavior SimpleDoubleProperty has
I might have to try javafx, their MVVM actually looks pretty intuitive
can you use whitespace in buttons
i want the buttons and select menus to align
so i want to use whitespace in those two disabled buttons to achieve that
actually it is
you would simply add whitespace to the 'label' attribute of the button
any errors?
hm
very sad
L discord
also
does anyone know if Fandom has an API?
I want to get data on items from a game but manually inputting each item will take forever
seems it doesn't, scrapping it is
I mean, looks like you searched a grand total of 9 minutes before coming to the conclusion that scraping is the easier option. I'd much rather spend some time digging to see if there's an API
i'm sure if there was an API i would have found in within 9 minutes of searching
Isn't fandom based on a heavily modified version of MediaWiki?
And MediaWiki has an API
it's possible this is what you're looking for: https://community.fandom.com/api.php
that's what I found in ONE google search
lol there it is
uh
random reddit post
looks old
and too hard
imma just use this https://www.npmjs.com/package/hermitpurple
but it's kinda wacky
Worthy to note, webscrapping involves using a headless browser (usually selenium)
So expect a spike in ram usage
Not big, but noticeable (even more if the library instantiates it on every request)
why
Because browsers have to allocate some resources
Just like chrome or firefox
Much less than then since it's a headless browser, but still needs to
whats a headless browser
A browser without visual interface
Shiiii may have to download one
oh ok
how do you guys get the bot developer role
ok ez
I do btw, all maintainers have direct commit access
But nobody should directly commit something in such extremely large and important repositories without a PR with appropriate amount of approvals and testing (through CI and stuff) unless absolutely necessary
(I also maintain JavaScript's specification
)
you should make nodejs depend on one image called coconut.jpg
Gonna make it depend on images of capybaras
is it a good idea to send all my server crashes logs on a webhook
how do i become better at rendering
Depends on what webhooks you're talking about, if it's Discord webhooks then it can be a bad idea as lots of crashes might lead to ratelimits, you could also use https://sentry.io/
are there any guides to map soft mass deformation
i should program a physics simulator

so what is sentry exactly?
I literally says on their website
yep i just finished reading through it
seems like a cool tool
i will prolly implement it
gives out alot of cool info
IntegerProperty value1 = new SimpleIntegerProperty(0);;
IntegerProperty value2 = new SimpleIntegerProperty(0);
IntegerProperty value3 = new SimpleIntegerProperty(0);
IntegerProperty value4 = new SimpleIntegerProperty(0);
DoubleProperty total = new SimpleDoubleProperty(1.0);
public void createSegments(){
TextField[] array = new TextField[4];
for(int index = 0; index < allValues.length; index++){
TextField textField = new TextField(null);
array[index] = textField;
root.add(textField, 0, index);
Label label = new Label();
label.textProperty().bind(Bindings.concat(Bindings.format("%.4f", allValues[index].divide(total))));
label.setMinWidth(200);
label.setMaxWidth(200);
root.add(label, 1, index);
}
hey so this will ofcourse show NaN as it tries to create a doubleproperty for a division with a 0. Is there any way to fix this? And upon startup actually showing 0.0000 instead of NaN
👀 you could just not run the function the first time until an input is provided.
hmmm, not sure whether that would work tho
why wouldnt it?
cuz we are creating labels and textfields inside this createSegemnts function, so if we don't call this function on startup, it will basically.. well give me nothing
👀 so, your function for creating them also does the math too?
shouldn't that be a separate function, thats only called on input?
public void addEvents(TextField[] fields){
for(int i = 0; i < 4; i++) {
TextField field = fields[i];
IntegerProperty property = allValues[i];
field.textProperty().addListener(
new ChangeListener<String>() {
@Override
public void changed(
ObservableValue<? extends String> observable,
String oldValue, String newValue) {
if (!newValue.matches("[1 -9]\\d{0,3}")) {
field.setText(oldValue);
}
property.setValue(Integer.parseInt(newValue));
}
});
}
}``` check the segments method, you see that addEvents() call? Refers to above.
What the first method does, it will create the labels, and fields and binds them to their own private value. Then i created another method to bind a listener to each textfield.
so that's why its a bit hard
My java knowledge is zero, so I'm just spitballing.
If this runs on initialization, why not add an if statement if the newValue is empty set property to 0.000?
because if we bind it, we cannot set a value manually iirc. It would destroy the bind and not update anymore.
are you not setting it manually here?
property.setValue(Integer.parseInt(newValue));
that is the textfield, we are not bnding that one, only the label. And the label is also the one that gives problems.
ah, I see.
I also see I have no idea whats going on, and I cant really be helpful 😦
what went wrong?
fs.readFile("../../restart.txt"), (err, data) => {
if (err) {
return;
}
if (data) {
const restart = data.toString();
const [messageId, time, userid] = restart.split(",");
const user = client.users.cache.get(userid);
console.log(time)
const timeLeft = Math.floor((Date.now() - time) / 1000);
user.send({
embeds: [
new Discord.EmbedBuilder()
.setTitle("Started!")
.setDescription("The bot has started up!")
.setColor("#a8f1b0")
.addFields({ name: "Time taken", value: `<t:${timeLeft}:R>` }),
],
});
fs.unlink("../../restart.txt", (err) => {
if (err) {
return;
}
});
}
}```
You're not passing the callback to the fs.readFile() method
Note the ) after .txt" at the first line
oh wait
i got a new error
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received an instance of Object
fixed
but
why does the time says 19 days ago
because you entered it as a timestamp, which shows a specific time and not a duration
They most likely started the bot a few seconds ago before taking the screenshot.
So there's most likely something wrong with their calculations and now the way it's getting displayed.
but the way they display the time with rich presence will always make it say “in ” or “ ago”
unless I missed something important and that’s what they wanted
It's not a rich presence though
And no you can have multiple formats
<t:TIMESTAMP:FORMAT> where STYLE can be any of the following: https://discord.com/developers/docs/reference#message-formatting-timestamp-styles
Hi
but they’re trying to show how long it took to start… none of the styles for a timestamp support that
What you want is duration, not a timestamp
Thus the timestamp tag won't work obviously
Duration requires a start and an end, you'll need to manually do that
do replit have variable limit ?
If you are worried about this, then you are using replit secrets wrong
Use a config file for anything that's not really sensitive
What should be put in secrets and config.json
anything that could potentially give access to sensitive data or accesses (like tokens) should be put in secrets
things like urls, paths, ids, numbers, etc which do expose anything dangerous can be put in config
@lyric mountain stupid question, but do you know how to colorize the output on intellij's console?
Tried using ANSI escape codes, doesn't seem to work properly
is it using cmd or pshell?
The built in console, I believe it's powershell
cuz intellij technically doesn't have a console per se
but well, it should work with ansi escape codes
my logs use it and do appear colorized
try switching to pshell
the default is cmd
it's in the config, search for terminal
Yeah it's using pshell
ok nevermind
I hate the internet
it was double escaping the backslash
\\u001B..... instead of \u001B.....
lmao
You're closing the for loop early, and so the commandFiles variable goes out of scope
early??
Notice the } after you call .filter()
You're welcome
man I hate fighting bugs in an ECS
😭
IT DOESNT MAKE SENSE
aghhhhhh
For some reason my removeGameObject() method doesn't work
Something is wrong with it, I just can't figure out what
hmmmm, I can't seem to remove components correctly either
maybe there's more wrong with this than I thought
oh maybe I'm stupid
yup that was it
I was calling the same listener more than once because my code is bad
implement hashcode
im tryna add a reaction to the embed thats being sent to another channel and i keep on getting errors
Code:
setTimeout(function(){
client.pollChannel.send({
embeds: [poll]
})
pollChannel.react("✅");
pollChannel.react("❌");
}, 1500)
Error:
pollChannel.react("✅")
^
ReferenceError: pollChannel is not defined
You add reactions to the message, not to the channel
i also did message.react("emoji type") and it gave me message is not defined
message.react("✅");
^
ReferenceError: message is not defined
setTimeout(function(){
client.pollChannel.send({
embeds: [poll]
})
message.react("✅");
message.react("❌");
}, 1500)
did you even define message, you need to define it
message.react("✅");
^
TypeError: Cannot read properties of undefined (reading 'react')
Exactly, your message must be the embed you sent
Over 76% of my MAUs are now using slash commands. Adoption seems to have tapered off. Probably can't get the other ~24% to adopt them without being more aggressive about it.
Also interesting that my MAUs are still growing consistently at an all-time high, and total command calls have managed to get back up to the point they were at before slash commands in Jan 2022 👀
JWT or express-session
Monthly active users
I use express-session
but thats purely down to the fact I already have a redis instance running for cache
no i dont meant that i was just asking can we have a number of variables ?
There's none
No limit
But at some point you need to ask yourself if you really need that many constants there
do i need to add .save() after i use the model.create funciton in mongoDB js
I'm afraid that without this you won't even save this file
how do i find everything in the collection in mongoDB Js?
Who made the topgg discord webhook vote website again?
I remember it's one of the mods.
Woo?
Something like db.collection.find() i guess
Jwt seems so much easier, you can even use it anywhere
And as a db i am using prisma
No. That's only for updating a model
so I have a union type with a bunch of strings, how can I give the user intellisense for them but also allow any string at the same time? (ts)
type something = "a" | "b" | string; should work afaik?
then something ends up as just string
same thing
You could use an enum
It’s probably not exactly the result you want but it would work
afaik they fixed enum stuff in 5.0 so you cant input anything anymore
And then just have your type be type S = EnumType | string;
I didn’t mean exploiting an enum, I meant using it like an actual enum
oh right, lemme try
Seems to work for me on ts playground
Unfortunately I’m on mobile so testing is kind of difficult
/help
Yeah that looks correct since A.a is assignable to type string and itself
since the type of the enum includes its members
itd be another story if you Extract<A, string>
But your example shows all enum members as being strings
Although I consider it bad practice to use mixed type anything
is this reliable? like will it always stringify the full function?
Yes
im trying to get the client variable defined in src/index.js my current pwd thingy is src/imports/embed. i already add module.exports = {client} thingy.
why are you trying to export a variable
hello, I'm trying to do things with conditional typing in typescript but it doesn't work. I get the error 'data.dataAfter' is possibly 'null' and I don't understand why because I checked if data.action is not delete
if you are sure it's not null then add an ! prefix after that
data.dataAfter!.id
hm ok thank you
@earnest phoenix help ```ts
src/index.ts:169:31 - error TS2550: Property 'replaceAll' does not exist on type 'string'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2021' or later.
169 const s: string[] = result!.replaceAll(result!.slice(-16), '').split('\n')
~~~~~~~~~~
Found 1 error in src/index.ts:169
tsconfig.json:
nah it's just typescript doing it's job
🤷
There's no es2021 module version
then what should i dooo
i tried esnext and it didn't work either
Use es2022
nope
doesn't work either
WAIT
@earnest phoenix it works now
sorry i was dumb
Nah it's alright
@earnest phoenix i was working on migrating from Jest to Node.js™️ v20™️'s native™️ test™️ runner™️ so i was writing a separate test.ts file, how do i supply several --lib options?
--lib esnext --lib dom doesn't work...
just specify it in tsconfig
--lib esnext,dom
it won't work with just one file (npx tsc test.ts)
nvm i didn't see "several" word
@earnest phoenix so uh how do i write a proper TypeScript™️ test runner in Node.js™️ v20™️ for my own project?
Though note that we haven't marked Node.js v20 as LTS so be careful using it for the time being
i tried writing a test.ts file
so i can get TypeScript to also check the types
Well there are bugs and stuff users reported after we released Node.js v20 so there are stuff that needs to be fixed, but sure if you want to use it
but i dunno how to run it
i can do ```sh
npx tsc
npx tsc test.ts -t esnext -m esnext --lib esnext,dom --removeComments --strict
node test.js
is there any other way
Why is that unintuitive?
Also you should use the test mode by using the --test CLI flag when you're running a test file that uses node:test
what's the difference?
yeah but i need to test it in a TypeScript way
How's that related to what I said?
wait nevermind 
@earnest phoenix i can't do node test.js because it gives Error [ERR_MODULE_NOT_FOUND]: Cannot find module '...\dist\timeout' imported from '...\dist\index.js'
the first few lines of dist/index.js:
import { deflateRawSync, gunzipSync } from 'node:zlib';
import { randomBytes } from 'node:crypto';
import Timeout from './timeout';
import languages from './languages';
ESM requires the file extensions to be passed as well
You're welcome, and nah you're good
@earnest phoenix ngl Node.js v20's test runner looks like a better replacement to Jest, you guys did a good job!

You're welcome for the test runner, though we got lots of optimizations to do as running multiple child processes for the test runner has quite a lot of overhead
Time to learn how quadtrees work for enhancing my collision algorithm
currently my algorithm is REALLY bad 
Imagine not using a space after statement keywords 
it should
btw @wheat mesa
u can use a spliterator if u want to multithread that loop
Yeah I'm not worrying about optimization on that, I'm going to be completely replacing it with a new algorithm in a bit
Or did you mean for the Set<Integer> layer : entities part?
Cus I haven't bothered with making the ecs threadsafe yet
nope
I should probably turn that on
I'm sure there's an option for it
mean the while loop
spliterator is threadsafe iirc
ah yeah I don't need to do that anyways, the method is hella slow and I'm going to replace those while loops
if i want to change a bots permission do i need to kick it and re-invite it with the right permissions or can i modify it some how through server settings?
you can modify the integration-role permissions
this is read only right?
under the roles tab
ohh
that is read only yes
should be marked like this
it looks like discord only creates a role for the bot if permissions are needed. if the users gives the bot no permissions and then wants to add permissions later they will need to manually create a role, give it permission, and assign it to the bot if they want to give it permission without kicking it. it might be easier to instruct them to kick it and re-invite it with permissions
it's exactly that
my bot has manage role permission now, but the api call is still failing with this error
{ message: 'Missing Permissions', code: 50013 }
This is the call
await axios.put(`${URLS.api}/guilds/${guild_id}/members/${player.id}/roles/${roleId}`, null, {
headers: {
Authorization: `Bot ${discordTokens[application_id]}`
}
});
Is it failing because it's trying to give me a role and i am server owner? Do i need to use the interaction token instead of the bot token?
whats a regex that matches the first occurence and the last occurence of a word?
u dont need regex for that
so does the bot role need to be moved up above the role it's trying to assign or else it fails right? this is to prevent the role from acquiring more permission that it was given
yes
I want to ship a function from nodejs to html (yes, its infact needed), now .toString() works fine but there is one mayor issue, I do not get all variables that the function is referencing, so is it possible to get all external variables the function is referencing and getting their values (in nodejs)? or is that not possible
cant u just make an api?
Sounds like some X & Y problem
That isbt really what im doing, im letting a User define functions on the Server and I dont want them to have Errors that they couldnt expect
process on the server and return the result
instead of embedding a foreign code into the page
Yeah but what about onclick handlers or stuff like that? I cant really do that in the server
Like Most Things I could do Sure but Not when you interact with the Page, i Just actually need it the way i described
u can seriealize the event and send to the server
I dont think its a good idea to make a request on every event
it begins
Still no idea why Java doesn't have a stdlib implementation of a Pair class
what is that new Rectangle[4]? I've never seen something like yhat
It instantiates an array of Rectangle objects with a size of 4
(Default values are null, null, null, null)
Ohh that's awesome
I'm beginning to like spacial data structures a lot
if u know the size, use List.of() instead of new arraylist
What's the difference
it prevents the list from trying to resize during runtime
List.of() and similar methods create a fixed-size list
Wait what, List.of()?
Yeah I know but like, it seems like it only accepts objects themselves
or regext to strip numbers
List.of((TheClass) null, null, null, null)
ah
I think so
this one will create an array-backed list
so fixed size too
anywhere u know the size it's worth to use fixed size lists as you save a ton of time not resizing it when it nears the limit
ah I can't use arrays.aslist because I need a generic array
and casting would probably be scuffed
Also @lyric mountain List.of doesn't work because it creates an immutable list
am too lazy to search, but well, someone explains to me what finally do when trying to catch a error? idk
like try {} catch {} finnaly {}
finally will always run, regardless of whether or not you encounter an error
hmm
.set() doesnt work?
only in Map i guess
Usually it's used for cleaning up resources to guarantee that they're properly handled
list has set too
I haven't tried it, but it says "creates an unmodifiable list"
thanks waffle
oh
Which I would assume means it's a readonly list
I think it's immutable as in "cannot be resized"
I'll try it rq
yeah that isn't gonna work for me
actually
maybe it will
yeah it doesn't like null being given to it
And I need null for this
damn
oh it's Java 
I don't think the arraylist does any resizing as long as I don't go above the initial capacity I give it
isn't it when u pass 50%?
I thought it was once you reached capacity
dont remember it
nice
@lyric mountain this is more of a structure thing, but my core folder is starting to get overwhelmed with things that don't fully deserve their own package, but also shouldn't be in the core folder. What kind of package should I make for this stuff?
Maybe I should make a structures package?
A lot of these are just basic structures anyways
could also call it struct
there's no rule abt that tbh, whatever u find appropriate
yep
btw
for things that are immutable u can use records
they're quite new to java, but are structures meant to hold information
they're pretty fast to instantiate and destroy many times per second
Yeah I've used them a few times, one of the very few syntactic sugars java has added
Unfortunately most of my structures need to be mutable afaik
ah
Although there are a few I could convert
how do i get the client that was defined in index.js?
i have tried adding js module.exports = {client} and then requiring it in my file, but it shows me this warning. (node:18252) Warning: Accessing non-existent property 'getclient' of module exports inside circular dependency
Is there a tutorial somewhere that goes into detail about how to use the monetize api? if i enable this and someone subscribes how can i programmatically know who subscribed? i want to list subscribers for a month on my website, but i'm not sure where to begin
With the Discord API docs
E.g. role objects have the available_for_purchase tag set
hello there -
any suggestion for a discord bots host?
free or not but at least cheap

^
anything within the limit of 2$ per month?
Search it up
Someone from the administration here probably has hosting or at least advertises it
gotta love how toxic the python community is https://github.com/psf/black/issues/47
their only working code formatter doesn't even have configuration 
lmfao
@earnest phoenix time to make a pull request to Prettier to make it only comply to this very specific configuration and remove all configurations so it will become an "uncomprising code formatter" 
Watch your pull request receive a thousand toxic comments and even ||death threats|| at the first hour

when they complain just say that their code style is literally the devil 
Python community is goofy ahh
@radiant kraken what GUI library is good in rust
why
Are ImGui Rust bindings good
why are you using rust to make gui apps
i've tried making a gui app in rust but my computer always died from the resource-intensive compiling process


at this point i'd rather use C++/C#
bump
oof
Also using import "C" everywhere which makes sense
@earnest phoenix yapf, the only other python code formatter that allows configurations doesn't even work 
Honestly black is awesome
black is terrible
it would be awesome if it had configuration
it's way too strict with the whole "all Python code must comply with PEP 8"
but other people have their own preferences too
I mean, Yapf is still in alpha stage so nowhere near being stable
indentation, print-width, single or double quotes, etc
Then you can write your own 
Or just don't use an autoformatter
Which will lead to inconsistent and more horrible code most of the time
i can write a python lexer in rust
but it's too much effort 
Then deal with what's existing 
Hello. :>
hi
Hello!!!. :).
@earnest phoenix sorry for the long response but i forgot about tauri https://youtu.be/-X8evddpu7M
Tauri is a tool for building cross-platform desktop apps on Windows, MacOS, and Linux with JavaScript & Rust. It is very lightweight and fast compared to similar tools like Electron.
#dev #programming #100SecondsOfCode
🔗 Resources
Tauri https://tauri.studio
Tauri GitHub https://github.com/tauri-apps/tauri
Reddit thread about Tauri https://w...
some say it's a good UI framework for Rust
Yeah but that's with React so TS etc. not just plain Rust
We have the exact same in Go so not really worth it
sadge
Vote command in what sense?
do u know to make
if we do /lava-link and if we enter it should show u did not had vote the bot in top gg after a member vote that member can get lava link
like that
do u know to make
It depends on what language your bot is written in, but everything is based on topgg api. Look in the documentation for examples related to your language and possibly some external libraries
my bot is js and its v12
Why are you using v12?
or even how
because i codded my bot befor and the bot work was in pending that why now if i change to v14 it may take time that why
any one knwo to support me pls
I would recommend focusing on migrating from v12 to v13 and then to v14, instead of focusing on implementing vote-locking because v12 runs on a deprecated Discord API version that'll be shutdown soon enough
😦
And besides, v12 isn't able to handle quite a lot of the newer requests so your bot will frequently crash if you don't update
😦
Here are the migration guides you should follow:
v12 to v13: https://discordjs.guide/additional-info/changes-in-v13.html
v13 to v14: https://discordjs.guide/additional-info/changes-in-v14.html
It's literally shown in the websites, read them
but i cannot because my phone just have 1gb ram if i open google it will crash
bro
if i do npm uninstall discord.js
does not work
so what to do
i ned a helper
TL;DR: you'll need to rewrite a significant part of your code
simply updating d.js itself wont cut it
😦 but the main problem is with the uptimer command for my bot
if any thing so worng it all stop workin
well, you need to fix those issues
i need aa helper
we dont have aa helpers, only bb helpers
did you write your bot? or did you follow a tutorial?
tutorial
well, that's an issue
tutorials are timeless (they don't get updated with the framework), you need to focus more on "why" than on "how"
basically, try to understand why they did it, not on how they did it
Am I the only one who thinks it would be easier to write a bot from scratch on v14 than try to rewrite a bot from v12 first to v13 and then to v14?
you can't even add it for now
not without having the bot approved on topgg
even if you could, your bot is a ticking bomb as it is now, it'll start crashing more and more until it no longer starts
you don't have access to votes without being approved
you cant develop a vote feature if you have no access to it
^
the more you wait, the harder it'll be
Also queue is like 1-2 weeks long so they won't approve it right away
AND there's the chance it'll get declined if it crashes during test
^
so that why iam not adding command
you said you followed a tutorial, did you make any custom command?
like, commands not included in the tutorial
yes
ss comand and server info command
and ban and moew command
i just looked the uptimer command in yt
ok, ig
@wheat mesa btw, I forgot to tell u, there's a handy plugin for intellij called spotbugs
it spot bugs that the built-in analyzer can't catch (such as possible runtime issues)
basically a second layer for code analysis
👀
was staring at my screen until i remembered I had it installed lul, didn't have much too fix, mostly possibly-null values in if branches
🫠
malicious code vulnerability lmao
I like it cuz it explains to you each catch
in the right panel
some of the complaints are about unread/unwritten fields but it just can't tell that I'm using reflection for some stuff tbf
This might be useful later on when I clean up the codebase, but as of right now it's going to be annoying
I'm going to disable it for now then use it later
afaik it doesn't analyze automatically, I just leave it there
ofc, make sure this is disabled
else it'll check on every commit
I'm trying to connect to my lavalink server and it say connected then it throws this error
Node Main had an error: Unexpected op "ready" with data: [object Object]
and my music command throws this error
Promise {
<rejected> TypeError: Cannot read properties of undefined (reading '0')
at Object.run (/home/container/slashCommands/play.js:145:44)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
}```
because of this line:
``` interaction.data.options[0].value;```
What do you guys have in go?
lmfao @clear plinth can help you get out of here
Wails, been longer out in the wild than Tauri as well
Just gonna delete for precaution
I missed it, was sleeping
😩
#topgg-api average scammer
@verbal oriole again, no self promotion please
I see.
You
I've only heard about kaliber 44
yoo
Is there something in Electron that I can use to encrypt user data with?
Not as in a function but as in like, a passkey
If you're using a LavaLink version above 3.7, downgrade LavaLink or upgrade your client to one that supports the new rest api
electron is just a framework to run node projects as a self-contained app
isnt it webjs since it uses chromium
what's the difference 
It's in Go
Nothing much as said
We have the exact same in Go so not really worth it
maybe some tiny differences that the average user does not care
nice
while I use a slash with my bot, as long as the command is not finished I cannot execute another one. It's normal ?
If you coded it like that, yes
if anything, it'd be not using a promise
js is monothread, if ur doing something that hangs the runtime it'll affect everywhere
//exemple command
const {getMatch} = require('../utils/chess-data')
const {redifMatch} = require('../utils/createCanvas')
const { ApplicationCommandOptionType, AttachmentBuilder } = require('discord.js');
module.exports = {
name: 'chess-replay-match',
description: 'Replay a chess match',
options: [
{
name: 'match_id',
description: 'The match ID',
type: ApplicationCommandOptionType.String,
required: true
}
],
run: async(interaction) => {
const match_id = interaction.options.getString('match_id');
await interaction.deferReply({ephemeral: false});
let start = Date.now()
await interaction.editReply({content: 'Fetching data...'})
getMatch(match_id).then(async(match) => {
await interaction.editReply({content: 'Image creation...'})
await redifMatch(match.coup, match.white, match.black, match.result, match_id).then(async(imgBuffer) => {
let buffer = Buffer.from(imgBuffer, 'base64');
let img = new AttachmentBuilder(buffer, {name: 'chess-replay-match.gif'})
interaction.editReply({content: `Execution time ${Date.now()-start}ms`, files: [img], ephemeral: false});
}).catch((e) => {
console.log(e)
return interaction.editReply({content: 'An error with the image creation. (To help us fix this problem, describe when this problem is triggered (/chess-link))', ephemeral: true})
})
}).catch((e) => {
console.log(e)
return interaction.editReply({content: 'An error with the data. (To help us fix this problem, describe when this problem is triggered (/chess-link))', ephemeral: true})
})
}
}```
```js
//handler
const {glob} = require('glob');
const {promisify} = require('util');
const globPromise = promisify(glob);
module.exports = async (client) => {
let arrayOfSlashCommands = [];
let slashCommands = await globPromise(`${process.cwd()}/src/commands/*.js`);
slashCommands.map((value) => {
let file = require(value);
if (!file.name) return;
client.slashCommands.set(file.name, file);
arrayOfSlashCommands.push(file);
});
client.on('ready', async () => {
await client.slashCommands.set([])
});
}```
```js
//run
const client = require('../../index');
client.on('interactionCreate', async(interaction) => {
if(interaction.isCommand()){
const cmd = client.slash.get(interaction.commandName);
if(!cmd) return;
cmd.run(interaction);
}
})```
Sending code won't change what was said
I sent before receiving the answer
what's redifMatch?
creation of several images with canvas and then combined with giftencoder
There you go
There's no alternative really, that's just how much it takes to execute, you can't do anything that makes it execute in much less time
Optimizing it won't make that big of a difference in this case
that's not the issue, that command hangs the whole bot
And if I make sure that everything is done in the order file (so no more promises we agree that the bot will not be "blocked"
Don't use synchronous IO calls
yeah, that's very likely it
Oh, then they're doing something that blocks the main thread, you could try showing what you're doing in the redifMatch() function
async function redifMatch(data, white, black, result){
return new Promise(async(resolve, reject) => {
try{
const canvas = createCanvas(840, 1180)
const ctx = canvas.getContext('2d')
const encoder = new gifencoder(canvas.width, canvas.height)
encoder.start()
encoder.setRepeat(-1)
encoder.setDelay(500)
encoder.setQuality(10)
//
//canvas
//
for(let element of movement){
let img = await loadImage(await createBoard(await chess.fen()))
ctx.drawImage(img, 100, 280, img.width, img.height)
encoder.addFrame(ctx)
}
encoder.finish()
const buffer = encoder.out.getData()
resolve(buffer)
}catch(err){
reject(err)
}
})
}```
Function is not complete too long for discord is useless (rectangle tracing/writing etc etc)
Share it in a bin like https://sourceb.in/
In any case, the command takes around 30 to 60 seconds to execute and when it is executed it is as if the bot did not want to respond.
Is there something in URLSearchParams where it leaves out a param if it's value is something?
Like undefined?
build the urlsearchparams separate from the request
const params = {}
if (something) {
params["key"] = value
}
the boring options is sometimes the best option
😭
not all code needs to be shiny and techy
- Declare variables that are not going to change with the
constkeyword likecounter,img, etc etc - Leave constants out of the functions where their values are always the same, like the
corsvariable - Wrapping all of those functions in a
Promiseexecutor is a bad idea because not all of them need it - Lines 34 and 35 can be refactored to
const lowLetter = letter.toLowerCase();
if (!(lowLetter in cors)) return;
counter[key][lowLetter]--;
- At lines 139 and 140, you can just do
!element.includes() - Finally, load all of the images you're gonna use in memory because you seem to be repeatedly loading the images you use many times, like the images of the chess pieces
btw, just to add to it, gif might not be your best format
matches longer than a few turns will easily surpass the level 3 discord upload limit
What format would you recommend? ?
thx !
honestly, the best would be mp4
if discord supported apngs then it'd be the ideal option
None
Hey I want to get my bot verified on discord. Do I have to enter my real information like name etc. in the terms of service?
No
okay thanks
The information you give during the verification is not the question they asked though.
The terms of service/use of their bot does not need to contain their real name etc. they can just use the bot's name or similar or simply "Bot"
Same for the privacy policy
But is this the case in all countries? i thought it was a must in germany / europe to conatein their real name etc
https://www.termsfeed.com/blog/sample-terms-of-service-template/ contains everything you need to know about Terms of Services
Thank you
CSS is totally my favorite
gotta love 20 rules for just one class
or one button
oh hell no
bye
no
nope
hell no
more work for the same thing
except you have to maybe google a bit
to get the right rules
but no thanks
there's a reason why I don't use style attributes and use css files instead
To not have a HTML mess
bootstrap
bootstrap decent
tru
but doesn't work for everything
😩
waiting for desktop
web support planned but tbd 😭
yea
the only guys who can have text this big and have it look good
but yea looks good
oh hell yeah
i thought you couldn't do .emit and .on on ipcMain with electron on just the back end
🔥
that looks like windows 11 menus
lol
tailwind is better imo but material is nice
Tailwind CSS is a utility-first CSS framework for rapidly building modern websites without ever leaving your HTML.
without ever leaving your HTML.
without ever leaving your HTML.
what scares me ^
Yes
I like sorted things
HTML is just 3 colors all over on default in VSC
and then 20 classes getting added
did your former pc explode from fiddling with available memory?
I'm trying to figure out why https://hamoodihajjiri.com/blog aren't displaying the blogs, it's only displaying during next build.
console my boy, console
What does that even mean?
means ur ssl is invalid for that domain
not for the base url, for the resource url
hm, did u try without www?
I noticed I get redirected the moment I access the resource url
Hmm, it does return revalidated as true when I don't access it via www.
yeah lol
won't do it again
it looks so clean i almost don't wanna start downloading every single app i had before
did you specify your ssl address as www.hamoodblablabla.com or hamoodblablabla.com?
cuz that matters
remove www
no, I mean in the certificate
where did u get yours?
Ohh, in the Let's Encrypt?
also damn why axios
Let me double check.
it's such a bloated lib
Honestly, I've been following this one tutorial for like months and this dude kept talking how axios is this and that.
axios is unnecessarily bloated, like, really
node fetch does everything axios can do but is more lightweight
I'll probably consider switching, really. I just need to figure out what I'm doing.
btw, just as an aesthetics tip, use something else instead of secret for the name of the key
What do you mean?
secret doesn't sound very safe to be in an url
like, use &v=thekey or smth
or better yet, use a post request + body
which u should if that secret is something sensitive
Also, it yet doesn't display:
Don't have a file with that name.
There’s gotta be a portfolio file
I'm running about 100+ bots with a single script, how do I reduce the bots resource consumption? How do I make it more stable? Heroku crashes continuously. I'm using the code below, any other suggestions?
intents: 1,
makeCache: Options.cacheWithLimits(
{
...Options.defaultMakeCacheSettings,
MessageManager: 0,
ThreadManager: 0,
ThreadMemberManager: 0,
UserManager: 0,
GuildMemberManager: 0,
GuildBanManager: 0,
GuildEmojiManager: 0,
GuildStickerManager: 0,
GuildInviteManager: 0,
GuildStickerManager: 0,
}
)
}```
The portfolio content is displaying fine, actually. I called the main file index.tsx in it, though it's the blog content that's not displaying.
What
Wtf
Why do you run 100+ bots
That was going to be my first question
Looks like someone is doing something against ToS here
How are they running 100 bots in one file
index.json did load, are you updating the body?
I don't know if even my VPS with 4gb of ram would run it
The more I look at it the more questions I have
I'm unsure.
simple, you don't
nah it is easily able to do that, though mostly only tried with 10
but can easily tell you
100
Without frying the vps, it’s nearly impossible
first thing is WHY you're running 100+ bots in JS which by itself can barely handle a single bot
make sure you're on djs 500 for that
I cant even see a single speck of reason to run more than 10 bots
like, focus on a few bot projects damn
max I've done is run 10 bots concurrently to test stuff, otherwise just separate processes
I have 3 bot accounts, but only 1 working bot
My man’s on another IQ level above us





