#development
1 messages · Page 1528 of 1
doubt
Brutally ignores what i said and links the question again
150% brain cells lost so far

Uh guys what about me?
You need a break 
I had a stroke trying to read your question, sorry
Brutally ignores what i said
Wtf, did I just say..
175% brain cells lost so far
you know it helps to put your question and your code in the same message right?
Wait, I’m dumb I explained wrong
Like one part embed, and one part not-embed so how do I do that
I.e
So the message both has a content and an embed?
Mhm, like it’s 1.19AM and I also my brain cells at -0 @earnest phoenix
<TextChannel>.send('content', {
embed: <your embed here>
});```
Why does autocorrect make my damn sentences not make sense..
does message.author.send("text", embed) not work @earnest phoenix ;-;
It’s a dm help command, not uh the one in the channels
It doesn't since the second parameter needs to be an object
And, I need one without embed
Already have the embed one
Uhh
Umm
[Visible Confusion]
Hm, like look at this
change <TextChannel> to message.author
One is not embed, and one is embed
Isn't that what he told you how to do?
I literally sent the right code to do that
No, it’s a dm help command not a channel one
DM channel is also a text based channel
<TextChannel> → <Message>.author
Alrighty, thanks
But, I don’t want it embed
I just said that smh
300% brain cells lost so far
Oh man this guy is going to die tonight lol

Look at this
This is exactly what you want
It’s embed...
..
I understand why people don't want to become teachers now
@earnest phoenix are you trynna make it look like this https://i.imgur.com/kiLtEkf.png
yea so
I’ve already made an embed one
Yes, and that's exactly what the code above does
That's literally what i said
voltrex
Now I need the one without embed
message.author.send("content", embed)
500% brain cells lost so far
how should I turn 'x.x.x.x.x' into ['x']['x']['x']?
so its a nested object
kinda
Bruh, I have more brain cells lost than you
it sends content outside and inside an embed at the same time in the same command
@earnest phoenix https://i.imgur.com/f3lUQuu.png results = https://i.imgur.com/kiLtEkf.png
Thank you
You shouldn't convert it to that unless it's not accessible by normal syntax, such as a property named bruh-moment can't be accessed like object.bruh-moment, so it should be object['bruh-moment']
OMG, AUTO CORRECT I SWEAR
lol
Damn, he just completely ignored what i said at first tho
No I was a bit confused and my eyes are red rn and from what I’m seeing it’s kinda blurry for me
its an input but I need to get the 'x.x.x.x' property of 'X'
ye
yes
say 'response.first.url' or 'response.second.delete_url'
its all different
but my code needs to work
message.author.send("content", help)
Yes, but under message.author... or do I replace it?
here is my new code
if(message.content.startsWith(prefix + "level")) {
message.channel.bulkDelete(1)
if(!xp[message.author.id]){
xp[message.author.id] = {
xp: 0,
level: 1
};
}
let curxp = xp[message.author.id]
let curlvl = xp[message.author.id]
let nxtlvl = curlvl * 300;
let difference = nxtlvl - curxp;
const lvlEmbed = new Discord.MessageEmbed()
.setAuthor(message.author.username)
.setColor("#FFC0CB")
.addField("XP", curxp, true)
.addField("Level", curlvl, true)
.setFooter(`${difference} XP until next rank!`, message.author.displayAvatarURL);
message.channel.send(lvlEmbed)
}
Try it :)!
use your current message.author, just add "yourMessage" infront of the help
it send this
!Corizya
XP
undefined
Level
undefined
NaN XP until next rank!
so it will be message.author.send("content", help)
const args = <String>.split('.');
args.reduce((T, A) => (T = <Object>[A], T), null);``` @MILLION#1321
Thanks discord
Alrighty, so it’s almost like replacing it right? @zenith terrace
@crimson vapor
750% brain cells lost so far
thats pog if it works
All brain cells lost
What happened to just 100% of braincells
more like editing it 
Yep, true lol

