#development
1 messages · Page 2024 of 1
so thats what you have to do in your js
also instead of changing the opacity you can toggle the show class
so on page load, select the modal element, add the show class to its classlist and change the display style to block
element = document.getElementById("staticBackdrop")
element.classList.toggle('show')
this is adding the show class
when i show the modal with the button the css goes to this
so basically getting rid of display none and adding the display block
yes, so add it yourself
bruh c++ is cracked up its literally a variable
maybe it doesnt support a one liner in that particular situation?
¯_(ツ)_/¯
element["aria-hidden"]
also, element.attributes / element.setAttribute()
Once I started react/other templating langs I would never go back to static html/css/js
Makes doing stuff like that on the dom so much easier
webhooks = await channel.fetchWebhooks();
webhook = webhooks.find((w) => w.name === "TESdT");
console.log(webhook);
``` am i dumb? why is webhook still an array of webhooks instead of undefined??
const webhooks
Not sure if that’s your issue but js is not python, you must have a declaration keyword before the variable
Sometimes js screams at you for it, sometimes it doesn’t, but it should always be there no matter what
One message removed from a suspended account.
^
You dont know which is a declaration and which is a reassignment of a variable
One message removed from a suspended account.
You should never do that either way though :p
oh wait im dumb. im editing the copy of the function
wait... you wrote that without a declaration keyword
, or did you declare webhook before this line of the code?
js doesnt scream at me for it soo..
^^
ill do it once js starts screaming at me
I dont think your code would run without error if u dont declare webhook
ey it works
Just because js does not error does not mean that it’s not an error on your part. Do not always trust js to error on everything that’s wrong in your code
We’re telling you that you NEED to have an identifier keyword
Otherwise you’ll have unexpected behavior later and you’ll wish that you spent the extra two seconds to put a keyword on each variable as your wrote them
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
Yeah
Generally speaking 99% of all other langs ignore most whitespace
I think js has a small exception to that in some cases
not some cases, in switch cases. Unless u use {} for each case
💀
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
I mean it's not that hard to not use the same variable names
You should care about indents
Because otherwise you get fuck-all formatting even gods would question
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
Because it practically enforces the consistency in indentation
Which you should be doing regardless of whether it forces you to or not
One message removed from a suspended account.
One message removed from a suspended account.
amount, type = str.split(" ");
``` how do I assign amount from [0] and type from [1]?

