#development
1 messages · Page 114 of 1

Who is this guy are they actually using gpt
you don't want to know, better leave it as is
It's an experiment
they're doing that?
It's scamming time
Discord will become even more aids than it already is
Doesn't change much than now
Great
So excited for big text spam
any
I wonder, can u make tables?
Nope, tried
meh
Would've been awesome 
any language can be used to make anything
They can't even make block quotes look good and fit good for mobile and desktop so don't expect tables
the only difference is the learning curve
No as you will use a backend
I hate that they removed inline code background from embeds in mobile
Which can be done in any language
I used it to highlight certain parts, now they look all the same
Where you can actually make backends
I hate anything about code blocks for iOS
Still not even syntax highlighting
what is it always spitting out / for the path
Or the ability to click and watch a code block full screen
bruh
then you hire 5 developers, setup a JIRA account, setup jenkins/github CI/CD, have morning meetings every monday, schedule demos with interested clients
oh and dont forget to make the code look as awful as possible
Aye
yes, "enterprise codebase" ain't rainbows as everyone think
hobby projects are much cleaner and efficient than them
just use whatever language and tools you want to achieve your goal
don't bother with "standards" unless you're making a public api
Wait for it soon text colors will also become a thing maybe exclusively for nitro
ofc, don't also disregard them completely, just not focus entirely on it
Pin this
That would fit pretty much into their customizability philosophy for nitro users
are you saying my project is better than google

I said "cleaner and efficient", yours is neither
GPT projects do not count as hobby projects :/
just make sure you use a language you like, else your life will be hell maintaining the backend
Languages are tools to solve problems
Some are better at solving some problems than others are
how can i remove characters at beginning
You can't
bruh
That's a shortened IPv6
This is literally how ips look like
oh my
Are you a real person

No it's a shortened version of it
bruh so it's my ip?
ok so, waffle how did u make ur projectile collision check?
Aaaahaha
trying to find ideas on how to optimize mine
No it's the local address
I’ve totally done that 👍
eh
Can be written like ::1 as well
and not 127.0.0.1
I’m probably going to use the bounding volume hierarchy algorithm or whatever it’s called
Separate each hitbox into intervals on each axis and check which intervals overlap
Then if either axis has an overlap, check if they collide
Waffle creating the next battlefield?
That way you reduce your collision iterations a ton
I mean, that'll still require iterating over each entity wont it?
my issue is that it gets quite slow on high entity count
since each entity checks for collision
Yeah the bounding volume hierarchy algorithm is to reduce the checks needed
I'll need to look into that
Checking the actual collision is expensive, checking if intervals overlap is cheap
This is an article I just looked up rq to show the algorithm I’m talking about
Might explain it better than I can
It’s in C++ but should get the idea across just fine
Make a prober hit box detecting
Don't wanna make a head shot being count as leg shot

if(Math.random() > .5) { hit = true; } 🧌
Why bother checking collisions if they’re random anyways
that book is extremely technical lul
Yes it is
There’s tons of resources online about collision tho
Tons of stuff and algorithms to choose from
I'll give it a read later, eyes aint ready for lightmode reading atm
Just gotta figure out how to implement it
I feel like in 10 years my copy paper will be dark and the printer scratches letters and numbers out instead of printing
To "save" your eyes
I mean, at least paper isn't emitting light on your eyes
but then, this also exists
At least it isn't brown
why is this returning nothing 
a
that should definitely return something
there are so many things in my database with a in it
I only see the placeholder ? And no parameter being passed anywhere
i said what query is
Ok send me the message link where u did so
right here
I Said i wanna see the query not "a"
the query is a
he said the query is a
bruh
lmao
LMFAO
Is this hidden camera ?

im literally laughing irl rn
I'm still not sure if I should laugh or cry
both