message.author.send("content", help); @zenith terrace won’t I need the ; at the end?
if u want
I’ll just add it
The ; is optional and is more just a development style choice
BRUH, AUTO CORRECT
It's not optional when it comes to doing
const bruh = 'moment'
(SomeExpression)```
@zenith terrace ayyyy congrats it worked and thanks again 
mhmm
Because if you don't end it with a semicolon it will decide to call the string as a function
Well. Obviously, strings are not callable
It should work, i forgot it used Object.assign() to sanitize options

And also you're the qt not me
you are the qt yes
Don't use JSON as database
They're prone to corruption
They usually corrupt more often when they get written to a lot and an XP system would write to it a lot (anyone correct me if I'm wrong)
It would corrupt if it tries to read and write to a huge chunk of JSON data
yra
It would most likely corrupt if it tries to read and write and the process exits before it's complete
That's why atomic read and write exists
if you do use json make sure you use jason.db
We already discussed about that package like an hour ago

This is a certified bruh moment
time to implement json as the back end of my database implementation instead of being smart and implementing chunked files
I already lost all my sanity from trying to make a NodeJS backed db anyways

lol
Man, JSON is only good for read purposes, not read and write, time to find a way to stop Node.js from allowing to write to JSON files 
mutate the state of the fs write methods
Yes
Tomorrow I'm going to see in tech news "Node.js but you can't write to Json by voltrex master"

Node is already turing complete
just detect if string is a JSON object then throw a ShitCodeException
Why is it doing this..
Just make a long ass error name
YouNoobWritingToJSONfilesPleaseStopAndUseARealDatabaseInstead()```
The bot inv btw
.jason > .json
Jason, reminds me of the creator of discord
Really?
Yes?
Aw man..
Reminds me of this guy
idk maybe
Is there a way to make the link shorter?
what link?
Yes, put it in the embed
oh
Make a web server and have a handler to redirect either sub domains or paths to the bot invite URL
or just put it in the embed and don't worry about it
we are learning webservers today?
it's over 9000!

Time to finish reading this c++ book. Idk when I'm supposed to get to the part where programmer socks are completely necessary
are they not always needed?
They are absolutely necessary. I just need affirmation from "an expert"
Bro, don't forgot the "Good programming chair" that gives you the ability to write good code for an eternity
it's all in the socks
That's kinda gay bro
indeed
My programming teacher at uni literally told us that we shouldn't use google, it's better to look in books and at their fucking slides
idk

