#development
1 messages · Page 2028 of 1
Just pick up asm and never have a worry about performance ever again!
good luck
lol im gonna have my brain exploded if I do that
How would I execute multiple tasks at the same time, then return the data once the tasks are finished? For example, if I have this async function:
async function doSomeTask() {
return new Promise(async(resolve, reject) => {
String data = "";
// await and do something
resolve(data);
});
}
How can I execute 3 of doSomeTask(), then when the task is finished return all of the data variables?
Ex.
let data1 = await doSomeTask();
let data2 = await doSomeTask();
let data3 = await doSomeTask();
let finalData = data1 + data2 + data3;
I just don't want to have to await, rather have all the functions execute at once and then return all the data once they have all finished.
Promise.all()?
The Promise.all() method takes an iterable of promises as
an input, and returns a single Promise that resolves to an array of the
results of the input promises. This returned promise will resolve when all of the
input's promises have resolved, or if the input iterable contains no promises. It
rejects immediately upon any of the input pro...
Might be relevant to what you’re doing
Oh. Thanks I'll look at that
you can await a Promise.all()
👍
How to refresh users count in cmds
wdym?
value is not changing when bot is running
Does your bot have the priviledged member intent?
Yup
Without that it's just an approximately number
Well then guild.memberCount should be accurate
This value not changing when is bot online even i add bot in one more server
let or const issue?
Which value are you talking about?
The guild member count should update once a member joins or leaves a guild
After restart value +
But you need to loop through all guilds to get the current property value
let ucount = 0;
client.guilds.cache.forEach((guild) => {
ucount += guild.memberCount;
});
.addField(`Users`, `${ucount}`, true) ```
disagreed. use whats most performant and optimised
sorry my dark os dev side is showing
do you have the GUILD_MEMBERS intent?
Well instead of looping through all guilds at any time I would create a global var and add or subtract the guild member to it in the guild join and leave event
Yup
do you also have the GUILDS intent?
Value is not refreshing when bot is running
Yup
does client.on("guildMemberAdd") show anything?
This is cmd
no, not command
im talking about the guildMemberAdd event
client.on("guildMemberAdd", member => {
console.log(`new member added: ${member.displayName}`)
})
I have
add that to your code and see if it logs anything
so confirm if your bot is detecting members or not
but i want add +1
that code only works if your bot is detecting new members
so first you need to check if the detection is working
and btw, show the full command code
Its works
show the full command
When my bot is running, then if I add a bot to a server, then the values are not added to that value until I restart the bot.
Sorry for mistakes
Tim trying hard
edit isn't a function, means playembed is not what you think it is
log it in your console and see
Yup
aaja server
<MessageEmbed>.edit() is not a thing, try reading the documentation

which documentation
Discord.js
LMAO

but complaining about non accurate numbers
How do i shard my bot on multiple hosts? Cause how im doing it rn the bot responds 2 times...
Clusters i think is what your referring too

what library are you using?
how many shards do you have in total? or how many guilds
Hey, Tim, do you recall this question I asked you? You also gave me an answer...
lmao
i guess? i dont remember
This was your answer.
This was my logs so far.. so what's the best ideal solution?
[SHARDS]: Launched shard 0
Error [SHARDING_IN_PROCESS]: Shards are still being spawned.
[SHARDS]: Launched shard 1
Error [SHARDING_READY_TIMEOUT]: Shard 1's Client took too long to become ready.
Node.js v17.4.0
I've tried this, but I kind-of got lost in the end, and the Shards are still being spawned error still kept appearing.
check this #development message
Damn, although, I have only used this 9 lines of code on my shard.js file since I started sharding.
require('dotenv').config();
const { ShardingManager } = require('discord.js');
const manager = new ShardingManager('./src/index.js', { token: process.env.TOKEN, totalShards: 'auto' });
manager.on('shardCreate', shard => {
console.log(`[SHARDS]: Launched shard ${shard.id}`)
});
manager.spawn({ delay: 10000, timeout: 60000 });
what exactly are you running that is causing the error?
are you using broadcastEval in shard 0?
I replaced 'auto' with 2 for testing purposes, and shards are still being spawned error comes up.
You see, my client#ready event immediately fires since shard.js runs index.js and the index file runs the event file which the event file runs all the events in the event folder including the ready.js file which is the ready event that has the broadcastEval, yes.
shard.js --> index.js --> event.js --> ready.js (which has BroadCast Eval)
What I'm thinking is put some sort of sleep() function or promise that waits till all shards are ready, but although, I do not know how to calculate the total amount of time for all shards to get ready.
you can do something like this
// manager
manager.on("shardCreate", shard => {
shard.on("ready", () => {
if(manager.shards.every(x => x.ready)) {
manager.broadcast("allReady");
}
});
});
// index.js
process.on("message", message => {
if(message === "allReady") {
// all shards are ready
}
})
//manager, the code of the sharding manager, correct?
yes
djs
Oh, do I put it inside there?
I mean, that's up to u, "Lauched shard" just means it started, not that it is ready
that's why I said nvm
at the end of the day that's up to u, it's logging after all
Where should I put it, though, inside the ready event or outside of it.
i dont have many shards. i just want to know how to do it
djs's client has options to define the exact shard ids you want to run
for example ```js
new Client({
shards: [0, 1],
shardCount: 4
})
that would tell the client to run shards 0 and 1 on this process
out of 4 total shards
so you're free to run shards 2 and 3 anywhere else
ok thank you!
Well, it's spawning one shard only. :/ Hold on while I share my code.
how many guilds do you have?
it's around 1 shard per 1500 servers (on auto)
I put a 2 value.
yeah you cant use "auto" if you dont have at least 1500 servers
otherwise it will only spawn 1 shard
Yup, but for now, I put a 2 value, and before you told me to test out the code you sent me, it would spawn 2 with errors, although, with the code you gave me, it's spawning only 1.
How would that affect that, though, it's not even spawning 2 shards, not even erroring.
its spawning one tho right?
Only 1, correct.
I set the totalShards to 2, although, it's spawning one, only.
add client.on("debug", console.log)
to index.js
also
change the code i gave you to this
manager.on("shardCreate", shard => {
shard.on("ready", () => {
if(manager.shards.size === manager.totalShards && manager.shards.every(x => x.ready)) {
manager.broadcast("allReady");
}
});
});
Sure, I'll do that once I come back. 👍
Where's that happening?
yes
command js
...no, like, the line
await g.commands.permissions.set({ fullPermissions })
ye, wont work
How do I get around it then
They deprecated batch edit guild application command permissions and will not be bringing it back. People are supposed to edit 1 by 1
@gloomy vessel
ehhhh dat sucks
btw, I've been testing a dashboard sharding things and it always gives an error process.send is not a function
wtf
"business"
Business?
google suggestions
Oh sorry
that gboard thing you know?
If im assuming correctly your send process isn't registering
@quartz kindle can u help this man?
Tim must know me in real life and doesn't even know 
ok, just joking, if you can help me :D
code?
wait a second
Note: it seems that the error occurs every time when accessing the homepage
that also looks weird...
where is process.send?
in his code duh
that is the problem
I don't find this shit at all
show full error then
so either you have it or something is requesting it
ok
TypeError: process.send is not a function
at /***/*****/*******/node_modules/discord.js/src/sharding/ShardClientUtil.js:85:17
at new Promise (<anonymous>)```
@quartz kindle
thats all?
ive had shorter errors before
"you did something wrong you idiot"
looking into your code, you seem to be running a client inside the manager
and trying to use broadcasteval from the manager itself
hmm
which obviously doesnt work
ok
basically, delete this
done
does it work now
Hello if i remove top.gg-autopost from my bot codes is it still work after that?
It won’t post the server count automatically anymore
It do remove it 3 hours ago still posting right counts
I doesn’t magically post the server count
Then how is it possible
If you don’t post it manually or have the autoposter included somewhere (again) it won’t update anymore
Ik just asking how is it happens if i remove autopost stuff from my codes then how is it updating page details
Well I don’t know your code
Example codes
Check if you have included the package anywhere else again
Provide on npm example
Just install and set up it in index file
Just remove codes from index.js
again, that's very vague
Check messages from up
I did

It still doesn't make sense

in fact it makes even less sense
reading it without reading the messages above it makes it sound like fake is asking you for help
and not vice versa
??
No i don't
Facts please, auto posting the server count only works with the package
Like i use auto Post package for statics of bot i remove it from bot now still sending right information to page
If you removed it correctly and restarted the app it can’t post anything anymore since it doesn’t get loaded
Hmm
Make sure there’s no second instance running with the package still loaded in
If package send stats it send messages on console about it
Now it not sending message but still website update after bot server increase
The website uses a cache
Ya maybe
A change you will see in about an hour can already be hours old
Wait an hour or more, it shouldn’t update after that anymore
Okay
As I said if the library isn’t loaded in anymore it doesn’t happen automatically
Understand
Alright
Hii, I have some questions regarding discord oauth2 that i am not sure i understand it right, and i am not sure where to ask so i asked here
https://discord.com/developers/docs/topics/oauth2#authorization-code-grant-refresh-token-exchange-example
in this function, what should i pass?
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
oh nvm ig
my bot not registering all the commands, just 1 (i have 20 commands) and i waited 3 hours and counting
You might not be using the bulk override commands endpoint
why?
Btw, im for hire if anyone need
Redis is cache database. Use it only to speedup mongodb. You cant store it forever
you most likely don't even need redis
I use it
I'm just saying at a smaller scale the complexity isn't justified just for caching
I use it for dashboard (to cache user logins so they dont have to keep login again) and to cache user levels, economy and guild configs to not make request to mongodb every command
people underestimate how much load databases can take before they start to slow down
Hope i can get some client soon. Need to get some money
well i did it for it to work faster
And it is faster
did you need it to work faster?
you cache user levels and configs but now you have to deal with things like cache invalidation
nothing is free
Wdym
what happens when a user changes their settings? You gotta clear their redis key
I update Redis key
doesn't that defeat the point of using redis
so you basically have 2 databases you keep in sync lol
that's the complexity I'm talking about
and for what? 50ms speed increase?
yes
Nope, i make request to mongodb when i want to delete/update/create smth
I fetch data from redis
If it isn't there then fetch from mongodb and put into redis
It means the module you were looking for was not found
i know that bu thow to solve
Type the right path
You realise you can't just clone https://github.com/SudhanPlayz/Discord-MusicBot and put on top.gg 
nah just for the server
Send the ss of the folder(where it shows the files)
And if you using this, use npm start
^^
I wonder why people clone bots and struggle to solve errors when making one from scratch is easier and faster
lol
And worse, they expect somebody else to fix it
When I use the command, the command does not work and gives a voting condition.
should not use the command without voting how do I do
ah yes the infamous sudhanplayz music bot
dblapi.js is deprecated, use https://npmjs.com/package/@top-gg/sdk instead
Official Top.gg Node SDK. Latest version: 3.1.3, last published: 5 months ago. Start using @top-gg/sdk in your project by running npm i @top-gg/sdk. There are 6 other projects in the npm registry using @top-gg/sdk.
any experts help here?
The content doesn't appear next to the sidebar for some reason, but underneath the sidebar
return inside .then() does not affect the rest of the code
{
label: 'Util',
submenu: [{ role: 'reload' }, { role: 'toggleDevTools' }, { role: 'zoomIn'}, { role: 'zoomOut'},{role:'zoom0'}]
},
how do i reset the zoom? its not zoom0 or something
context?
resetZoom
its not
Can Discord bots access the disable/enable command thing that discord released a few days ago?
thats the only mention of zoomIn and zoomOut i found in the entire electron docs
Cmd+/-/0 zoom shortcuts are controlled by the 'zoomIn', 'zoomOut', and 'resetZoom' MenuItem roles in the application Menu.
Not an expert but you can achieve that but multiple ways like
• Setting the dark blue area width to calc(100% - width of grey area) and make it float to the right
• using margin/padding
• use grid temple area
role string (optional) - Can be undo, redo, cut, copy, paste, pasteAndMatchStyle, delete, selectAll, reload, forceReload, toggleDevTools, resetZoom, zoomIn, zoomOut, toggleSpellChecker, togglefullscreen, window, minimize, close, help, about, services, hide, hideOthers, unhide, quit, 'showSubstitutions',
You mean the slash-commands permissions v2 system?
Yeah
nvm i accidently made it "resetzoom" whitout camel case
zoomer
It's not exposed to the bots' API scope, it's only available through oauth
what system do u recommend me to host my bot
Oh okay, thanks
any vps
By system do you mean operating system or VPS?
os
i only used ubuntu and debian, and i liked debian more
In general it doesn't matter, but Linux is more preferred for hosting things like a web-server or a Discord bot or anything similar, and if you're planning to host it on a VPS, Windows servers are way more expensive than Linux servers
so any linux dist
Yes
Ubuntu Server
except arch linux unless you know what you're doing
is like the most popular
i tried to install arch on my main lap, but failed somehow to setup the graphic thingy
so only cmd shows up
:/
rip
yeah, I had to buy a windows cd from amazon
so i can boot back to windows
no sec lap :<
Instead of downloading the iso?
no computer
And mounting it to a usb drive

There's also Archinstall made by the Arch Linux developers, which installs Arch Linux on your device, although it's experimental and the manual installation is currently recommended
https://wiki.archlinux.org/title/Archinstall
thx but no, if i fail 1 more
rip my 60 euro
again
fun fact, arch linux is governed by a democracy with a new leader elected every 2 years
wtf
thanks
either pirate or buy a cheap key on ebay for like £3
dont pirate nfts tho
where there aren't a "shared power" and "full power", like the candidate need to get more then 45% for a "full power" and less is "shared power" with the sec guy
pirates speedy
READ ABOVE
why i didn't think about it
please summarise
30min on internet cafe with decent internet
Speed dumpy dumb
i dont want to read a whole convo
reminds me of my NFT i made
I've been running off my windows 10 ISO for almost 4 years now
if its about nfts im all ears
never had any problems
i have old ass isos on my external disk idk why
completely free :^)
including windows xp isos
why cant bro use a library computer
yeah now I have like 3 usb for 3 diffrent os
It’s actually difficult to install XP on newer hardware
for every case
usually library computers don't allow you to download large files like that iirc, or at least it's against their rules
yeah but like gaming net yk
Rules exist to be broken, Sir

:D
FakE's car exists to be bombed, sir
No day without Voltrex’s threats to attack the western world
No day without FakE spreading FakE news
Fake news
Don't expose yourself!
Xd
can i make a click string?
Quiet terrorist
Or I reveal your location to the fbi
Quiet, before I trigger the bombs in your house
like on Tray
Well there are some in your car as well
The insurance will pay a fair amount of money
@earnest phoenix qt do u know electron
Sure, what's the problem?
can i make a click string on ApplicationMenu
like onClick or something
for help etc

Well it contains menu items, so you should be able to do that
https://www.electronjs.org/docs/latest/api/menu-item
Add items to native application menus and context menus.
is it ok to relase v6 tommarow?
Sure
click Function (optional) -
yup
there it is
can i make it on the role thing
like;
@earnest phoenix
yup,it did! woo
Is it a bad thing for someone to learn about brute force attacking with Hydra?
learning is never a bad thing
attacking something or someone with it who doesnt want it is bad
Ahh, now, I've currently attempted a brute-force-attack on my VPS (which I did ask the hosting provider before I did do so), and working with Hydra was really fair (but had to deal with firewall block, etc.).
Having to deal errors with something like these. 
Anyways, it's fine, I'm happy I got to learn about Hydra, for now.
i got my neighbours wifi password once
Really? Via what. 😂
Well, at least that is your first challenge, I suppose. 😂
Did you do it locally or from a virtual machine or a VPS?
i bought a usb wifi antenna and run it on a linux vm
LOL, that strategy. 😂
Ahh… that’s the reason you got better internet now. I see
i dont remember what i used to captue the wpa handshake
I downloaded Kali-Linux, it's laggy af.
I used wsl so I could run it on my terminal and that would take me to the look-alike kali-linux terminal, then I used xrdp to create a machine on my local computer via the Remote Desktop app.
Basically installed xrdp via the look-alike kali-linux terminal.
Yes
Still spawns one shard. 👋
OOP, hold on, forgot to put 2.
Yup, back to the Shards are still being spawned error and the ready event didn't work.
did you remove the broadcasteval?
NGL I’d recommend discord-hybrid-Sharding
I mean, I did and both spawned successfully.
then it works
So.. here's what I think should be our solution..
We need to wait for the shards to launch before our ready event fires.
How can I achieve that?
you just need to put your broadcasteval in the allReady event
and remove it from the ready event
is it still considered the decorator pattern if you dont modify the input object, but make a copy of the input object and modify that?
Sorry, where?
In the ready event of shard?
God, there.
Do you think adding a promise to this process and putting it before the forEach()s would work?
forEach doesnt work with promises
No, the message event for the process, I would put it in line 6, supposedly, instead of 12.
And make a promise for it for it to finish.
why?
I would wait for the shards to launch then run the event handler which has the ready event.
then your bot will not work at all until all shards are ready
anyone know if there is a way to turn this:
[
{ name: 'Laptop', value: 'laptop' },
{ name: 'Lottery Ticket', value: 'lotteryTicket' },
{ name: 'Diamond Ring', value: 'diamondRing' },
{ name: 'Pentecostal Coin', value: 'pentecostalCoin' }
]
to this:
{ name: 'Laptop', value: 'laptop' },
{ name: 'Lottery Ticket', value: 'lotteryTicket' },
{ name: 'Diamond Ring', value: 'diamondRing' },
{ name: 'Pentecostal Coin', value: 'pentecostalCoin' }
``` (javascript)
Isn't that how it's supposed to work?
no, as soon as each shard is ready, those guilds in those shards should already start working
thats liteally the same thing? what is the difference?
const x = [
{ name: 'Laptop', value: 'laptop' },
{ name: 'Lottery Ticket', value: 'lotteryTicket' },
{ name: 'Diamond Ring', value: 'diamondRing' },
{ name: 'Pentecostal Coin', value: 'pentecostalCoin' }
];
...x
maybe the spread operator is what you are looking for?
...
im using discord.js v13 and .addChoices takes only objects but i want to convert from being an array to seperate objects
do what ben said
Use the spread operator (...).
sorry im not sure what you mean by spread the operator
yo tim do you still work on tiny-discord or is it mostly contributors?
function test(a,b,c,d) {
console.log(a,b,c,d)
}
test([1,2,3,4]) // [1,2,3,4] undefined undefined undefined
test(...[1,2,3,4]) // 1 2 3 4
i work on it from time to time
ah ok
You can learn more at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax.
Spread syntax (...) allows an iterable such as an array
expression or string to be expanded in places where zero or more arguments (for
function calls) or elements (for array literals) are expected, or an object expression
to be expanded in places where zero or more key-value pairs (for object literals) are
expected.
ima be honest I didn't even know you could use the spread operator like that
It has two names, rest paramter and spread operator.
Two different purposes.
One that spreads the arguments and one that rest (merges) the arguments.
(new to ts) getting this error on collection.find(), cant seem to fix it or find anything clear enough to help
members is an object
I think you should mention the type of value it will return.
Alright, I've done that, although, still on going issues. Basically, the two shards are spawned but shard 1 took too long after 0 spawned.
My code so far.
Soo... allReady hasn't been logged, unfortunately.
add bot.on("debug", console.log)
Where do I put that, after which line in the index.js?
anywhere after bot =
God, does it log this much?
[SHARDS]: Launched shard 1
[WS => Shard 0] [HeartbeatTimer] Sending a heartbeat.
[WS => Shard 0] Heartbeat acknowledged, latency of 335ms.
C:\Users\HamoodiHajjiri\Desktop\Rewrite\node_modules\discord.js\src\sharding\Shard.js:166
reject(new Error('SHARDING_READY_TIMEOUT', this.id));
^
Error [SHARDING_READY_TIMEOUT]: Shard 1's Client took too long to become ready.
at Timeout.onTimeout (C:\Users\HamoodiHajjiri\Desktop\Rewrite\node_modules\discord.js\src\sharding\Shard.js:166:16)
at listOnTimeout (node:internal/timers:564:17)
at process.processTimers (node:internal/timers:507:7) {
[Symbol(code)]: 'SHARDING_READY_TIMEOUT'
}
Node.js v18.0.0
its a collection
For shard 0, it logged fine and connected successfully.
objects/collections dont have a find method. only arrays/lists
instead of doing an if statement just do the comparing in the function
<Member>.find(member => member.blah === "something")
its multiple if statements tho
You're using typescript?
yea
typescript is being difficult
Have you specified the value that you want to return from the method?
ye
Where did you do so?
<Member>.find(member => (member.blah === "something") || (member.something === "something"))
will try that
you can use logical AND and OR in them
What?
pretty sure its
(member: GuildMember)
not
(member): GuildMember
think it was meant for the other guy
iirc either works
I haven't used ts in a while tho so don't quote me
:^)
theres an error either way anyway
Did you try?
Are you sure members is a collection?
yes
Well try what I suggested
this seems to work
thank u
yeah i just did
whoops. yeah i replied to the wrong codes
@sharp geyser@digital swan
Ah right I was thinking of something else
the type is for the parameter, not for the entire list of params
the function wouldve returned a guildmember anyway
it works now tho so problem over
I was thinking about this
let {member, user}: { member: GuildMember, user: User } = data
on the website?
yes
ive been looking for a way to delete and i cant find one
heres my profile, dont know where to go from here
i've looked in "edit", there's no delete button anywhere
wow i am an idiot
lol
Like me
So I am messing with react and electron together and I am noticing it isn't displaying my stuff when I implement react-router-dom with it
import ReactDOM from "react-dom";
import {BrowserRouter, Route, Routes} from "react-router-dom";
import {Home} from "./routes/Home/Home";
import { GlobalStyle } from './styles/GlobalStyle'
const rootElement = document.getElementById("root")
ReactDOM.render(
<BrowserRouter>
<GlobalStyle />
<Routes>
<Route path={'/'} element={<Home />} />
</Routes>
</BrowserRouter>,
rootElement);
I assumed this would work as I see no reason it wouldn't render what is on the Home page
don't try it... i already tried and it sucks
I recommend that you build it first and then you start the app
Im learning electron too
Which frontend framework is best for electron? Or things like ejs works better?
Never tried EJS with electron
Even when building it then starting it nothing shows
Try inspect element
just shows a div with id root
see if there is an error
no errors
Damn...
Have you searched the internet about it?
yea
Did you find any relevant results?
https://stackoverflow.com/questions/36505404/how-to-use-react-router-with-electron#50404777 See if this works @sharp geyser
yea using hash router worked
Did it really work?
Np :D
Discord uses react with electron
ima be honest I used google to figure out how to get electron to work with react
and I found a boilerplate that uses electron, react and webpack
Electron with react is kinda hard to work with and ig they has a limited community
If i try to search something
It shows me 4-5 years old ans
Which 40% of time dont work
I feel like electron is one of those frameworks that is overly difficult/painful to start with, but if you know what you’re doing it’s a godsend
oh look you're not playing overwatch
And getting started with electron is the hardest part for me
im in queue
mhm sure
if you think electron is too weird, try nwjs, its pretty much the same thing but simpler
Tim, why don't you sleep, it's 00:53
is something wrong with top gg sdk?
when someone votes its calling the webhook multiple times
im sending a 200 success status tho
res.sendStatus(200)
Guys i want to create an interval to change my server banner how much should I set for the interval to dont spam the API?
If you change the banner in a loop
They will ban you ig no matter the interval time
I have seen people try to making rainbow roles, they set it up properly but discord still banned it
is there something wrong with djs??
my bot suddenly went down and now the node process wont even start?
the shards arent starting'
Anyone using erela.js ?
ya me
const res = await client.manager.search(
message.content.slice(6),
message.author
);
How can we change youtube
to soundcloud
as search platform
i think you can specify a platform
check their docs
i kinda forgot, but i used lavalink with erelajs to control the streaming platform
you need soundcloud key as well
how?
up
the shard process is not running at all, it just stops
no logs
no errors
so umm
im getting a Rate limit issue
for some reason
when i try to start my bot
pls help
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
if you get that on all shards that means youve been temp banned, wait an hour or so and try again
Yeah gotcha figured it out, implemented a queue to send dms. hope it works tho
if you dont get it on all shards, that means youre trying to connect multiple shards at the same time
also, if youre manually making a request to /gateway/bot you might also wanna log the headers
could give you more information
what is the problem
req.body wont work, you'd need to get the form first from the request
boldly would assume req.form because thats how its done on python iirc
Do you use bodyparser?
Oh
It would work, most likely it was a problem with his middleware
req.body is the correct way
either req.body, or req.params, depending on if its a get or post request. and either way, a middlware needs to be setup
const body_parser = require('body-parser');
const express = require('express');
const app = express();
// To support json and url encoded bodies
app.use(body_parser.json());
app.use(body_parser.urlencoded({extended: true}));
^ to setup middleware for parsing the properties for req.body and req.params
eyyy thats pretty neat!
very
Is it just me or is the guildScheduledEventCreate event not working?
None of the console logs logs. ;-;
I forgot to send the source, bruh, one sec: https://sourceb.in/qQWgM7f2Gr
What is bulk 0verwrite
you only must to wait
discord-player ?
no i got it
my node version is 16.4
nvm
my friend fixed it
i want to use req.hostname but i'm using nxing reverse proxy
whats the best solution to fix this
step 1 acknowledge there is a skill issue at hand
i fixed it now
Hi guys please can anyone suggest me a coding website pls
to make a bot with?
Ye
just download vs code and code there
It is not free hosting
I need website like replit
C:\Users\creative infotech\Desktop\Uchiha\node_modules\discord.js\src\client\Client.js:206
if (!token || typeof token !== 'string') throw new Error('TOKEN_INVALID');
^
Error [TOKEN_INVALID]: An invalid token was provided.
at Client.login (C:\Users\creative infotech\Desktop\Uchiha\node_modules\discord.js\src\client\Client.js:206:52)
at Object.<anonymous> (C:\Users\creative infotech\Desktop\Uchiha\index.js:290:5)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47 {
[Symbol(code)]: 'TOKEN_INVALID'
}```
your discord token is invalid
i put the right one
i reseted my token
I need to ask something if i didnt maked like slash commands i can change prefix to / and it will show like /command?
just responding to a message starting with / will not actually make slash commands
Several other people tried that already
Oh
<h1 class="text-white text-xl md:text-2xl"><button class="rounded-full p-3 bg-gray-300"></button> Offline</h1>```
how to make same height
move the text down a bit
how !!
you really dont know how to move an element around?




