#development
1 messages Β· Page 1597 of 1
or you can just
export class botClient extends Client {
commands: Collection<string, Cmd> = new Collection<string, Cmd>();
}
Can provide initial values in class properties descriptors
loving ts so far ngl
forgot this doesn't execute the commands until I fix all files in ./commands
xP
bash is so fckin useful
and have a efi partition
just made a script to check all gif in one folder recursively, delete those smaller than 400x200 and rename them to 000, 001, 002... format
whoops
That's a pretty dumb rule. The this keyword is weird when trying to access it within some child scopes and can instead reference the child scope. Aliasing can hold a reference
I'd most likely disable that rule
omg
you realize that val will be the current value of the loop right
you don't need to index it
then why the fuck are you not using it
entry.changes is Array<AuditLogChanges>
Object.keys(Array<T>) will return ["1", "2", "3", ...]
for (let val of Object.keys(entry.changes)) {
console.log(entry.changes[val]);
}
Your logic for accessing properties is flawed as the keys are no longer indexes. They are strings.
isn't is obvious?
just acess the property on each object
you can have a nested loop
entry.changes is an array right?
That is what I said
wow I just discovered that we can BroadcastEval from ShardingManager also!
This just made my work 10x easier !
.eslintrc.json isn't triggering on tabs and "
idk why
{
"rules": {
"@typescript-eslint/indent": ["error", "tab"],
"@typescript-eslint/quotes": ["error","single"],
}
}
``` but I have these two rules
Hi
why not
Isn't it possible anymore the get the shard id from the bot client in discord.js v12?
(guild_id >> 22) % num_shards
Uh?
gotta use BigInts
const shard_id = msg.guild ? Number((BigInt(msg.guild.id) >> BigInt(22)) % BigInt(total_shards)) : 0
DMs are always handled by shard 0
js moment

So, apparently you can't do operations between BigInt and Number?
Is there no client.shard?
I mean yeah, that wouldn't make sense what to return
Isnβt it an array somewhere with ids
which aren't mapped to each client
Ahh
You can do ops between BigInt and Number, just JS' number precision gets off whenever the numbers are too big
What JS already does with ints and floats is kinda r word
BigInt doesn't have that problem
its annoying how you have to specify a BigInt
USE ```js
Array.from(client.guilds.cache)[0].shardID
How??
why the hell would you do array.from()
can't you just do 22n
Doesn't client.ws.shards give you all shards the client handles
you know client.guilds.cache.first() is a thing, right?
For guild IDs I understand
is it ?
yes
but for small numbers
i didn't know
collections have a whole lot of array-like features, that's why they're collections and not just Map() objects.
Oh so just client.guilds.cache.first().shardID?
yes
k thanks
I got an error from VSC once that directly putting n after an int was not supported on some js versions.
you can also client.ws.shards.first().id
Had to use the BigInt constructor
Array.from would be useful if dealing with mentions
Uhm wait
Would it? How would Array.from() be used with mentions?
wait
I don't think that's what I need JAGUAR
help
Because, again, you have .first(), you can also do forEach, Map, Filter, etc.
it just returns a random shard id
Array.from(message.mentions.users)[1] //for second mention
So message.mentions.users.first(2)[1]
what the hell are you doing
wait that also works ?
of course it does
bruh let me see collection docs
I know it works because I'm the one that PRed that change 
Evie just is a collection, fun fact
mentions.first()
mentions.second()
mentions.third() /s
imagine
mentions.atIndex(0) /s
dont work
that would be so stupid
thats the point
I wonder why.
today I typed my db differently than I structured it
can u send Collection docs link ?
Mobile back at it with the wrong reply
i can't find it
NaN go brrrrrrr
mentions.fiveHundredFortyThree()
that can't be
max limit is 2000 chars
and 1 mention consumes @old cliff these many chars
what
You understand the concept of humor, don't you Jaguar?
2000 chars for what?
How is that relevant
I know but this is dev
You know, like, jokes, memes, funny things, sarcasm?
not #memes-and-media
devs can joke too
oh shit im in #development
Yeah we got a lotta jokes
we're developing humor
leave.