@earnest phoenix how do you use your function help
If you don't look at StackOverflow you're not a real programmer
Yes. Stack Overflow is virus. Please read book
God. Why did that remind me of that video that crashes chromium
"Hello. Your computer has virus"
crash
Might aswell write code by hand in a notebook then
I use fucking text instead of fucking rurl
Baljeet
phineas and ferb?
Yeah. Wanna see the video?
sure y not
Saw it like 500 times lmao
I need a break from this fucking pain
FUCK FUAIDHWDIUAOGWDIPYAGDWYU
IT WORKED
FUCK YES
Loggers
Telk kinda cute ngl
lol
🗿 Bro
Million
that would have saved like 30 minutes
Did what i showed work?
indeed it did
Loggers
Doesn't control shift i bring up the chromium dev tools
const [...args] = rurl.split('.');
const url = args.reduce((T, A) => (T = json[A], T), null);```
command option i on mac
idk on windows rn
Also you can just name it args
If args was an IterableIterator, that would make sense
Then again, could always just do Array.from
Pretty sure spread duplicates the memory
memory go brrrr
memory optimizations are all my brain is swelling with
Memory leaks are fun
I got one earlier
voltrex what happens if the object doesn't have the fucking shit
like
{ '1': { '2': data }}
but
I do 1.2.3
hey! that language
I can make it return
._.
checking for selfbot smh
const args = rurl.split('.');
const url = args.reduce((T, A) => (T = (json[A] ?? {}), T), null);```
ty
@crimson vapor has been banned. Reason: bad language
Error: I need the ADMINISTRATOR permission to work
lol
most bots miss the second line
@crimson vapor has been banned. Reason: bad language
I know. Sometimes, I have seen messages sent right after detailing the error but eh
You need Node.js v14
14.15.2
can I just use ||
since its a json response from an api it shouldn't matter right
You could use logical or
|| would also skip it if it's 0 or an empty string
hmm
You'd have to check for if it === undefined
const args = rurl.split('.');
const url = args.reduce((T, A) => (T = ([null, undefined].includes(typeof json[A]) ? {} : json[A]), T), null);```
We're not checking for the string that's trying to access the property
@earnest phoenix typeof null === "object"
We're checking for the value
Oh yea i forgot about that
JS please explain

Why is null an object
const args = rurl.split('.');
const url = args.reduce((T, A) => (T = ([null, undefined].some(K => K === json[A]) ? {} : json[A]), T), null);```
why is NaN a type number
why is null >= 0 when null is not greater than, less than, or non strict comparatively equal to 0
why is js
js do be js
LOL
-atmods
@earnest phoenix
Please do not mention (ping) more than one or two moderators for help, unless there is an emergency.
Here are some examples of emergencies:
- Raids / Multiple members mass spamming.
- Severe disruption of Discord's ToS (NSFW content, etc)
- Anything that requires more than 2 moderators to handle.
LOL
lmao
BRUH
he forgot the CMs
I just left the fucking channel for 1 second
We generally dont give bot recommendations
check the string index [0]
LOL
I fucking hate spelling errors
<@&695153281105920070>
🗿
self bot
YES
it worked
fetch(conf['custom_settings']['url'], {
method: 'POST',
headers: headers,
body: formData
}).then(async (res) => {
const text = await res.text();
const rurl = conf['custom_settings']['rurl'].toString();
settingsWin.webContents.send('log', rurl);
settingsWin.webContents.send('log', rurl.startsWith('json.'));
if (rurl === 'response') {
clipboard.writeText(text);
notif_upload.show();
} else if (rurl.startsWith('json.')) {
rurl.replace('json.', '');
let json;
try {
json = JSON.parse(text);
} catch (err) {
customError(err.toString());
}
const args = rurl.split('.');
const url = args.reduce((T, A) => (T = (json[A] || {}), T), null);
clipboard.writeText(url);
} else {
customError('Response URL not acceptable');
}
}).catch(e => {
customError(e.toString());
});```
Good job
Why still use ||
?? didn't work and I cba to use anything else
realistically no need
no response is gonna be an empty string or 0
since anyone who uses this code will have to compile it
so they will likely understand it
and realize not to do json.status and return 0 or smth
always assume the end user is actually stupid
In a perfect world, we wouldn't have to error check, but we don't live in a perfect world
we live
hi tim
loggers
you missed my realization that I can't spell
Logical errors happen all the time
hardly a realization
lol
:^)
Aight, gn chat
gn

Gn
anyone wanna do tedious work for me?
hi thank you owo
Yo Tim. How much would you say you know about databases
thats kind of a wide question lul
Okay. I guess I could be a lot more specific but I don't wanna retype the long message I already typed here: #development message
i know they store data
hey guys
Tim.IQ = 0
can I ask a quick question?
Im trying to make a command that stores something after the command
like if /test test, it stores test
you could just have redis NOT lose cache after your bot restarts
I try to store the thing in a variable
from the quickl glimpse i saw, i didnt read all of it, but that seems like the issue
It's not
Redis stores data beyond restarts of my bot. Storing guilds and voice states in redis is a bad thing

nvm
Im just trying to make variables distinct for each server
but stay a general variable
not sure how
i still dont get the issue though, why you bothering updating redis when you mentioned redis has the non mutable data? why does it need to be updated on restart?
also how did you set your stuff, cuz redis has an index, it should not be slow at all to find an index
unless you're filtering
which you shouldnt need in most scenarios
@lament rock
yeah im confused as to why GUILD_CREATES would be starving redis if you're not storing them in it
I was previously
there are also separate indexes that I do store such as channels and roles
I keep all of the data separate
why not keep it simple and keep everything under a single index for guilds?
but that doesnt really tell us why redis would have any change whatsoever when your READY state is fired
overhead with fetching data
WHAT data?
Guild data just to access role data or channel data
those shouldnt be updated nearly as often to be causing a clog at all on redis
^^
define "how"
as a json string using get/set?
storing all of the Objects as stringified version of the Object and storing using SET
I guess the real overhead with that is that it routes through a method which gets the old resource to Object.assign new data to
well that makes it very inefficient to attempt to get any data from inside the object
on updates, be it roles, members, channels and all that, they'd need to be re-written no?
why not use hashes?
though you did mention you had them separate
I don't know how to effectively use Redis, if I'll be honest
correct
Is there a resource I can look at to learn about this
ngl i should be using redis a lot more than i am
its such a pain to install on windows though
so then how does this apply to what I need
instead of storing stringified ojects
store them as hashes
with keys and values
for example
iirc hashes work just like objects/map
HSET guildidhere name abc membercount 999 channelcount 777
let newMap = new Map().set('hash', {field1: 'value1' , field2: 'value2'})
i remember someone explaining it somewhat along these lines
hello Erwin
map being redis, hash being your index, field1/2 being the key/pair inside the hash
Let me find the current redis cache wrapper I use
hello million
I think it does offer HSET and HGET specifically, but I was using default options
dont use a cache wrapper, use a redis driver directly
scaling is a bitch, i had to scale my twitch app to support 500k streams, it was a bitch and a half
if you want to scale, you need to directly interact with databases, you wont get far with wrappers and abstractions
and that
I figured using a wrapper would introduce overhead, but I liked what it offered.
discord cache?
i'd highly avoid those pre-made things btw
and working like tim said, directly with redis
the thing with redis
is that its kind of a low level database
it offers you the possibility of designing your own data structures
but it doesnt give you built-in stuff like other dbs do
i'd personally run with pg, its been an amazing companion to me even at high end web-scale projects
I do dislike that it doesn't offer native filtering over the data although that's why I have the cache worker.
I really like Redis. I'll try to use the redis wrapper directly, unless you suggest something more suited for Discord related Object storage
there isnt anything "discord" suited
I meant something more suited for my use case
I tried using MariaDB and it was painfully slow, so no
you just want persistent stuff from the looks of it, there isnt much point in using redis for just that
I am using it as a memory database. Persistence is not my end goal
then why use a memory database?
?
you're using redis as your persistent db from what you explained
I said I don't care if there is persistence
something that stays on while your bot restarts that the bot can fetch immutable info from
I'm gonna flush the instance when I move to using hashes
thats a database
im telling you, that use-case isnt necessarily the best case suited for redis
the problem is likely not the tool but the design
you should be using redis as a cache, and a high speed one at that, not for something persistent, which is what you've told us
the way you are designing your data structures, storage and access patterns is inefficient, thats the only reason why its slow. it doesnt matter which databases you use, they can only be as fast as your storage design
it is acting as a cache. It's just so happened to persist data across bot restarts. That doesn't mean I'm using it as if it was a persistent database. I patch data, delete old data which isn't sent by Discord anymore and do other stuff
I have other workers accessing the data
I can't just flush it when one of the clients disconnects
Alright. I'll look more heavily into my design
a well designed storage will be fast enough even if it runs on json files
Like I mentioned, I tried using Maria and creating relations, but the queries were very slow
And this was with selective data storage
not storing as just a string
how slow?
Minutes to filter to find a guild
my sqlite3 takes around 500ms to do a full scan over 20k rows
example query: SELECT * FROM Guilds WHERE name LIKE Poggers
3k guilds stored. I don't believe name is indexed. I only had the IDs as the PRIMARY
then you should be fetching by ID
rather than name
any specific reason you are querying by name?
My use cases were filtering over the data sets because of certain features I offered
even if name is not indexed, it should never take 1 minute to run a full scan with only 3k rows
but indexing should be done regardless
It took significantly longer when I was querying over 100k users by username or discrim
i think i got over 87k entries on this db
like we both said, it should NEVER take that long
so yeah, i dont know exactly what you did, but something was likely terribly wrong
it should never be that slow
Probably. I didn't feel like my query statements were unoptimized
Perhaps just the database layout
i ran the above query a couple more times and it went down to 18ms lol
but its indexed
That's some fast access time. I guess it's pointless for me to try to use a redis instance if I could also integrate my cache into my Maria instance?
most likely
Alright. Thank you for the help. I greatly appreciate this info
if you're still getting slow queries, send code and stuff later
Will do
so im adding a music feature to my bot
and im using ytdl
idk how to resolve this error tho
can anyone help?
did you even read the error?
then?
clearly it isnt installled
uhh
use chocolatey
you surely isnt installing ffmpeg correctly
its not related to python
that'll install it on windows
you run it via shell, not with py
Is it a good idea to have a separate SQL table for each guild your bot is in?
probably not
I'm very new to databases and I want to store information about each user, per server
and I'm not really sure how I would do that, other than making a table for each server containing the user data
So I store moredata in string json format?
then query WHERE userid = '' AND guild = ''
why would you json format it?
its a table
use collumns
I thought you meant moredata as a single collumn
no, more data as in, whatever else other columns you want
np
@rustic meadow 
@snow tendon Are you still having issues with installing it?
Are casino bots hard?
yes and no.
if you know how to gamble, no
if you don't know how to gamble, yes
with mine, i played atleast a few hours of every game i added before even starting making that game.
totally for research 😉
For every loss, cross off some method/function/variable from the library/standard library you’re using.
.users doesn’t return a collection
Check the docs because it’s under the cache
I think I've got it all sorted now thanks :)
See discord.js’ docs for client.users
yeaaaaaaaa... research
why is my bot showing users as NaN no?
It was working perfectly yesterday
I'm getting total bot users from the cache
is there like a way to reduce emoji lengths? like insteqad of typing :small_orange_diamnd: can you do like a shorter aliase?
in your code?
hi i want to ask, i'am using collection for save song data and in the repeat mode, how to auto set song if song has finished?
explain
i want to auto set this song if the song has ended and the music in repeat mode
before you remove the song from the queue, check for if the queue is in repeat mode, then just add it back to the end of the queue or set it next in the queue depending on if you want to implement repeat (one) or repeat (queue).
You should also keep track of if there was an error playing the song and if there was, destroy the song and do not loop or you will get stuck in an error loop and your bot will become unresponsive.
What does this mean? And what to do next? Can anyone please help
Do you use a .on inside of a .on or a command without removing it afterwards
adding 26 event listeners to process 👀
I think I've used
Don't do that
Ok but what does this mean? I am still confused
if (queue.loop) {
queue.songs.set(queue.songs.first().identifier, queue.songs.first())
queue.songs.delete(queue.songs.first().identifier)
module.exports.play(queue.songs.first(), message);
}
```I made it like this but nothing happened
Do you delete the song somewhere else? You should only add it to the desired queue position inside the checks then let your standard queue handler do the rest
client.on("message", message => {
// do stuff with message or something. IDK
process.on("unhandledRejection", console.error); // DO NOT DO THIS!!! It adds a listener on each message.
// Which is what the error message is
});
Extra disclaimer in case you don't see the comment in the code block. DO NOT DO THAT
no, but the song keep ended
Got It!!! Thanks For The Help
show your queue logic
const queueConstruct = {
textChannel: message.channel.id,
voiceChannel: channel.id,
guildId: message.guild.id,
songs: new Collection(),
connection: null,
loop: false,
volume: 100,
playing: true,
timeout: null
};
That's not the logic I'm looking for. How do you handle where the song plays and then on end, go to the next track
ah wait
let streamtype = song.url.includes("youtube.com") ? "opus" : "unknown"
let dispatcher;
try {
if (song.url.includes('youtube.com')) {
dispatcher = queue.connection
.play(
await erityt(song.url, { filter: 'audioonly', quality: 'highestaudio', highWaterMark: 1 << 25, bitrate: 96000 }), { type: streamtype }
)
.on("finish", () => {
if (queue.loop) {
queue.songs.set(queue.songs.first().identifier, queue.songs.first())
queue.songs.delete(queue.songs.first().identifier)
module.exports.play(queue.songs.first(), message);
} else {
queue.songs.delete(queue.songs.first().identifier)
module.exports.play(queue.songs.first(), message);
}
})
.on("error", (error) => {
console.error(error);
queue.songs.delete(queue.songs.first().identifier)
// queue.songs.shift();
module.exports.play(queue.songs.first(), message);
})
dispatcher.setVolumeLogarithmic(queue.volume / 100);
}
you should just be able to use the unicode for it
It seems like you don't even check for if there is a song in the queue at all. Also, you have to actually call the queue.connection.play function unless that's what your module.exports.play is
If it is, it's adding more event listeners to the dispatcher which may not be intentional

so i got the unicode for the emoji, but how do i send it and convert it to an emoji when it sends
I have a question, for example I have an forEach loop. I want to wait until forEach loop end (I mean async - await). I know I need to use Promise but I don't know how to resolve. There is example code below.
const a = [1,2,3];
const list = [];
a.forEach(e => {
list.push(a);
})
console.log(`${list.join(" ")}`)
I can use promise but I don't know where to resolve?
await new Promise(resolve => {
a.forEach(e => {
list.push(a);
})
})
Also, I know it will work but what if my forEach loop takes 5 seconds to work?
use a for loop instead of forEach. for respects async
try a different loop, iirc you can have for as example async
What changes if I use for loop instead of forEach?
it respects async
Only key differences is that for loop respects EOL (end of line) execution unless a continue statement is used. continue is basically return but for for loops. return returns out of the scope above any for loops you may be in.
forEach is on it's own internal loop which just iterates over all of the entries and calls the provided callback fn which means it'll execute much faster on all entries since it doesn't wait like for does.
Now that I think about it, I don't think you can even Promisify forEach
forEach is much slower than a native for loop regardless
@lament rock hey I have question do I need to change this?
Why would you want to do that
Thanks so much
I did this too. I took a error mesage. You reached maximum event listeners.
You should never have to raise the number of listeners
That's the wrong solution to the wrong problem.
What is solution?
This usually means that you're creating new event listeners inside another one - or in a loop
OR you just literally have a lot of event listeners because you don't know how to use conditions.
Me and my friend made this bot he added this and I don't know what does even mean and when I checked the server I saw this message and when I was checking I founded this
common issue is that a message event listener is created for each command
Should I remove this?
Take a look at the whole code and try to spot any file that has an event listener inside of it. For example, an event listener added inside a command, or inside another event
Yes, it should be removed.

how to iterate on collections with for loop. For example, I have 3 channel reference. How can I iterate with for loop?
what lang
node.js
Loops offer a quick and easy way to do something repeatedly. This
chapter of the JavaScript Guide
introduces the different iteration statements available to JavaScript.
something like js for (const item of collection) { // do something with item }
Thanks
.on("finish", () => {
if (queue.loop) {
queue.songs.delete(song.identifier)
queue.songs.set(song.identifier, song)
play(queue.songs.first(), message);
} else {
queue.songs.delete(song.identifier)
play(queue.songs.first(), message);
}
```i am try with this and work, thank you @lament rock
How can I sort json object by value. Example below
const data = [
{1: 15},
{2: 5},
{3: 19},
]
const sortedData = [
{2: 5},
{1: 15},
{3: 19}
]
data.sort((a, b) => a[0] - b[0])
Why index in a json
it was just example
Eh, if you understand it, I'm not gonna say anything
because you're indexing the object as it if were an array
except it isn't
you need to index by property name
that structure looks very wrong though
Asking about your attempted solution rather than your actual problem
what are you actually trying to do
I fixed this by typing
invites.sort((a, b) => Object.values(a)[0] - Object.values(b)[0]);
i don't believe in god but may the lord be with you
you're adding unnecessary complexity to your iteration
so i have a pacman command with a grid, but the grid is slightly too big and is over 2000 chars, it is only missing 1 line, but is it even possible to like reduce the emoji length or somthing? if there isnt i can just reduce the grid
what is complexity in code?
Object.values(a)?
In computer science, the time complexity is the computational complexity that describes the amount of computer time it takes to run an algorithm. Time complexity is commonly estimated by counting the number of elementary operations performed by the algorithm, supposing that each elementary operation takes a fixed amount of time to perform. Thus,...
you can use the description which has a slightly bigger limit of 2048 chars
it is the embed description
so, what do you suggest?
are you sending the emojis in colon notation or their unicode variant
i need to know what this is for in order to give you the right advice
idk what that means but in the code im using \🔸
I am making top invite list.
alright, so unicode variant, i think what you've already got is the best you're going to get
ok
...and storing the data in json?
take a look at this
<#development message>
there's some suggestions for a proper database in that message
There is no json file
...but you're storing in json
as a variable*
🤔
that is only in memory, that data will be gone once your bot process shuts down
🤔
why would you transform the objects then
why not just use the invite objects djs gives you
Because djs gives me collections and I hate it
maybe cheat the system and render it as a image, sure its slower but could help
I don't know how to sort in collections
collections are just maps
^
isnt collection data structure of discord.js
you dont have to use it all, just use the stuff you need.
when i log console.log(displayBoard().length) it returns 447
it might be a rendering bug with the discord client then
i remember this being an issue
the client just refuses to render emojis when there's too many of them
oofe, oh well thanks for ur help
Can someone help me about this?? #development message
how did you get the users?
${client.guilds.cache.reduce((a, b) => a + b.memberCount, 0).toLocaleString()}
why to string?
won't really affect anything
Idk I usually do that
are you doing this in/after the ready event
It was working until yesterday
restart the bot. maybe it helps
try using a native for loop instead of reduce
I already did
client.on("guildCreate", guild => {
if(guild.memberCount < 50) {
guild.owner.send("You Must Have 50 Member's To Make Me Stay In Your Server")
}
});```
is this function is correct?
hmm
also did you use normal d.js or something like d.js light?
what do I do then ._.

do the loop
console.log(`Ready on ${client.guilds.cache.size} servers, for a total of ${client.users.cache.size} users`);```
Is this correct?
......
totalMemberCount = 0;
for(const guild of cache)
totalMemberCount += guild[1].memberCount;
I tried this but the problem is when I run it it shows 1 user
enable intents
both in your code and on the developer page
otherwise you won't receive member related events
and your cache will be empty
Ohh
same thing
NaN users
🤔
let totalMemberCount = 0;
for(const guild of client.guilds.cache){
totalMemberCount += guild[1].memberCount;
}
//Bot status
setInterval(() => {
client.user.setActivity(`${totalMemberCount} Users
| ${client.guilds.cache.size.toLocaleString()} Servers | -help`, {type:"WATCHING"});
}, 10000)
try console.logging totalMemberCount and the guild's memberCount
and seeing what it outputs
Why do you use guild[1]
what is NaN though
It's just guild
it isn't
I use code to do that, and I use guild.memberCount
for...of on a map returns an array, first element is the key, second element is the value
A collection doesn't
bitch a collection is a map
A collection works differently
👁️ 👄 👁️
They changed that
why no work

guild.memberCount should work...
breh
a
Can you try remove the [1] and see if that changes anything, just try it at least
I need the total members of all the servers that the bot is in
It can't even compile bruh
error
Show code
djs' collection does not change iterator behaviour
let totalMemberCount = 0;
for(const guild of client.guilds.cache){
totalMemberCount += guild.memberCount;
}
//Bot status
setInterval(() => {
client.user.setActivity(`${totalMemberCount} Users
| ${client.guilds.cache.size.toLocaleString()} Servers | -help`, {type:"WATCHING"});
}, 10000)```
removed the [0]
One of my server's returned undefined as a memberCount
console.log guild and you'll see that it's an array
Is there any difference between setPresence and setActivity
Console log guild.memberCount in the loop maybe just for science
setPresence sets status as well as activity and setActivity is just activity
Oh well ..
undefined
Ohh, some people said setActivity is no longer available
for every single one
Ah
guild not defined
Hm
Inside the loop?
What does it say?
with?
wait
Can you send an example
A lot of stuff Idek
Ok good
Can you show a longer thing
Full object
Is there any []?
No, not in the loop
hmm
just console.log that
true
true
true 100s of times lmao
How true is it?
Console log: YES
index guild like i told you
I have problems on defining this on Unix
const { badwords } = require('../swearwords.json')
On windows, all is working fine
guild[1]
He cant run this on Unix
I mean, it's still NaN with the guild[1]
do something like this
if(!guild[1].memberCount)
console.log(guild[1]);
Log guild[1]
console log now we wait for console to spam

ah god
what have you made me do
lol
the snippet filters out guilds which have a defined member count
so you'll only see guilds that don't
lmk what it outputs
you need to add the if check
Yep
available: false
hmm
oh actually
available set to false just means that there's some api issues
you don't have to leave it then
by leaving i meant https://discord.js.org/#/docs/main/stable/class/Guild?scrollTo=leave
You could filter through guilds using available: false before adding to totalmembercount

nah
that'd make it slower
since O(n^2)
a simple if check to see if memberCount is defined is enough
True
const g = guild[1];
if(g.memberCount)
//addition here
else
//if you want to handle unavailable guilds here or something
Can't there be multiple problematic guilds
sure
Can I do if(guild.memberCount) in the loop then
Oh ye
xD
umm lol
for(const guild of client.guilds.cache){
if(guild.memberCount) {
totalMemberCount += guild[1].memberCount;
}
}
console.log(totalMemberCount)
//Bot status
setInterval(() => {
client.user.setActivity(`${totalMemberCount} Users
| ${client.guilds.cache.size.toLocaleString()} Servers | -help`, {type:"WATCHING"});
}, 10000)```
oh wait
bruh
can't you just use Collection.reduce
I wonder if I had to do that in my code now. I can't remember. Seems odd.
It outputs 0 now 
share your code
this
yey
first element is the key (the id of the guild)
second element is the value (the actual guild)
worked xD
Oh
Not that memberCount actually means anything anyway 😂 they dont all use your bot
lmao
I have 600k memberCount but 30,000 lifetime users
Thanks for your help @earnest phoenix @rose warren
Looks kinda good lmao
I would do toLocaleString() on that personally
Same way you did to server count
In setActivity
But that's details
Oh yeah
Could you give an explanation? 👀
Quite curious how that's O(n^2)
you would have to iterate over it to filter the guilds out
and then iterate over it again to use memberCount
i think
Well, unless we do that in one loop?
yeah
Oh, actually
I see where you're getting at
Yeah. Makes sense to me now, thanks man
I also need this for my bot
You can take it xD
so i am confusion, heres my code:
let output = "";
for (let i = 0; i < 11; i++) {
for (let j = 0; j < 20; j++) {
output+=":ox:"
}
output+= "\n"
}
message.channel.send(output);
``` and it returns this
which is only a 10 * 20 grid missing one
but it works as its suppposed to when i remove the output += "\n"
o
there's not really anything you can do except try to find workarounds
well, not until discord devs decide to fix it
which is probably... never
:(
you're not doing it in/after the ready event
for(const guild of client.guilds.cache){
if(guild.memberCount) {
totalMemberCount += guild[1].memberCount;
}
}
console.log(totalMemberCount)
//Bot status
setInterval(() => {
client.user.setActivity(`${totalMemberCount} Users
| ${client.guilds.cache.size.toLocaleString()} Servers | -help`, {type:"WATCHING"});
}, 10000)
};```
I just copied this I don't know how to fix
🙄
Cry literally just told you
But I don't know how to fix...
Put it in the ready event
how to check if the voice channels size in a category is not above 10?
i tried like this
if(oldState.channel.parent.channels.filter(c => c.type === 'voice') > 10) return message.channel.send('Sorry, you cannot create the channel.')
can someone tell me how to do it
when bot become online it start noting time on embed liek uptime but live on embed
...huh?
Like the uptime of the bot keeps updating every second?
It's possible but it would be API abuse
lol
after 10s?
Yeah I guess
But I suggest against it
Because many people will use the embed and the bot will have to update every embed
Every 10s
If I use the command 10 times, the bot wil have to update 10 embeds every 10 seconds
lol
its private bot
Hmm
so it will be only in 1 server with 1 embed
i think api abuse is for 3-5s
I have a string of text, can I send it to a person (express http) in a file without having to actually write any files locally?
check djs docs
is there a way to check with discord.js if a server has member screening enabled or not
Which operating system do you recommend for dicord bot? I was using widows server 2012 R2 before
Doesn't matter too much but use Debian 😏
i think that's where you search up the docs
I have never used it in my life, will I have any difficulties ?