if you laugh hard enough you end up crying
b
ok
Also I highly doubt the executing method of the prepared statement is called .all()
But yet I dunno the lib
Either way for a proper LIKE query you need to pass a pattern and not some random shit -> https://www.w3schools.com/sql/sql_like.asp
usually LIKE queries require a pattern matching operator, like %
i am not stupid
for example LIKE '%a%'
lemme see
Errr no
ty
You also use like without % to ignore the case
fixed it
In other words to match case insensitive matches
% is not avoiding the case
thats good
i want that
case sensitivity is defined in the table charset afaik
Yeah, or just lower everything lmao
Well that's just wildly guessing around
what
Not as PART of it
no
lmao
i said the query is a
Oh man... I decided to cry
fair enough choice
For real
Because I feel physical pain
what do websockets have to do with that
what physical pain?
i do too kinda
i cut my finger today
while chopping up some cucumbers
guys
how can i easily test POST stuff
like i can test get in my browser
can i do the same with post
By sending a post request
Using curl for example
?
curl
what is curl
Available on any OS
will it work for my post request?
Idk using an online service for testing and debugging stuff which sends request
Ahh yeah that was the name
Or simply use curl which already available in your command prompt
Google?
Though it's a malware, don't download it
My gosh
or in url
curl -d "param1=value1¶m2=value2" -X POST http://localhost:3000/data
In the cookies
cookies?
There u go
bruh
it's ok i am downloading postman
i don't like stuff where i type a lot
I ask everything to ChatGPT
So you can use your most used keys CTRL C and V
i swear 
or do i need to do something
Thankfully I have to do some work now
same 

0:0:0:0:0:0:0:1 IPv6
127.0.0.1 IPv4
I don't care what JavaScript says
How you handle the IP is something different
I tell you, ::1 is the same as 0:0:0:0:0:0:0:1 but compressed
Replace ::1 with whatever you want????

now i have to do all the sessions and use jwt
make what?
uhh did you even read the express docs
no
req.body usually means that's the body you are looking for
did u pass it as a param
show me the req handler in the express
what request handler
the one u are using to get the body data
show me the entire thing
ok
copy pasting is easier btw
i also found another issue unrelated to that
ok i fixed it
but this issue still presists
is this localhost:3000
Do you still filter by your local address?
If so exclude the source ip of postman from your statement
Also consider filtering the source IP in your firewall not in your code
Filtering on this network layer will make you cry very soon
idk why but Im proud of this
that has nothing to do with the issue
i am getting the requests
but body is undefined