@crimson vapor why not 7.5 Billion ?
I promise you, sometimes devs need to escape the reality of their job through humor. It's a function of our brain to find() ways to cope with issues.
Today I discovered I could broadcast eval from ShardingManager
yessir
assuming you don't use stinky internal sharding
semantically irrelevant distinction without a difference.
evie do you have a job yet?
Yes.
nice ice
poggers
Great job working with vuejs to do contract work for businesses that can't or won't do their own inhouse dev for internal tools.
is vue one of the frontend frameworks ?
yeah Vue is like React and Angular. And yes it's a great job, good pay, good benefits, and since it's contractual it means there's variety in the work itself.
I find react pretty tough to integrate with discord auth login
And Vue > React
oh benefits?
so I used ejs
thats poggers
https://million.is-a.computer/files/siKtjl74srmtq6up.png this true? @umbral zealot
yes.
oh
It's not good because in order to do a lot of operations you need to fetch all the values which are all stored in memory
enmap-light coming any time soon? or is enmap pretty fucking memory optimized?
whats JOSH?
ah
where's drake?
so its like quick.db but better?
where's the door hole?
remember to always draw a dino
I use vue but I like react more
We all have our preferences π
Yea
Any idea?
That`s a pretty complicated answer, actually. Because it requires you to read the audio stream and also figure out how to pass that through some voice recognition software or API, which in and of itself is a fucking pain in the ass.
I have made a command which talks in VC
But I don't have way to take imput
Direct from vc

yeah like I said that requires speech-to-text and that's either very slow or really really expensive.
Lol
That's true
BTW my bot ain't showing correct users
It must say 150k
Shows 90k and gradually increase and when restarted come backs to 90k
ppl: sucking microphones
bot: Hello, you used "marry a capybara" command, is that right?
LOL
Perfect
cache prob
Are you checking via the cache?
probably you're relying on cache instead of adding up all the guild's member_count properties
Yea
triple kill
Do this instead
client.users.cache.size()
yeah don't do that
Because not all users are cached when your bot starts
.size is a function?!
Yea
isn't it a getter
don't do that
Hm
it caches the array iirc
It does
i always do [...collection.values()]
try this instead: client.guilds.cache.reduce((x, y) => x + y.memberCount, 0)
or if I want to loop for (const value of collection.values())
foonspeed
Ok thx
for that tidbit that took me a full fucking 6 months to understand? Yes I''m going to spoonfeed it.
Where is Evie btw
reduce() isn't easy to grasp at first
No see from days
eh
But once you get to know how it works, it's really handy
you're literally talking to me
lmao
Duh name change
Hasnβt hit me hard yet though so Iβll keep using bad practices :βD
LOL
Sorry Evie why name change based on memes always
;+;
because memes are funny
Can't she have fun too?
Lawl
Has anyone built a bot of a phone before?
voltrex has
Use repl if u want to use djs
Or Dbd.js
Im trying to look into easier options im using an app to make a bot
Repl
Use repl
Ok
should I move over to Repl from Heroku?
Oh
o_o
Hmmm
Any other op4
I use it to host my bot
Options
bitches
With 90 servers and 159k users
which
mine is in 105 π
How does repl work?
U need to use uptimer bot @tidal cave
ye
not if you configure it right
never died randomly
yep
file named Procfile inside root, with worker: node index.js inside
no
you have 550h, around 26 days for hosting
if you provide your Debit/Credit card
u get +200h
which is 750h, around 35 days
That works fine unless you got more apps running
yes, exceeds 31, cuz if u host 2 bots on the same account, both count on the same hours
or apps in general
Still, not much customization and you can run only simple bots
how so?
there is a cap on resources that you are allowed to use
not to mention you will be unable to install or use any third-party software beside your bot itself
e.g. databases (mysql/mongo/etc), cache servers (redis)
hyperlink?
wdym hyperlink
host the db somewhere else, then link it
well sure, but there isn't "free" dbs out there
then host your bot along the database
yes there is
sad
No. Repel (glitch too) exposes your code to the public unless you pay. For heroku, if you add your credit card you are set for one bot 24/7.
mongo atlas is one
those are crap
500MB
I use Firebase
Agree.
yeah but you get limited
but you get 500mb
ok but everything is limited
on firebase at least
you can just get 500$ for free from having GitHub pro
let it be limited
mongodb > mongoose on drivers
literally everything in life is limited except misery.
my bot isn't huge yet
you mean education pack, not pro
and its $200, not $500
hmm
the starting plan on mongodb atlas is $57/mo, which means it'll barely last
Selfhost 4head
why is .eslintrc.json not triggering on typescript?
{
"devDependencies": {
"@types/eventsource": "^1.1.5",
"@types/node-schedule": "^1.3.1",
"@typescript-eslint/eslint-plugin": "^4.15.1",
"@typescript-eslint/parser": "^4.15.1",
"babel-eslint": "^10.1.0",
"ts-node": "^9.1.1",
"typescript": "^4.1.5"
}
}
```this are my devDependencies
"babel-eslint": "^10.1.0" not this one?
don't you also need tslint or something
fack
do I?
thought that was only needed for Dev
yes
Same thing
npm i -D eslint
yeah I Did mean dev dep
"@typescript-eslint/eslint-plugin": "^4.15.1"
anyone know a html parser for nodejs
I just kinda need to be able to access some stuff from the html
and its a string with the html from a page
[Info - 15:45:11] ESLint server is starting
[Info - 15:45:12] ESLint server running in node v12.18.3
[Info - 15:45:12] ESLint server is running.
[Info - 15:45:14] ESLint library loaded from: C:\Users\ragsf\Desktop\gumball-and-penny\node_modules\eslint\lib\api.js
weird
still not triggering anything
like quotes
"@typescript-eslint/quotes": ["error", "single"],
Can you show your fulll eslint file
put it in a bin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
there
ik
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Oh no, my code is over 2000 charaters!! What should I do?
Use an paste service. Here's list what you should use:
https://gist.github.com
https://hasteb.in
https://paste.mod.gg
https://paste.mozilla.org
https://pastebin.com
https://paste.gg
There's alot of other paste services but here's the most frequently used ones.
too late though :(
for me
"import/extensions": [
"error",
"ignorePackages",
{
"js": "never",
"jsx": "never",
"ts": "never",
"tsx": "never"
}
]
Could this be the reason
remove that
other than that everything looks fine
hmmm
Actually I think the snippet I gave just tells eslint ignore node_packages
I dunno
but why is it in the rules section?
dw, good effort
same thing
Btw, does eslint not work in ts files, or js files? or both
used to work in .js
when I swapped to .ts
I changed the rules names
to match ts
cuz without them it may not do anything with ts
actually they didn't as they were
client.on('guildCreate', async message => {
const welcomeChannel = message.guild.Channels.cache.find(channel => channel.name === 'general')
const vc = new Discord.MessageEmbed()
.setDescription("This bot will help you and it be updated alot and we are trying to give 75 server so can u help us!!")
.setColor('RANDOM')
.setTitle(`Thank You for inviting me`)
.setImage("https://media1.tenor.com/images/d185187feba0e4daa627f344d07cfad7/tenor.gif?itemid=14465470")
welcomeChannel.send(vc)
})
lowercase c in Channels
it not working
i will remove the embed later
ok
the error is it cant read property channels
so i need to denfied message
no, you don't need the message at all
there's no message
the function gets called when your bot joins a guild
Only the guild parameter is given
thx the doc really helped
and it fixed my problem
more like "Oh no, my code has a line break! What should I do?"
even smaller code can be unreadable on discord
true
Cannot seem to get the font to work on this anyone know why?
<p><span style="font-family: Monotype Baskerville">Welcome to the official website for Echo</span></p>
im having an issue with dpy and the wait_for method, it works fine for few seconds and then for apparently no reason at all it stops working, this is the code:
at first i thought it was timing out when it shouldnt, but its not printing the "timedout"
also no errors on the terminal
@ norizon
Dpy makes me scared ngl
the "checking" also does not print
djs scares me
ive found some ppl on stack overflow with the same issue but none of them had solutions lol
if it doesn't print "checking" then the event isn't getting triggered
maybe intents?
Python needs intents
Even for reaction
it works fine for a few pages and then it stops accepting the reaction adds
its definitely stuck on the wait_for method but idk why
btw why while True ?
cause the user can keep passing pages as long as they want
It will always be true

ye thats why theres the try except return
if the wait_for times out the function stops
Ok
Use raw_reaction_add instead, reaction_add only gets dispatched for reactions on cached messages
Who said I use djs π³
wat
no way
ok lemme try it out
c# then?
what do u use lol
batch script
discord.js?
Make sure to read the docs, it returns different thing
Shush flaze
5 hours non-stop
theres another discord api module for js?
does anyone know how to show how many servers your bot is in in python?
Eris, Discord.js, Detritus
^
JPBBitch berry is nice nohomo
i did but i forgot about the raw thing kek
also don't forget fetch
you use that?
JCord is long gone
Itβs not even v1 yet
i code on js once in a lifetime so i didnt even know there were multiple modules for discord api
but you use that?
Yeah itβs berries lib
alright
damn
it worked
thx a ton
np
oh i c
Does anybody know how to set a playing status similar to yui's?
I know how to do it but i want it to show multiple and say how many servers its in
hey guys
const obj1 = require("./trainers.json");
const obj2 = require("./trainers.json");
index1 = obj1[targetMember.id].mons.indexOf(given1)
index2 = obj2[targetMember.id].spawnIds.indexOf(given1.spawnId)
trainers[targetMember.id].mons[index1] = given1
trainers[targetMember.id].spawnIds[index2] = given1.spawnId
index3 = obj1[firstmember].mons.indexOf(given)
index4 = obj2[firstmember].spawnIds.indexOf(given.spawnId)
trainers[firstmember].mons[index3] = given
trainers[firstmember].spawnIds[index4] = given.spawnId
fs.writeFileSync("./trainers.json", JSON.stringify(trainers), "utf8");```why is this not overwriting the trainers.json?
owh so i most likely should use fs.readFileSync?
I mean you should NOT Be using json as a database in the first place, mind you, that's ridiculously dumb
yeah i know, i have explained it many times.
you've explained many times you really want to keep shooting yourself in the foot?
and you choose to do the things that will lose you data?
ok then
good to know you're fully aware of how stupid that is
i have explained so many times that this is just a test bot for testing purposes. Also, i am using real databases for all of my other projects.
Ok so why not use a real database here then
you're doing something that's HARDER than using a database.
it's easier to just use sqlite or, failing the desire to write sql queries, use quick.db or enmap
both of which are synchronous and extremely trivial to use
Yeah my main database is mongodb
So just use mongo, seriously.
honestly why do people keep insisting that json is easier than it is.
well it technically is
but you should just use mongo
makes promoting things to production easier
it's just a snap of the wrist and all json is...gone
"Oops! You read this at the wrong moment in time, sorry not sorry GOODBYE ALL YOUR DATA! BYE FELICIA!"
Does anybody know how to set a playing status similar to yui's?
I know how to do it but i want it to show multiple and say how many servers its in
what does yui's playing status looks like? we don't know yui.
the yui bot
yeah I get you're talkinga bout a bot
it says how many servers its in
yeah, that would like take 1 week of rewriting everything as it really depends so much on json atm. But yeah, i will reconsider it.
there's a hundred thousand bots
sorry
I just want code that shows different playing status and to show how many servers its in
ok heres the issue, if you dont do it now you will need to do it later anyways when you make it into an actual bot with users
so yea
I mean honestly I don't wanna be that jackass but... had you listened the first time and not continously tried to justify using JSON, you wouldn't have so much code to rewrite at this point.
"I'm going to keep making excuses for doing something bad and then complain that I've been doing the wrong thing for so long and it's too hard to change now" is a shit defence against doing the wrong thing.
there isnt a "yui" bot that I can see in this server, you'll either need to show us an example with a screenshot or somehow
what programming language and discord library are you using?
that is the point. I won't deploy it as a real bot. It is just for my use only.
python
also do let us know what you have tried and what didnt work
we're here to help and not to feed
i had stated my code and stated what didn't work.
not you, I meant Astral
my bad
I haven't really started anything
I couldn't find anything on how to do it
d.js?
I'm guessing it's a size or count property on client.servers ?
no, python
yep
I don't know python at all but it should be pretty straightforward to get the size or the client.guilds structure
you just do len()
no I know how to do that
I just want one of the statuses to be showing how many servers its in
ah, that
just get the length of guilds collection then
thats the problem- I don't know what the code is for that
len(client.guilds)
at this point i really do not care about what database i am using for this project. Also i am definitely not complaining. Just stating that my code depends too much on json to change it at this point. After all, it is just for my own personal use. I am not publishing this bot or whatsoever.
len(client.guilds)
so I put that in the status?
Ye
is there a way to get the bot owner in discord.js?
get your point tho, don't get me wronjg.
The irony here is that you are saying you're using too much JSON code but your example JSON code that started this question shows that you don't understand how JSON and JS work in the first place
the owner of a bot? I don't think so
you can't have that much JSON if you don't know require()ing a json file caches it
i found this but i have no idea how to call it: https://discord.js.org/#/docs/main/stable/class/ClientApplication?scrollTo=owner
only works for your own bots, you can't fetch applications for other bots/clients
I mean, If the bot is in top.gg i guess you could
Damn this attacked me personally. Getting a bit heated? I am not trying to argue with you, i was just defending my way of code... we are humans. We learn etc. You can say that i don't know proper json and js and that i don't know it catches it... That can be true, however I am a human that is still learning. Everyone learns. Even you.
yes i know thats what im trying to do
I am blind
holy fuck
oh i call it first then i can get the owner
I'm not getting heated I'm just trying to explain to you that you're defending a really bad position by attempting to explain you have too much of something, while simultaneously showing you can't possibly have done too much of it or you'd know how to do the thing you're doing, which is, for all intents and purposes, the very basic way to do the thing.
You want to get the owner of your own bot?
yes
I'll give you a hint: you're the owner 
lmao
Cant u just hardcode It?
no shit thats not the point
So TL;DR:
"I've been doing JSON for months and I know how to do JSON, I don't care if JSON is bad, just tell me how to fix this JSON thing"
Answer: "Do the JSON thing the exact same way you've been doing it for months, or stop doing JSON altogether, it's bad.
Yeah i understand. It was just a little question. I mean, i will rewrite my whole code special for you.
learn mysql
I'd say PostgreSQL
you should never learn that in 2021
post the tag
(from DAPI): MySQL is a bad database. Don't use it unless you have LITERALLY no other option.
Why?
- MySQL has no transactional DDL. This means that if you fuck up creating a table in the middle of a migration, you CANNOT ROLLBACK easily.
- MySQL has a lot of security issues. New zero-days are found REGULARLY.
- MySQL is owned by Oracle. Yeah.
- MySQL is slow. It beats Postgres etc at some things, but once you move beyond basic queries it begins to DRAG.
- MySQL disconnects you randomly. Unless you setup your connection specially, it will break regularly.
- MySQL allows all kinds of insane data to be inserted.
'0000-00-00'is valid in MySQL. - MySQL is not ANSI compliant. You have to turn it on; even then it isn't fully compliant.
- MySQL has no feature advantage over other databases; PostgreSQL has many more useful features (such as RETURNS).
There is NO reason to use MySQL over PostgreSQL, or even sqlite3. See also:
https://blog.ionelmc.ro/2014/12/28/terrible-choices-mysql/
https://grimoire.ca/mysql/choose-something-else
thank you
mariadb: exists
MySQL disconnects you randomly. Unless you setup your connection specially, it will break regularly.
This was one i had a ton of issues with
every 8 hours on the dot, and it doesnt seem to be disableable? why 
mysql ew
use json.db

jason.db π
im convinced even that would be better ngl
To be fair, there are good functional databases using a json back-end, but they're implemented using proper atomic read/writes which prevent corruption - but that stuff is harder to implement "simply" and require more code and boilerplate than most people care to write.
also, not using VARCHAR(191) instead of VARCHAR(255) fucks your table pretty hard
true
so "your life, your choice, don't come complaining later"?
why is my ready event being emitted twice? https://i.callumdev.pw/r1zws.png
await sync lmao
in forEach too 
you registered the ready event more than once?
ermm no
where are you logging that connected part
hrm
also just saying
your client event collection or map or whatever gets overriden if you have more than one of the same event
use an array instead or something
could potentially cause issues later on
anyone here know how to open ports on windows?
- router port forward
- windows firewall
search for Firewall on windows search
open it, then Advanced Settings
then you have access to everything the firewall has
click on New Rule in Entry Rules
choose Port > select the protocol you want > type on local ports what pot you want
probably 8080 is the one you want
it's 80 so xD
yeah, but windows is being windows
Hola, I'm struggling with sending information across the shards once again... How would I set fameLeaderboard variable on all shards to the array values? This code throws reference error and fameLeaderboard on other shards than 0 is empty
let array = [
"1. someone\n2. someone\n3. someone\n4. someone",
"5. someone\n6. someone\n7. someone\n8. someone"
]
client.shard.broadcastEval(`fameLeaderboard = ${array}`)
The array should probably be attached to every client instance
attached as adding it directly to the client object?
like
client[array] = [
"1. someone\n2. someone\n3. someone\n4. someone",
"5. someone\n6. someone\n7. someone\n8. someone"
]
yeah
except... you should probably JSON stringify the array
and also you attach it to the client inside the eval script
and then access it by doing client.fameLeaderboard
for example
alright, I'll give it a try, thank you π
is this channel like stack overflow?
na not really, we dont spoonfeed
localhosting my bot written in TS, I get 300+ from ping command
but my bot written in JS and hosted in Heroku, I get 100+ from ping command
np! Here's an example:
Set the array:
broadcastEval("this.someArr = [1, 2, 3]");
Read the array:
client.someArr; // [1, 2, 3]
I wonder if it's because of my local, or because the time TS takes to answer
Typescript just compiles your code to javascript
he needs to do that only once, at startup
Not really compiling tbh since js is interpreted
yeah but the ts code gets compiled to js
Also, javascript also gets compiled to bytecode behind the scenes, before getting interpreted
this would be handy to have variables spread after the eval
broadcastEval(code:string, ...variables:any)
TS to JS is usually called transpiled
actually
so, is TS slower than just JS?
to compile? yes, to run? not usually, no
ts will most of the times make your code more optimized than not
I successfully rewrite all .js to .ts
even the functions are .ts
come join us in the dark side
I'm moving from Atheism to TSism
indeed
just gotta use a Ts lib now
since d.js is js
cough cough detritus cough cough
everything is js, wont matter
its just that for ts users, detritus is a whole lot better
not counting the library functionality
which beats d.js by a mile
check this for example
these are the options per COMMAND
theres options for the handler too
no more that fs.readDir bullshit with setting the module.exports
no more checking if a user has permissions
no more checking for custom prefixes
give it a directory and it will pull all commands/folders from inside
and organize them
thats ONLY for command handling
detritus offers a shit ton more stuff thats far better than d.js
this is what your client looks like, this, with all the commands loaded
just this
i have this code and instead if listing the files after each other in the logs i want them under each other client.once('ready', () => { console.log(commandFiles + ' loaded'); console.log('Bot launched successfully'); }); i am dumb ik
tell it the directory your commands are in, and it'll auto load them
that's not hard to do though
indeed it inst, but its cleaner, has more options, is a lot smarter and has a solid framework to be worked upon
I prefer making my own command handlers. That ^^ feels bloated
just think of how much code you skimming from your index for not checking:
prefixes
cooldowns
permissions
your permissions
loggers
error handling
trust me, i done both, and im 100% sticking to this one, even after have made my own
I think I'll stick to discord.js-light for making bots
i much rather this one, you can change its caching behaviour just as equally, and ive shown tests before of how it compares to d.js
then stabilized at around 810mb
i wouldnt throw dirt at detritus until you try it tbh, even on a test bot
the difference is huge
o_O
but it can't beat djs-light :))

it can
810mb with all caches enabled?
indeed
well if you disable every cache, no i think (in djs-l)
o_O
oh no
thats why i mention it in my readme
is it? so it's too much for me π
its overkill to a point
I can't handle so much power
the amount of handy stuff it has is insane
djsl is for people who like the djs api
^^
if you dont mind moving to a whole different api style, i do suggest detritus
detritus is perfect for TS users, the types are super well organized
the ONLY thing i had to whine about it, is that it didnt have reaction collectors, so i had to make my own, which was like, 20 lines of code
at least not as far as i could tell
whoops
i have this code and instead if listing the files after each other in the logs i want them under each other client.once('ready', () => { console.log(commandFiles + ' loaded'); console.log('Bot launched successfully'); });i am dumb ik
well, that'll be my problem
the internals are super well organized though
a bit too organized
and this is the bot from the dev
he made it open source so people could see how to do stuff
Is that the notsobot?
erwin say how clusterclient helps in clustering uhh?
no, your main client in detritus is commandClient
You could always write abstraction layers to mirror DJS' API, but that would introduce some overhead
commandClient.client(as clusterClient or ShardClient)
weary
// with cluster
commandClient.client.shards.get(0) //rest
//with shard
commandClient.client //rest
you can always map it too
so commandClient can't have shards but clusterClient can?
nono
also not yet it's not fully released smh
okay, lets reiterate in a d.js manner
imagine client as commandClient
as in d.js
client.shards.map(shard => shard.guild.cache.get('1234')) //cluster client
client.guilds.cache.get('1234') // shard client
client in this instance is either a cluster client(if you're sharding)
or a shardClient (single shard)
idek why use detritus if you need to cluster
go whine to the author berry
i still dont get it tbh
i told you
i don't, i just wanna know how things work differently compared to djs
its working amazingly for me
it looks fine, but if you need to cluster it takes a huge performance hit just for the sake of being easy
Let me guess, if I do a library to return 10, will I get Library Developer role in here? π€£
nope
heheh
i found a good mongodb* wrapper thats not quickmongo
though still, detitrus for me is the ultimate library
how large of a bot have you made in it?
djs has internal sharding though? and also what about shardingClient in detritus?
click me berry
i tried running my bot with detritus and got a memory leak
that's terrible
its not
it is
remember i have my own custom cache
that should make it even less lmao
you are under the assumption i only use the library cache
i have 1.5GB on a 40k bot
which isnt true
and regardless the way it handles events cannot scale period
remember i have custom objects for each user
even djs handles it better
not only that i save image buffers in memory too
for canvas
some of those images are 8mb in size
and i have around 300k other objects for genshin_users
ig that makes sense
hi nerds
but still events are just poop
so thats 450k from the library + 300k frmo my own personal cache
are you just doing internal sharding esc stuff?
me? no
like 2 shards on the same process
each shard uses its own worker
i think i mistakenly set the shards to 2 cuz i forgot to remove it
but it was at 5
that makes canvas a whole lot better
mmm... so I tried to attach it to the clients but it doesn't seem to attach across all of them but only the one it was sent from
attaching at shard 0:
client.shard.broadcastEval(`this.fameLeaderboard = fameLeaderboard`).then(() => {
console.log(client.fameLeaderboard) //expected array output
})
logging w command at shard 1:
console.log(client.fameLeaderboard) //undefined
since its not all blocking on the same thread
@opal plank-sama, explain me something ππ»
TS:
canvas is used quite a lot
idk it's just so strange to me
also you should just use a separate api for the canvas but that's opinion ig
wait
vs JS:
no idea, ping varies
erwin
Β―_(γ)_/Β―
@crimson vapor maybe u can learn a thing or two
TS has sent me more 300s than JS 200s
thats what i was planning on doing, but im gonna ditch canvas
beeg brain
hey
a friend is probably going to be doing a rust api
anyone from JS that can help me with alias?
fameLeaderboard is not a thing - you have to put your array in the string
thats related to websocket ping, unrelated to the lib
wait Erwin do you use canvas on the shard process?
why though only 1 shard per worker? isn't that a bit waste?
i do, yes
module.exports = {
name: 'pokemon',
aliases: ['pk', 'p']
}```
this isn't working for some reason
how many processes?
yeah at that point you end up taking a performance hit for doing it
may I speak in PT for him a little?
indeed it is, but all other cores are just idling, with the exception of one being overused, might as well split it
but performance isnt the goal in detritus anyways 
so its not blocking
const arr = [1, 2, 3];
Then, inside the broadcastEval:
this.fameLeaderboard = ${JSON.stringify(arr)};
the fameLeaderboard on the right is the array with values I'm passing, that shouldn't be the issue, could the stringify be doing it mb π
well, berry, feel free to ask the author of the lib if you think its unoptimzed, cake is always willing to listen to feedback https://discord.gg/5Jgz8Xfk
The thing is that you define fameLeaderboard in shard X, and the code executes on all shards.
the only way to fix it would be to bork the ease of the library
which ig is the whole point
So it's going to be undefined for all shards except for shard X
its made for simple users (no offense) and it's prolly fine that it doesn't scale
bro im ngl
like i said, tell em not me, for me its working amazing
berry just called it shit
weary
still scales much better than djs
^^
and its not for simple users at all
there's no way that scales at all
it sounds like you barely looked at it tbh
i literally tried using it to confirm my suspicion
depends
its one of the possible design patterns
it depends on your workload to see how much it scales
sort of defeats the purpose of clustering if everything just gets sent back to the master
I agree that sending all events to one process isn't a good idea
there are people for whom the shards themselves use a lot more cpu than the actual bot commands
for those cases, the funnel pattern works fine
that cannot scale
it can if done properly
regardless of what you're doing funneling every event back to a single process is like anti-scaling lmao
the same way you use nginx for ssl termination, you use worker processes for websocket + zlib termination, plus you can add custom filters to them
and funnel only the useful packets back to main
i literally memory leaked just trying to run my bot with default caching
that's not a good sign
lmao
did you ask the author if you were doing something wrong?
i followed the example to a tee
which example?
not so bot uses it
That doesn't look like THE notsobot, notsobot has so many more commands
and worker handles multiple shards?
correct
ill look into this source code, but atleast whatever is default for this and according to the example it just doesn't work well
possibly
I mean
ohh, I guess I kinda understand... but in that case how would I go about it, because the variable I need to have accessible on all shards, loads only on the shard X to reduce the Discord API calls
I want the variable that loads once on shard X just forward to all other shards when it's loaded
Exactly
That's a fair assumption xd
maybe they have two version of it
one in py, the other in detritus
ask them which one they run in prod
they've gotta be using a different design pattern then what's the default if they're running a 500k bot with it
I doubt the old python code can still run
idek how to change it with detritus but there ought to be if they haven't
well, if you can customize shard ids and shard total, you can use any client with your own design pattern
true
i used pm2 cluster mode with djs lul
You have to stringify the variable
I gave an example
well then again idek cuz with detritus unless there's a way to change it (looking rn) it forces all the events to go to master
I literally copied your example afterwards but still no luck :x
so even changing it wouldn't make any real affect on the issue i see
still returns undefined on other shards
even so, you have to actually benchmark the funnel pattern because it may be more performant than you'd think
weary so much effort
im gona do it
funnels in djslight?
i'd love to see your results
but then again i cant see there being an issue unless its a bigger bot tm
time to steal mee6's token
xD
I think the funneling approach is definitely going to get super slow when the bot gets big
yeah
launch your bot 10 times and send all events to your lib
to simulate a bot 10 times your size
lmao
- this.shard.worker.emit('*', msg)
+ this.shard.worker.emit('*', msg)
+ this.shard.worker.emit('*', msg)
+ this.shard.worker.emit('*', msg)
+ this.shard.worker.emit('*', msg)
+ this.shard.worker.emit('*', msg)
+ this.shard.worker.emit('*', msg)
+ this.shard.worker.emit('*', msg)
+ this.shard.worker.emit('*', msg)
+ this.shard.worker.emit('*', msg)
+ this.shard.worker.emit('*', msg)```
xD
ez
this is from shard 0, if I call client.fameLeaderboard on shard 1 it returns undefined
the way they're describing it is how the traditional clustering should be done
but in practice im receiving every event on a master process rather than on each individual cluster
nah
depends on what your bot does
idk why they chose 8 either
they prolly just say it cuz in their own practice 8 is on the dot
I'd hate to be paying for 50+ VMs
i do 5 for mine
that might be due to your implementation then
not a flaw in the lib
i followed the example