using one line of code
Which lang?
js
let [amount, type] = str.split(" ");
my brain defaults to const and im getting useless errors saying i cant use const twice
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
yeah and its getting frustrating
One message removed from a suspended account.
wasting api calls
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
:c
One message removed from a suspended account.
why use var if u have let and const 💀
Yes that’s different though
Problem with var in js is that it’s hoisted and it’s at function scope
let is block scoped
(and const)
Neither of which are hoisted like var
Ok fuck it I'm gonna remove the var keyword from JavaScript
No balls
Oh no. This reminds me of remix.run using let for everything as it is shorter to write than const 
been there done that
(i dont do it anymore tho xd)
Whenever I see a let, I instantly starts skimming thru the code to see where it was reassigned
It confuses me so much xD
xDDD
Just use a linter such as ESLint, makes things way easier to control
You can also use it's recommended config derived from the repo by running npm init @eslint/config
But again, eslint needs to be used correctly (see attached meme)
i mostly just stick to recommended, with a few personal preference additions
Somebody save me please
We’re forced to do this for my web design class
Our teacher teaches us literally nothing
So he just assigns websites to do it for him 
lmao
same but with AP CSP
My history state test and my AP CSA test are on the same day
i get that node wants fetch to be basically the same as the browser fetch, but its kinda stupid that everything else in node uses Buffer, but fetch doesnt
it only returns ArrayBuffer, you have to do Buffer.from(await response.arrayBuffer()) lol
reliability issue
consistency issue
An unfortunate error regarding the components of skill
I have a form that I submit with jQuery, how can I pass this file in the POST JSON ?
I'm getting the buffer and passing in the JSON but nothing is being recieved on the server side
Hello guys my bot is named "HyperX" I just put it because I like HyperX company, should i change this will it be a problem for me? I also submitted a ticket on support discord for this, but I did not get a response even after 1.5 months lol
what file?
you dont send files with json
It’s an image file
either convert the image to base64 or use formdata instead of json
I mean, you need to put a disclaimer somewhere stating that you're not affiliated nor related to the other hyperx
Okay thanks for reply, I will
how can i make these all the same height?
using tailwind
<div class="mt-5 my-1 px-1 w-full md:w-1/2 lg:my-4 lg:px-4 lg:w-1/4 ">
<article class="overflow-hidden rounded-lg shadow-lg box text-center" style="cursor: pointer;" >
<div onclick="location.href = '/blog/81e10d5b-3f6c-4284-aefa-a66a5d84dc96';">
<div class=" h-32 overflow-hidden mb-3">
<img class="w-full" src="/assets/images/81e10d5b-3f6c-4284-aefa-a66a5d84dc96.png" alt="" />
</div>
<header class="flex items-center justify-center leading-tight ">
<h1 class="text-lg">
<span class="text-white">
big buns world
</span>
</h1>
</header>
<h1 class="justify-between leading-tight p-2 md:p-4">
<a class="text-white text-sm leading-7">
welcome to my first post!<br> hello world!<br> boom shakalacka!<br> wiener??<br>
</a>
</h1>
</div>
<div class="flex justify-center items-center">
<button onclick="location.href = '/blog/81e10d5b-3f6c-4284-aefa-a66a5d84dc96';" class="boxbtn uppercase text-white font-bold hover:shadow-md shadow text-xs px-4 py-2 rounded outline-none focus:outline-none sm:mr-2 mb-5 ease-linear transition-all duration-150" type="button">
View Post
</button>
</div>
</ar```
Hi I want to create activity invite link any one know whats the problem?
EMBEDDED Indicates if an app is embedded within the Discord client (currently unavailable publicly)
What is an embedded application?
It is an web application that runs inside of the Discord windowCurrently supported applications(that i know the id of):
Youtube 755600276941176913
Betray.io 773336526917861400
Poker Night 755827207812677713
Fishington.io 814288819477020702
Chess in the Park 832012774040141894
Doodle Crew 878067389634314250
well if it says its not embedded then its not
ids are always strings
so this is the problem 
i didnt even notice you didnt use a string lul
lol
can i have some rest apis please
@quartz kindle do databases like mysql traverse through the entire data file slowly and carefully until it finds the record if it has no indexes?
sounds stupid but i want to make sure theres no dark magic going on
and so records inserted first would have better speeds than records inserted last?
yes
if indexed yes
much faster to search through
oh so if not they're not?
wow thats slow
really shows how important indexing is
at first i thought its just as simple as "this thing is here"
im not sure about non-indexed hashing
maybe depends whether it has UNIQUE or something
collisions are not usually a problem because they use a hash table with stuff like separate chaining
actually no i have an idea
if there are two same hashes they will be compared character by character
yeah
that way you're only comparing and spending time on potential candidates instead of a bunch of other strings
first the hash resolves to the entries, then the entries are compared to the query
and check the length of the string to see if you can compare the strings every 4/8 bytes instead of 1:)
sure
the optimisations are melting on my tongue
i learnt how slow comparing something byte by byte really is through osdev
even tho its graphics it still ran like a 90s computer
xD
even worse
luckly all those low level optimisations are built into everything we use
like indexOf in js is stupid fast
yeah
it probably does a bit of what i just said
loads multiple characters into memory at once instead of one
of course some dude thought of it first and decided to put his name on it
how did i know it was a name
i might make an algorithm and name it after myself
the speedy algorithm
dont need any marketing or points the name says it all
xD
did i ever mention i wanted to do data science/ml as a career
until i saw the learning curve
even im not that dedicated
xD
really interesting
i constantly see tools being released that simplify it
meaning you dont need statistical mathematics/calculus do make a machine learning model from scratch
or fancy mathematic algorithms that take ages to write down
One message removed from a suspended account.
faithythythytht
i saw this library and love how and whats its trying to do and looks impressive https://www.npmjs.com/package/ml5
learned about algorithms today in cs, I think I'm one of the few people that actually enjoys them
(not related to discord bots)
would converting a string to uInt8Array() be more 'optimized' than just sending a string over? (javascript)
sending to where?
idk what that is but looks like something that would be fun to optimize even more :^)
there's room to improve
but it just needs to beat O(log (m+n))
oh cmon i cant even run a test code without having to create an account
fuck that
it's worth it
just use oauth
dont even need to make an account
like how? sending via fetch post request? via websocket?
oauth2 with github gave me 502 lmao
websocket
some shitty extension for tampermonkey interfering with it
disabled it now it works
oh for gods sake
go fuck yourself
Tim said a curse word, tim said a curse word
ok so first attempt got 70ms on test run but 180ms on submission
i think it runs through a bunch more tests on their servers
otherwise people will just store all the answers in an object for O(1)
ye i figured
internally eveything is converted to buffers anyway, but from a js side converting it to a typedarray yourself is gonna be slower
Why cooldown commands to mongoose not working? command not throwing? no error too.
command
https://sourceb.in/Tg2jCedZax
I have decided that I do not want to look at that much code at once C:
iz okay
why not use a cache or whatever for cooldowns
unnecessary data usage for the database and your internet if you use online mongodb ||-.-||
is there anyway to get application icon (one in the discord developer portal ) with the application id?
you can look on the invite screen of the app and inspect element to see where the cdn link leads. Pretty sure the application_id is part of it. Idk if the api returns the icon of the application, but just the application_id might be a no
Separate caches wouldn't work across clusters, so storing cooldown info in database isn't a bad idea
https://sourceb.in/gQEeAt5pKt how do you divide in mongoose? $divide not working
How do you disable SelectMenu after a specific time?
You can use the $inc operator and provide it a negative value to divide the value
ohhh
found out a negative way, using $min 😭
then data.wallet -= data.wallet
How do You do that ? Like Without ANY STATUS ?
pls telll
@pale vessel
You Created Aeon Right ? Can you tell me How you make its Status Invisible
bc i can't see if the Bot is Online, DND or Idle
it's using the interactions webhook
how pls tell
I already tried it, it's something like
cdn.discord.com/icons/<application_id>/<random alphabets>.png
I was look to get that random alphabets with the application_id with api but it didn't worked
What I Understood:
Discord Developer Docs Are Idotic and Top.gg's Docs are 1M times Better
What I Didn't Understand:
How to Keep the Bot Status as Invisib;e
honestly if I saw that I'd be equally as mad
Are you using the Discord gateway, or are you bot application/slash command only?
One bot of mine is also stuck like that. Does not have any slash commands nor webhooks configured. Running DasWolke/CloudStorm
is this looking good?
remove the duckduckgo part
was talking bout the header but ok
lmao
its like when people "Top.gg Verified Developer" or "Official Discord Dev" to make themselves sound official 
think i should've centered the "Toneh" part
people really show off being Topgg verified
put image on top
center text underneath
yikes

?
whats the point of saying "duckduckgo enthusiast"
it's just a joke cuz windows also sells ur data
thats like me saying "Discord user"
idk i couldn't describe myself

kinda like designing
Developer, gamer, aspiring designer.
im a google enthusiast
yeah theres a tool which makes windows a little more privacy respecting
like disabling ternary data beyond what you can disable
and if you want windows to be more respecting than that you gotta use a local profile not a microsoft account
they're making that a lot harder by putting it in tiny letters at the bottom with a confusing name
apparently some editions dont even have that option
i have a pro license so i have that option
everything's selling ur data there's no point in trying to avoid it at this point
time to hop on linux
not everything
most of the things people commonly use and the vast majority of the internet is
I'm talking about products here not open source stuff
i would get linux on laptop but im kinda locked to a windows os because i have a surface pro and linux most likely doesnt have the software i need
and 99% of the time you're not using an open source tool or app or whatever
if it's not open source then it's likely to have money involved
data is digital gold
hop on chromium
hop on the discord clone made in c#
websites are also in this category
uh
youtube, facebook, twitter, etc.
brave?
lmao
i love brave but hate its focus on crypto
crypto is too risky for me im not dipping my fingers in it
I mean crypto enables better privacy in some ways
yeah not this which is permanently embedded in your search bar
I use Bot Slash Command ONLY
It isn’t much work to do to remove like any (diag) tracker in Windows 10
Also to manipulate group policies, block feature updates, telemetry, stop auto restarts etc
That’s the cool thing with Windows 10, nothing is hardcoded
And if you go to combine that with a pihole things are going to be very good in terms of privacy
Hello, i am using discord.js 13 and have a question regarding sharding and database connections.
Currently i have 80 shards running, all using their own connection pool to a single mysql database. As i cache a lot of results, the database usage of every shard goes down after start. So at some point i have way more connections than needed, which takes a lot of ram on the database vps.
Now i would like to tunnel all db requests through the sharding manager's connection pool (is this a good idea?), but i can only find a broadcastEval function, where i can send messages to all shards. Is there a way to request-response (with async await) from one shard to the shardingManager only? How is this done?
set it to an empty array
i think set yea
But i want to delete
not replace
set can delete?
Its craeted an other object
which is null
i want delete all object except 0
Get the index (array key) of your item (object) and use detele array[key]
👍
Just a quick question, can I do this somehow in an one liner?
x = str(guild.bans)
return len(x)
return len(str(guild.bans))
easy as that
Ah, god damn, I just used that in another command and didn't think about it here, ty lmao
what lang is that?
python
if you call /api/v10/applications/{application_id}/rpc
it'll return a json which will include the icon
it's also a great way to check what intents a bot has, assuming they have the "add to server" button set up
Python, I'm using d.py 1.73.
len(string) what
how would one wait for this function to return? idk im new to callbacks tbh
async confirmationCollector(embeds, interaction) {
...
await collector.on('collect', async i => {
if(i.customId === row.components[0].customId) {
return true
} else if(i.customId === row.components[1].customId) {
return false
} else if(i.customId === row.components[2].customId) {
return null
}
})
}
how im calling it:
const confirmation = await client.utils.confirmationCollector(...)
console.log(confirmation)
its a bit more complicated doing that with a callback but im pretty sure there is an async version of the collector you want to use
what are you collecting?
this is what you want to use https://discord.js.org/#/docs/discord.js/stable/class/Message?scrollTo=awaitMessageComponent
you would do something like
const i = await message.awaitMessageComponent({ ... });
if (i.customID...) { ... }
then your returns would work as expected
ah thanks that helped a lot
never noticed that in the doc was it added in v13? or was it always there
v13 is the only version with Interactions iirc
i've been sitting here for an hour and a half trying to get this unsafe c code working
i am going insane
this is like operating system development all over again
We have extended the deprecation period for message content by an additional four months. The new deadline is now Wednesday, August 31, 2022, with enforcement starting on Thursday, September 1, 2022. During this time, we’re going to be educating users actively on Slash Commands, from content in our marketing to in-app indicators and prompts.
That has been announced weeks ago already
they're going to extend it again in a few months
because slash command adaptation is low
slash commands are not stable enough to be the major way to invoke commands
especially with slate2
I mean they are still missing features they announced in the beginning
Like sub command grouping in the UI
I would also like to see a date picker
(as field type)
autocomplete is needed for modal fields
slash command permissions
Yeah but I guess they might not do that or commands and their options in this field over here will be most likely useless
Everyone would then probably prefer to open a modal when using a command
i was going to replace most of my commands with modals, but it's missing too many features
also needs array input
Yea
I don’t like to verify any input string to match my data type I want
Also simple check boxes would be neat
But as cry said…
I doubt at this development speed we will see these features in 4 months
at this point I doubt discord will even enforce slashes (go ahead with message intent)
it'll probably be just another "one day" implementation
Discord's docs for slash commands also suck so badly
I was so fucking confused about how booleans are sent since the field for value only says string, int or double but when I asked, they said it's also sent as boolean
Is it possible to wait for CSS and/or JavaScript to load when making HTTP requests? I'm using Puppeteer and looked up quite a few tutorials on improving the load time, but the hoster I'm using (specifically a VPS) only has 2 GB of RAM, so regardless of how much I improve the load time of Puppeteer it's not really possible to speed it up enough. TLDR, can I make HTTP requests and wait for CSS or JS to load?
css and js files are requested independently from the html, if it exposes a page ready event or render or something that would intrinsically imply what you're looking for, then that would be great. Otherwise, you'd have to wait for someone who actually knows or dig through source code
Yeah I remember I had to try that out, too since it didn’t actually made sense for me
You learn something new every day
So… length isn’t counting the items but returning the private property?
length is a property not a method you are correct
why is c++ so slowwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwvwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
i swear they've chosen simplicity over performance
look at this
this is disgusting
c is over 2x faster in file reading and seeking
just put everything on the stack!
if you didnt notice sherlock i put the data buffer on the stack and not the heap
who wouldve known a segfault in unsafe code
Arrays are just fancy objects
the same way you can access members of Objects, you can do to most things including primitives when they're assigned to variables
this thing was damn hard i'll tell you that
but i dont like their measurements
i finally got something that works but every time i run it the measurements are very different, without any code changes
those are some good numbers though.
yeah took me a hell of a long time lmao
rip
im gonna benchmark this myself to see what the real numbers are
the js engine is too tricky
yeah i really dont like their measurements
it likes to optimize
look at this
var findMedianSortedArrays3 = function(nums1, nums2) {
const a = [...nums1, ...nums2].sort((a,b) => a - b);
const x = a.length / 2;
return Number.isInteger(x) ? (a[x-1] + a[x]) / 2 : a[Math.floor(x)];
};
this gives me 1300ms at 1 million iterations in dev tools
in their website it gives 180ms
my latest code gives me 25ms at 1 million iterations in dev tools
their website gives it 100ms
another code i tried gave me 125ms in dev tools, and 170ms on their website
doesn't this break O(log(m+n))
const a = [...nums1, ...nums2].sort((a,b) => a - b);```
the sorting
yeah, i did it to test if they actually measure performance correctly
doesnt look like they do
the code with sort is almost 100x slower compared to the more optimized code on dev tools, but on their website its barely 2x slower lol
they have quantum computers
xD
also memory usage for this kind of test is useless in js
this kind of tests are really made for C langs, not js
btw this was my final code if you wanna check (idk if you can see it?)
https://leetcode.com/submissions/detail/685697102/
Thanks a lot brother, it worked ✨

