#development
1 messages ยท Page 1341 of 1
yes u smart man
i forgot what is on line 39 of the Client class
does nothing @Voltrex Master#0001
K then
SpoonFeed ๐คฆโโ๏ธ
@earnest phoenix
function addMaterialsToInv(array = [{ itemid: "2", amount: 1 }, { itemid: "1", amount: 2 }], string = "1:4,2:3")
{
let output = "";
let items = string.split(",");
for(let a = 0; a < array.length; a++)
{
for(let b = 0; b < items.length; b++)
{
let element = items[b].split(":");
if(array[a].itemid == element[0])
{
array[a].amount += parseInt(element[1]);
break;
}
}
}
for(let c = 0; c < array.length; c++) output += array[c].itemid + ":" + array[c].amount + ",";
return output.substr(0, (output.length - 1));
}
if(array[a].itemid == element[0]) why should I continue the loop in this case if my string.element.id matches array[a].itemid and array[a].amount += parseInt(element[1]); is done. Continuing the loop will increase my script time even if that's not needed
Just for this particular case
client.shard.broadcastEval(
`(() => this.channels.cache.get(\`${sguild}\`) ? this.channels.cache.get(\`${schannel}\`).send(\`${suggestmessage}\`) : null)()`);``` try this mate @tired panther
SpoonFeed
when you released that its a string inside a string
@boreal iron because I can get more then 1 drop, meaning it needs to add more then 1 item
you don't need to use ` for the get methods. " should work here
@earnest phoenix but why is it getting two times the channel?
@boreal iron break keywords is only used if you seriously need to break out a loop in a condition, in your case, just interate through with map, instead of a for loop
@boreal iron because I can get more then 1 drop, meaning it needs to add more then 1 item
Yes and that's what it is suppost to do, you can also add the same item id multiple times in the string and it will update the value
huh tagged myself again uff
@earnest phoenix but why is it getting two times the channel?
@tired panther Like is it sending the embed twice?
Or what you mean
just one time in an another shard @earnest phoenix
i am as confused as you are right now
Oh, you meant in the code
thats elvis operators
First is a condition to check if the channel exists on that shard, second one sends the embed to the channel if the condition has been passed
@tulip ledge Anyway, don't worry justed wanted to state the fact even if my code style may looks weird, the code has a lot lower runtime, than the example you used (or Voltrex posted?!)
but how does it get the guild?
Both work and you're free to use what ever you like, just wanted to mention this benchmark test
i forgot to do schannel lmao
you say your code style is weird fake, i use allmans brace style
who is weird now
what type is the suggestmessage?
an embed
don't incase the embed in ``
const suggestmessage = new Discord.MessageEmbed();
suggestmessage.setTitle("A new Suggestion:");
suggestmessage.setDescription(args.join(" "));
suggestmessage.setAuthor(
message.author.username + "#" + message.author.discriminator,
message.author.displayAvatarURL
);
suggestmessage.setFooter(
"ID: " + message.author.id + " Name: " + message.author.username
);
suggestmessage.setTimestamp();
that was Voltrex idea xD'
I see why