My statement has nothing to do with the issue but is fairly important recommendation
idc then
i need help with this
theres no reason why filtering from my code is bad
i dont see the issue
Didn't expect you to know anything about network layers
I just wanna be able to tell you later "I told you"
told me what
Did you have app.use(express.json()) in your code?
You need it for it to parse JSON body
so i need to use app.use twice?
The object?
yes
Did you add content-type: application/json as the header while making the POST request?
no
Add it
I would trust fake btw, he’s got quite a bit of web api experience in all seriousness
It wouldn't know if it's a JSON otherwise so it won't parse it
well
i don't know how to do what he's saying
w
now i can insert games from my website 😱
gaymes
I gave you the tip to at least filter the source IP on a different layer, for example your firewall
That's much more "efficient" and reliable when it comes to attack or simply request spam
Yeah a firewall is probably a lot faster at blocking requests than programmatically doing it
like
i want my endpoints to be organized so i can put it in a games folder in my endpoints folder then put the file in there and it'll make that the path
Ah, so like the way nextjs does it
just check if the type of something is a folder and then loop it again with the same logic
but i want it to infinitely loop if there's more than one folder
aka fs.stat exists
so if there's another folder in a folder it needs to loop through that one
you dont need fs.stat
Yeah, recursion is usually pretty good for filesystem stuff like this but iteration will be faster
Tim has probably done this before :^)
how do i do
hm
import * as fs from "fs"
export const getAllFiles = (dirPath: string, arrayOfFiles?: string[]) => {
const files = fs.readdirSync(dirPath)
arrayOfFiles = arrayOfFiles || []
files.forEach((file) => {
if (fs.statSync(dirPath + "/" + file).isDirectory()) {
arrayOfFiles = getAllFiles(dirPath + "/" + file, arrayOfFiles)
} else {
let filePath = dirPath + "/" + file
arrayOfFiles?.push(filePath)
}
}); return arrayOfFiles
}
export const getAllFilesFilter = (dirPath: string, suffix: string, arrayOfFiles?: string[]) => {
arrayOfFiles = getAllFiles(dirPath, arrayOfFiles).filter(file => file.endsWith(suffix))
return arrayOfFiles
}```
I do it like this
readdir or readdirsync with { withFileTypes: true }
i use readdirsync already tho
it returns a dirent object instead of a file name
if you set withFileTypes true
a dirent object contains everything about the file
but
i am getting an error now

Error: Cannot find module './endpoints/[object Object]'
so you no longer need fs.stat

Whatever you’re concatenating with the file path is an object and not a string like you expected it to be
bruh
i am doing what tim said
show code?
yes and now you need to handle the object
if its a file then add it else fetch the folder
also, reread it returns a dirent object instead of a file name
but
youre broken
true
this is too confusing
no code no help
what does this return fs.readdirSync('./endpoints', { withFileTypes: true });
an array of fs.Dirent objects
what is a dirent
an object containing information about the entry
what entry
named after Directory Entry
entry as in, the file name
filesystem entry
instead of returning filenames
it returns an object with more information about the file
not only name
to access the name, instead of using the entry directly, you have to add .name
how will that help me succeed
this is similar to what you need
because it also gives you the isDirectory() method
that you can use to check if its a file or a folder
which is what you need to check folders infinitely
i don't get it
how will that help me check it infinitely
idk how to do an infinite loop
You don’t need an infinite loop, you need a loop that goes until you meet a condition
just like in the screenshot I sent, just call a function over and over until you finish
i don't get
what you want is called recursion
or a recursive function
its a function that calls itself
for example
function abc(path) {
const files = fs.readdirSync(path, { withFileTypes: true })
for(const file of files) {
if(file.isDirectory()) {
abc(`${path}/${file.name}`) // this is recursion, the function calls itself again, but with the updated path
}
}
}
bruh
i can do that?
wow
yes
stack overflow:
@solemn latch
ok
it's not working
function setEndpoints(path) {
const files = fs.readdirSync(path, { withFileTypes: true });
for (const file of files) {
if (file.isDirectory()) {
setEndpoints(`${path}/${file.name}`)
} else if (file.name.endsWith('.js')) {
endpoints.set(`/${file.name.replace('.js', '')}`, require(`${path}/${file.name}`));
};
};
};
setEndpoints('./endpoints');
@frosty gale don't post content like that please
bro why are you always minimodding 💀
quite a bit of files
This will infinitely loop
That's a fair ping, I'd rather be pinged for that than not pinged
bruh
You have no “base case” to stop the function from calling itself into oblivion
its a for loop
its not infinite
it will stop
It’s just a ping for mods to handle it
I’ll let them decide
Didn’t see that it’s outside of the function
oh wait
it does work
function setEndpoints(path) {
const files = fs.readdirSync(path, { withFileTypes: true });
for (const file of files) {
if (file.isDirectory()) {
setEndpoints(`${path}/${file.name}`)
} else if (file.name.endsWith('.js')) {
endpoints.set(`${path.replace('./endpoints', '')}/${file.name.replace('.js', '')}`, require(`${path}/${file.name}`));
};
};
};
setEndpoints('./endpoints');
w
this works
yes
it works beautifully
jesus Christ
a client of mine
thinks that his 2 mb/s upload ubuntu server
is good enough for a discord bot
and he keeps complaining that I have to fix it "beCaUse iT wOrKeD for DowNLoaD apPliCaTioNs"
thats not too bad
Yikes...
When the body of the ready event is too large causing a connection timeout
2mb/s is awful for a server, but honestly it’s not too far off from a slightly shitty home internet connection
16mbps is like half of what I get on average
I get 700 upload 30 download
And costs like 30-50 dollars a month
Or smt like that
Close to my router I get like 200 down 10 up
cable moment
We don't have super good fiber access in our area (plus it's expensive for the stuff that is actually here) and we don't need anything fancy
More than fast enough for the average internet user
Plenty
bot.command("homework", async msg => {
await msg.reply("a", {
"reply_markup": {
"one_time_keyboard": true,
"keyboard": [
[{
text: "Morning",
one_time_keyboard: true,
callback_data: "morning-class"
}],
[{
text: "Afternoon",
one_time_keyboard: true,
callback_data: "afternoonclass"
}],
],
resize_keyboard: true
}
})
})
bot.action("morning-class", async msg => {
await msg.reply("What's the homework for the Morning class?");
session.push({
session: "Morning",
date: new Date()
})
})
bot.action("afternoonclass", async msg => {
await msg.reply("What's the homework for the Afternoon class?");
session.push({
session: "Morning",
date: new Date()
})
})```somehow the bot doesn't action the thingy
we dont either
its all copper
Well yeah I figured since your upload speed is significantly lower than download 😉
You just pay for a better plan than I do, so you get more speed
who has tips for making a website
html + css + js
Anyone know if the new file upload limit also applies to bots or is it just for users?
You can use framework like bootstrap / tailwindcss to build faster a website
^ but not bootstrap
test it out
should apply to bots as well
@neon leaf So I was trying to add my email to gmail but I don't quite get what I am supposed to do here
I know that mailcow smtp is on port 25 as for the path for it I don't know what else it could be other than mail.aarondye.dev unless I have to set it somehow
and I assume the username and pass would be what I use on sogo to login to the email
Thank you very much 
Use <iframe>
Afaik u need to use pop3 with Port 993, Username is also the full email
Hello, I need to talk about how Topgg developers make that red and black theme color on the Topgg page. Can anyone explain it to me, please, in HTML?
<Link color="purple.600" fontWeight="semibold" href="/signup">
Sign up
</Link>
i am using nextjs and for some reason when i use <Link> it causes hard refresh?
they are using a gradient, which is generated by a modular component library
in this case it is chakra-ui
can you give me any example as video or docs
it's only available for react tho
we can't do it static website?
i am not sure, but i think you can achieve it with css not sure how as i am shit at frontend
😔
but this method known as?
you might have to do some digging
it's just a gradient
but they do it very nicely
hmm thanks
The easiest way of doing it is to structure and separate your css files
For example one only containing the layout and one your theme adjustments for the entire body
@austere mica ^
oh hmm
Now load the default theme (css file) in your html head
Then create an user interactable element like a button or icon etc. and simply use JS to replace the src attribute of your meta tag
Like I said using a button or by registering an event handler for the element
On every click you can get the current value of your meta tag that loads your theme file and change the value properly
It's nothing special, it not animated etc. but it works smoothly and instant without reloading the site
so now that i am thinking of adding a themeswitcher, should i make a config file to set the default one if there is nothing on the local storage?
or what's a easy way of getting through it?
On every click you can get the current value of your meta tag that loads your theme file and change the value properly
console.log("Start")
for (let i = 0; i < 5; i++) {
if (i === 3) return;
}
console.log("End")```
Would "End" still get logged?
Give the meta tag an ID attribute and get the value of the src attribute using JS
Those are all in the same scope?
Then no
You will need to use break
hey @slender wagon what is theme hex color of topgg?
I believe thats not what u need
found out the way
not need to add texture color
idk why it says 53 years
this is the time variable when the started embed was sent
const timeLeft = Math.floor(Date.now()/1000) - time;
and this is the time variable
Math.floor(Date.now()/1000)
Believe it or not if you subtract a number by the same (or very similar) number it’ll result in a small number
The discord time stamps aren’t really good for showing time taken as far as I’m aware they just show a specific date
you just have to request to the openai api so yes
i have tried for hours now, i have made the bot and api
but the code part messes it up
i even asked chap gpt himself
chat
then its most likely that you did something wrong
yes
could you help set it up
post your code and the error you get
If you have any questions about your code, ask them, but no one will write you a bot from scratch
import openai
import discord
Set up the OpenAI API client
openai.api_key = ""
model_engine = "text-davinci-003"
Define the intents for the bot
intents = discord.Intents.default()
intents.members = True
Initialize the Discord client with the specified intents
client = discord.Client(intents=intents)
Define a function to generate responses to user questions
async def generate_response(message):
# Send the user's message to the OpenAI API
response = openai.Completion.create(
engine=model_engine,
prompt=message.content,
max_tokens=1024,
n=1,
stop=None,
temperature=0.7,
)
# Get the generated response from the API
response_text = response.choices[0].text.strip()
# Send the generated response back to the user in the Discord chat
await message.channel.send(response_text)
Define an event listener for incoming messages
@client.event
async def on_message(message):
# Only generate responses to messages in a specific channel
if message.channel.id == :
# Ignore messages from the bot itself
if message.author == client.user:
return
# Generate a response to the user's message
await generate_response(message)
Start the Discord bot
client.run(".")
chat gpt said its fine
it dont answer proberly
@earnest phoenix
@deft wolf
they said they could help
never said that i could
I don't quite understand what response you expect from the bot to the hello message
```py
code
```
please
same api
Then ask your bot the same question and see what the answer is
Have you tried logging the entire response object and seeing what the prompt being sent to the api is
logging the entire response object
not show your generate response function
@rustic nova in new to this, pls explain
have you ever worked with python before?
yes a little
you have a response object
created by the Completion.create function from openAI
that response contains the response
now just print that out
``import openai
import discord
Set up the OpenAI API client
openai.api_key = "sk"
model_engine = "text-davinci-003"
Define the intents for the bot
intents = discord.Intents.default()
intents.members = True
Initialize the Discord client with the specified intents
client = discord.Client(intents=intents)
Define a function to generate responses to user questions
async def generate_response(message):
try:
# Send the user's message to the OpenAI API
response = openai.Completion.create(
engine=model_engine,
prompt=message.content,
max_tokens=1024,
n=1,
stop=None,
temperature=0.7,
)
# Get the generated response from the API
response_text = response.choices[0].text.strip()
# Send the generated response back to the user in the Discord chat
await message.channel.send(response_text)
except Exception as e:
# Handle any errors that occur with the OpenAI API
print("Error generating OpenAI response:", e)
await message.channel.send("Sorry, there was an error generating a response. Please try again later.")
Define an event listener for incoming messages
@client.event
async def on_message(message):
# Only generate responses to messages in a specific channel
if message.channel.id == :
# Ignore messages from the bot itself
if message.author == client.user:
return
# Generate a response to the user's message
await generate_response(message)
Start the Discord bot
try:
client.run("..")
except Exception as e:
# Handle any errors that occur with the Discord API
print("Error starting Discord client:", e)``
posting your whole code again wont change anything
i dont undstand what you mean
I really suggest looking into python first (general debugging, possibly even how to use it at first) before approaching openai related things
printing out your response object is as simple as doing print(response) or just responding with the response object on your discord on_message
and dont rely on chatgpt literally giving code if you do not understand what you have just generated
ik
i think i have a ok understanding of the code
mostly doing this to learn
oh
so it's about right
why would u perform rounding and dividing multiple times?
(Date.now() - timestamp) / 1000
errrr... good question, i think 5 was the limit
but lemme take a look
Select Menu Types
There are 5 different select menu components that can be included in Action Rows.
Impossible yet
Yes
Currently there are only 2 possible styles for text input
Name Value Description
Short 1 Single-line input
Paragraph 2 Multi-line input
aka text input or text area
ehm regarding this #development message
might have misunderstood you
you're talking about rows, right?
ah nvm it still seems to be right
5 rows
djs probably returns the response as string, always
You simply use the isNaN() function
isNaN("2") will return false
basically means it is not not a number
means it is a number
the function is called "Is Not A Number"
not "Is A Number"
so you need to rethink what it returns
it will return false once the passed argument, for example your response "22" is a number
would return true if the response for example "22ff" is not a valid number
also something important
the entire user input of the text field or text area will be send as response
this means if the user accidentally adds a space behind a number, it will be a string
"22 "
so use trim() when getting the response
if I enter one digit only together with one space, it will become a string
just add the method when getting the value of the field
<modalsubmitinteraction>.fields.fields.get("field-name").value.trim()
or by using the methods...
<modalsubmitinteraction>.fields.getTextInputValue("field-name").trim()
I always prefer to not use the methods and access the data directly
As djs tends to change the method names all the time, or their case etc.
the structure of accessing them directly will most likely never change is djs tries to keep the structure like as the api structure
maybe you will end up to change the name of the methods on the next release of djs
as those retards being known to randomly change the names, or case or simply remove existing (useful) methods/guards etc.
<modalsubmitinteraction>.fields
until here
then
accessing the field data
<modalsubmitinteraction>.fields.fields
Type: Collection <string , ModalData>
so... you can use the available methods to get the data out of the collection
like I wrote above
<modalsubmitinteraction>.fields.fields.get("field-name")
which returns an object
to enter the value for example, you select it's property
<modalsubmitinteraction>.fields.fields.get("field-name").value
The structure itself is defined by the discord api
Lets be nice please FakE 

wut
ah u're speaking about my words regarding the djs stuff?
rodeo
well it's just the truth imo but I try to formulate things differently
you installed the db and not the client is my guess
never installed mongo under linux
Does anyone know how to tint a BufferedImage in java? I saw this online, but it just produces a white rectangle when I supply it my image: ```java
public static BufferedImage applyTint(BufferedImage src, int r, int g, int b) {
BufferedImage img = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TRANSLUCENT);
Graphics2D graphics = img.createGraphics();
graphics.setXORMode(new Color(r, g, b, 0));
graphics.drawImage(src, null, 0, 0);
graphics.dispose();
return img;
}
Perhaps you might know @lyric mountain?
The problem with that is that it would add colors to areas with full transparency
I need to preserve the original alpha values if possible
Not if u use DST_IN
Or was it SRC_IN
Whatever, I have that in my code, just a sec
...except I don't remember where
Anyway, what u want is setComposite() method
Fiddle with it a bit, it's in Graphics2D
Remember to return it to original state afterwards
This 2d Java tutorial describes 2d graphics, geometry, text APIs, images, printing, advanced 2d topics
From the time oracle was a decent company
So I'm pretty close to getting it to work, but for some reason it looks like it's just completely overpowering the source image
I'm using this: ```java
public static BufferedImage applyTint(BufferedImage src, Color color) {
BufferedImage img = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_INT_ARGB);
Graphics2D graphics = img.createGraphics();
graphics.drawImage(src, null, 0, 0);
graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_IN));
graphics.setColor(color);
graphics.fillRect(0, 0, src.getWidth(), src.getHeight());
graphics.dispose();
return img;
}
setColor includes alpha right?
Like, the rectangle is just drawing completely over the original sprite and leaving nothing behind
Hold on, let me get an example
That's with 50 alpha
Even more odd, at 10 alpha the entire thing just disappears
Oh, I'm stupid
I was using SRC_IN when I should've been using DST_IN
Lul, I always confuse both
They could simply use ORIG_IN and it'd be 100% more intuitive
Actually this is wrong too
It seems to ONLY care about alpha now, not the color of the rectangle
Try the other modes, there are a bunch
Actually from looking at the description DST_IN that seems to be exactly what it's meant to do
I don't see any modes that seem to match what I'm looking for, it might be a RenderingHints thing
Could be
DST_IN is definitely what I want for alpha tho, I'll try to look for color blending solutions
There's a ton of different draw modes but none of them seem to combine color of the src and destination while preserving src alpha
maybe chatgpt will know, I'll ask that
Ok it appears I wanted SRC_ATOP
got it
preserves original alpha, applies a transparent tint
(Don't worry about the player shooting stuff rn, that's just a WIP lol)
Well, that's just an example for buttons, I want to be able to tint any bufferedimage to any color I'd like
And this does exactly that
There's RescaleOp for that (darkening or lightening), it's simpler and more performant than alpha ops
But if u want colors then alpha is the way
Performance isn't super important here since all of these operations will be done during load time
dynamically doing this every frame would be EXPENSIVE
Fair
I suppose I could implement a wrapper over BufferedImage though for something like darken() or lighten() so I could be as performant as possible depending on the operation the user wants to perform
But that'll be later since that's not a big priority
I like g2d for how high the skill ceiling is without having to enter too much into opengl
like, it can be insanely powerful for advanced users yet simple enough for newbies
It's quite interesting because I can definitely see the almost word-for-word functions that go to ogl, then it also has something as simple as drawImage
g.setComposite(AlphaComposite.SrcAtop) is essentially just a fancier version of gl.setBlendMode(SRC_ATOP)
whats the best way to handle errors in an eventemitter? I found this but its deprecated since atleast 8.x and idk if I should use it https://nodejs.org/dist/latest-v19.x/docs/api/domain.html
my current code looks like this:
you want to catch errors from an event callback?
or what
yes, like ee.on('foo', () => { throw new Error(123) }) ends up in a unhandledruntimeerror
technically youre not supposed to do that, the consumer of the event is responsible for catching their own errors
swallowing errors caused by the consumer may lead to unexpected behavior for users, as they will expect one type of error and get something else
but you can do that by using the private _events property
try {
emitter._events[eventname](args)
} catch {}
but you need additional handling in case there are multiple listeners
if there is more than one listener on the same event, _events[event] becomes an array of callbacks
so you have to loop over it
if there are none its just undefined / null / ..., right?
alr then imma have a bit of fun handling that, but what do you mean with unexpected behaviour?
updated
basically if you have a library that emits events, the user might not expect the library to swallow errors caused by the user
and get confused when their code does not error like it should
basically I have a ton of events and an event for manual error handling for all events combined
and if the error handling event fails there is obv a fallback to prevent infinite loops
ive done exactly what youre doing in the past with my lib
but then decided to revert it and let users catch their own errors
i feel like it makes more sense that way
but you can do that if you feel it makes sense for your project
I mean I understand it but I dont want a users webserver to randomly crash
I think there its needed
you can check the way i did it
it should be in some past commit on github, before i reverted it (tiny-discord repo)
i had special handling for all sorts of situations including race conditions from multiple event listeners
that sounds very similar to mine
this should work as intended, right?
import TypedEventEmitter from "../types/typedEventEmitter"
import { EventHandlerMap } from "../types/event"
import { EventEmitter } from "events"
export default class SafeEventEmitter extends (EventEmitter as unknown as new() => TypedEventEmitter<EventHandlerMap>) {
emitSafe<E extends keyof EventHandlerMap>(event: E, ...args: Parameters<EventHandlerMap[E]>): Promise<boolean> {
return new Promise<boolean>(async(resolve, reject) => {
const callback: undefined | Function | Function[] = (this as any)._events[event]
if (!callback) return resolve(false)
if (Array.isArray(callback)) {
for (const cb of callback) {
try {
await Promise.resolve(cb(...args))
} catch (err) {
return reject(err)
}
}
return resolve(true)
} else {
try {
await Promise.resolve(callback(...args))
} catch (err) {
return reject(err)
}
return resolve(true)
}
})
}
}```
Any of yall know if bots can send audio in the top format, instead of the bottom format?
Yeah bots can
nice
Voice messages are not the same as files though
Some magic around it
Probably need the X-Super-Properties header as well because it's not documented yet iirc so not really official and may be subject to changes
And remember that it's limited for now
DMs, GDMs, and servers with fewer than 200 members on mobile
I mean
Every platform can listen
But your bot won't be able to send them
Can always make fallback to old method if the voice message one fails
Yeahhh true, it would be super cool to use a voice message instead of an mp3 file
Just looks way nicer
It does, and it takes up less space which is another big plus for me
Yeah definitely
Depending your usage you may want to let users seek to a specific time
Not sure if that's possible with voice messages
it is
Never used it nor listened to one 
but I dont need that functionality
Yeah then it's fine
Though considering it's iirc undocumented, API related to it may change in the coming days
fucc it we ball

Can I get an answer on this one still
No, a return statement completely stops the execution and returns back to the caller with the value on the right-hand side of the return statement, and return statements can only be used inside functions
looks good yeah
A break statement completely stops the loop (for, while, and do..while), but doesn't stop the execution of the code in the function or ones outside
yes that will run the function then exit the loop
and continue the rest of the code after the loop, if any
I just dont get it bro

Why is it using mail.aarondye.dev
I assume it is cause of either my cloudflare DNS settings or nginx itself
the only thing that is accessible on my site is mail.aarondye.dev but going to just aarondye.dev gives me a "Your connection is not private"
Krill issue
@undone rose If you don't want to copy paste the header for voice messages:
'x-super-properties': 'eyJvcyI6IldpbmRvd3MiLCJjbGllbnRfYnVpbGRfbnVtYmVyIjo5OTk5OTk5fQ=='
It's base64 for
{"os":"Windows","client_build_number":9999999}

lul I said two times
The Error: Cannot find module 'node:events' occurs if you are not using the latest version of node. js 16.6. 0 or above and developing the discord bots. We can fix the issue by upgrading the Node.
first google search
big w
I tried but its not fixed
hm
Do node --version
that's probably a good idea
both work actually
well
nice
Yeah, update it
there's your issue
is it supporting v14?
Node v10 is old as shit
^^
which is 18.x
how can I upgrade this
Visit nodejs.org - Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.
You can download it on their website, or you can use the nvm tool (the recommended way)
but I m using a site
Yeah go for nvm
I know how to upgrade in normally
what site
average replit moment i guess


Oh boy
Didn’t glitch ban running discord bots on their services a while ago?
idk
Or is that just abusing stuff like uptimerobot to keep it up
doubt
glitch does
Doubt they banned discord bots honestly
hmm
https://discord.com/developers/docs/getting-started#remixing-the-project discord themselves encourage of using it 
they banned using third-party services to ping projects to keep them awake
Just go in your package.json file and write down "node": "18.x"
In the engines field
ok
So like
{
"name": "...",
"version": "...",
"main": "...",
"engines": {
"node": "18.x"
},
"scripts": {
...
},
"dependencies": {
...
},
"devDependencies": {
...
}
}
I m going to good words about this
finally mission passed
but
...
I have one more problem
which version of the moment is best
lts
thx
oh
I have a problem again
I look like an cave man
but
who is this person
const { SlashCommandBuilder } = require("@discordjs/builders");
its erroring
require it from discord.js
What error?
requireStack: [ '/app/src/commands/ping.js', '/app/server.js' ]
I m not using discord.js
what
this ain't an error
how is that an error
replace @discordjs/builders with discord.js
its now in the base module

- /app/src/commands/ping.js
- /app/server.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1026:15)
at Function.Module._load (node:internal/modules/cjs/loader:871:27)
at Module.require (node:internal/modules/cjs/loader:1098:19)
at require (node:internal/modules/cjs/helpers:108:18)
at Object.<anonymous> (/app/src/commands/ping.js:2:33)
at Module._compile (node:internal/modules/cjs/loader:1196:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1250:10)
at Module.load (node:internal/modules/cjs/loader:1074:32)
at Function.Module._load (node:internal/modules/cjs/loader:909:12)
at Module.require (node:internal/modules/cjs/loader:1098:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/app/src/commands/ping.js', '/app/server.js' ]
}```
matey please just replace the module with what I / battleless said or install it
☠️
thank you so much
does someone know quite a bit about js references?
like I have an array thats an object with more nested objects, most of them arent references but I want few of them to be, so I made a variable that acts as my reference (its an object) and add it to the object in the array, now if I use Object.is to see if an object has the same reference the global reference says false when comparing to the first elements reference but is true when comparing to the second objects reference in the array, so all objects in the array share the same reference but it isnt the reference to the global one. why is that and can I fix it?
I didn’t quite understand
like I have an array of object, right?
and lets say that object has two properties, name which is a string and school which is another object
now normally when you do const x = otherobject, x will be a reference so when you do x.name = 'test' the name also changes on otherobject
thats what I want for the school object
but for some reason when I lets say do people.push({ name: 'foo', school: globalObjectForSchool }) it isnt actually referencing school like I want it
imagine globalObjectForSchool being a variable thats accessible everywhere and that contains random properties, doesnt matter for this example
but now if I change the global variable for school it doesnt change in the people objects
but when I change the school property of one of the people, all change
so the reference somehow moved without me wanting it to
all objects are references
Is this possible? js {} += {"key": "value"} //Expected outcome: {"key": "value"}
nope

but you can do that like this
yeah
spread op
but I dont really mean generally