@proven lanternyeah this is really stupid
i looked up some solutions that people post in discussions
look at this
just ran this and it gave me 108ms lol, but dev tools gives me 1000+ms, aka still 100x slower than my code
lol, people are not learning the point of that lesson
the guy that made json recommends to never use arrow functions
he thinks they look too much like comparisons
also, this is the fastest recorded time on their website
i disagree with him though
it's the jsdoc that makes it fast 
yeah, their website it broken
such a shame really
people be thinking their code is fast af and gonna try use it in real world
rip
btw did you try running your soluton on dev tools?
sure
indeed, also makes much more sense
i got 125ms with my first solution, then 25ms on the final one
now i can finally sleep lmao
been breaking my head over this for 2 days
lol, those problems are addicting
you handled like every base case possible
these are too hard
yeah i often rule out as many edge cases as i can before applying something more generic
i like this part
xD
stupid question: is there an easy way to get rid of this annoying horizontal scrollbar on my website? Currently using react + mantine + nextjs
find the element that caused the website to overflow
and try activating windows, that might also work
try doing
body {
overflow-x: hidden;
}
in the global/s.css ig 🗿
or just apply on the element that causing overflow
no
💀
that's a duct tape solution...
there's something wrong with the measurements or the content is too long (with no word wrap)
You'll have fun making "reactive" apps for mobile if you design to your screen's specs, so using percentages is the better option if you want a consistent style across all devices
This is just a portfolio website for myself, I'm not worrying about supporting mobile atm
Mainly using it to learn nextjs and react
I'm really liking the modularity that react provides
And how easy it is to define routes/pages with nextjs
https://sourceb.in/h3D9Q8qJ3s how can i trigger the 10,000 and 15,000 if there's no data saved in database?
when i change their positions, even there's a data in database, it keeps calling the 10,000 and 15,000
fixed
you're welcome
LMAO XD
No need to thank me
https://srcb.in/viSjk4QUf9 why overall leaderboard not going to highest to lowest? but when only wallet and balance is good
hello
i was uploading my bot
like
rn
but i need to have top.gg invite link
does anyone know how do i get that?
What’s your bot/application ID?
966764448939393084
I don’t see that you have submitted the bot. It would be located on http://top.gg/bot/966764448939393084 when you have submitted and approved by us
Go to https://top.gg/bot/add and make sure to follow all the required steps to add your bot 👍
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.
Nah, that’s optional
If you got a support server. You could submit it here https://top.gg/servers/new then connect it to your bot if you want
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.
i already linked the support server in the
submit appeal
or however it is called
cuz my native language isnt english
as i said submitted 👍
I see it here now. A bot reviewer will have a look at it within a week or so
Normally it goes a lot faster. But yeah, we get hundreds of bots each week that we all manually review
We got strict guidelines to provide a high quality curated bot list
lmk when u can review it
it would be my pleasure
to guide u in
btw have a nice day
Sounds good. Enjoy the rest of your day
If your bot is approved:
You'll get a DM from @gilded plank and you'll be assigned the <@&265125253443878912> role here.
If your bot is declined:
You'll get a DM from @gilded plank and you'll also get a ping in #mod-logs.
💡 Please make sure you have your DMs activated for this server.
same
btw
some of the commands are broken
in the bot
does that affect anything
in the submission?
As long as the majority works and the main functionality of the bot is also working your good
Error: Could not locate the bindings file. Tried:
→ /home/container/node_modules/better-sqlite3/build/better_sqlite3.node```
What is the best way for me to get all servers my bot shares with a user from a user id?
Discord.js
A loop with a condition for logging I'd say
Alrighty
It’s because at the moment I detect when on userUpdate when an accounts name/pfp changes to a discord scam one (modmail, hype squad etc), and I need to ban them from all servers they’re in with the bot
client.guilds.cache.filter(([_, v]) => v.members.cache.get("ID")) this should work
forgor should it be ([_, v]) or (_, v)
youll have to fetch the member on each guild
Amazing, ty
yeah, if he got guild member intent, then yes
i am slowly losing my sanity segmentation fault by segmentation fault with c
is there like no way to actually pass docker-compose env variables into volumes?
nevermind figured something out
you dont need the intent to fetch a single member
nonono, i meant for <Guild>.members.cache
code i sent only works if guild member intent enabled or unless all people cached after they send a message
Have you check what your client variable/parameter even is?
it should be ([v, _])
Oh wait that error is thrown from the second part I suppose
[key, value] while key is indeed a snowflake and value the guild object
why are you even doing that
just do .filter(guild => guild.members...)
no need for (v,_) or any of that
.filter and .map iterates over values not over entries
thats what i'm doing
💀
How can I set my Bot's prefix as bot mention
<@{bot.user.id}>
I don’t think that was the question but yeah
Ig he meant prefix as bot ping
how do i use the mongusdb database
💀 i forgor it is for for loop
In what language?
Here is general mongodb docs https://www.mongodb.com/docs/
<@!?{bot.user.id}>
https://webhook-topgg.com/ does it work when this is upvoted?
Simplifying top.gg webhooks for all users, allowing non-developers and developers to use webhooks for their bot and server without confusing configuration.
yes
so is this topgg's or did someone else make it
ok thank you
Do we need that ? and ! ?????
- User mentions with an exclamation mark are deprecated and should be handled like any other user mention.
Don't need to cover nicknames anymore
I still get exclamation marks sometimes
Who even thought it was a good idea to begin with?
Or can use
message.mentions.users.first() and check if that mentioned user id is same as your bots 
idk, just useless bullshit in my eyes
i'll create
🤦♂️
lmao
well it uses json to send/receive data but the underlying data is stored in a raw binary file
gonna use msgpack?
wot
is it just a way to serialise data to a string
to binary/buffer
that works too
except my database side parser uses nlohmann json
not the fastest but the simplest
might switch to a faster one in the future
msgpack is the most popular binary serializer (not necessarily the best tho), it has implementations in dozens of langs
so it can kinda encode data into smaller sizes right
soon 'speedypack'
guess what
my db support dynamic string lengths
even tho it kills a lot of the performance potential in seeking for data
because it has to read the header of the record to see the size of it
yeah basically
for example it doesnt waste bytes for non-data characters in json such as " and }
it encodes numbers in their proper binary formats instead of string
its schema-less so you dont need to define schemas beforehand like you do with protobuff or avro
How would I change every user's nickname in the server while waiting if the bot is getting rate limited? I have 1.4k members in a server and the bot get's rate limited every so often. I have this bit of inefficient code that loops through all the members and get's their nickname, but the bot get's rate limited after around 20 members.
guild.members.fetch().then(members => {
members.forEach(async member => {
await message.guild.members.fetch(member.id).then((member) => {
if (!member.displayName) {
console.log("Couldn't get " + member.id + "'s display name.");
return;
}
if (member.displayName.includes("[") && member.displayName.includes("]")) {
let memberNick = member.displayName;
let splite = memberNick.split(" ");
member.setNickname('[1000] ' + splite[1]);
console.log(member.displayName + " -> " + '[1000] ' + splite[1]);
}
});
});
The goal is to change every user's nickname to [1000] <some_string>. Currently, some user's have their nickname as [1023] Eltik, or something similar to that. So now, I want to change it to [1000] Eltik.
(btw i made this bit of code a year ago lmao)
and depending on the implementation it can be a lot faster than json
dont use forEach
use for(...) { await ... }
Ah so something like:
guild.members.fetch().then(members => {
for (let i = 0; i < members.length; i++) {
let member = members[i];
await message.guild.members.fetch(member.id).then((member) => {
if (!member.displayName) {
console.log("Couldn't get " + member.id + "'s display name.");
return;
}
if (member.displayName.includes("[") && member.displayName.includes("]")) {
let memberNick = member.displayName;
let splite = memberNick.split(" ");
member.setNickname('[1000] ' + splite[1]);
console.log(member.displayName + " -> " + '[1000] ' + splite[1]);
}
});
}
});
no, members is a collection, not an array
you can do for(const member of members.values())
Oh ic. Ty
also, it would be better to use await for everything
fetched = await members.fetch()
as well as await member.setNickname()
Alright I'll do that 👍 For changing all 1,000 members would the bot just take a while to finish changing all the nicknames, or would it just stop midway through?
oops i just noticed that ty.
if no errors happen it should keep going until it finishes
djs will take care of adding the proper delays for you
as long as everything is awaited
i ran this bit of code a while back and noticed that the bot actually stops the action of changing the user's nicknames and whatnot, but it took long enough i had to shut down and restart the bot and update the check for nickanmes (ex. includes("[1") instead)
oh okay. tysm this is super helpful
MySQL best database !!!
💀
we probably need some exorcism in here
sheesh
mongusdb better
OurSQL
yes
i made a db called that and named it that when i was still active on glitch.com
it was just a server based sqlite3 rip off
literally just sqlite3 databases under the hood and you sent in sql queries

on the off chance anyone has used react with mantine here: jsx const Home: NextPage = () => { return ( <> <BasePage title={"Home"} logoText={"WaffleDev"}/> <Grid> <Grid.Col offset={2} span={3}> <ProjectShowcase name={"something"} githubLink={"something"} description={"something"} imageLink={"something"} /> </Grid.Col> </Grid> </> ) } Something is wrong with the Grid.Col element, it's giving a padding of -8px which causes the div to overflow by 16px and give a horizontal scroll bar
(I know it's an issue with the Grid.Col element, if I remove the content within the Grid.Col, the issue persists, and if I get rid of all the columns the issue goes away)
guys i how fix this problem
even changing this to be one grid still has the same issue ```jsx
const Home: NextPage = () => {
return (
<>
<Grid>
<Grid.Col span={12}>
<BasePage title={"Home"} logoText={"WaffleDev"}/>
</Grid.Col>
<Grid.Col offset={2} span={3}>
<ProjectShowcase
name={"something"}
githubLink={"something"}
description={"something"}
imageLink={"somnething"}
/>
</Grid.Col>
</Grid>
</>
)
}
str.startsWith(“https://paypal.me/“) 🙃
I guess add a check that aligns with PayPal regarding length and valid characters after the / too lol
It returns http 200 regardless of valid link or not 
I mean, why is it needed? How do you deal with PayPal being down for a few minutes
What about anti ddos/bot technologies
I was hoping there was an api for it or some shit 
Nah. There definitely is one internally, but nothing public that I’m aware of
ah ok
(Used to work for PayPal)
making a donation page thing which links to Stripe and Paypal (paypal api is hard to use
)
I thought they may have had it in the LogIn with PayPal api. But does not seem so https://developer.paypal.com/docs/log-in-with-paypal/
I guess users fault if they provide something invalid 
does the login with paypal bit allow me to get client id and secret?
Uhm, what do you mean? The users client and secret?
https://developer.paypal.com/docs/api/identity/v1/#userinfo_get some more details what it returns
I mean for when I want to use Paypal express checkout
afaik i have to have their client id and secret for payments to go to their account
either that or just make the donate button lead to their paypal.me page
Hum. No idea about the login api tbh. Was a different department, so never dealt with onboarding that stuff
ah ok
You would need to read the docs unfortunately
PayPal docs are so confusing imo
Seems like they have redesigned it a lot. But not close to Stripe
Maybe try to see if you could use PayPal account ID to send a payment too maybe
https://developer.paypal.com/docs/log-in-with-paypal/integrate/
Ugh. Seems to be used for payouts
If it returns 200 even if it is an invalid username, would the page still display a 404 error (or some other kind of error)? If so could you not just crawl the webpage? (Probably a bad idea in the long term but just one to throw out there)
I mean it is possible. But it’s a bit hacky, prone to breaking and possibly against TOS for scraping/crawling
True
It also does not prevent spelling mistakes where the spelling will resolve to another user
Mmm yea
What I would have done tbh, check if the URL matches the PayPal requirements (starts with, length and invalid characters) and just ask the user to double check their entry 🤷♂️
its irelevant whether its their page or not, I just hoped to add some validation to ensure their page is correct and leads to a valid user
Well this seems like something beyond your control at this point
Also what does it matter if it is a valid user anyway? What are you doing this for?
Donation pages, and it will have Stripe too
I originally hoped to be able to use paypal checkout with email addresses, but its not possible
Honestly if you are doing donation pages just integrate with paypal oauth2
That is what nearly everyone does
This way you can be a lot more certain they are a valid user
If you’re trying to confirm if something is a valid user is there not an api GET call for a user page that returns a 404 if it doesn’t exist?
What does a user link look like
https://paypal.me/USERNAME
Seems like returning a 200 status code on a unsuccessful getting of a user seems like bad practice for a platform that allows developers to interact with it but idk
yeah
i tested with random spam as the username and it returned 200 even tho i confirmed it was invalid
Though this does seem a bit pointless as it is unlikely someone will just spam something and if it does happen so what?
just add ratelimits and move on
I'm sure if you really cared enough you could scrape the html to validate but that's just stupid to do
@quartz kindle haha speedydb / mongusdb is on the rise
still considering using that library you suggested
(< 1ms time taken to process + receive data with no compiler optimisations)
even tho its simple numeric data atm its a sign
i've optimised the database to ignore advanced certain features that arent needed when dynamic data (strings) is not present in the table
and hashing is automatically done only if the string is long enough
Any idea on how I can get the "Click me" to go below everything?
<Container style={{minHeight: "85vh", display: "flex", margin: "auto", alignItems: "center"}}>
<div>
<Avatar className={'mr-5'} radius="lg" size="xl" src="https://imgs.search.brave.com/Q1JPL__FReDNKqetfnrYnBMKYs-uB8OwCnE6G55y7LE/rs:fit:1200:1200:1/g:ce/aHR0cDovL3dhbGxz/ZGVzay5jb20vd3At/Y29udGVudC91cGxv/YWRzLzIwMTcvMDEv/RG9nLWZ1bGwtSEQu/anBn" />
</div>
<div>
<h1 className={'text-2xl'}>Hello I'm Aaron and I'm {age}</h1>
<p className={'text-lg'}>I'm a small time developer who enjoys working on random projects. I also love nature and watching MacGyver.</p>
</div>
<div style={{display: "flex", flexDirection: "row"}}>
<Button>Click Me</Button>
</div>
</Container>
Rn this is how everything looks
Everything is in their own divs inside a Container element
and that container element has its own styles where I make it have display set to flex
instead of telling you what to do individually i'll give you a plan
- make a parent div and make it display flex with flex direction row (include the aligning items)
- make another div and place "hello im..." and "im a small time developer..." inside it
- after the above div place the button
<div style={{display: "flex", flexDirection: "row"}}>
<Button>Click Me</Button>
</div>
has no effect whatsoever because there is only one element inside of the div (and it wont solve your problem)
@sharp geyser
Mmmm alright I will try that
play around a bit with flexbox and you will master it trust me
Yea I am rather new to actually doing my own css and plus it is limited to what I can actually do with a lib it seems
huehuehue
what are you using for storage?
also the second div is not necessary just in case you wanted to do some extra styling with it
it wouldnt be a custom database if it didnt use the raw C filesystem api
the c++ one is 2x slower (did a benchmark)
MacGyver though >>>
for now there are 2 files in a directory (table), one file holds the table header which describes the names of the columns and their types and a second file which holds all of the data, each record (row) prefixed with a header describing the sizes of the data held in columns + a size of the entire record to skip over it easily
Hell ye, already watched it once now im rewatching it
:^)
only problem is to save space i made the record header structs packed which basically tells the compiler to not add padding between fields to prevent unaligned memory access and i got 3 warnings complaining about that
well yeah to find relevant data
yeah my first thought on adding strings which can be any size
only disadvantage is there is basically no room for a longer string unless the user has shortened it by updating the record and so the record needs to be relocated to the end of the file, leaving a gap in the records
im surprised still modern operating systems havent figured out a way to insert data between existing data in a file
typically in order to support dynamic content size with best performance you would use pointers
each table row would be fixed size and its non-fixed contents would be pointers to a dynamic sized data located somewhere else
yeah thats what i was thinking too
otherwise its slow and inefficient running around the table having to read a header to skip to the next record
i'll keep that in mind for my next revision
but then another issue is that - you have to read from another file and keep the pointers updated if you were to move things around in the file to maximise space (unless they both point to each other)
anyone know how to get an svg background image to stay at the bottom of the page even when scrolling?
body {
padding: 0;
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
width: 100%;
height: 100%;
background-size: contain;
background-image: url(../public/background.svg);
background-repeat: no-repeat;
background-position: bottom;
}
``` this works for me, but only when there's no vertical scrolling
Not to mention it cuts off the bottom of my background color
Nevermind I have a different issue now
Ok so does anyone know how to make body extend through the entire height of the page? It's only extending to the viewport height, but I need it to extend to the whole thing
there are may strategies for handling that, the biggest issue is keeping up with fragmentation
yeah
i just tested the database under a little load and it works great
(also found an issue in my tcp group splitter mechanism under load)
inserted 1000 different records with 3 columns, one being a string
it performs very fast, the hash seems to be doing its job
what kind of hash are you using?
just the standard one that comes with c++
std::hashstd::string
dont like the std::string overhead with it tho
if it matches i load it and use strcmp on it
you see loading a whole column/record into memory for no reason would be a waste
there are dozens of third party hashers for cpp lel
also the data file is 60kb
most of them are faster than std::hash
xD
and before even comparing the hash or string it first compares the lengths from the 5 byte header thats loaded on every record search
well not 5 byte
more like 21 bytes since each column adds an extra 4 bytes to the header#
what hashing algorithm would you suggest?
doesnt even have to be 64-bit
in fact the saved 4 bytes would be nice
collisions dont matter all that much but would be preferred if it was avoided
position: fixed;
bottom: 0;
```?
well i heard good things about xxHash
I fixed it
am hosting my bot and website in same vps both are in nodejs
so if my bot cross 10 k guild i have to made one more cluster for shards so thats mean i need to create one more flask?
I have an ExpressJS server and a config.json file for all configs. Can the user somehow read the config.json file if it makes a request per url in the browser and then in the devtools??
Up to how many servers is 1gb ram enough for hosting?
It really depends.
You can stretch 1gb really far with a cacheless(or near cacheless) bot.
or by not using Discord.js
you should get a cheap server until your bot grows and needs more resources
Discordjs should be quite efficent memory wise when you configure it.
The issue is most devs don't, so it caches everything, then devs blame the library.
This couldn't be further from the truth. Just importing Discord.js or a derivative I made to be cacheless still causes my bot to spike to 180MB. Without any abstraction layer other than just cloudstorm/snowtransfer, 50MB
module import strings are what took up the most memory in my bot
👀 I don't think I've ever seen my djs bots use 180mb of memory
wtf how
my bot is apparently using 0% mem and cpu atm
I'll check when I get home, but I had maybe 10-15 djs bots on a 1gb machine at one point. I dont think that's normal to have so much memory usage with the library.
If you wanna see meme memory usage, this stats page of my bot (not currently posting) shows when I started on djs v10 and v11.
https://amanda.moe/to/stats
random drop and increase of servers ?
shard dropped and missed a report window
ok
I migrated from redis to postgres at that time
ok
my redis instance was dying so hard
I haven't reported to the stats page in 3-4 months
👀 what happened here
diead
Moved away from actual Discord.js to a cacheless version of Discord.js I made (now being deprecated lol)
When stats start to post again, I'll just be interacting with raw api
You'd like some modules by DasWolke on github then
Yeah we use both SnowTransfer and CloudStorm in the company I work for. Thanks for all the work on it lately 👌
Nice to have a “lower level” wrapper
I have a Discord Bot Dashboard.
I'm saving actions with the user_id and username#disc
now if the user changes his username or dics how can I get this? I was thinking about only saving user_id and then fetch but that would probably exceed the rate limit... Any suggestions
Use the userId as index/lookup as would never change. But also store userName+Disc as a local cache and if there is a mismatch when a new entry gets added, just update the local userName+Disc
You could also have your own local cache / ratelimiter that gets passed a userId and returns a username. So it uses the cached userName+Disc for X amount of time, and if it’s expired refresh it within your rate limit check
aight thanks
raw api gang
@quartz kindle i want to run a shit ton of queries at once for my db but tcp is being an asshole and idk how to solve it other than add a 5-10ms delay between sending data
basically like a massive group of packets get grouped together, which is fine my db can handle that but i think it eventually starts splitting a single packet in half and puts it in another one and so my database kills the connection because it detected an "incorrectly formatted" packet
the packet sizes just get too large
you dont know whether someone is maliciously sending too many packets or if it is done by grouping
dont know how to solve it
waiting for another query to complete? a "maximum concurrent" queries count before the client starts throttling?
god how do people live with tcp - yeah yeah its a stream connection but at some point too much becomes too much
the concurrent query thing works very well btw
finally when the file is at 1.7mb it starts slowing down significantly on empty queries
funnily enough string search perform a bit faster than number searches because the strings arent loaded because of the length
tcp should be abstracted away from everything else
if you get a split packet in a tcp message, you store it away and assemble it when you receive the next tcp message, only when you have the complete packet you can do anything with it and decide if its valid or not, and parse it/send it anywhere
you cannot detect maliciousness on a tcp level that easily
I have a bot that blocks words, should I keep a whitelist folder that only I can edit inside the db or in a txt file?
:|
literally on the verge of just using udp and using a checksum to verify the message
found that confusing at first too
it's an object now so like setFooter({name: "", value: ""})
You can use like .setFooter({ text: 'sometext, iconURL: 'someURL' })
footer has text ig
not name
name is in author
I haven't used djs in over a year cut me some slack lol
setAuthor
.setAuthor() have name
ye
I stopped developing bots altogether
It works in vscode perfectly fine
But its deprecated
honestly it doesn't really matter but for your simplicity a text file will probably be easiest
you should load it all into memory anyways so the performance won't matter
What do you mean by that?
you will put all of the bad words in a variable anyways so the speed of both doesn't matter
oh okay
it won't be supported later, you need to change it
it is 99 times out of 100 a very bad idea to keep using deprecated things
I am using djs latest

I know
Solution?
It's deprecated right now, which means it will likely not be supported for much longer

There was like 20 people that gave you solutions
Ah nevermind that was for the wrong thing
💀

The last two are optional. You only have to give it the name
I using same things
You're using .setAuthor('iconURL', 'URL')
make sure you're using the same version everything
like same node version, same djs version
etc
Same node
Your vps does not automatically update your code for you
Same code same node same npm
Then you're not running the same command that's causing the issue
You need to update it to the new stuff
Do not keep using deprecated methods
Then you're not using the same djs version
If you're not getting a WARNING in your console
No
Show your package.json on your vscode version
you have two different warnings
so you have to update your code for both of them
again, the warnings have given you something to fix, and we gave you the solution to it
I'm not quite sure why you're not changing it 
btw djs latest version is 13.6 you're using 13.1
node-fetch 2
?
I know which error will blob up next after he updates the packages
You might wanna stay on version 2.x

a sec




