#development
1 messages · Page 191 of 1
Yes, it's supposed to be with console
like first get the number,then get the operator,then get second number
Yes
Then do more complex stuff
A snaker game is a really nice project
Yk, the snake that has to eat apples and avoid its body
I do it in every lang that I start
Even console tbh
yes even console
Just need to clear it on every frame
remember that telnet link
that plays the entire star wars movie in your terminal
with ascii
telnet to towel.blinkenlights.nl
lmao
on the internet,i only find snaker games with web dev
The concept is the same on every lang
Arrays + recursion
But that's just an example, you can come up with any project u want
thats also where knowledge about computer science comes in, it helps you determine the limits of each language and environment and lets you know what is possible and what is not possible
The more you challenge yourself, the better you'll become
become a challenjour
Just try to avoid online help as much as you can, except for documentation ofc
Only resort to it when u become truly stuck
also, dont stress yourself too much
we got to where we are after many years of experience
you'll get there as well
thanks!
btw you guys are web devs or application devs or what
must be doing job somewhere right?
not really no
i work on my own personal projects, i do freelance work and i teach js part time
freelance hmmm
so website slike fiverr and all?
One message removed from a suspended account.
One message removed from a suspended account.
not really no
it mostly through my bot and linkedin
my area is pretty niche
astrology/astronomy programming
nice
astrology bot?! seems interesting
linkedin ohh
cool
let me try your bot actually
so let's say, the url is quote/quote-here then for the quote-here quote the textbox be a slightly darker colour
if (keys.includes(req.params.id)) {
console.log('yes' + req.params.id)
key = req.params.id;
} else {
console.log('no')
}``` I am assuming I am supposed to add something in the if the conditoon is true - however I am unsure
<% Object.values(constants.quotes).forEach((q) => { %>
<div class="col-6">
<a href=""></a>
<div class="p-3 border"><%- q %></div>
</div>
<% }); %>``` for the `a href="<key here>"` i am unsure on how to match the `object.value` to the `object.key`
u can use Object.entries(quotes) instead
that will give both key and value in an array
Let me tryhow would I display?
Object.entries(constants.quotes).forEach(([key, value]) => {
that works - thank you
css is done on the browser side, with css+html
for example, you already have a class p-3 and border in your div element
you can change the color style for one those classes
or create a new class and add it to the div
and set the color for that class in your stylesheet
One message removed from a suspended account.
One message removed from a suspended account.
whose balls?
thats the problem im running into now - how can I check the /quote/this-here and add the css to the correct div
you can add a custom class to the div
or add an inline style
<div class="p-3 border" style="color:<%- colorvarfromjsside %>"><%- q %></div>
yh but then it'd change all the colour? not the specific one though right?
<div class="row gy-5">
<% Object.entries(constants.quotes).forEach(([k, q]) => { %>
<div class="col-6">
<div class="p-3 border">
<a class="quote" href="<%- k %>"></a>
<%- q %>
</div>
</div>
<% }); %>
</div>``` this is how it is looking now
Specific one
you will need to define which colors for which quotes in your quotes data
and specify a variable for them
thats what I am struggling to do, how would I go about doing that?
theres a ton of ways to do that
for example, you already have a quotes object
{
abc: "my abc quote"
}
you can simply make the quote an object so it can have multiple values
and add a color to each quote
{
abc: {
quote: "my abc quote",
color: "#ee44ff"
}
}
of course, since you're changing your structure, you will need to adapt your code accordingly
you're using Object.entries(constants.quotes).forEach(([k, q]), which means the variable k is the key in the object, ie "abc", and the variable q is the value of that key, whcih before was "my abc quote" but now its { quote: "my abc quote", color: "#ee44ff" }
so instead of using q directly, you will now need to use q.quote or q.color
i keep getting "Authentication failed" from mongo even though my creds are correct?
unless mongodb is trolling you theyre probably not correct
or your syntax is incorrect
i assume youre trying to connect to mongodb atlas?
no
not sure, they are based on how i configured it via ptero i think
pterodactyl?
When it comes to sharding, is it pretty simple to implement this in k8s? I'm thinking 1 shard per Pod. Curious what other people have done or if this is overkill
There isnt really anything special with sharding. If your gateway logic is simple enough, you can implement cluster logic and make use of multiple cores or push the single core to the limit. Depending if you need message events then spreading more would be beneficial
My question makes it seem like I know more about it then I do lol, when you say the gateway logic, I'm hearing a seperate service to handle the incomeing requests that get forwarded to the appropriate shard. I'm using the JDA library to implement the discord bot.
Idk if jda is just monolithic, but the idea to not be monolithic if you want to spend less on servers and have your logic separated into where it makes sense like gateway and worker logic
ah I gotcha
I've been looking through JDA and it sounds like it's more monolithic. But i'm hearing ya
It's not worth it to me to implement the discord API myself lol. Thanks for the advice
yes
and also
here's a live issue of this happening
and hence this happens in node
even though it doesn't happen in compass
sharding is simply your bot telling discord that you want some subset of connections/servers
you can run anyof your shards on any hardware anywhere so, so using a k8s pod per shard makes sense
the problem is sharding across different machines takes a lot of orchestration and synchronization
rest rate limits need to be centralized, shard connection statuses also need to be centralized and correctly queued
Uhhh, I don't think that's the case
Pretty sure one can think of each "shard" of your bot as completely independent from each other
yes, the shard itself
but not the rest api, and not the login sequence
ie, how many shards can login at once, and which shards
which is important when handling reconnections
for small bots its fine, since you can ignore and retry
but for big bots you wont be able to ignore such things
ah, the max_concurrency field on start?
yes
guess i've never had a bot get large enough to care about that haha
but even more reason you could build out in k8s to make some of that inter-shard communication 🙂
max_concurrency works in buckets, so for example if you have 160 shards with max_concurrency 16, you can login shards 0-15 concurrently, but not shards 0,16,32,...
if shard 16 disconnects, you need to check if shard 0, 32, 48, 64, ... are connecting before you reconnect
so you need to have some central server to handle that part
Is fire base config considered environment variable or not? I am so confused
Like the API key, etc
lol only a test install
uh
yes, if you set one up locally
I'm trying to generate best case array for quicksort, this is the code I'm using:
fn make_median(arr: &mut [i32], lo: usize, hi: usize) {
if lo >= hi {
return;
}
let mid = lo + (hi - lo) / 2;
arr.swap(mid, lo);
make_median(arr, lo + 1, mid);
make_median(arr, mid + 1, hi);
}
The initial array given is a sorted array. It should give the best case input for quicksort but I have a one off somewhere
For a length of seven it generates the array [3, 2, 1, 0, 5, 4, 6] which when used quicksort gives:
[2, 1, 0] 3 [5, 4, 6]
The second array is correct and can be split into [4] 5 [6]
But the first gets split into [1, 0] 2 [] when it should be [0] 1 [2]
The correct array should thus be [3, 1, 2, 0, 5, 4, 6]
Fixed it, I shouldn't return if lo >= hi. I should return when the size of the slice between lo and hi is smaller than 3
Hello tim, just to inform you that intel cpus is better than that Ampere (ampere doesnt even have AVX)
ok, does anyone here know how to work with godot? specifically godot 3
why huh
wait, writing context lmao
omg make your game use discord activities
you are slow bro
I'm trying to connect to value_changed signal of Slider, which I need to pass 2 additional parameters
however
Error calling method from signal 'value_changed': 'Control(Settings.cs)::_SliderValueChanged': Method not found..
does not compile to web when using c#
and I'm not going to use a python-like language
yikes
4.3 does I guess
kuylar moment
I'll get an earlier commit of my repo to try it, brb in a sec
yes, that's why I resorted to 3.6
iirc it's due to c# wanting to have .net as entrypoint, but godot uses something else
anyway, need to figure out how to connect this method to the signal
my actual intention is to port my tcg to activities
but first I'm porting my ship game to get experience with godot
solved it
stupid cause, the node path was wrong
anyway, now the code is fully ported back to 3.6, time to resume what I was doing
that being the rest of the game
nice
i hosted my bot on cloudflare workers but it keeps going off as soon as i close vs code
what do i do
Are you sure you deployed it?
yes i did
when i open dashboard on cloudflare
it is showing my worker there
help guyz
guys help??!
it is not even repsonding to commands after i close vs code
responding*
there probably might be an error at production, things like maybe missing token maybe?? you should review cloudflare logs if there is one (i've never used cloudflare myself).
does your bot use interactions only? or does it run a normal websocket connection?
afaik cloudflare workers only support "serverless" bots, ie bots that only use the interactions api and do not keep an active websocket connection
Why isn't the bot returning guild owner for many servers?
It works for few like mine
when i do server.owner for others it just returns none
is it because the bot got into too many servers or smth?
but it's just in 960 servers for now
damn haven't seen jishaku in a while
Awesome but thats not helping xD
guild.owner is supposed to be a member but since it wasn't cached, it probably returned None instead
pretty sure guild.owner_id exists, so fetch the member or user using that
it's not returning the id either
wdym
Try owner_id
what is a wbesocket
owner_id. like i said, owner would be None
Damn man you're some angel for that
I totally overlooked _id's existence xD
can someone explain what tim meant here
Well for some context the system is like
the bot goes over all server's it's inside, if the command user has bot in any of his/her server, they get an extra pull every reset
it wouldn't work if u want to receive events (e.g. messages) since that requires connecting to the gateway through websocket
bots can work in two ways, websocket or webhooks
Well for now there's only 1000 servers, would it be bad to run this check once the bot's in a ton of servers
ok?!
websocket = bot keeps a constant connection to discord servers and receives events via this connection. this is the type that most libraries use, it requires keeping the connection online, reconnecting when it drops, dealing with shards, etc
not really, since it'll be looking through the cache and wouldn't make any API requests
unless u fetch the owner though
yeh ofc not
i don't think u need to, ID is enough right?
i dont think i have shard system and my bot is not evenn in 25 servers
for guild in self.bot.guilds:
if guild.owner_id == ctx.author.id:
total_pulls+=1
break```
this is the piece
webhook = serverless type of bot that does not require a connection. instead you give discord a specific URL in your bot's page, and discord will send web requests to your url whenever you receive an interaction event, and you respond like an API
yeah that's awesomesauce
Once I shard the bot, I'd have to do some re-write for it i assume?
don't think so
hm
u just have to run that same code on every individual shard
i think i have this one(not sure)
ah aight sounds simple
do you have an interaction webhook URL in your bot's page on discord developers?
no i dont
then you dont
yup, the first box there
i remember i saw some vid about setting this cloudflare on dc bot and he did smth about that box
but i did not tho
so what is the problem rn
bot completely is not online
the problem is that cloudflare workers are a serverless system, that turns itself off and on based on activity
and activity comes via http requests
a normal bot does not receive http wequests, it uses websocket
so to the cloudflare worker, your bot is not active
so it turns itself off
and it will turn itself on again once activity is detected
so what would the solution
but activity can only come through http
nah nah wait
which your bot doesnt use
bot is not responding to commands
once i close vs code
bot goes off
and does not responds to command
yes, because it turned itself off
so what can i do to fix
you cant fix it
unless you change how your bot works
and depending on the features your bot has
so basically cloudflare is useless for me right now
yes
hmmm,how much changes would i need
a serverless discord bot has to be designed from stratch, first of all you wont use a noirmal library like discord.js
youd need a specific library for discord webhook interactions
No
then you need to have a domain and url assigned to your cloudflare workers
so that when you access that URL, it runs the worker
then you put that URL in your discord bot dev page
i saw some vid as i told and he went to some website to get some endpoint as i remember
well,can i get some docs/vids
Coz yeah i want my bot online 😩
also
a serverless bot is never "online"
because it doesnt have a connection
and there are many features it cannot use
example of a serverless bot would be?
There is Giveaway bot that is serversless I think
it responds to interactions only
it does not receive any other type of events, and cannot access data from other events
ok and if i dont want like that
i can not use cloudflare workers
it cant even access guild count for example
so i dont know how many guilds it is exactly
i can only go by what discord reports
You need hosting
i was looking for free stuff
cloudflare was free so iused it
500 mb it provides
Free but limited
That's enough for your first bot
But replit has its problems with rate limits
bro when i am making smth,i am making with the intention to make it grow
500mb is just too less
i have experienced that
cloudflare workers give you 128mb lol
Then you need to invest and get the right hosting (paid)
also, cloudflare workers can only be online for 30 seconds max
and have a cpu limit of 10ms
You can't create a growing bot on free hosting
cloudflare workers are designed to run small things and only when needed, they turn themselves on when a request comes, and turn themselves off when the request is done
you cant run anything persistent on it
google compute engine has a free vps with 1gb ram
i dont think you can find anything better for free
although you can try that oracle thing
i dont know if still exists, but they were offering free stuff up to 24gb
but they also cancel you for no reason
XD
first i had memeory issues
now i have hosting issues
what most bot devs do once their bot grows is pay for a vps
5 bucks per month
5 bucks in US might be some one's pocket money
you dont need to be in the us, but you do need some form of payment
memory issue on a discord bot? What kind of bot have you made?
well, if you wanna stay free, either make a serverless bot, or make a cacheless bot
so first thing is bot won't grow until i have some unique idea (which if is complex will require me to pay money)
what are limitations to serverless bot again?
another alternative is to buy a raspberry pi if you're not willing to rent a vps
only slash commands and data inside slash commands is available
there is no message, member, presence, channel, etc events
essentially you're only using the api to post your slashcommands
"buy" "pay" i cant do this until i have donations
bro so what is left
💀
Which are not guaranteed
i wonder if dank and carl used to pay 5 bucks even when there bot was not grown and no donations
riyal
I pay 10 a month
and I get 0 donations
I got 1 40$ donation once
thats it
they were probably already paying for hosting before they started getting donations
Same XD
i cant rely on "my bot will grow"
You shouldn't be developing bots with the intent of making money
not many bots are lucrative
if youre making a bot for money, thats not a good idea
hmm,well what else i do it for
For fun
experience, fun, learning new stuff
and i cant be in loss right
why can't you be in loss?
people do it for fun, for challenge, for wanting to provide a service
bro i ain't some rich guy
theme and how many servers currently
but one vps can hold multiple bots
1 rpg bot with ~200 servers one general purpose bot with ~500 servers
I also have a couple other things on the vps
not just bots
like backends for some websites i made etc
i used to make like 50 bucks a month from my bot, today i get like 10
I would recommend a vps cause you'll learn a lot about managing a server aswell albeit on a low scale application
the astronomy bot?
look the thing is
i cant be in a loss coz 416 rs is smth that mean to me
ye
iirc there's hosts specifically for bots that charge $1-$2/month but idk how reliable they are
and u only get like 256mb of ram or something like that
I made a bot to get what I consider to be a missing feature and already had an infra, which is good because right now I'm my only user 
i used google compute engine free vps for many years and as my bot grew i learned how to reduce caching and eventually make it cacheless, so ram usage was not a problem anymore
"I'm my only user" famous words
look, you shouldn't get into bots to make money
if you want to develop stuff to make money go freelance websites or something
there is a free tier on Google Cloud, AWS and Oracle Cloud, you can host your bot there but make sure you don't store anything important there because they can lock your account at any time for no reason
so of you dont wanna pay, you can learn how to make it use less resourxes so yoi can stay in the free tier for a long time
i dont expect much money,but should be enough to pay for vps and all
ah yeah oracle has free aswell
the free Oracle Cloud tier is generous
i was not paying fpr vps until my bot reaxhed like 2000+ servers
yeah but Tim, you're on another level
You didn't pay for a VPS until your bot reached 2k servers
I was paying for dedicated servers before I even had a bot
We are not the same
same here haha
haven't tried AWS problem is that AWS is like windows, once you get into the ecosystem you can't get out
i disnt know anythoing about it at the time, i learned out of need
that's about the same thing as Cloudflare Workers, it isn't meant to be used by a stateful bot
also can't AWS charge you if you go over the limit?
I've seen some absurd bills for AWS
it isn't an issue if you're fine with their ecosystem and their pricing model, let's just say that you either use the free tier or you give them tons of money, no in-between
(there is an in-between, but what I mean is bills can indeed grow a lot if you don't put limits in place)
also AWS requires quite a lot of knowledge just to understand their dashboard and the sheer amount of products they have
ngl i am feeling like to leave bot dev and just develop skills for 3-4 years enough to get a job
web dev,mern uff
I work with AWS because that's essentially my job, but I'm never using them for personal projects
you won't learn without making projects
a bot is a good project to work on
problem is if you want it online 24/7 you'll need a reliable host
woah u got badge of bot dev
whats ur bot dev
bot name*
you can host the bot at home on a cheap computer or Raspberry Pi
told them already, they don't wanna spend any money
in the learning phase you don't need 24/7
yeah but if you're, like them, only developing for making money you'll need 24/7
well techinally if i see
I can make projects
and what can happen if i dont host
Hi
btw this is my friend(we both make bots together or used to)
but like we said earlier, especially if you don't have enough skills yet you'll want to make projects to learn
and imo a cheap vps is definitely worth it
you'll learn skills to manage your server which is essential if you're looking to get a CS job
you'll also want to learn docker and stuff like that which is also an essential tool to learn
make a bot that can run on your computer, you can install tools like Docker or Node.js or Python just fine
eventually you'll fall so in love with linux that you'll ditch windows and daily drive a linux distro
:(
linux is not all about hacking lol
bro ur bot name,say?
Raspberry Pi
yeah but u know
linux dont need hacking
Hacking need linux
once you have a working bot, come back to us and I'm sure we'll find a way to find you a VPS lol
not necessarily
I'm part of the Aperture team, it's a moderation bot, my own bot isn't verified yet
lol,u wil
my own bot will be verified the day I'm not its sole user 
damn configuring a bot with yaml is a totally different approach than usually done
it's interesting
add support for toml aswell
it was imagined by b1nzy, a former Discord employee, when he made rowboat
because rust
Aperture is a rowboat clone that spawned when rowboat was stopped
then it was maintained, iterated on, etc.
interesting
not sure it would be wise, I don't expect any ROI on advertising for such a niche bot
JUST DO IT
it's like, if you need it you'll probably find it, otherwise you have no reason to invite it lol
about me-
Aperture - link
My own bot(name) - link
technically it's one of the many domain names on my profile already
"one of"

I didn't even remember we had that emoji on ShareX lmao
if you are just looking to keep your bot online for now, one thing you can do is dockerize your server and host the image locally using the docker desktop app, this should keep your bot online without relying on your local development environment.
Why cant i submit my bot?
bot dev is one of the least lucrative activities you can do
at best you'll break even, very very rarely you'll go positive IF the bot is popular enough
you oughta think about it as personal hobby (so you're never at loss, as you're investing in yourself) or you'll jump out of it
also I saw you mention web dev, I have bad news for you lul
"that requires hosting" right?
the thing is
5$ a month would be hard for me
that sounds very complex
Have you thought about trying to take advantage of some referral programs?
Galaxygate has a $3 a month vps, their referral program offers 10% of whoever uses your referral link.
a hanful of people using your refferal link would cover that $3 a month.
I just list my referral link in my discord profile and it can cover a large amount of my VPSs'
Oracle has VPSs for free
Just sayin
No idea why nobody ever mentions it, it’s perfect for discord bot hosting, especially if you can’t afford a “real” host
(You still need a debit card for verification purposes but no purchase is required)
pretty sure you need to add cc tho
Yep
yes, as I said
oh, totally skipped that line
because it's somewhat volatile
oracle might terminate your services with no previous warning
happened to me, tim aswell
oracle is fun if you want to live dangerous
One message removed from a suspended account.
hey guys, i have used mysql to create my program. Could someone enlighten me on how to actually deploy this program to my vps?
Like, do i need to install mysql client on the vps as well and run the localhost database or,..?
you created a program that uses mysql as a database, I suppose
or did u manage to make a program with mysql lul
anyway, install mysql as you did in your local machine, then run the ddl there
hahaha no sorry i used mysql as my dbms for my program
or dump the db and restore there
i see
there's no mysql client, only mysql
connect() {
const connection = mysql.createConnection({
host: "localhost",
user: "root",
password: "pass",
database: "BackupBot",
});
connection.connect((error) => {
if (error) {
console.error("Error connecting to database: ", error);
return;
}
console.log("Connected to MySQL database");
});
this.#connection = connection;
}```
this is how i connect tot the database, it's bound to my user account. Should i just keep this configuration and dump the code onto the vps? From there on load it and it should work??
you want to host the database there or on your pc?
on my vps
does anyone know how to access auth js session serverside?
i btw recently discovered that js supports classes as well? That's so cool
been a while, tho people are switching back to functional js again nowadays
personally I'll always use classes, they're much more intuitive imo
Generally speaking this doesn’t happen very often. I’ve only ever seen that happen to you guys
I’ve never had a problem with them
But the only thing I’ve used them for is hosting a discord bot
I must say though their 2fa is dogshit and it got me locked out of my VPS, and I’m too lazy to contact support to login to my account
much much
i love java mainly for its classes and such
tho i have never used api's with java, is it easy?
Packages as a whole seems really hard compared to nodejs
depends on how vanilla you want to go
barebones http request is extremely verbose, but on the other side of the spectrum there's stuff like okio, which is extremely simplified
oracle loves doing that
they also love banning you from making an oracle account for no apparent reason
and will refuse to tell you why
theyre like an ex that wont tell you what went wrong
You didnt pay enough
They're the gold digger ex that wont tell you you're too poor
WELL LOOK AT ME NOW ^-^
oddly specific bro 😭
that sounded like a confession
banned for existing? sounds like a thing oracle could do
let botInfoEmbed = new EmbedBuilder()
.setColor(embed["color"] || "DarkButNotBlack")
.setFooter({ text: `${embed["footer_text"]}` })
.setTitle(`${embed["title"]}`)
.setDescription(
`> *Original embed sent by <@${message["message_author_id"]}> at ${message["message_timestamp"]}:*\n\n${embed["embed_description"]}.`
)
.setTimestamp();
this is the embed["color"]: 2895667
Uncaught DiscordjsError TypeError [ColorConvert]: Unable to convert color to a number.
how is this possibl
djs accepts numbers as color right?
i am
it's a valid string representation that is accepted by setColor
when u print embed["color"] you get that number (2895667) right
yu
it already is an Int
apparently you were right lmao
I forgot my database stores the color as a varchar
haha nub

hey guys, to host a website, we can practically do it for free using free certificates and hosting right?
I hosted some before and i paid a lot for domain names and stuff
but certbot is a free Certificate Authority, does it also provide webnames?
like domain names?
certbot just provides certs, it doesnt provide the domain.
I think theres two ways to go about it.
Pay for hosting, youll often get a free domain with it. Or pay for a domain and use github pages or some other free static site host for free hosting.
I dont think free domains are a thing anymore from anyone unless you're paying for something else.
Ie paying for hosting.
certbot isnt a certificate authority but its a tool which allows you to generate a free certificate from letsencrypt which is a free ca
i believe you can still get some free domains but your choice is limited to some and from shady sources
like .ga
but idk about 2024
Well, freenom was shutdown
because they had so many phishing domains and whatnot they no longer are allowed to provide domains.
but it did provide free domains
They loved to wait until your site blew up, then take away your domain and make you pay a large fee to get it back
Thats how they made money.
Free domains, if you were the one in a million that grew they would hold you and your domain hostage
At least imo
actually yeah freenom must have been paying for the domains indirectly
because icann at least charges a fee for allocating the domain
are there websites which let you get a subdomain at least for free?
i know you have glitch but i dont think you can use their domains without hosting on their platgorm
Yeah, but they are typically application based.
thats a gap in the market then
but how would it make money
https://js.org is a good one
yeah i thought of that but they dont let you use it for everything
has to be connected to js in some way
and have decent content for an audience
Yeah, those are typically the kinds of requirements you have to meet.
I dont think anyone really wants to provide subdomains unless you use their service, or you are doing something that they want you to(like js.org for things related to js)
owh i thought certbot was a CA lmao
how are these CA's selected btw
like an authority that deems a website as secured... i suppose not everyone can claim the role of a ca right
i believe becoming a ca is pretty difficult
you have to number one make a business that can release certificates
then you need to convince browsers and tools to trust you as a certificate authority
the whole thing is based off of trust
I imagine the process is somewhat like getting your own tld. If I wanted to make a .woo tld its crazy hard and expensive
i would imagine its mostly the trust part thats tricky and getting browsers and operating systems to add your certificate authority as trusted
anyone can make a custom certificate authority with openssl
and one incident like leaking your master certificate authority private key thats used to sign certificates under your ca is enough to ruin that hard earned trust and get you taken off every trusted list
i believe that has happened to CA's before
so they take security and keeping that stuff safe extremely seriously bc its literally their entire business
Hahahhaha yeah i read about one company that did that
i forgot the name
yeah and you have to remember a trusted CA has the power to forge fake certificates that can impersonate to be websites like google.com and have your browser show the site up as "secured and non tampered" so they need to be very trusted
by the way the only exception to that rule is if the government like NSA/FBI asks you to make a fake certificate for them
i believe theyve done that before
what i don't get is why don't all browsers just use one single monopoly ca. That way you always know it's to be trusted. Like the whole thing about security and trust in my opinion is, the less it's spread over different companies that manage such important things the more secure but i could be very very wrong
this is why we actually dont trust hardware encryption (like TPM's and hardware drive encryption) in our security consultant laptops because they often contain backdoors which can be used by the gov or an attacker or an insider
not sure actually i believe its down to the history
internet is supposed to be free and decentralised to an extent
if you had one CA that can only give out certificates youve given them control of the internet to an extent
and they can make a dangerous monopoly like charging extreme rates for certificates
ahh yeah i see ofc
Whenever I go to the site to vote, it says application error (see browser console for more information). What is the reason for this?
Can someone recommend me a solid bot hosting which doesn't have resource charges or such?
Currently I use railway to host the bot, it's awesome for 5$ plan but it's like 5$ + network usage charges.
For network as my bot uploads images to discord in many-many commands, I believe the charges are a bit too high. It asks me to pay like 5$ for hosting + 80$ for network charges monthly?!?!
Is there a way or some different hosting to avoid that?
Any VPS
The least I was able to observe was 1TB of data transfer per month, which is still more than any bot needs unless it sends hundreds of photos a day
Personally, I think this offer without setup fee is very attractive (contabo)
Sounds awesome, another little trouble! Usually my close friend or you can say project admin does the payment as my card doesn't support international payments.
Regardless of whatever hosting I choose, I'd have to ask him to do the payment. Is there a way on this one to conduct it or such? Like maybe a gift feature/buy for someone else etc.
Usually I just give them my railway log-in details to buy the host on account as it shares minimum information.
what??
Oh, I'm not sure about that, but I assume you can use the same method on contabo. You don't have to provide any real data there either, no one probably checks it anyway
happened to me as well, discord seems to block a lot of messages that contain suspicious numbers, that resemble phones or ids
i see
sparkedhost is so fucking shit
i cannot connect to my mysql database
it's so annyoing
they don't even provide console access, only logging?
is connecting to localhost, is the db installed in the same system?
is it one of those pterodactly thingies?
bro
you literally
could not be anymore accurate
however, it's topgg blocking them, not discord in general
We get a ridiculous amount of phone number whatsapp scams so we have to block them unfortunately
yeah well its topgg rules, but its discord's system doing the detection and blocking right? xd
I think we customised the regex a bit because we had a lot of people bypass the default one
but yeah without automod this place would be like the trenches 
dam
Quick question. Is it worth rewriting a whole bot after not touching it for a while and having gained more experience?
what would be the best way to host an api? mainly searching for easy scalability without needing to spend hundreds of euros into a single server if my api gets and does tens of thousands of requests a day
if u want to, yeah
I am a 🤓
to reinforce and use your experience
hetzner
like, the last time i rewrote it i tried to keep it clean but it still looks so ugly. for example: ```javascript
public static async SendNewArticleToAllGuilds(bot:Client)
{
await this.getFullArticleData()
await delay(2000)
var image = FullArticleData.image
var title = FullArticleData.title
var secondTitle = FullArticleData.secondtitle
var date = FullArticleData.date
var link = FullArticleData.link
var guildIds = bot.guilds.cache.map(guild => guild.id);
guildIds.forEach(guild =>{
try
{
var Rguild = bot.guilds.cache.get(guild)
if(Rguild?.channels.cache.find(channel => channel.name == "riot-games-news"))
{
var channel1 = Rguild?.channels.cache.find(channel => channel.name == "riot-games-news")
var embed = new MessageEmbed()
.setColor("#eb3434")
.setTitle(title)
.setDescription(secondTitle + "\u200B" + " [Read the full article](" + link + ")")
.setImage(image)
.setTimestamp()
if(Rguild.me == null) return
if(channel1?.permissionsFor(Rguild.me)?.has("SEND_MESSAGES") && channel1.permissionsFor(Rguild.me).has("VIEW_CHANNEL"))
{
if(channel1.type == "GUILD_TEXT")
{
try {
channel1.send({embeds: [embed]})
} catch (error) {
console.log(error)
}
}
}
}
} catch (error)
{
console.log(error)
}
})
}```discord.js btw
the await delay(2000) 💀
wait, is this bad practice?
whats the problem with var?
do you recommend a server in particular? all is need to do is execute bun and pray that nothing dies
Depends on your budget
I recommend their dedicated servers, I host an api handling 250k requests a day there and it’s fine and fast
35eur a month for 64gb ddr4 ram, 8core i7, 1tb ssd dedi
It’s under server auction
Ello ello more issues!
I finally bought a hosting and it's working fine for most text commands.
The commands that build a connection to database are very-very slow. I believe its because the location of my database is set to India and my hosting is set to Texas US.
How can I change location of my mongodb database?
I tried doing it but the "review changes" button doesn't highlight or anything https://prnt.sc/URhiWc4Af0Aj
You can easily get more than one and use Hetzner load balancing
Same with their vps servers
good to know
If you’ve got a choice, Cloudflare load balancers all the way
i’ll note that, thank you!
cf for sure yeah
your whole code becomes
public static async SendNewArticleToAllGuilds(bot: Client) {
const { image, title, secondTitle, date, link } = await this.getFullArticleData();
for (const guild of bot.guilds.cache) {
if (!guild.me)
continue;
const channel = guild?.channels.cache.find(channel => channel.name === "riot-games-news");
if (channel?.type !== "GUILD_TEXT")
continue;
const perms = channel.permissionsFor(guild.me);
if (!(perms.has("SEND_MESSAGES") && perms.has("VIEW_CHANNEL")))
continue;
const embed = new MessageEmbed({
color: "#eb3434",
title,
secondTitle: `\u200B [Read the full article](${link})`,
image
}).setTimestamp();
channel
.send({embeds: [embed]})
.catch(console.error);
}
}
also use === for strict comparison
== will attempt type conversion which may result in undesired behaviour
also your code looks like typescript
it is
i recently noticed that my code in production wasnt compiled to js but was still running as typescript
it is compiled
or transpiled
depends on runtime
if you are debugging, there is a good chance that the transpiled code is mapped into source code
const { image, title, secondTitle, date, link } = await this.getFullArticleData();```honestly, stuff like this i cant wrapp my head around
object destructure syntax
does it just extract the props of the object with the same name into equally named variables?
yes
you can compare this with your original code
see what changes are interesting
i made a few optimisations as well
for (const guild of bot.guilds.cache)```so this puts all the guilds into the guild var one by one and then you just check if its the current guild and continue?
edit your bot description and click refresh data on the bot page
ah thx
can anyone help me build a discord bot, I just need some guidance
what are you having trouble with?
just want some guidance on how i would go about starting something specifically
do you know any code or programming?
like javascript/python/etc
good
a discord bot is made by creating a connection to the discord api
if you already know js, then you must be familiar with node.js and the npm ecosystem
there are many libraries on npm that will handle discord's connection for you
so pick one, install it with npm, then create a bot in the discord developers page, get the bot's authentication token
then create a js file, require the discord library and login to your bot using the bot's token
check the library's documentation to see how to use it
how do I create a file
most should provide plenty of examples
i know how to create one, I just want to scrape a database and constantly have it scrape so it always updates, andd then i want that information to be accessible by a user by asking a bot a question about it
@quartz kindle
then connect to the database and query it
the discord api will send you events through the library of your choice
you listen to those events, for example a message event, or an interaction event for slash commands
and depending on the contents of the message you receive, you respond accordingly
generally the workflow is as follows (for slash commands):
- create and register a slash command with the discord api (can be done with code using the library)
- code an interaction event handler to receive interaction events
- code it so that if the interaction is a slash command and matches the command you created before, it runs a specific function
- code your function to connect to said database and query the information
- once you have the information in a variable or so, send it to discord by replying to the slash command you received earlier
okay thank you
oddly enough filesystems dont provide a way to create a file
you have to create a file by writing to it
or opening it
in append mode*
dont you technically "open" an nonexisting file?
yes but not all modes create a file if not exists upon opening so you probably need to also do a write
its complicated
i think the intention is you wouldnt usually just create an empty file and leave it at that, youd wanna write to it right after
they want you to do it all in one go instead of making an empty file then writing to it
well it makes sense
no, that loops over all guild objects in bot.guilds.cache and puts the item of each iteration onto guild
check if its the current guild
your original code didn't do that
if you want that, then the loop wouldn't even exist
bot.guilds.cache.get(InteractionSourceOrMessageSource.guild.id);
btw how do you paraphrase?
also you can create virtual/temp files
ie mmap, socket
hi timmit
what do you mean by that
what does my constellation mean
nothing
> [message]
😔 thought libra has something special
western astro's signs are not linked to constellations
oh
i'm silly
indian astro does use constellations tho
anyone made any activities yet?
No work to tiny discord?
fake imposter files
did you know the /tmp directory on newer versions of the linux kernel is usually purely memory based
the entire directory is stored in a ram filesystem and doesnt touch the disk
windows take notes instead of having a dumping ground for applications to write their "temporary" files using up your ssd erase cycles and not cleaning up after as well
Hello everyone
I want to start making a Discord bot. Programming language weth. Javascript
What are your tips and advice?
read some of the opensource ones on git.
ye
pick one of the many available discord libraries on npm
and read their documentation
don't
trying to understand someone else's codebase will make it look much harder than it is, and will only confuse you
it's hard enough to do so when you work with that, imagine as a complete newbie
just spend a few weeks studying and learning what is programming and doing a few minor project, THEN attempt a bot, you'll get one running without much hassle
i dont do that because otherwise ill accidentally copy their project and their design decisions
i wanna make my own project
honestly
me when reading someone else's code on github:
wtf is this? dafiq are thehy doing here? why is this here? which dumbfuck did this?
especially if its djs code base

I looked at their code base to understand better on how to make my library
it was pain
idk how the contributors do it
drunk @harsh nova commits
standard practice
My drunk code is some of my best work
when you dont code its your best work
btw ima fry you up soon
been on the hunt for some natural salt
Djs, the only project where you leave with less knowledge than you had before

i laughed
p funny
the jump from d.js > raw javascript is wildd
The embed builder was actually really easy to understand.
Validations are done reasonably well.
none of which are important to a lib
that is just add-ons
the gateway stuff is super annoying
Discords gateway is kinda complex, so discordjs's implementation is pain I bet
the gateway isn't very complex
I just feel they implemented it poorly and overengineered it
not to mention they inheritence is a shit show
One class has a 3-4 layer inheritence
👀 I feel like this is pretty complex for a gateway no?
indentify and resume is simple to implement? 👀
imo
yea?
why not?
9 times out of 10 discord tells you when you need to resume a connection or re-identify e.g establish a new one
so its not very hard to do so.
Also in cases where they don't its better off to start a new connection
I wish I had an old repo of mine
the only annoying thing is handling rate limits on the gateway, making sure you aren't spamming it but 
I've never tried to work with the gateway directly, it just seems really complex to do it properly.
Especially in the case of a library
if you make discord bots its something I always recommend someone trying at least once
Large bots that use off the shelf libs like djs end up running into problems with connection limits.
Realistically a lib should be exposing(and accepting) resume data right?
Like I should be able to restart a shard and provide resume data directly into djs.
"should" meaning in an ideal world
I mean
Regarding this, from my experience with the gateway (which isn’t a whole lot) it’s not ideal to willy nilly resume connections. In some cases it’s not ideal to resume a connection. Discord usually tells you whether you should or shouldn’t and when they don’t it’s ideal to start a new connection all together
So libs that handle sharding for you like djs are perfectly fine how they are
not really
its just
The biggest qualm with libs like djs is that they are meant to be beginner friendly and not meant for large scale bots in a lot of cases. Using your own lib lets you control what you’re actually doing and in turn be a little more memory efficient
an auth handshake and an event loop
connect -> identify -> setup heartbeat -> start event loop
Djs tacks on a bunch of overhead due to their useful features that make it easy to interact with the api and gateway
on error -> <is recoverable?> --yes--> resume
--no--> reconnect
here
i have docs in my gateway for this
ye
Don’t assume a connection is resumeable
Yes but why waste time
Which is the way the discord dev docs tell you to iirc
Starting a new connection doesn’t hurt
YOUR TOKEN HAS RESET
Classic mimu
(which is where this question comes from)
If you hit a connection limit you get your token reset iirc
The 1000 a day or something
Well yea
But 9/10 you won’t be able to resume anyway 
I guess it doesn’t hurt to try
But at the same time I’ve not run into a case where it successfully resumes if discord hasn’t told me it can
I just don't see why libs don't allow you to stop a shard disconnect it, provide the resume info, then resume it. Or maybe they do I've been so disconnected from discord libraries for so long.
They don’t
Cause there’s no reason to
What reason could you possibly need to resume yourself?
Tbh, I feel like it's the opposite.
Why would you ever want to not resume?
Resume includes all your missed events.
So any time things go down on your end you can resume.
A buggy shard can be stopped and resumed and likely lose no events.
Bot restarts, resuming is a better solution.
Even weird things, like temporarily moving shards to another server could be done.
A "rolling" update that resumes to prevent event loss
Idk, there's a lot of interesting things people could do if it was an option.
Someone out there would find something intriguing to do if it was more accessible to the developer.
libs dont do this because of their caching
resume on restart requires the cache to be offloaded and reloaded
or stored off-process
which most libs dont do
Hello
🤔
this is very bare bones testing before i implement fully... but i'm attempting to
make request to generate pdf on nextjs client side -->
send request from nextjs backend to bot api to generate pdf -->
generate pdf bot side and return binary to nextjs backend -->
return binary from nextjs backend to nextjs frontend and download the pdf
now it downloads the pdf but the content of it is empty despite setting the page content to have stuff in it on the bot api? can anyone help pls
bot api route: https://pastebin.com/qbU9mzFp
nextjs api route: https://pastebin.com/mfv2L6SA
nextjs frontend: https://pastebin.com/CBAy2QHR
did you check if the generated pdf is working?
ie, fetch it directly from the bot api, or save it locally in the bot api host then download it and open it
oh sorry should've deleted this. the issue was that the response type wasn't set to arrayBuffer
thank you anyways though
Oh interesting
JDA allows this 😀
oo
Tho this code is largely outdated, I didn't make it on the new rewrite yet
hi everyone
heya mo
how ya doing woo?
doing good! just moved into a new house last week so been busy unpacking and setting up all this new stuff i got
it’s going well! i’ve been studying and trying new things. starting to sorta be able to find what’s wrong with some of the coding that i’m implementing
my next goal is to set up a data base but i’m having trouble lol, gonna look for some youtube tutorials at some point today
what database are you using?
i keep getting that sqlite is the one i should use
i just dk where to start with setting it up lol
one thing is disconnecting and resuming while the process is running
another thing is restarting the process and directly resuming instead of creating a new connection
Ah, i misinterpreted it then
all libs can restart shards, but very few allow you to create a shard with resume data already included
(mine does tho xd)
what i’m gathering is
- install sqlite with
npm install sqlite3 - code in a connection to the sqlite database in the the bots code
- create tables to define the structure of the database
- perform database operations to implement the methods of using the database in the code
better-sqlite3 is recommended over sqlite3
will it be the same steps?
and can it be used with discord.js v13
no, read the docs for the lib, its slightly different usage
yes, databases are independent from djs
ok will do!
in consulting you see some horrific code
it becomes impossible not to judge
sometimes i think do they really pay you to write this code
lmao
does anyone know how in the world does emoji.gg copy emojis from a server that it isn’t in???
Likely by using the cdn
So long as an emoji is used on discord you can get the id of it
Then bots can use that to upload the emoji to the server or download it and send it to you (though they will likely just send the cdn link to avoid downloading it)
Commands are loading but do not appear in the / section
application.commands is turned on in settings
What do you mean by / section?
Slash commands do not appear in the bot
And what type of commands are these, global or per guild?
only commands that will run on a single server
Then make sure it's the right server and that you have permission to see them if they have any required minimum permissions. You can also check the integrations tab to see if they have been created at all
The bot has permissions, also available in the bot developer section.
u need to have people use the bot. the commands that appear on the profile would be the frequently used commands used by its users
why is this causing a RangeError: Out of memory?
import { number } from "@rjweb/utils"
import chalk from "chalk"
import fs from "fs"
import bytes from "bytes"
export default async function download(display: string, url: string, dest: string, overrideSize?: number | null) {
const request = await fetch(url)
if (!request.body) throw new Error('no body')
const size = overrideSize ?? request.headers.has('content-length') ? parseInt(request.headers.get('content-length') ?? '0') : null,
file = fs.createWriteStream(dest)
let progress = 0
for await (const chunk of request.body) {
progress += chunk.length
const percent = number.limit(Math.round(progress / (size ?? chunk.length) * 100), 99)
process.stdout.write(`\rdownloading ${chalk.cyan(display)} ${percent}% ${size ? `(${bytes(progress)} / ${bytes(size ?? 0)})` : ''} `)
file.write(chunk)
}
file.close()
process.stdout.write('\n')
}```
i run into a bunch of errors when trying to install this package: https://www.npmjs.com/package/trello
on cf workers
i tried the node_compat stuff too and that didnt work either
Commands do not appear in the bot's profile, that's the problem
because it's not something instant
you have to wait and have users use your bot, and then discord will know what the bot's popular commands are
u have to wait
it's not a list of all commands, it's a list of most used commands. the data for that takes time to gather
How long does this take because it's been hours and still no Slash commands
its possible that the download is faster than the file is written to disk
you need to wait for writes to be flushed before you write more chunks
await new Promise(resolve => {
file.write(chunk, () => resolve())
})
what node version do cf workers use?
can you decide your own node version?
or are you using bun/deno?
i dont think node js is enabled
it requires the nodejs_compat in the wrangler.toml file
but i cant do that bc its too big
idk ive imported other npm packages just fine
ok so
when i want to interact with my sharded mongo database, i use the config server
when i want to shard a collection, i use the mongos router?
is that ... right?
from the looks of it, they dont use actual node.js
they use something similar, modified, or something like bun/deno under the hood
yeah they don’t
they require node api's to be required using the node: prefix
but how come that is preventing me from installing that specific package
I’ve installed other ones like mongo-http just fine
which means you'd need to edit all your deps to change require("a") to require("node:a")
if they use node built in libs, like url and zlib
I’ve tried that but that didn’t work either, I believe it said it couldn’t be resolved
Will try that again once I can
the thing is
you'd need to edit it in all deps including sub deps
if i understand correctly
sup fellow nerds
sup fishmonger
Channel for chatting about development not for supping
Yo fellow nerds except noooooooooob
Thank you

tim, can you just transfer all of your coding knowledge to my brain pls man
at this point, i just wanna be like tim when i grow up
Lmao
half his brain is reserved for storing node and javascript functions as well as js optimisations
i really like what tim does in terms of optimising js though
if theres a way he will find it
Lol
gotta go fast
@quartz kindle Since you're here.
Is it okay to upgrade to a websocket connection then authenticate it? Would I run into any issues?
I wrote this code awhile back, but I think I'm doing this to send proper status codes when authentication fails
should be fine either way
you can send auth headers during the upgrade request and reject there
or you can establish ws first then auth on first message
like discord does
oh yeah, thats what discord does. derp
should be fine
What was that other websocket lib you recommended? thats not ws
I wrote it down somewhere, but I'll never find it again
uwebsockets?
That's it yeah
uwusockets
Thankfully I'm building something very simple so trying it shouldn't be to bad. Then just picking the one I like more.
Lmao
tbh I haven’t worked with web sockets in a while
I plan on using them soon though
the only thing about them is that uwebsockets is pretty much designed to be exposed directly to the web
so if you're using a reverse proxy like nginx in front of your node, then it doesnt make sense to use it
since uwebsocket itself is arguably faster than nginx
So its probably super overkill for what I need
At max I'll have 5-10k connections at once in the next couple of years.
give it a try anyway
yeah for sure
not sure how to benchmark them tho
I'm just going to stick a link to this conversation in my readme lmao
throw 50k connections at it and see what happens? ^-^
xD
I really should hire you one of these days to do code review on this.
I know I'm not doing things completely right
lmao
gonna remade my bot to “Tim” i stg. that mf will be able to do any and every thing one day.