smart


its not hard. If its HTML and CSS its no hard at all...
bro you use a template 
your point
if html and css isn't hard, why are you using a template
sorry for using one tempo3rary while i make my own
people can be in a rush to get shit up aka I was
so I bought a template and posted it while im making my own
oh and next for referance w3school helps alot with that stuff.
or just google it
const track = player.get("trackforautoplayfunction");
const url = `https://www.youtube.com/watch?v=${track.identifier}&list=RD${track.identifier}`;
let res = await player.search(url, client);
I switched in soundcloud so the autoplay will stop as it is in youtube
so in soundcloud what should i do
tyty
anyone mind testing something for me please
visit https://dl.dpp.dev and see what happens? you should get a tarball download via github
why can't you test it yourself?
it would in therory download whatever virus to your pc
One message removed from a suspended account.
One message removed from a suspended account.
so why couldnt he test it himself if its a library?
One message removed from a suspended account.
i have tested it myself
I'd also be surprised if he planted a virus in that URL due to being also former staff of this discord
no need to jump to conclusions lmao
but i get intermittent redirects to another site on my server
well sorry last time someone wanted me to "test" something it was a virus and I had to wipe everything
the apache vhosts are playing up
One message removed from a suspended account.
its called people are not trustworthy
nah im not staff here, i used to be
One message removed from a suspended account.
I was also staff if you remember.
but i have too much to lose by trying to infect anyone with any virus lol
One message removed from a suspended account.
im just saying god damn

