#development
1 messages · Page 157 of 1
Honestly might try and make detritus2.0 but the shitter version cause I will never reach the level of cakedan

how does paying for servers and renewals work? it's not really clear and i don't wanna make a mistake
it says the servers are "prepaid" and when buying a server it tells you your duration, this makes me believe you pay for your time upfront and it doesn't renew after the specified duration, but in the tos it's talking about renewals?
You pay for it upfront
if you decide not to pay again, they'll just yeet your server
So that means you pay in advance for that month
Yea, after paying for first month you can extend this time
It’s a method to prevent people from using and leaving before paying I assume
yup
You can also upgrade your server at any time
this also allows you to use stuff like paysafecard or paypal to make one-time payments every month
which isnt possible on a recurring payment
so I'm guessing they have some sort of account you can add balance to, and it'll take that to pay for the next month
I must admit though, their dedi pricing is shit 
how long have you had your server @deft wolf
4 days
oh
are you sure 
do it
I might try to make a game engine in C++ but with Raylib for rendering because I'm too lazy to learn opengl at an advanced level
Well
the worst that can happen is they'll remind you about it before it runs out
Who plays dbl
ah okay, i'm assuming your server is €4.95 right, and there's no like extra fee for extending
do you mean dragon ball legends
No, you are paying regular price for server
you're on the wrong server
It is cheap
not enought
I have 4 vcpu and 12gb of ram for 5 euro
which plan did you get
Hetzner and DigitalOcean are absolutely the best if you can afford them, Hetzner is quite cheap
This one
Yea, that is like 4-5 lays chips packs in Poland XD
I'm so broke ahahahah
they have like verification before you can get your server, right
What kind of verification do you mean?
for hetzner don't you need ID verification?
Bet I will !!!!
Also yes do it
Honestly just go with contabo
:)
mfw locked myself out of my dedi again
using rescue to add a crontab that starts wireguard