serialize it
send({ embed: ${suggestmessage} })
embeds have their own serialization method
tried that to, but trying again
what tim said
@quartz kindle and how are they? never heard
You don't have to stringify it to send the embed
you have to stringify it to send it to broadcastEval
otherwise you're sending [Object object]
now the profi comes
No i meant to providing it to the property value of embed
Like i showed up there
yes but if you dont stringify it, it will be converted to embed:"[Object object]"
Yea i meant by converting it
show code
.send(\`JSON.stringify(${suggestmessage}.toJSON())\`)
don't incase it in ``
.send(${JSON.stringify(suggestmessage.toJSON())})
send({ embed: {suggestmessage.toJSON()} })
;-;
Wait a second, does that even work Tim
not sure
what is going on why is there 2 different answers for one thing. i was only gone for like 2 minutes, and stuff has happen
How can access suggest message @quartz kindle ?
hmm?
what is going on why is there 2 different answers for one thing. i was only gone for like 2 minutes, and stuff has happen
@vernal rivet I amhere
@quartz kindle the embed declaration is outside the broadcasteval
yes, you're building the embed outside of broadcastEval
so you need to serialize it, to pass it to the eval as a string
@quartz kindle What you said would just output that lmao
client.shard.broadcastEval(
`(() => this.channels.cache.get(\`${schannel}\`) ? this.channels.cache.get(\`${schannel}\`).send(JSON.stringify(${suggestmessage}.toJSON())) : null)()`);
``` error
UnhandledPromiseRejectionWarning: SyntaxError: Unexpected identifier
at Client._eval (C:\Users\shahn\3D Objects\Botcode\sharding\node_modules\discord.js\src\client\Client.js:391:17)
at ShardClientUtil._handleMessage (C:\Users\shahn\3D Objects\Botcode\sharding\node_modules\discord.js\src\sharding\ShardClientUtil.js:185:82)
at process.emit (events.js:327:22)
at emit (internal/child_process.js:876:12)
at processTicksAndRejections (internal/process/task_queues.js:85:21)

do suggestmessage.toJSON()
indeed
@tired panther Try
.send({
embed: \`${suggestmessage.toJSON()}\`
})```
Wait fuck

lmao

what are you doing voltrex
Wtf
lmfao
Jesus
client.shard.broadcastEval(
`(() => this.channels.cache.get(\`${schannel}\`) ? this.channels.cache.get(\`${schannel}\`).send(${JSON.stringify(suggestmessage.toJSON())}) : null)()`);
``` same error
still has problems
the error is unexpected identifier?
yes
does it show which identifier it is?
probably \
(node:5088) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected identifier
at Client._eval (C:\Users\shahn\3D Objects\Botcode\sharding\node_modules\discord.js\src\client\Client.js:391:17)
at ShardClientUtil._handleMessage (C:\Users\shahn\3D Objects\Botcode\sharding\node_modules\discord.js\src\sharding\ShardClientUtil.js:185:82)
at process.emit (events.js:327:22)
at emit (internal/child_process.js:876:12)
at processTicksAndRejections (internal/process/task_queues.js:85:21)
i mean
you should be able to replace \` with "
Did mine even work
usually unexpected identifiers should show what the problem is before the error
like this
blablabal
^^^^^^^^
Error unexpected identifier```
@tired panther Try
.send({ embed: \`${suggestmessage.toJSON()}\` })```
@earnest phoenix
didn't i just say what it is. its evaling, \ doesn't escapes out of string
mmh
replace \` with ", then try again.
your injecting the object in the string before correct?
Turning it into a json as you see
Yes
.send({
embed: {
description: msg.toJSON()
}
});```
Wot
toJSON turns it into stringified?
UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token ':'
at Client._eval (C:\Users\shahn\3D Objects\Botcode\sharding\node_modules\discord.js\src\client\Client.js:391:17)
at ShardClientUtil._handleMessage (C:\Users\shahn\3D Objects\Botcode\sharding\node_modules\discord.js\src\sharding\ShardClientUtil.js:185:82)
at process.emit (events.js:327:22)
at emit (internal/child_process.js:876:12)
at processTicksAndRejections (internal/process/task_queues.js:85:21)
,maybe that @quartz kindle

That caused by which code?
by tim ones #development message this one
Hm
try this ```js
client.shard.broadcastEval(this.channels.cache.has(${"${schannel.id}"}) ? this.channels.cache.get(${"${schannel.id}"}).send({embed:${JSON.stringify(suggestmessage.toJSON())}}) : null);
I'm close to cry
okay testing it
(node:5088) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message
at RequestHandler.execute (C:\Users\shahn\3D Objects\Botcode\sharding\node_modules\discord.js\src\rest\RequestHandler.js:170:25)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
@quartz kindle the message is not empty , hmm
can you console.log(suggestmessage.toJSON())?
{
title: 'A new Suggestion:',
type: 'rich',
description: 'test',
url: undefined,
timestamp: 2020-10-22T19:00:05.642Z,
color: undefined,
fields: [],
thumbnail: null,
image: null,
author: {
name: 'Meister#2787',
url: undefined,
icon_url: [Function: displayAvatarURL]
},
footer: { text: 'ID: 691288534375596062 Name: Meister', icon_url: undefined }
}
``` @quartz kindle
"rich", you're using an old version of d.js?
No that type property shows the type of the embed structure
Exists on all d.js versions
try this ```js
client.shard.broadcastEval(this.channels.cache.has(${"${schannel.id}"}) ? this.channels.cache.get(${"${schannel.id}"}).send({embed:${JSON.stringify(suggestmessage.toJSON())}}) : null);
@quartz kindle console.log gives [ null ] out
schannel is an id
let sguild = "734707332163829780"; //guild id
Ah, I knew it was like that in v11 I thought they would have changed it.
where was the .id?
ah u mean that
=> schannel
@client.command()
async def leaderboard(ctx):
with open('pointspotd.json', 'r') as json_file:
pop = json.load(json_file)
embed = discord.Embed(title = "Leaderboard", description = "This the leaderboard in The Calt Server.")
for item in sorted(pop.items(), key = lambda x: pop[x]):
idpop = int("{0}".format(*item))
points = int("{1}".format(*item))
user = client.get_user(idpop)
embed.add_field(name = f"User: {user}", value = f"Points: {points}", inline = False)
await ctx.send(embed = embed)
``` Please help.
this looks familiar
@quartz kindle it worked thanks a lot, it means that you do not have to fetch the guild , just the channel?
Channels are cached by default
^ if you're using normal discord.js, all channels are always cached
things change if you use discord.js-light
Also if you used Node.js v14, the method we told you to use would have been much smaller
this.channels.cache.get(${`"schannel"`})?.send({
embed: ${JSON.stringify(suggestmessage.toJSON())}
})```
Optional chaining is op
best sites to get VPS's for discord bots?
Check pins, there is a few listed
ah ty
user = client.get_user(id) Why does this give me none for user?
might the user is not cached
is get_user() a valid function of djs?
i use py
ok than, same question for py
so i should do discord.Client.get_user(id)
ok
just start node.exe yourbot.js
u have to use a hosting server
@modest smelt hm ok
or node.(notexe)
Using js how can i create an if statement which will check between 2 variables if the first if greater than the 2nd and insert the result of that if statement inside a new variable? pls '@' me.
the guildMemberUpdate includes also if the game a user is playing changues?
2nd and insert the result of that if statement inside a new variable?
huh? that part is a bit harsh to understand. what?
let a = 1;
let b = 2;
let c = ((a > b) true : false);
What is the result supposed to be.
Is this what u mean?
yup, i'll try it in a sec
@jovial nexus no
I mean not needed to use short statements...
that information will be in a presenceUpdate
client.on presenceUpdate?
yes
that works for users or only for the bot?
all users
holaendersoyvo1d
ok thx
<oldPresence|newPresence>.user
@boreal iron There's 1 issue in your drop thing
when there's only 1 item to add so the array only has 1 object and the string has 2 items it only gives 1 item
[{ itemid: "2", amount: 1 }], string = "1:4,2:3"
returns: 2:4 and it should return 1:4,2:4
oh, you wanna add the string to the array?
It basically needs to have the string right, but add to the ones that are gotten
So it should return 1:4,2:4
if u get what I mean
ChickenDev
?
Oh I didn't know it that fact, did you mention this would be needed?
Mine didn't work? Or you're just explaining that to him
I think so
Yours worked
I'm just saying that his isn't working like intended cuz I wanted to use his since his was way faster$
alright then lol
I do have to say that Voltrex' was way easier to understand what it did, it took me about 15 minutes to understand how yours worked lol
Well maybe like 10 minutes
lol
could also be cuz urs is using variable names I wouldn't personally use
hmm so I'm gonna update it for u or is it just about u wanna tell me that this case wasn't "supported" by my code?
I mean it would be nice if u'd update it cause I have no clue how, I tried to do it myself but failed miserably
roger, just have 5 mins left, let me check
@tulip ledge Here's the fastest way possible, i made my function way smaller
lol this turned into a competition on who's the fastest
function addItemsToInv(items, string) {
return string.split(",").map(i => items.find(item => item.itemId === i.split(":")[0]) ? i.split(":")[0] + ":" + (parseInt(i.split(":")[1]) + items.find(item => item.itemId === i.split(":")[0]).amount) : i).join(",");
}```
Here
its a 1 liner lol
oh
hi
Guess I pushed him to the next level 
how do i like insert a bot or make one?-
do you have the bot programmed?
no
in fact, do you even have a bot application

Online JavaScript benchmark tool / playground. Find the best performance and speed up your code!
Voltrex urs is still slower lol
FakE is still the fastest of the west rofl
As I said before, mapping and finding will take some time
I'm usually not working with array mapping, which is the reason I didn't put it in my code
The reason mine was slower is because i was doing the same find and split again
what is a error
@earnest phoenix let me see your code
FakE would u mind updating ur code so it does what I wanted? if you don't want to I'm not forcing u but I kinda wanna see if it's still faster then
in dm @misty sigil ?
yes
FakE would u mind updating ur code so it does what I wanted? if you don't want to I'm not forcing u but I kinda wanna see if it's still faster then
@tulip ledge That's getting complicated right now, since I'm on my mobile on the way into my car
oh yeah no problem you don't have to
I just wanted to see if it would still be faster since Voltrex is getting close ๐คท
i send in dm @misty sigil
just use Voltrex version, I can if u really fear any delay, update it tomorrow for u
just use 1 message listener
Jaja
I could say it would, just to trigger Voltrex
Maybe he would present an even faster version after
Where should this end? lmao
There's a way you correct my code and send it back to me because I'm a bit lost!
plz @misty sigil
@earnest phoenix you only need one event
hahaha we're gonna get to a function that will process this in .1 of a millisecond like this
If you don't understand handlers use a switch case
you are allowed to use more than 1 if statement
Or learn
hahaha we're gonna get to a function that will process this in .1 of a millisecond like this
@tulip ledge Probably... or we would both explode
in fact I'm French and when I translate your text it doesn't matter so I don't know what to do
Voltrex's one literally takes 3ms to complete rn
i know a function that processes in .1 of a millisecond
does anyone know how to pick random server and return it's ID? I'm doing it for music, and what I'm trying to do is get a music title from a random server and set it as my bot's status (discord.js)
hahaha, it would be good for me tho cause I'll have a faster method ๐
function a () {
return
}``` return
@ancient nova I think u can run a for loop on all ur guilds and add the ID to an array, then get a random index of that array
this will get slow if u have alot of guilds
yeah I could create an map with all the guild
So might not be the best solution
function addItemsToInv(items, string) {
return string.split(",").map(i => {
let splitted = i.split(":");
let getItem = items.find(item => item.itemId === splitted[0]);
return getItem ? splitted[0] + ":" + (parseInt(splitted[1]) + getItem.amount) : i).join(",");
});
}``` this should be faster i think
be a very big file
HAHAHAH
@tulip ledge well he seems to be way more experienced then me in JS, so probably I have no chance
If u need the code optimized in php let me know 
php
tbh, who used php these days when u have ejs?
@tulip ledge is there any way to do that in a function and have return only 1 ID as a string
ikr
Wait lemme make that look better
ejs >> php
ight then
Me because I do since 14 years, still lol
damn u been doing php since I was born
function addItemsToInv(items, string) {
return string.split(",").map(i => {
let splitted = i.split(":");
let getItem = items.find(item => item.itemId === splitted[0]);
return getItem ? splitted[0] + ":" + (parseInt(splitted[1]) + getItem.amount) : i).join(",");
});
}``` here
Free functions pog
I don't know what I'm writing here? ๐ค
Say what your bot does
how old are u o.O
Better donโt talk about that, letโs say too old
Euhm Voltrex
so, too old as in 120+?
I wanna try to fix the syntax error but I'm afraid I'll mess up ur big brain shit
I think that ) inbetween i.join has to go
But I'm afraid
to remove it
I did it
oh god
I messed it up
i.join is not a function
uh oh I think I messed up haha
Say what your bot does
@earnest phoenix
But how is that? I don't know programming?? ๐ค
bruh
Your short statement is weird
what
yeh I think he messed up on the ternary operator
It looks weird
I'll just use his one liner
Cuz who can say no to a one liner am I right?
Me
o.O that's like the 3rd update this week
@tulip ledge Yea i did a syntax error, here
function addItemsToInv(items, string) {
return string.split(",").map(i => {
let splitted = i.split(":");
let getItem = items.find(item => item.itemId === splitted[0]);
return getItem ? splitted[0] + ":" + (parseInt(splitted[1]) + getItem.amount) : i;
}).join(",");
}``` xd
Even need an extra line between declarations and and statement for example
Guess thatโs what people call coding style idk
Do I see 2 returns
0 milliseconds lmao
Let's try 1
Canโt be in competition with Voltrex while driving
u better not be texting while driving
Huh donโt worry
With 1 index in the array
But urs doesn't work like intended
So guess I'll use voltrex's
Yeah because I didnโt understand u well enough I guess
haha
FakE is fastest in SingleIndex% and Voltrex is fastest in MultipleIndex%
(speedrunner joke)
Iโm gonna update it tomorrow evening if Iโm back at home
what competition is this lmao
Why are we doing a competition of how fast a function is anyway lmao
I'll keep all functions in a file so we can save them lol
Idk looks like we both are bored
It serves it's purpose lol
Ouch, that hurts
There's something i wanna ask tho
How tf is mine fast on multiple index but slower in a single index
It doesn't make sense 
i think it's the same, I think that FakE is just faster on single index
Voltrex, what does .find do? And why dont u use filter?
I've never used .find before lol
U thought about the fact the benchmark site may is lying to us?
Maybe
I tried find because if I didn't, then i would have needed to use 2 function calls instead of one and that would have made it slower
Does anyone have a api for a random penguin image?
The thing is, if FakE's method worked as intended it would be slow
Anyway since ur right - mine isnโt working as supposed - letโs end it here and wait until I enter the contest tomorrow (again) 
Because you know, something working as intended would need to do things more intensively
Leading up to slowness 
haha voltrex is so competitively
Probably since I would need another loop to catch the non existing values
@tulip ledge make a loop that runs the function like 10000x
I wanna see how this ends
that will give you a better measurement
Wont that fry my pc?
ChickenDev let's do a barbeque while it's running it many times
10000 is quite low, i regularly loop 999999 times or more for these kind of tests
I wanna see how this ends
@tulip ledge worries about mine gets slowier
It would cook some meals fast
That would ruin my day
increase it to 999999
Ouch
@quartz kindle
PC running minecraft with seus shaders: kalm
PC running our functions 10000x: Panik
@tulip ledge donโt post results like this or Iโm probably hit a tree
It is with 1 index tho
what is the function supposed to do btw? increment a number inside a string?
kind of
Well his method would have been slower if it worked as intended, so maybe we try next time when you fix your method?
lmao
I have an array with an object and a string like this: 1:4,2:3
It needs to look at the string and if the object has id 1 for example it needs to do 1:4+object.amount,2:3
ยฏ\_(ใ)_/ยฏ
lets try with 2 indexes now
Well his method would have been slower if it worked as intended, so maybe we try next time when you fix your method?
@earnest phoenix aye thatโs what I mentioned above already
FakE after he fixes his method: 69420ms
lmao
haha lol
so like this? function("a:10,b:20,c:30", {id:b,amount:5}) => "a:10,b:25,c:30"?
This will not happen
I'm gonna have to wait here for a minute for it to finish .--.
Already know how to fix it without another loop
But canโt do it on mobile
why using a string tho?
you can json parse it and stringify it
Cause I need to compress it
{ insert FakE ditching emoji here }
Wait tim wdym?
Shh
save it as an object
Not gonna give up that fast, Voltrex
We'll see
Aye
show the string you have right now
thats all?
yes but it can become pretty long
do you have a longer version? or not yet?
ok
But that string can go up to 25 "indexes" basically
and you want it to be as small as possible, in terms of file size?
ok, the problem with using json here is that it doesnt support numbers as keys
only strings
well, I could sacrifice some space for speed
so using json it would be saved as {"1":4,"2":3}
So I would turn it into a JSON object? And save it like that?
yes
Heโs just trying to destroy our competition
well, you can use zlib on it

I'm currently using lzjs
should work as well
FakE I don't think he is, it's just a different way to return it
U can still make ur functions but instead of returning a string returning a json object ๐
sarcasm
i mean, im offering an alternative way of doing it, but i still want to enter the competition as it is
brb
LOL
lmao
Tim is gonna destroy you guys
Competition accepted
Who's gonna profit from this competition? Me
Cause at the end I'll have an extremely fast function lol
I mean I don't think it's that hard to turn the string into a JSON object right?
U will pay for our efforts
oh god
๐
Don't be sarcastic to me 1. This is chat so it's hard to see 2. I have autism so it's even harder lol
huh there are no sarcasm tags yet
what
There is 1 shimposter among us
ur fake :<

: (
That name abuse
????
The database name
dont u have to make a db?
I did
@tulip ledge try this ```js
function addItems(object,string) {
let array = string.split(",");
for(let i = 0; i < array.length; i++) {
let [key,value] = array[i].split(":");
if(object.id === key) {
array[i] = ${key}:${value+object.value};
return array.join(",")
}
}
}
Oh god
spoon feed
doesn't matter
Tim not good
It's a competition
we are not spoon feeding, we are performance testing
Lol
they're tryna prove who the alpha male is right here
Lol
lol
i have to use many events
@willow mirage its ez
Tim
just making it look gud is hard
Theres an issue
my design skillz r bad
Err Tim
How fast their functions are
First argument is an array with objects inside
oh I see the issue
oh
he's not using the right keys
let me fix
{ itemid: "2", amount: 1 }
Yes
Yes
It's inside an array
ok brb
Hmm
even under 0ms
oh back in time I see
Alright when Tim is done I'm heading to bed tho
Aye and I will leave the highway
So if u come up with more stuff just dm me
I'll try them all tmrw
after school .--.
I hate school so much
Y'know what DBL should do, they should host competitions like this. Fastest to make a certain function would be hella pog
Did tim just enter the competition
yes
Oh no fuck
He didn't do the way we wanted though
try this
function addItems(data,string) {
let array = string.split(",");
for(let d = 0; d < data.length; d++) {
for(let i = 0; i < array.length; i++) {
if(!array[i].startsWith(object.itemid+":")) { continue; }
let [key,value] = array[i].split(":");
array[i] = `${key}:${value+object.amount}`;
break;
}
}
return array.join(",");
}
Tim
If u use data in the parameters
U should also use data in the function lol
Rookie mistake
lmao
wait let me fix
Not with the added amount
Oh, challenge accepted, imna do with for loops then, 
function addItems(data,string) {
let array = string.split(",");
for(let d = 0; d < data.length; d++) {
for(let i = 0; i < array.length; i++) {
if(!array[i].startsWith(data[d].itemid+":")) { continue; }
let [key,value] = array[i].split(":");
array[i] = `${key}:${value+data[d].amount}`;
break;
}
}
return array.join(",");
}
so DM or ping me we can continue this tommorow
Hmm Iโm gonna develop a new loop method to be faster lmao
Tim, ur slow now
well rip
haha
๐
I'm gonna go sleep I have 3 revision test tommorow .--.
So DM or ping me if u come up with some more big brain stuff
Have a good one
Let's continue this tmrw
I mean there are no rules tho
Its just get the required output in the fastest time possible
Would du u mean? Just hammer a return in the first line?
since the test is running the same functions 999999 times, i could just make it save what it did in the first run and skip half of it on the other 999998 runs
caching ftw
Which would win the competition but actually wonโt be used later in his code
Oh no ye it needs to achieve the same in 1 run
exactly
Ok letโs continue this tomorrow as u said already, Iโm off
Ight imma put away my phone before my mom catches me cya tmrw o/
see ya
@earnest phoenix just a quick question - ur always coding on ur mobile phone?
Yes
Bruh how lmao
Because god mind
God damn, makes u a winner in a different category of this competition
@tulip ledge Try this
function addItemsToInv(items, string) {
let splitted = string.split(",");
for (let i = 0; i < splitted.length; i++) {
let splittedString = splitted[i].split(":");
let getItem = items.find(item => item.itemId === splittedString[0]);
splitted[i] = (getItem ? splittedString[0] + ":" + (parseInt(splittedString[1]) + getItem.amount) : i);
}
return splitted.join(",");
}```
At this point i have went crazy with this competition
Think heโs off now
I ran it 10000 times and only 23ms, is this a record? 
Oh wait we run it 999999 times
Lemme see
lmao im doing it too
both of your functions are equal at 1450-1500ms
mine is slower by ~150ms
let me try something new
(im using a slightly larger data set btw)
a string with 5 items and an array of 3 objects
is there any way I can leave someone's server by their ID? (not server ID, user ID)
I'm trying to get his server's ID by his ID
Discord doesn't provide you the information of who invited the bot, but you can check if the ownerID is the id you got and leave
@earnest phoenix I only have his ID
he is the owner
and I wanna check what guilds he added my bot to
to leave them
discord.js?
yes
let guildsOfMember = <client>.guilds.cache.filter(g => g.ownerID === "ID");
// Use 'guildsOfMember' to see all guilds this user is the owner of
guildsOfMember;
// Use this to leave all of them
for (let guild of guildsOfMember.array()) {
guild.leave();
}```
I don't think you need the .array() call btw
You need it, or else it doesn't work
I tried to log in, but
Vortrex I don't have a bot running Discord.js to test, but I'm pretty sure you don't. Could you test to see?
I am trying to host my bot on github with heroku (silly questions to be asking but I cant find a awnser online) I am using commando I keep on getting the same error when trying to deploy it.
Vortrex I don't have a bot running Discord.js to test, but I'm pretty sure you don't. Could you test to see?
@sudden geyser Do you want me to leave guilds
Just kidding, i will do a simple iteration
@sudden geyser Oh you actually didn't need the array, i remember when it needed it but now it doesn't
They might have updated the collection
@ancient nova 
@earnest phoenix You might have been requiring /app/index.js directory from somewhere but it can't find it
Yeah, since it extends Map which is an Iterator which is why I was confused
the only require I have is path commando and config.json
Did you put your files on GitHub right?
yes
everything but node modules
Can you show me your package.json
hi so idk if this is a discord.js bug, but when I try webhook.send({embed: embed}) it does not work, whereas it would if it was channel.send.
I need to send a file and the embed through the webhook so i tried .send(embed, {files: []}) but it sends the embed as Object Object. Any thoughts?
I think the field is called embeds
.send({ embed: embed, files: [...attachments] })
@earnest phoenix Can you show me the top of your main file
Hmm, i don't see any issues there, something is requiring that path, but idk what is requiring it
thats what im saying
if I reupload it inside a app would that work?
Can you show me your github repository where you uploaded these files?
give me a sec
I think the field is called
embeds
@sudden geyser ERROR TypeError: Found non-callable @@iterator
webhook.send({
embeds: embed,
files: [{
attachment: `${process.cwd()}/../TicketLogs/${this.id}.txt`,
name: `Ticket-${this.id}.txt`
}]
});
Did you try what i said
?
question, does it count as advertising to paste the link for a github u have?
Oh it's a webhook nvm, it has to be an array @snow urchin
Oh it's a webhook nvm, it has to be an array @snow urchin
@earnest phoenix what has to be an array
[embed]
F
@snow urchin I was just reading the docs: https://discord.js.org/#/docs/main/stable/class/Webhook?scrollTo=send
The first argument is the content, which could be an empty string. The second argument can be a MessageEmbed instance. The reason my answer didn't work is because the embeds field asks for an array of objects, not an array of MessageEmbed.
So I can use an empty string, then the above, but with [embeds]
I don't get what you mean by "but with [embeds]"
If embed is an object, yes. If it's a MessageEmbed, no.
ye, its an object
Also if you don't want to send any content and only embeds you don't have to pass an empty string to it
Just pass the options as the first parameter
That's it
hey guys
how do i create a discord.js bot that will get all the id's of a member in the server?
and it will save to a txt file
Map all IDs and use fs to create a stream and put them in a file
You iterate over <Guild>.members.cache, map all the IDs to whatever and work from there. But why do you want to do that in the first place
@earnest phoenix i reuploaded the repo and it worked
Nice
weirdchamp but it worked
no sense at all
Wtf
btw, i made this like a while ago, it's a messaging system that opens a listener to localhost, that listener then encrypts http data to re-send it to a "main-server" which only evaluates things like creating/logging into user accounts or chat rooms but the actual messaging is client to client https://github.com/Y0ursTruly/slate
sry if yall see it as kinda advertisment like :l
but i never really got a dev perspective on it
lmao u guys are still battling
Does anyone know if heroku stopped working as discord bot host service?
Heroku have not stopped hosting discord bots, maybe you just ran out of dyno hours
But never use heroku
It's not meant for bot hosting
Does anyone know if heroku stopped working as discord bot host service?
@viral timber so u just didnt like host it urself?
strange
I know itโs just for trying the bot, and I still have hours
Self host is worse
xD jkjk not everyone will have it on the mercy of their laptop
self host, well if electricity goes then yea
@quartz kindle Oh so you beat my function by 300ms?
something like that ye
Time to write a better one
what r yall racing about?
let me test yours again
Efficiency
ooh a challenge????
yeaaa ik... about what
what result or function they tryin to see who cud get done more efficiently?
@quartz kindle This is the new one btw
function addItemsToInv(items, string) {
let splitted = string.split(",");
for (let i = 0; i < splitted.length; i++) {
let splittedString = splitted[i].split(":");
let getItem = items.find(item => item.itemId === splittedString[0]);
splitted[i] = (getItem ? splittedString[0] + ":" + (parseInt(splittedString[1]) + getItem.amount) : i);
}
return splitted.join(",");
}```
Just in case if you didn't see it
add items to inventory huh
how efficient is find()?
Wot
with a for { Array.find() } wouldn't it be O(N^2)?
@quartz kindle It's not broken, i used itemId not itemid
can i get an example of the params pls
..^^
@earnest phoenix still not working for me lul
static addMaterialsToInv(array = [{ itemid: "2", amount: 1 }, { itemid: "1", amount: 2 }], string = "1:4,2:3")
{
let output = "";
let items = string.split(",");
for(let a = 0; a < array.length; a++)
{
for(let b = 0; b < items.length; b++)
{
let element = items[b].split(":");
if(array[a].itemid == element[0])
{
array[a].amount += parseInt(element[1]);
break;
}
}
}
for(let c = 0; c < array.length; c++) output += array[c].itemid + ":" + array[c].amount + ",";
return output.substr(0, (output.length - 1));
}```
above is what the link showed
@earnest phoenix still not working for me lul
@quartz kindle What's the output?
"0,1,2:NaN,3,4:NaN"
O(N^2)
Tim, itemId should be strings in my function lol
The original idea was itemId as string and amount as number
Yeah since he just used numbers as placeholders
Expect the itemid to be a real string
Someone help me?
@earnest phoenix lmao
Huh, it only took me 1300ms to execute it 999999 times
Someone help me?
every time i log in this happens
addItemsToInv([{ itemid: "2", amount: 1 }, { itemid: "1", amount: 2 }], "1:4,2:3") = "0,1"
@quartz kindle What was the previous version again?
this is gonna take me a bit to understand FOR SURE what's going on LMAO
What the fuck did you use
@earnest phoenix this version ```js
function voltrex2(items, string) {
return string.split(",").map(i => {
let splitted = i.split(":");
let getItem = items.find(item => item.itemId === splitted[0]);
return getItem ? splitted[0] + ":" + (parseInt(splitted[1]) + getItem.amount) : i;
}).join(",");
}
@viscid gale go to the message I mentioned and take a look at the convo between ChickenDev, Voltrex and me
Hmm
@boreal iron what was your version of the function?
Itโs not the right moment @quartz kindle
oh mb
ah found it
But remember it will not result items in the string argument if they do not exist in the array
#development message
@boreal iron would it be faster if you used string interpolation?
Which was an issue of misunderstanding on my side
ye i saw it now, it only returns changes
Not sure test it out Cloudfox
Canโt test it atm
alright
@quartz kindle gonna fix that tomorrow and beat you lmao
nvm
@boreal iron xD

Oof thatโs getting difficult
What in the name of my disappearing api.html is going on here
U better donโt think about it
True
A simple benchmark test of two provided functions to solve one issue turned into an international performance and efficiency contest
โInternationalโ lmao
Nice auto correction
I'm back and still struggling with promises in javascript.
I've tried more things and made more progress but now my bot crashes with no error log and the code the promise is supposed to run doesn't even happen.
I don't understand promises.
It seems to finish the code, run some more code, then mysteriously crash. If I comment out the promise code it doesn't crash.
international feeding
what does it look like when it works and doesn't work?
What are you all doing? sorting?
The code within browser.visit doesn't run but the other code in the promise does.
we should post the sample input and desired output and have a performance ranking of the different functions made by people
Hmm later that day
Think you can add lots of blocks on the benchmarking site
Just renaming the functions to our Discord names
i would win
actually
make it a hidden ranking
where we cant see what other people did
we can only see its performance
Think thereโs not much to more to optimize seeing the last results
so we can try guessing what other people did and try to beat them
@viral plover the resolve() method should pass the thing you want the promise to return
I added the promise to prevent a too many listeners error so that the code would go all the way through without continuing through loops.
I see now that I should probably not be stubborn and try using the promise for its intended purpose...
If even after my next attempt the code within the visit function doesn't trigger I'll return.
if i have a clear command
does it like get denied?
i dont really have a ratelimit thing
<img class="space-img" style="overflow-x: hidden;" src="exo-images/space.png" alt=""> will the image work? I have the exo-images folder in the same directory as the file that this piece of code is in. The problem is that the images aren't showing up. I'm using django with an apache2 webserver.
if i have array ['thing1', 'thing2', 'thing3'] how would i enter it in a function so it would be function(thing1, thing2, thing3) {}?
and this isnt the channel to ask
@silver lintel where to ask
After trying to get the promise to return a value the code within the .visit function still didn't trigger.
I then removed the promise code and now it triggers without giving the too many listeners error.
I don't completely understand but I'll take it.
@silver lintel you can do function(...array)
but how do you want to name them?
if you know the size and order of the array, you can use destructuring
its still easier to just pass the array itself
@quartz kindle I think this competition's winner will be unknown, whatever function i provide, it's execution time seems different on our end, maybe because we need a NASA computer to see 
well, all functions would need to be executed in the same machine
there should be a judge doing it
also to make sure the function doesnt have any cheats
does anything matter really?
i made another one using different methods, still not good as the first one tho
Can you show how you did the first one
Kinda curious

this.connect()
.then(() => {
redis.connect()
.then(() => {
this.logger.log('Redis client connected.', 'database');
});
});```
(node:14928) UnhandledPromiseRejectionWarning: Error: Redis is already connecting/connected
anyone know how i can disconnect other redis instances?
check if redis is already connected
idk which library you're using, but there should be something like redis.status or redis.connected or whatever, check your library's docs
xD
Command = Auto Message with Counter
Database = MongoDB
Discord.JS = v12
There are no errors in the lines. The problem does not appear. But every time I run the command the database is rebooted and the bot restarts at the same time.
Command (auto-message.js): https://hasteb.in/cimatizo.js
Command (auto-message-remove.js): https://hasteb.in/jehagefu.js
Models/TimeCommand.js = https://hasteb.in/hirimoni.js
Events/Client/Ready.js = https://hasteb.in/sajahavo.js
why client.emit("ready", client);?
idk, help me
remove that
remove that
@quartz kindle Can you check my message again?
this is a bad idea
do 1 interval instead of 832746927 intervals
your Ready.js has a lot of things, so you should never use client.emit("ready") anywhere, it kill your bot
Can you edit it and send it to me?
no sorry
can i update the typing status for my bot in a channel? so it says BOT is typing... in the channel
do you have fetchAllMembers on?
No
@quartz kindle does discordjs have a function that lets me set it?
add a client.on("debug") in your shards
see what they log
@proven lantern yes
although djs's version of it is weird af
what is the -- for pm2 to not auto restart
tbh the entire "typing" api is weird af
@blissful coral
It literally says
just do client.on("debug",console.log)
i didnt sent the full version assuming you knew how to use it lul
yup, limit exceeded xD
await msg.channel.startTyping(); blocks forever. lol
that is many confuse
yup
5 confusing 3 me