toxic people 😂
no you raise a legit point
"how can I trust you"
the others answered your question
🙂
and how can I trust any one in here?
you'd have to start somewhere, as this place is probably going to list your bot
why else would you be here 😄

fair point
maybe servers
its a pretty useless community to be in without being related to servers or bots lol
i forgot you can add severs too
either way seems my server is being arse
arse?
its not really a "community" server here
hey this community is great
#general btw
😔
ok i have a real development question now
how do i do that skeleton loading thing 
I want to make my site use skeleton loading until I have the API response with my status
instead of just showing "Offline" until it loads
One message removed from a suspended account.
I don't really know how to export the clientproperly :/
because when I call the function, it just say that client is undefiened
someone help me T.T
Solved Actually my Backend GraphQL is not on yet, so yeah.... sorry for wasting time
export const client
Anyone know how I can use react with electron? I have been trying a lot of boilerplates and other things and I can't get any stable instance to run without problems occurring later on
@quartz kindle do you think its faster to write a little bit of data, move to another position then write/read again or do it in one massive chunk even if most of the other data is untouched or not needed
i was thinking its faster to do one big buffer because a) disk can take time to acquire again b) system call disk overhead c) if the disk is a hdd writing one long sequence of data requires no head movement and it can simply be written in a linear manner (ignoring fragmentation of course)
yes, the same holds true to ram as well, and pretty much everything else, thats why pools exist
does this wait for all promises?
await Promise.all([[promise1],[promise2]])```
i dont think Promise.all() looks inside subarrays
rip?
yes
yeah, it just insta-resolves the array
they should just flatten it for us
that could cause unintended scenarios
both could
for example if you want to resolve a list of promises that resolve to arrays mixed with already resolved promises or normal arrays

so how do i use the 15 usd i get from the 1st 100 votes my bot gets
auctions
We don't flatten it in the Promise.all() method because of exactly what Tim said, it could extend it's depth to go deeper into the sub-arrays and start resolving encountered promises, leaving no room for short-circuiting, and could cause lots of unexpected behaviors, even with your idea of throwing an error when a non-promise is passed, because we would additionally have to check whether the value is a promise or not, leaving us with a performance regression
ok
it could be like concat where it unnests one level into the array and resolves all those promises too. and when it resolves it keeps the same array structure. ie some resolves are nested in an array. but that might be even trickier
if a user is passing a nested array of promises to Promise.all they are probably expecting those promises to resolve before going on
I get what you mean, I suppose I can bring this up to the team and discuss it
💀
tc39 i believe they are called
yeah
also, since when are you officially part of llvm and nodejs?
TC39, as you mentioned 
It's been over a year at this point
That's awesome btw
do you know why webhooks of interactions give the error DiscordAPIError: Unknown Webhook?
wtf
awesome
Like you
n-no 
Mmm, yes 
.<

Someone rewrite my discord.js bot to slash commands and using cacheless libraries for free please :)
So much pain
I am not actually offering
Opa
someone write my api for me pls
i'd even pay for it (although i dont have much), the issue is shit's hard yo
.<
hell no
xD
_rude boi _
And here we observe two brazillians at their native habitat
lol
How to make a delete all messages commands in py?
purge
How to code it?
We do not spoon feed. We only help with errors and stuffs in your code, and not write teach the whole coding itself. If you want to learn how to code, consider watching tutorials on YouTube and reading documentations of the language that you are coding in.
K
Hi
so I was wondering if there is a way
like I can tell my machine to do a certain task at a certain time (in NodeJS)
for example: I set a time of 28 days, and then add a .on event or something, then after 28 days, I get a response on that event with the required details
I assume my bot is having mem leak with this metric 🤔 whats the best way to detect mem leak? I've tried installing some package but they were all outdated or somehow unable to install
or maybe because im using djs
how many guilds?
its only in 351
does it do music?
nope
well its a little bit excessive but still looks like normal djs to me
are you using v13?
yea im using v13
have you tried disabling the caches you dont need?
oh I never heard of that
its a new thing in v13, caches are now customizable (to a certain extent)
check the docs for client options
ok i'll take a look into that
you can disable message caching and user/member caching for example
those usually take a lot of space
but does it mean when I have some commands related to role/finding message, its gonna be slower right?
depends on what the command does
or I wont get the access to cache at all for those disabled ones?
messages contain member data, so you can still access the member object in a message
to find messages its a bit tricky, you wont be able to find past messsges by content
ok let me check which caches my bot is using first
since I most access member object from interaction, its fine to disable cache for member caching right?
the server names?
you list them from your library's guild cache
which library are you using?
just a heads-up, only you (or other devs) can see such info
unless those servers agree to be listed publicly
still waiting for which library they are using
something tells me it's dpy
client.guilds gives you a List of guild objects
One message removed from a suspended account.
@quartz kindle the db has used too much of my attention its now my os's turn
I'm planning to refractor the scheduler since I'll be showing my os to someone my teacher invited to the school
I want to implement the SJF (shortest job first algorithm)
and you have been selected to be my guide
Guild objects means it's a list that contains information about each guild your bot is in. Names, member counts, and so on. So, yes.
lmao
you probably know more about that than i do
in your code, you need to use client.guilds to get the list of guilds your bot is in, then decide what to do with it, for example map the list into a new list of guild names, and then print that list, or make a command that sends that list to a channel, idk you decide
lol probably but I'll ask for some advice on how to implement the priority system
should probably explain the algorithm to you first
the shortest tasks get the highest priority and longer tasks get the least priority, so short tasks are first and long tasks are last
Are the tasks just "short" and "long" or does each task have a specific time
how do you decide which tasks are short or long?
if (task.length > 10) return "long";
else return "short";
that's the part I'm not exactly sure on
I think it depends on all other tasks
the "short" and "long" tasks probably don't exist
how about a priority system where the task itself can decide its own priority?
I think it's just a priority queue where higher priority tasks get executed first
yeah that could work too
because i dont see how the os can measure and assign the correct priority to each task
unless the os is running real time metrics
Have two arrays, one with short tasks and one with long tasks, first pull from short tasks until empty, then long tasks
Priority in the array is a different subject though
you can use some hacks to determine how much time the thread has used
but putting that into longer or shorter is the harder part
if you cant do something as simple as that, you might want to learn python first
if I can't come up with something I'll just go with what Tim said lol
though there's probably a video on it
you could store the execution time each time it's ran (last X executions), then use the average time to sort
yeah that's what I thought
first few times it'll be mostly unsorted, but after that it should start to order itself
less than average = short task else long
you'll also need to introduce a limit
but then very short or long tasks can dilute the average
use geo mean
so you dont lock the cpu by flodding it with small tasks
for example for every 5 small tasks ran in a row, run one larger task
I was gonna answer that question earlier
if you have too many short tasks it will starve the longer tasks so you often also implement a priority decay so longer tasks eventually gain higher priority
forgot to send lol
use geo mean to prevent average biasing
the longer the long tasks sit without cpu time the more priority they gain
never heard of geo means what is that?
geometric mean, it's one of the averaging methods that's made for datasets with spikes
ah wait
not that yeah it's that
In mathematics, the geometric mean is a mean or average, which indicates the central tendency or typical value of a set of numbers by using the product of their values (as opposed to the arithmetic mean which uses their sum). The geometric mean is defined as the nth root of the product of n numbers, i.e., for a set of numbers x1, x2, ..., xn, th...
actually diluting the average shouldn't be an issue
each time slice is capped at whatever the CPU timer is set to
I'm thinking to set it to 20ms
it's currently at 2ms no wonder my os is lagging on vms lmao
that was before I really know anything
well, if u face issues with biased averages that's the way to solve it
it's not really hard to implement
frost
😡
there's also the median, which literally picks the middle point
but it doesn't reflect the actual range
no moda?
ye that
geomean u usually learns on later years
the same year that u learn plotting data iirc
yeah not in my curriculum when I did maths
science too
so like cube root of values a, b, c... ?
basically
can't find a website that explains it without the ramble
ultimate wikipedia fail
lmao
the formula
PSA: big math symbols are just for-loops
y = x[0];
for (i = 1; i < n; i++) {
y *= x[i];
}
y = y ^ (1/n);
in a nutshell
code is so much easier to understand
fuck I cant decide if it's inclusive or exclusive
people should start writing formulas in code instead of math symbols, or at least offer the code version as an alternative
I started understanding math after I saw someone say that phrase