because I forgor to autostart wireguard
Yeah, it's quite annoying but not that much
this is cool
its good 👍
i have a reseller acc too
ah, i just asked bc i needed to ask a question about it, thanks
https://paste.gg/p/anonymous/43c2f6e186af4647bcccb889928d2fb7 @earnest phoenix what you think about my spiffy new Socket 
not done yet but you can at least make a connection to the gateway!
minus presence
That's pretty good
tyty
Any idea on how to effectively mitigate rate limiting on the gateway?
I was thinking of using a queue system so that way priority requests get sent first
but idk
PriorityQueues are fun to use 😉
I see
how do I determine whats important tho
obviously any reconnect/heartbeat requests are priority
I’m not sure about js but in Java PriorityQueue determines the sorting arrangement via the compareTo method on the type being stored
You could assign a different level of importance to each request with a property and sort by that property
https://stackoverflow.com/questions/42919469/efficient-way-to-implement-priority-queue-in-javascript wtf
Yes that’s a pretty standard way of implementing things
Heaps are commonly used in tandem with priorityqueues and are usually implemented on an array to be more memory efficient/cache friendly
Don’t worry too much about the implementation, it’s more important to know how to use it
The implementation isn’t too hard once you’ve learned about what a heap is (max/min heap) and how to implement one
There's also very good implementations that you can already use like https://github.com/luciopaiva/heapify
A heap is just a special tree, a max heap is when the greatest element of the tree is the root node, and each parent element is greater than their children
And a min heap is the opposite, when the smallest element of the tree is the root node, and each parent element is smaller than their children
queue.push(1, 10);
what df does this mean, I assume one of this is the priority
However this isn't the same as a binary search tree, since that implies that the nodes are sorted in a particular order where the (usually left) child is less than the parent and the (usually right) other child is greater than the parent
?
It all depends on the implementation
Oh you're looking at heapify
anyways, gotta go to work now
cya misty gl
Thanks
Have a moment to talk with me about this?
Sure
Okay so, when it comes to using a priority queue what would be the best way of setting the priority of requests being sent over the gateway and even if its queued, I still need to make sure its not rate limiting by sending too many requests
Should I just assign priority numbers to specific requests and when they are being made just load them into the queue and process the queue that way?
Yes, that's exactly what you're using the priority queue for
The requests that are the most important should have the highest priority
Okay
I’m wondering how I should do this then cause obviously just doing it how I’m currently doing won’t work with a queue system
I think I have an idea
It’s probably not the best though
Question, with box-shadow there is a tiny bit in the corner where, well, it acts like a shadow and isnt shadowd
any idea how i can replicate this ?
tiny bit in left corner
is missing
need to fill it
Move the offset to the left
It's not missing, think about the shadow as if it was a paper you're holding next to a light source
So in the same way there's a tiny gap there, there'll be a tiny excess on the other side
Because I have poor explaining (due to autism+ Not English Native), I need a native English to rewrite all my commands description/ Parameters description and success error messages that may not explain everything important
How does autism make you bad at explaining I have autism and all my friends come to me for help with basically everything because they always understand it if I explain it
I could do it if you translate all my stuff to french
Or use gpt
Also is it possible to translate command descriptions per server?
Not per server (unless you use guild commands which is not recommended if it's a public bot), if you're trying to accomodate for different languages Discord has i18n support
I can be your French translator
hi I'm not able to get topgg webhooks working on AWS
It used to work when I used to host my bot on railway
It does not show any errors and I have enabled all ports in aws settings
Can you try going to the webhook url in your browser? (even if its a 404)
im not sure
how do i check
try using iptables or ufw
ufw status to check if you have any ufw rules set
iptables --list if you have iptables set
Still no clue why it isn't working
then its an issue with your aws instance, can you even visit a normal webserver to begin with?
such as by just installing apache2 and visiting that
also, what port are you using
5000
well then visiting your webserver like that here will obviously not work
not providing a port defaults to 80
you need to append :5000 if you're visiting a webserver under that port
It shows 405: Method Not Allowed
at least you can connect to it, that error means that you're trying to make a get request to your webserver (aka directly visiting it on your browser) and not a post request
which is intentional
top.gg makes post requests to it
Hmm
So it should be working right
But it's not
0|bot | Error handling request
0|bot | Traceback (most recent call last):
0|bot | File "/usr/local/lib/python3.10/dist-packages/aiohttp/web_protocol.py", line 332, in data_received
0|bot | messages, upgraded, tail = self._request_parser.feed_data(data)0|bot | File "aiohttp/_http_parser.pyx", line 557, in aiohttp._http_parser.HttpParser.feed_data
0|bot | aiohttp.http_exceptions.BadStatusLine: 400, message:
0|bot | Bad status line "Invalid method encountered:\n\n b'\\x02\\x01'\n ^"
0|bot | Error handling request
0|bot | Traceback (most recent call last):
0|bot | File "/usr/local/lib/python3.10/dist-packages/aiohttp/web_protocol.py", line 332, in data_received
0|bot | messages, upgraded, tail = self._request_parser.feed_data(data)0|bot | File "aiohttp/_http_parser.pyx", line 557, in aiohttp._http_parser.HttpParser.feed_data
0|bot | aiohttp.http_exceptions.BadStatusLine: 400, message:
0|bot | Bad status line "Invalid method encountered:\n\n b'\\x16\\x03\\x01'\n ^"
0|bot | Error handling request
0|bot | Traceback (most recent call last):
0|bot | File "/usr/local/lib/python3.10/dist-packages/aiohttp/web_protocol.py", line 332, in data_received
0|bot | messages, upgraded, tail = self._request_parser.feed_data(data)0|bot | File "aiohttp/_http_parser.pyx", line 557, in aiohttp._http_parser.HttpParser.feed_data
0|bot | aiohttp.http_exceptions.BadStatusLine: 400, message:
0|bot | Bad status line "Invalid method
I got this error
I think it's from viewing from the browser
try:
...
except:
...
avoiding the problem method
That's not the problem here
i didn't read sorry
I just want to get the webhook working
Yes understood
It's intentional according to this ^
Top.gg webhook
when I try to visit on browser
Then simply make a custom error endpoint to handle it
You shouldn't even log 4xx error to the console
As those are request issues
Yes, but helps sanitizing your log
He wanted to check if the webserver is working
Else someone could spam your log with it
First let me get the webhook working
I have no clue why it's not working
Are u trying to test with test button?
yes
really?
Is the port open?
Nvm, u did access it on the browser
Do you have any logging inside the endpoint?
To know if the request is being received
When the user votes
Not what i mean
wdym
Do you check anything or do database operations whatever?
Ik
Nothing is wrong with the code it was working with my other host
Put a log message at the very first line, before anything else
wdym
print("here")
Right at the first line of your endpoint
To be extra sure it's not code issue
I'm sure it's not
Won't hurt to assert
Inside it?
Programming isn't something you can be sure of anything, little apparently unrelated changes sometimes kill whole sections of code
First line of the function
Still nothing
I don't believe it's the code
might be top.gg issue
Perhaps, but probably not as I'm receiving votes normally
Use postman to try to mimic the request sent by topgg
Also, ur not running the bot locally are you?
I did tell that I'm running the bot on aws
should've read what I said from the beginning
free tier
Ooooor I can ask you
Your last resort is postman, if it fails we have a case
Else I don't really know what could be happening
Free tier can't keep it up 24/7 can it?
my very bold claim would be: this error originates when your webserver is only accepting http, but you're trying to visit it with https
that is why it cannot figure out the status code
can you post your full url you've set within top.gg
I changed it to http now
I tried with https too
Idk I tried many times with and without the ports
well using ports is required
as your webserver does not run on port 80 or 443
keep in mind that:
- if your webserver is only able to serve http, visiting
https://example.com:3000will not work, as using https will have top.gg assume that your webserver is using ssl
which will have top.gg initiate a SSL connection to said domain, which your webserver will not understand and will assume its some sort of status code unknown to it
"Invalid method encountered:\n\n b'\x02\x01'\n ^"
is an indicator of that
oh yes
I visited https on browser and it showed the error again
But nothing when I change the url on top.gg
what happens if your visit http://example.com:3000 on your browser
aka with your full url, using http and :3000
With https it shows ERR_SSL_PROTOCOL_ERROR
And with http it shows 405: Method not allowed
then your webserver cannot handle https connections
using http should work
yes that works
method not allowed is again intentional, as your webserver doesn't allow get requests
put that url on top.gg and see if it works
Yes I have
aka save before using the test button
yes
Whats the authorization so I can test that too
I'll send in dms?
you can also just change it to something different now or later on
Laughed a little
works fine
are you sure you have pressed save on top.gg, then used the test vote button
keep in mind depending on the library you're using, theres separate event listeners for both handling normal votes and handling test votes
a test vote will not show up on a normal vote
yes
screenshot the webhook section please
🗿
did you receive another test vote?
Nop
no clue
am not able to reproduce the issue on my end
wait for someone who is available?
Is it some DNS issue
I mean you could try testing it again later, possibly the dns is not being propagated yet
I'll try using the ip address
How long does that usually take
Because this has been happening for 2 days
no clue who your dns provider is, if you have just added aws.* to your domain, maybe 24 hours
I always suggest just using cloudflare instead as your dns provider
not what I'm referring to
I am referring to the provider who manages your domain
aka your stooby.tech domain
oh
How can I do that
Transfer the domain?
thanks
When my bot profile updates on top gg?
When you click "refresh data" and then "edit" and "save"
If you mean bot name/profile avatar
ok thx
hoi
im not the best with css, n was wondering how i can put the text to be at the bottom of the image
.desc {
background-color: rgba(0, 0, 0, 0.5);
bottom: 0;
left: 0;
box-sizing: border-box;
color: #fff;
margin: 0;
margin-left: 2.5%;
margin-bottom: 5%;
}``` margin botom made it go up, as expected, so i tried margin-top but it didnt work, it just stayed in the same position. Any ideas?
^ fixed
I am sure that everyone who is active on this channel can write a bot
So true
Maybe There Are Those Who Can't
Yea not in a discord server that is almost all about discord bots 
so
Maybe try some small community’s
maybe because it's something like advertising
Do you think I might have a chance in new communities?
No
?
No one will pay you $10 for a bot
I'm Turkish so I don't know much so what are the prices here?
It's literally downloading files from github, typing npm install and you have a bot that has 500+ commands
That's 10 minutes max
Yeah but most of them are outdated
Since you have the bot dev role I’m sure you can create one yourself 
chahaha so funny @deft wolf
But for somebody who what’s a custom bot for their community with a lot of commands and functions 10$ isn’t that bad ig
Yea but you need host it somewhere
Maybe I'm selling a very good boat for $10, how do you know?
There are a lot of free options and paid ones for like 0,25 cents xD
I would buy a boat for $10 
Are you selling Minecraft hosting or something or do you have a server?
Yea I sell lots of hostings xD
I can sell you a discord bot hosting for your special bots 
No I don't want to Xd
I got a free option too xD
UwU is this advertising
i have my own dedicated hosting bro
no
Lol

godzilla had a stroke trying to read that

m@L
lmao wat
Toic?
No, development
and fucking died

@cobalt torrent keep it sfw
I don't know what sfw is dude I don't know much
safe for work
Aka common sense
One message removed from a suspended account.
One message removed from a suspended account.
make a football/sports manager game
like bio inc lmao
One message removed from a suspended account.
help me
If somebody is going to help you they need a bit more context
i want to show it here on our website
Make sure your website allows iframes and you’ve correctly set the property’s of the iframe
Like the domain
it kinda sounds simple in theory but in practice its complicated
a lot of probabilities and events
and stuff you can upgrade
press F12
see on the console why it didn't load
Alt + F4*
i swear this is the first and only website i found that actually respects the browser "privacy opt out" header
Lol
gdpr and other countries should make it law having to abide by the header
it would also help solve the "mandatory cookie notice" annoying problem
not like it would solve any issues tbh
what
I feel like most companies would just ignore it
Unless it's actually heavily enforced
there it is
oh, btw
.tk domains are blocked in like 98% of the internet
and u never actually get to own it
freenom simply embeds your site in an iframe, and put a bunch of trackers in it
One message removed from a suspended account.
One message removed from a suspended account.
don't think they used to do that
One message removed from a suspended account.
One message removed from a suspended account.
I remember putting my freenom site on cloudflare
One message removed from a suspended account.
but yeah basically all freenom free domains are blocked by a lot of services bc it can be abused so easily
this is why we can't have nice things
domains should be free or at least some of them
for personal uses
but there needs to be restrictions so a person doesn't just acquire a lot of domains and resells them
and I just realised we've come full circle back to not having nice things
see the structure the page
basically, you never link domain -> server directly, like other providers
the domain itself is borrowed to you, but the page is never directly linked to the domain
also they reserve the right to reclaim the domain at any time
Yea once you get an decent amount of traffic they will xD
One message removed from a suspended account.
Last time I wanted to get a free domain freenom didn’t even work xD
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.
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.
One message removed from a suspended account.
since when does chromium make use of windows's efficiency mode
i only really see windows programs using it only
One message removed from a suspended account.
One message removed from a suspended account.
thats actually a good thing
w
it marks certain processes as not requiring as much of a priority or timely execution which improves system speed and responsiveness
chrome has done this for years
thats the first time ive seen it
One message removed from a suspended account.
Imma be real I’ve never used brave but if the product is good who cares about the owner?
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.
since like, 6 months?
hate the guy, not the browser 
brave is alright, but i like ungoogled chromium better
its not as polished tho, some things dont work on it
but it does feel lighter to use
what about firefox
i heard firefox is good
I use firefox
It's pretty nice
It's not exactly light on resources if that's what you're looking for, but it has a good feel to it
@quartz kindle hey buddy :)
hey buddy (:
8$ a year i found for web
i use it as a secondary browser, its good but slow and memory hungry xd
v8 >>> spidermonkey, sad but facts
spidermonkey is such a goofy name
No one will help you with this, you have to wait until everything calms down
yes it got shut down
cheapest tlds
spaceship </3
Wtf I paid like 3 euros for a .xyz domain xD
lol
Arent their renewals a bit more expensive
gibsonChurch() {
let randomIndex = Math.floor(Math.random() * 2);
if (randomIndex === 0) {
return "../.././src/IMG_4744.MOV";
}
return "../.././src/IMG_4745.MOV";
}```
I am trying to access the src from a file in the listings folder
it returns me undefined as the path is wrong?
I was thinking like this;
../ -> escapes from listings to commands.
../ -> escapes from commands to root.
./src -> from root to src.
You don't need the ./ so just ../../src/file.mov
but would that be the issue?
I found that ./ and none just returns the same result.
const attachment = new AttachmentBuilder(path, {
name: "church-of-gibson.MOV",
});```
where path = "../../src/IMG_4744.MOV"
still errors
am i doing sometwhing wrong
nodejs treats file paths differently when used by require and by fs
if attachmentbuilder uses fs to read the file, it might be interpreting the file path wrong
or trying to use it from its node_modules location and not your file's location
so you might need to be more specific and provide an absolute path instead of a relative one
anyone know how i can fix this issue? google just doesnt seem to want to index my pages
Click on see details
that just shows the list of pages
What does learn more point to? Or is it just a generic help page
yeah exactly that
See which pages Google can find and index on your site, and learn about any indexing problems encountered.
Open Page Indexing report
Yeah so I would wait a few days/weeks
Yeah I think there's no request indexing button on yours so you can't re-request that
If your site is correctly linked (i.e. all your pages link to each other) then as long as you re-request indexing on the root page it should appear (slowly, but you shouldn't have to request indexing on 500 pages either)
i had to make a sitemap for google to discover the pages
i can try reducing the amount of pages to see if that helps but i doubt it would
Sitemap works too
You dont need to await an async function if you don't care about the using the return value?
just checking to make sure im remembering correctly
Not exactly. Awaiting simply means "don't execute further code until this line completes", whether you want to get the value or not doesn't affect if the code blocks
good enough for me then
But if it rejects you can't handle it unless you use .catch()
yep
hey so,i am currently trying to make a ticket system on my bot(discord.js v13)
i want to first do the channel setup command which would setup the channel and then do send panel command
but i am having some issues with db
let channel = message.mentions.channels.first()
if(!channel.isText) return message.reply(`Please mention a text channel`);
if(!channel) return message.reply(`Please mention a valid channel`);
db.set(`ticketPanel_${message.guild.id}_${channel.id}`)
message.reply(`Successfully setted <#${channel.id}> as ticket ```
this is how i registered the channel id of the channel setupped of a server
i am trying to access it in send panel command like this
let channel = db.get(`ticketPanel_${message.guild.id}`)```
can someone tell what am i doing wrong
Not without you first telling us what is happening that you aren't expecting, or showing us any errors you're getting
hm so when i am trying to acess this,it just says undefined
you're forgetting the channel.id
well channel cant be defined in send panel command
then dont save it using both the guild and channel id?
i said that i want that user to setup the channel once
then i register it in database
okay but like
and send panel there
you are saving it as ticketPanel_guildid_channelid
without channelid its going to return undefined
if(!channel) {
const nochannelembed = new MessageEmbed()
.setTitle("Error")
.setDescription("There is no channel setuped")
.setFooter("Run the \ `channel` \ command to set a channel!")
.setTimestamp()
.setColor("RED")
message.reply({embeds: [nochannelembed]}) }
else{
const pe = new MessageEmbed()
.setColor(`#303136`)
.setTitle(`${message.guild.name}'s Ticket Panel`)
.setThumbnail(client.user.displayAvatarURL({dynamic: true}))
.setTimestamp()
.setColor("BLUE")
.setFooter("Making Unnecessary Tickets Is Against Our Terms Of Service!")
message.reply(`Successfully sended panel to <#${channel.id}>`).then(async () => {
const tsc = await client.channels.cache.get(channel)
tsc.send(`test msg`)```
so figure out a way to not need the channelid or find a way to get thechannelid
is that quick.db?
it is
thats the thing idk bro
doesnt quick.db automatically nest objects for you if you use a dot as a separator?
yes
so for example
@earnest phoenix come here
ticketPanel_${message.guild.id}_${channel.id} this will not work if you use ticketPanel_${message.guild.id}
Yes?
but if you use dots, it should get you an object with all its children
they explaning so listen
like this
ticketPanel.${message.guild.id}.${channel.id} and ticketPanel.${message.guild.id}
hmmmmmm
lemme try
it should ig
quick.db hardly changes
💀
well, its quick and easy for beginners
even tho its not efficient, most projects where its used are small, so its fine
Also I started my discord lib again

nice
Going horribly rn
xD
Honestly debating on just not even helping the end user mitigate gateway rate limits
and leave it up to them
😭
let channel = db.get(`ticketPanel.${message.guild.id}`)```
so this should work

gateway rate limits are easy tho, rest rate limits are the hard ones
I mean
it will not give you a channel tho
it will give you EVERYTHING that is inside that guild id
discord with its gateway/bot endpoint gives me all the data I need
but I don't know what would be the best way to use it
you mean gateway command rate limts right? the ones that you send via websocket, like request guild members
This is what it gives
those are per-shard, so its easy to implement
ah you mean the session start limit?
yea
I wanna help them not accidentally login 2000 times ahem glitch.com shenanigans
session start limit is basically every 5 seconds you can send 1 IDENTIFY request, multiplied by max_concurrency
icic
it also needs to be divided into buckets
huh
moduled by max_concurrency

If i saved as this
db.set(`ticketPanel.${message.guild.id}.${channel.id}`)```
but basically, you will always have max_concurrency = 1 until you have like 150k guilds
It should work?
So uh, yea lets just not give any fucks like discord.js :)
then you suddenly get max_concurrency=16
so when you get max_concurrency=16
its basically like this
shard id modulo 16 = 5 seconds cooldown
for example, shard 1 and shard 2 can login at the same time
but shard 1 and shart 17 cant
because they share the same modulo id
icic
no it only works in get ig
So would I just need to save a timestamp of their last identify attempt, and anytime a new attempt is made just compare it to the old timestamp
or is it more complex than that
Oh
for example
if you have 150+ shards
and you have max_concurrency = 16
shard 0 and shard 16 and shard 32 and shard 48... all have the same modulo id
because shard_id % max_concurrency === same number
0 % 16 = 0
16 % 16 = 0
32 % 16 = 0
so those shard ids
you can only login one of them every 5 seconds
regardless of order
Okay so I would have to check the shard(s) that is trying to identify?
so login shard 0, wait 5 seconds, login shard 16, wait 5 seconds, login shard 32
but you can also login shard 16 first, then wait 5 seconds, then login shard 0
for example
what matters is their modulo id
I can login shard 1 and 16 at the same time then no?
so it doesnt share the same limit as the first set of shards
it can be done concurrently
I see
so if you have max_concurrency = 16
you can login 16 shards at the same time
as long as they are all in different modulos
I see
Okay wait
So this here is the identify payload that you would send to discord over the websocket
If there is sharding, you would put the current shard's id there as well as the total number of shards the bot is going to use right?
ye
so each time a shard is spawned the id sent will be different
yup
Okay okay
now let me figure out how to formulate my next question
okay off topic real quick
so all shards wouldn't receive the same events?
each shard only receives events pertaining to the guilds assigned to it
huh
except DMs, which are always sent to shard 0
for example you have 3 shards, with 1k guilds each, total 3k guilds
events about a guild that is assigned to shard 1, will only be received on shard 1
never on other shards
well yea that makes sense
and if your bot receives a DM, it will always receive it on shard 0, never on other shards
I thought it meant that certain events wont be received because of the split connection
Okay so then should I put shards into queues?
Cause it seems to me that you want to connect the shards that have different modulo ids first and then connect the next batch but idk
basically the way i did it on tiny-discord is simple
const bucket = Array(max_concurrency).fill(0);
// shard login
const shard_bucket = shard_id % max_concurrency;
const previous = bucket[shard_bucket];
const current = Date.now();
if(current - previous < 5000) {
// wait and try again
} else {
bucket[shard_bucket] = current;
login()
}
Hmm
So basically you just make an array with the max size of however many shards can be connected within 5s
wait
so you're really only storing the time it was connected?
so the key is the shard connected, value is the time it was connected
and you're substracting the current time minus the previous shard that was connected and seeing if it has been 5s before logging in
What exactly do you do in the case of if it the time hadn't passed, do you just wait the remainder of the time and say call the function again?
as I assume i'd put this in a method of a class
yeah, call the function again in case some other shard already took it while it was waiting
so its possible it will need to wait more than once
icic
Also
sorry took so long to respond to my "also" message
async connect() {
if (this.sockets > 0) {
let num = 0;
while (num < this.sockets) {
const socket = new Socket(num);
this.socketStore.set(num, socket);
num++;
}
// once it breaks out of the loop do the bucket thing and connect shards as they are supposed to be
}
const socket = new Socket(0);
await socket.connect();
}
This is my current plan on connecting shards if they wanna do sharding
this.sockets will be the number of shards they wanna spawn which will be set in the client options
I am basically doing a while loop that will create all the shards needed until it reaches the max and then sets them in a socket store. if they don't supply a number of shards they wanna spawn it will default to just one and connect normally
Do you think this is ideal?
or should I just treat it as if they are going to spawn multiple shards anyway
its easier to always treat it like multiple shards, even if you only have 1
so you dont need to maintain two sets of code for the same thing
code for single and code for multiple
constructor() {
super();
this.sockets = this.client.options.sockets || 0;
let num = 0;
while (num < this.sockets) {
const socket = new Socket(num);
this.socketStore.set(num, socket);
num++;
}
}
probably a bad idea right 
https://paste.gg/p/anonymous/0b4e0a84935f4ba79fef90146e2f32b4 this is my current idea
Is it efficient? hell no
does it work? probably not
since you know the exact number of shards, its more appropriate to use a for loop
while loop is more for something irregular or dynamic
I see
honestly I haven't even used a programming language in a while
so ye didn't know that
ofc you can use a for loop my god im stupid
let channel = db.get(`ticketPanel.${message.guild.id}`)```
it still returning undefined
can someone say any othe metods
methods*
then you need to store an object or something
or use a more complex key
for (let id = 0; id < this.sockets; id++)
this.socketStore.set(id, new Socket(id));
ez :)
how many ticket channels do you have per guilds? only 1?
AH
how many other things do you have in a guild? only a ticket channel, or more things?
that bot only permits ticket
then you can do something like ticketPanel.{guildID}.channel
and use .set and .get with the same key
Okay I think its time to actually make the client
and see if identifying even works

i think that only works in get?!?
do you need to store multiple things in that channel id?
or its only the id
are there any things like timers, limits, etc
nah nah
only the server and the channel chosen
so just use .channel
bro channel isn't defined in send panel
// set
db.set(`ticketPanel.${message.guild.id}.channel`, message.channel.id);
// get
let channel = db.get(`ticketPanel.${message.guild.id}.channel`);
lemme try hold up
honestly you dont even need the .channel if you dont store anything else
you can just do this
// set
db.set(`ticketPanel.${message.guild.id}`, message.channel.id);
// get
let channel = db.get(`ticketPanel.${message.guild.id}`);
We dont store anything else
Yeah
you were doing this js db.set(`ticketPanel.${message.guild.id}.${message.channel.id}`, ...); not this ```js
db.set(ticketPanel.${message.guild.id}, message.channel.id);
We tried js db.set(`ticketPanel_${message.guild.id}`, channel.id)
try again then
Ok
Ah it shows
let channel = db.get(`ticketPanel.${message.guild.id}`);```
tell what are we deriving from here
only the server id??
you should be getting a channel id
We are getting undefined
it says its not function
because its a channel id, not a full channel object
you need to get the channel object from djs
client.channels.cache.get(id)
You need to fetch this channel
Ik
ig i did it before,lemme try again
there are two things here
first this
const ugay = client.channels.cache.get(chl.id)```
if we doing that ryt
and second is that
when we do channel.id ,we get undefined
if chl is what you get from the db, then chl itself is the id, there is no .id
const ugay = client.channels.cache.get(chl)
Thank you soo muchhh!!!
👍
I guess "thanks" is enough
@quartz kindle you think its worth doing this for every dispatch event
export declare interface Client {
on(event: 'ready', listener: (client: Client) => void): this;
}
so that way each specific event is intellisensed to what the data will look like when listening to the event

I feel like I could probably do this more effectively by using generics but idk
sure, you can define types for every single event
but you can also use the discord types library
instead of doing everything yourself
export declare interface Client {
on<K extends keyof IClientEvents>(event: K, listener: (...args: IClientEvents[K]) => void): this;
}
ez
export interface IClientEvents {
ready: [data: GatewayReadyDispatchData];
}
rn only ready cause thats the only event im handling rn but shhh

ye
God this is interesting
I am learning quite a bit about ts that I never knew
So when sending intents to the gateway, discord expects it to be a number which is the sum of all the intents bitfields they wanna send right?
So say they wanted the Guilds intent as well as GuildBans it would be 5 Guilds = 1, GuildBans = 4
ye
gotcha
and is it faster to use reduce on an array to get the sum of the numbers in it or would it be faster to use standard for loop
actually doesn't reduce use a loop internally
wait wait wait, no way I have to emit events like this: this.socketManager.client.emit('debug', () => message);
nvm
I did a goof
forgor to edit the emit override in my declare statement as I copy and pasted the on one

afaik array reduce is supposed to use a special reduction algorithm, but idk if js actually implements that
most of the time for loops are faster
I see
export function parseIntents(intents: Array<GatewayIntentBits>) {
return intents.reduce((partialSum, a) => partialSum + a, 0);
}
this looked so clean tho 😔
I mean if it doesnt run very often does it matter?
Not really
k
even in a hot code, the performance difference is usually negligible
also
its better to use the OR operator than a plus sign
a plus sign will fuck it up if they have duplicate intents
the OR operator wont
did you atleast know & was a thing
I don't know much about the bitwise operators tbh
never found myself in a situation that needed it, or at least one that I knew would be more efficient to use it

bitwise is awesome
I never really understood it
what does ~ even do
took a hands off approach
inverts all bits
help
and the NOT operator also flips the sign bit
ah yes, -110 my favorite binary
so basically internally js uses 32 bit ints
so 5 is actually
00000000000000000000000000000101
and ~5 becomes
10000000000000000000000000000010
the first leftmost bit is the sign bit
defines if the number is positive or negative
but it could also be represented as
11111111111111111111111111111010
idk which representation exacly it uses
there are two different ways of dealing with signed bits, twos complement and signed
up to the lang/compiler/cpu to decide
I pretty much only ever use & and |
& for checking bitfield permissions, | for creating them
for what 🤔
extracting subsets or binary
for example you have an 8 bit number: 00000000, and you decide that you want to use 4 bits for one thing, and another 4 for a different thing
const first = n >> 4;
const second = n & 31;
and then lets say you want to update the value of first in n
n = (newfirst << 4) | second
lmao
think of all numbers as a sequence of bits
and then decompose the number into sections
for example the number 88, equals 01011000 in binary
if you do 88 << somenumberhere, it will move those bits to the left
for example 88 << 2 will move them all 2 places to the left, resulting in 0101100000
but how does 88 equal that number in binary
0 = 0
1 = 1
10 = 2
11 = 3
100 = 4
101 = 5
110 = 6
111 = 7
1000 = 8
.... until you reach 88
Okay what

you know how when you count numbers in decimal
you go 1 2 3 4 5 6 7 8 9 10
yea
when you reach 10, you cannot represent it as a single digit anymore
so you have to start using 2 digits
10 11 12 13 14
binary is the same, but you cant go up to 2
everytime you reach 1 and beyond, you have to add another digit and start over
cause binary is just 0's and 1's no?
ye
I see
so you have 0, you can just write 0
for 1, you can just write 1
but for 2, you cant use 2
so you add a new digit, and go back to 0
how does it jump from 11 to 100
would itn ot become 110 ?
like
binary usually needs a fixed "size" to work
lets say our number is always 8 bits in size
00000000 = 0
00000001 = 1
00000010 = 2
00000011 = 3
00000100 = 4
00000101 = 5
00000110 = 6
00000111 = 7
00001000 = 8
the left side zeroes are always there, to determine the fixed size of the number
but you can omit them
wait there was a perfect gif for this, let me find it
but why does the 1 disappear when going from 3 to 4 if we are adding numbers to the end
let m find that gif
Using a wooden binary counter to demonstrate the binary numbers from 0 to 63 (in base 10)
This video contains content from UMG, who has blocked it from display on this website or application
Watch on YouTube
Okay that makes more sense but still confusing to get used to at first
Ima just keep researching more about it until I understand it fully
ye
you can also think about it as an array
for example, 00000000 > [0,0,0,0,0,0,0,0]
just that the values in the array can only ever be 0 or 1
but you can still manipulate them individually
just the way you use indexes is different
for example the OR operator: | is literally, change the value at that specific index to 1
so say a number is 8 bits then the length of the array would be 8 right?
ye
can't a number also be more than just 8 bits
it can ye
how would that effect things
you always need to define the size of the number beforehand
only bigints have no limit
because they use a special algorithm for that
otherwise in all languages, all numbers always have a fixed bit size
in low level languages you can specify the size you want, for example int8, uint32, long, etc
in js you cant
js always uses double precision floating point for all its numbers, which is 64 bit in size
except when doing bitwise because js is stupid
when using a bitwise operator, js will secretly convert the number to int32
which is 32 bits
and convert it back to double precision before giving you the result
ic
thats the reason why discord uses bigint permissions and shit
because there are more than 32 permissions, so it wont fit into a 32 bit number
doing bitwise on a js number bigger than 32 bits, will simply cut the excess off, causing data loss lol
ooo data loss dont we love that
same
aha just as I expected
it doesn't actually identify

No errors at least!
Now I just need to find out why
Ic its not actually creating any shards
OOO IM DUMB
why the fuck did I set the default of the amount of sockets to spawn to 0
no wonder it wasn't working



