#development

1 messages ยท Page 1341 of 1

earnest phoenix
#

Like galaxy mind

sharp thicket
#

yes u smart man

vernal rivet
#

i forgot what is on line 39 of the Client class

tired panther
#

does nothing @Voltrex Master#0001

earnest phoenix
#

K then

sharp thicket
#

SpoonFeed ๐Ÿคฆโ€โ™‚๏ธ

boreal iron
#

@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

earnest phoenix
#
client.shard.broadcastEval(
`(() => this.channels.cache.get(\`${sguild}\`) ? this.channels.cache.get(\`${schannel}\`).send(\`${suggestmessage}\`) : null)()`);``` try this mate @tired panther
sharp thicket
#

SpoonFeed

tired panther
#

xD

#

wait one min

vernal rivet
#

dogekek when you released that its a string inside a string

tulip ledge
#

@boreal iron because I can get more then 1 drop, meaning it needs to add more then 1 item

vernal rivet
#

you don't need to use ` for the get methods. " should work here

tired panther
#

@earnest phoenix but why is it getting two times the channel?

earnest phoenix
#

@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
#

@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
#

@earnest phoenix but why is it getting two times the channel?
@tired panther Like is it sending the embed twice?

#

Or what you mean

tired panther
#

just one time in an another shard @earnest phoenix

earnest phoenix
#

No i mean like you said it gets the channel 2 times?

#

I'm confused

vernal rivet
#

i am as confused as you are right now

tired panther
#

@earnest phoenix

earnest phoenix
#

Oh, you meant in the code

vernal rivet
#

thats elvis operators

tired panther
#

yes xD

#

It should send an embed message in another guild in sharding

earnest phoenix
#

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

boreal iron
#

@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?!)

tired panther
#

but how does it get the guild?

boreal iron
#

Both work and you're free to use what ever you like, just wanted to mention this benchmark test

earnest phoenix
#

i forgot to do schannel lmao

vernal rivet
#

you say your code style is weird fake, i use allmans brace style happy_boy who is weird now

earnest phoenix
#

@tired panther change sguild to schannel

vernal rivet
#

LMAO

#

don't you love when that happens

tired panther
#

pkay

vernal rivet
#

what type is the suggestmessage?

tired panther
#

an embed

vernal rivet
#

don't incase the embed in ``

tired panther
#
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'

earnest phoenix
#

I see why

vernal rivet
quartz kindle
#

serialize it

tired panther
#

๐Ÿ‘€

#

@quartz kindle thought that to, with Json. blabal

#

did not work

earnest phoenix
#

send({ embed: ${suggestmessage} })

quartz kindle
#

embeds have their own serialization method

tired panther
#

tried that to, but trying again

vernal rivet
#

what tim said

quartz kindle
#

JSON.stringify(embed.toJSON())

tired panther
#

@quartz kindle and how are they? never heard

earnest phoenix
#

You don't have to stringify it to send the embed

quartz kindle
#

you have to stringify it to send it to broadcastEval

#

otherwise you're sending [Object object]

tired panther
#

now the profi comes

earnest phoenix
#

No i meant to providing it to the property value of embed

#

Like i showed up there

quartz kindle
#

yes but if you dont stringify it, it will be converted to embed:"[Object object]"

earnest phoenix
#

Yea i meant by converting it

tired panther
#

thats come now

quartz kindle
#

show code

tired panther
#

.send(\`JSON.stringify(${suggestmessage}.toJSON())\`)

vernal rivet
#

don't incase it in ``

quartz kindle
#

.send(${JSON.stringify(suggestmessage.toJSON())})

earnest phoenix
#

send({ embed: {suggestmessage.toJSON()} })

vernal rivet
#

;-;

earnest phoenix
#

Wait a second, does that even work Tim

quartz kindle
#

not sure

vernal rivet
#

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

tired panther
#

How can access suggest message @quartz kindle ?

quartz kindle
#

hmm?

tired panther
#

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

vernal rivet
#

tbh thats the best answer i ever heard

#

how much js do you know?

quartz kindle
#

yes, you're building the embed outside of broadcastEval

#

so you need to serialize it, to pass it to the eval as a string

earnest phoenix
tired panther
#
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)

vernal rivet
quartz kindle
#

i told you, JSON.stringify should be inside ${}

#

like i showed

vernal rivet
#

do suggestmessage.toJSON()

tired panther
#

indeed

earnest phoenix
#

@tired panther Try

.send({
embed: \`${suggestmessage.toJSON()}\`
})```
#

Wait fuck

vernal rivet
quartz kindle
#

lmao

earnest phoenix
vernal rivet
#

what are you doing voltrex

earnest phoenix
#

Wtf

quartz kindle
#

lmfao

earnest phoenix
#

Jesus

tired panther
#
    client.shard.broadcastEval(
      `(() => this.channels.cache.get(\`${schannel}\`) ? this.channels.cache.get(\`${schannel}\`).send(${JSON.stringify(suggestmessage.toJSON())}) : null)()`);
``` same error
vernal rivet
#

still has problems

earnest phoenix
#

Meister mate

#

Try what i said

tired panther
#

yes

#

yes Tim was first now trying your dear friend

quartz kindle
#

the error is unexpected identifier?

tired panther
#

yes

quartz kindle
#

does it show which identifier it is?

vernal rivet
#

probably \

tired panther
#
(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)
quartz kindle
#

i mean

vernal rivet
#

you should be able to replace \` with "

earnest phoenix
#

Did mine even work

quartz kindle
#

usually unexpected identifiers should show what the problem is before the error

#

like this

#
blablabal
^^^^^^^^
Error unexpected identifier```
tired panther
#

@tired panther Try

.send({
embed: \`${suggestmessage.toJSON()}\`
})```

@earnest phoenix

vernal rivet
#

kellyded didn't i just say what it is. its evaling, \ doesn't escapes out of string

tired panther
#

mmh

earnest phoenix
#

I'm absolutely speechless

vernal rivet
#

replace \` with ", then try again.

earnest phoenix
#

That would replace it with a string

#

Wouldn't work

vernal rivet
#

kellyded your injecting the object in the string before correct?

earnest phoenix
#

Turning it into a json as you see

warm marsh
#

That's why string literals are being used.

#

Embed takes an Object as data?

earnest phoenix
#

Yes

warm marsh
#
.send({
  embed: {
    description: msg.toJSON()
  }
});```
earnest phoenix
#

Wot

warm marsh
#

toJSON turns it into stringified?

tired panther
#
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

vernal rivet
earnest phoenix
#

That caused by which code?

tired panther
queen stirrup
#

Hm

quartz kindle
#

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);

tired panther
#

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

quartz kindle
#

can you console.log(suggestmessage.toJSON())?

earnest phoenix
#

JSON.stringify returns a string tho

#

It doesn't accept strings, only objects

quartz kindle
#

you need a string

#

you're evaling it

tired panther
#
{
  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
quartz kindle
#

that author url is wrong

#

displayAvatarURL is a function

tired panther
#

oh sorry forget it

#

is it thats way?

warm marsh
#

"rich", you're using an old version of d.js?

tired panther
#

no

#

discord js. 12.2

earnest phoenix
#

No that type property shows the type of the embed structure

#

Exists on all d.js versions

tired panther
#

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

quartz kindle
#

is schannel already an id?

#

or is it a channel object?

earnest phoenix
#

schannel is an id

tired panther
#
    let sguild = "734707332163829780"; //guild id
quartz kindle
#

oh

#

then remove the .id

#

i thought it was a channel object

warm marsh
#

Ah, I knew it was like that in v11 I thought they would have changed it.

tired panther
#

where was the .id?

quartz kindle
earnest phoenix
tired panther
#

ah u mean that

earnest phoenix
#

=> schannel

modest smelt
#
@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.
faint prism
#

this looks familiar

tired panther
#

@quartz kindle it worked thanks a lot, it means that you do not have to fetch the guild , just the channel?

earnest phoenix
#

Channels are cached by default

quartz kindle
#

^ if you're using normal discord.js, all channels are always cached

misty sigil
#

things change if you use discord.js-light

earnest phoenix
#

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

tulip ledge
#

best sites to get VPS's for discord bots?

warm marsh
#

Check pins, there is a few listed

tulip ledge
#

ah ty

modest smelt
#

user = client.get_user(id) Why does this give me none for user?

quartz kindle
#

might the user is not cached

modest smelt
#

i have their id

#

how can i get their username?

boreal iron
#

is get_user() a valid function of djs?

modest smelt
#

i use py

boreal iron
#

ok than, same question for py

slender thistle
#

discord.Client.get_user is valid

#

Make sure the user is cached

modest smelt
#

so i should do discord.Client.get_user(id)

slender thistle
#

no

#

I simply implied that get_user is a method of the Client class/object

modest smelt
#

ok

drowsy kite
#

How do I get my bot online in the terminal?

#

node .?

modest smelt
#

wdym? terminal

#

u have to use a hosting server

#

service

boreal iron
#

just start node.exe yourbot.js

drowsy kite
#

u have to use a hosting server
@modest smelt hm ok

boreal iron
#

or node.(notexe)

viral timber
#

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.

jovial nexus
#

the guildMemberUpdate includes also if the game a user is playing changues?

boreal iron
#

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);
sudden geyser
#

What is the result supposed to be.

jovial nexus
boreal iron
#

Is this what u mean?

viral timber
#

yup, i'll try it in a sec

quartz kindle
#

@jovial nexus no

boreal iron
#

I mean not needed to use short statements...

quartz kindle
#

that information will be in a presenceUpdate

jovial nexus
#

client.on presenceUpdate?

quartz kindle
#

yes

jovial nexus
#

that works for users or only for the bot?

quartz kindle
#

all users

ionic dawn
#

holaendersoyvo1d

jovial nexus
#

ok thx

earnest phoenix
#

<oldPresence|newPresence>.user

tulip ledge
#

@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

boreal iron
#

oh, you wanna add the string to the array?

tulip ledge
#

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

earnest phoenix
#

ChickenDev

tulip ledge
#

?

boreal iron
#

Oh I didn't know it that fact, did you mention this would be needed?

earnest phoenix
#

Mine didn't work? Or you're just explaining that to him

tulip ledge
#

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$

boreal iron
#

Well then I may missunderstood, but can be changed in a few seconds

#

gimma a sec

tulip ledge
#

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

boreal iron
#

lol

tulip ledge
#

could also be cuz urs is using variable names I wouldn't personally use

boreal iron
#

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?

tulip ledge
#

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

boreal iron
#

roger, just have 5 mins left, let me check

earnest phoenix
tulip ledge
#

lol this turned into a competition on who's the fastest

boreal iron
#

well then, just got 2 minutes left until I have to go, I would say, take his code

earnest phoenix
#
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

tulip ledge
#

its a 1 liner lol

sick surge
#

oh

misty sigil
#

hi

boreal iron
#

Guess I pushed him to the next level oldEyes

sick surge
#

how do i like insert a bot or make one?-

misty sigil
#

do you have the bot programmed?

sick surge
#

no

misty sigil
#

in fact, do you even have a bot application

sick surge
#

n o p e-

#

hhhh-

earnest phoenix
tulip ledge
#

Voltrex urs is still slower lol

#

FakE is still the fastest of the west rofl

boreal iron
#

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

earnest phoenix
#

The reason mine was slower is because i was doing the same find and split again

#

what is a error

misty sigil
#

@earnest phoenix let me see your code

tulip ledge
#

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

earnest phoenix
#

in dm @misty sigil ?

misty sigil
#

no

#

please

#

here

earnest phoenix
#

my index.js

#

?

misty sigil
#

yes

boreal iron
#

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

tulip ledge
#

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 ๐Ÿคท

earnest phoenix
#

i send in dm @misty sigil

boreal iron
#

just use Voltrex version, I can if u really fear any delay, update it tomorrow for u

tulip ledge
#

Oh no, you don't have to lol

#

I just wanted to see if it would still be faster

earnest phoenix
#

what is my error

misty sigil
#

just use 1 message listener

earnest phoenix
misty sigil
#

and if / else if statements

#

just use one message listener

#

no need for 11

pure lion
#

Jaja

boreal iron
#

I could say it would, just to trigger Voltrex
Maybe he would present an even faster version after
Where should this end? lmao

earnest phoenix
#

There's a way you correct my code and send it back to me because I'm a bit lost!
plz @misty sigil

misty sigil
#

no

#

put all the bits in one event

pure lion
#

@earnest phoenix you only need one event

misty sigil
#

you can just copy paste the code

#

into one event

tulip ledge
#

hahaha we're gonna get to a function that will process this in .1 of a millisecond like this

pure lion
#

If you don't understand handlers use a switch case

misty sigil
#

you are allowed to use more than 1 if statement

pure lion
#

Or learn

boreal iron
#

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

earnest phoenix
#

in fact I'm French and when I translate your text it doesn't matter so I don't know what to do

tulip ledge
#

Voltrex's one literally takes 3ms to complete rn

misty sigil
#

i know a function that processes in .1 of a millisecond

ancient nova
#

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)

tulip ledge
#

hahaha, it would be good for me tho cause I'll have a faster method ๐Ÿ˜›

misty sigil
#
function a () {
  return
}``` return
tulip ledge
#

@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

ancient nova
#

yeah I could create an map with all the guild

tulip ledge
#

So might not be the best solution

ancient nova
#

but my bot has almost 200 guilds

#

and it will

earnest phoenix
#
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
ancient nova
#

be a very big file

tulip ledge
#

HAHAHAH

boreal iron
#

@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 zoomeyes

tulip ledge
#

php??

#

lol

misty sigil
#

php

tulip ledge
#

tbh, who used php these days when u have ejs?

ancient nova
#

@tulip ledge is there any way to do that in a function and have return only 1 ID as a string

misty sigil
#

ikr

earnest phoenix
#

Wait lemme make that look better

misty sigil
#

ejs >> php

tulip ledge
#

ight then

boreal iron
#

Me because I do since 14 years, still lol

tulip ledge
#

damn u been doing php since I was born

boreal iron
#

We figured that out already

#

Thank u

#

Now I feel even older

tulip ledge
#

hahaha

#

how old are u o.O

earnest phoenix
#
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
tulip ledge
#

Free functions pog

keen ether
earnest phoenix
#

Say what your bot does

boreal iron
#

how old are u o.O
Better donโ€™t talk about that, letโ€™s say too old

tulip ledge
#

Euhm Voltrex

misty sigil
#

so, too old as in 120+?

tulip ledge
#

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

willow mirage
#

@earnest phoenix is master about strings

#

:))

tulip ledge
#

I did it

#

oh god

#

I messed it up

#

i.join is not a function

#

uh oh I think I messed up haha

keen ether
#

Say what your bot does
@earnest phoenix
But how is that? I don't know programming?? ๐Ÿค”

tulip ledge
#

bruh

boreal iron
#

Your short statement is weird

misty sigil
#

what

boreal iron
#

if(getItem) huh?

#

Nah speaking to Chicken

tulip ledge
#

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?

boreal iron
#

Me

tulip ledge
earnest phoenix
#

@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
boreal iron
#

Even need an extra line between declarations and and statement for example

#

Guess thatโ€™s what people call coding style idk

tulip ledge
#

the real question is: "is it faster then the one liner?"

#

Damn

#

Hella fast

boreal iron
#

Do I see 2 returns

tulip ledge
#

I guess

earnest phoenix
tulip ledge
#

Let's try 1

boreal iron
#

Canโ€™t be in competition with Voltrex while driving

tulip ledge
#

u better not be texting while driving

boreal iron
#

Huh donโ€™t worry

tulip ledge
#

But urs doesn't work like intended

#

So guess I'll use voltrex's

earnest phoenix
#

If it doesn't work as intended then it doesn't qualify lmao

boreal iron
#

Yeah because I didnโ€™t understand u well enough I guess

tulip ledge
#

haha

#

FakE is fastest in SingleIndex% and Voltrex is fastest in MultipleIndex%
(speedrunner joke)

boreal iron
#

Iโ€™m gonna update it tomorrow evening if Iโ€™m back at home

tulip ledge
#

haha alright

#

Good luck

quartz kindle
#

what competition is this lmao

earnest phoenix
#

Why are we doing a competition of how fast a function is anyway lmao

tulip ledge
#

I'll keep all functions in a file so we can save them lol

boreal iron
#

Idk looks like we both are bored

earnest phoenix
#

It serves it's purpose lol

boreal iron
#

Ouch, that hurts

earnest phoenix
#

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 OMEGALUL

tulip ledge
#

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

boreal iron
#

U thought about the fact the benchmark site may is lying to us?

tulip ledge
#

Maybe

earnest phoenix
#

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

heavy fractal
#

Does anyone have a api for a random penguin image?

earnest phoenix
#

The thing is, if FakE's method worked as intended it would be slow

tulip ledge
#

They're literally all 0ms

boreal iron
#

Anyway since ur right - mine isnโ€™t working as supposed - letโ€™s end it here and wait until I enter the contest tomorrow (again) KEKW

earnest phoenix
#

Because you know, something working as intended would need to do things more intensively

#

Leading up to slowness OMEGALUL

tulip ledge
#

haha voltrex is so competitively

boreal iron
#

Probably since I would need another loop to catch the non existing values

quartz kindle
#

@tulip ledge make a loop that runs the function like 10000x

tulip ledge
#

I wanna see how this ends

quartz kindle
#

that will give you a better measurement

tulip ledge
#

Wont that fry my pc?

quartz kindle
#

no lol

#

unless you run it 99999999999 times

earnest phoenix
#

ChickenDev let's do a barbeque while it's running it many times

quartz kindle
#

10000 is quite low, i regularly loop 999999 times or more for these kind of tests

boreal iron
#

I wanna see how this ends
@tulip ledge worries about mine gets slowier

earnest phoenix
#

It would cook some meals fast

boreal iron
#

That would ruin my day

tulip ledge
quartz kindle
#

increase it to 999999

boreal iron
#

Ouch

earnest phoenix
#

@quartz kindle
PC running minecraft with seus shaders: kalm
PC running our functions 10000x: Panik

tulip ledge
boreal iron
#

@tulip ledge donโ€™t post results like this or Iโ€™m probably hit a tree

tulip ledge
#

It is with 1 index tho

quartz kindle
#

what is the function supposed to do btw? increment a number inside a string?

tulip ledge
#

kind of

earnest phoenix
#

Well his method would have been slower if it worked as intended, so maybe we try next time when you fix your method?

quartz kindle
#

lmao

tulip ledge
#

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

earnest phoenix
#

ยฏ\_(ใƒ„)_/ยฏ

tulip ledge
#

lets try with 2 indexes now

boreal iron
#

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

tulip ledge
#

2 indexes

earnest phoenix
#

FakE after he fixes his method: 69420ms

boreal iron
#

lmao

tulip ledge
#

haha lol

quartz kindle
#

so like this? function("a:10,b:20,c:30", {id:b,amount:5}) => "a:10,b:25,c:30"?

boreal iron
#

This will not happen

tulip ledge
#

I'm gonna have to wait here for a minute for it to finish .--.

boreal iron
#

Already know how to fix it without another loop

tulip ledge
#

Yes

#

Basically like that

boreal iron
#

But canโ€™t do it on mobile

quartz kindle
#

why using a string tho?

tulip ledge
#

cuz the inv is being saved as a string

#

How else would I save it?

quartz kindle
#

you can json parse it and stringify it

tulip ledge
#

Cause I need to compress it

earnest phoenix
#

{ insert FakE ditching emoji here }

tulip ledge
#

Wait tim wdym?

boreal iron
#

Shh

tulip ledge
#

I save it as an array?

#

or object?

quartz kindle
#

save it as an object

boreal iron
#

Not gonna give up that fast, Voltrex

tulip ledge
#

{
id:1,
amount: 1
}

#

Like that?

earnest phoenix
#

We'll see

boreal iron
#

Aye

quartz kindle
#

the string you have is pretty much already a json object

#

just needs {} around it

tulip ledge
#

Wow I'm confused now

#

So save the string

quartz kindle
#

show the string you have right now

tulip ledge
#

But as an object?

#

"1:4,2:3"

quartz kindle
#

thats all?

tulip ledge
#

yes but it can become pretty long

quartz kindle
#

do you have a longer version? or not yet?

tulip ledge
#

The user only has 2 items rn

#

Not yet no lol

quartz kindle
#

ok

tulip ledge
#

But that string can go up to 25 "indexes" basically

quartz kindle
#

and you want it to be as small as possible, in terms of file size?

tulip ledge
#

so if ud split it by "," and take the length it'd be 25 if it would be at max

#

yes

quartz kindle
#

ok, the problem with using json here is that it doesnt support numbers as keys

#

only strings

tulip ledge
#

well, I could sacrifice some space for speed

quartz kindle
#

so using json it would be saved as {"1":4,"2":3}

tulip ledge
#

So I would turn it into a JSON object? And save it like that?

quartz kindle
#

yes

tulip ledge
#

mmmh I could try that

#

Can u compress a json object?

boreal iron
#

Heโ€™s just trying to destroy our competition

quartz kindle
#

well, you can use zlib on it

boreal iron
tulip ledge
#

I'm currently using lzjs

quartz kindle
#

should work as well

tulip ledge
#

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 ๐Ÿ˜›

boreal iron
#

sarcasm

quartz kindle
#

i mean, im offering an alternative way of doing it, but i still want to enter the competition as it is

#

brb

tulip ledge
#

LOL

quartz kindle
#

lmao

tulip ledge
#

Tim is gonna destroy you guys

boreal iron
#

Competition accepted

tulip ledge
#

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?

boreal iron
#

U will pay for our efforts

tulip ledge
#

oh god

boreal iron
#

๐Ÿ˜†

tulip ledge
#

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

boreal iron
#

huh there are no sarcasm tags yet

blissful coral
#

Anyone here use mongo db?

#

Need help

willow mirage
#

what

tulip ledge
#

There is 1 shimposter among us

blissful coral
#

shut

#

lmao

tulip ledge
#

ur fake :<

boreal iron
willow mirage
#

: (

boreal iron
#

That name abuse

blissful coral
#

First time using mongodb, what the FUCK is the db name

#

LMAO

#

Is it project?

willow mirage
#

????

boreal iron
#

The database name

tulip ledge
#

dont u have to make a db?

blissful coral
#

I did

tulip ledge
#

Using new Schema or something like that

#

u using mongo db or mongoose?

quartz kindle
#

@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(",")
}
}
}

tulip ledge
#

Oh god

willow mirage
#

spoon feed

blissful coral
#

doesn't matter

willow mirage
#

Tim not good

blissful coral
#

spoon feed is fun

#

lmao

tulip ledge
#

It's a competition

quartz kindle
#

we are not spoon feeding, we are performance testing

willow mirage
#

Lol

tulip ledge
#

they're tryna prove who the alpha male is right here

quartz kindle
#

Lol

boreal iron
#

lol

blissful coral
#

I feel like a idiot rn ngl

#

Mongo is easy now that I found the fuckin docs

#

LMAO

willow mirage
#

dude making bot dashboard makes my brain explode

#

i have to use many events

chilly bison
#

i have to use many events
@willow mirage its ez

tulip ledge
#

Tim

chilly bison
#

just making it look gud is hard

tulip ledge
#

Theres an issue

chilly bison
#

my design skillz r bad

tulip ledge
#

Urs is the fastest by far

#

But

willow mirage
#

sad

tulip ledge
#

It returns undefined

willow mirage
#

????

#

the fck iz that

boreal iron
#

Err Tim

tulip ledge
#

How fast their functions are

boreal iron
#

First argument is an array with objects inside

tulip ledge
#

oh I see the issue

quartz kindle
#

oh

tulip ledge
#

he's not using the right keys

quartz kindle
#

let me fix

tulip ledge
#

{ itemid: "2", amount: 1 }

quartz kindle
#

ah

#

and inside an array?

tulip ledge
#

Yes

boreal iron
#

Yes

tulip ledge
#

It's inside an array

quartz kindle
#

ok brb

tulip ledge
#

I'm just being amazed how we started at 3ms

#

And are at 0ms rn

boreal iron
#

Hmm

tulip ledge
#

even under 0ms

boreal iron
#

Wait till tomorrow

#

-3 ms

tulip ledge
#

oh back in time I see

boreal iron
#

Thatโ€™s my goal

#

You will get a response in the past

tulip ledge
#

Alright when Tim is done I'm heading to bed tho

boreal iron
#

Aye and I will leave the highway

tulip ledge
#

So if u come up with more stuff just dm me

#

I'll try them all tmrw

#

after school .--.

boreal iron
#

Guess we will see each other in here

#

Hehe u lucky boy

tulip ledge
#

I hate school so much

boreal iron
#

School time is was a nice time

#

U will remember later in your life trust me

tulip ledge
#

Y'know what DBL should do, they should host competitions like this. Fastest to make a certain function would be hella pog

earnest phoenix
#

Did tim just enter the competition

tulip ledge
#

yes

earnest phoenix
#

Oh no fuck

tulip ledge
#

and he already beat u by like 1/3rd

#

But

#

It returned undefined

earnest phoenix
#

He didn't do the way we wanted though

quartz kindle
#

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(",");
}
tulip ledge
#

Tim

#

If u use data in the parameters

#

U should also use data in the function lol

#

Rookie mistake

quartz kindle
#

lmao

tulip ledge
#

Its not doing what it should

#

It returned the original string

quartz kindle
#

wait let me fix

tulip ledge
#

Not with the added amount

earnest phoenix
#

Oh, challenge accepted, imna do with for loops then, OMEGALUL

tulip ledge
#

haha lol

#

when Tim is done I'm heading to bed tho

quartz kindle
#
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(",");
}
tulip ledge
#

so DM or ping me we can continue this tommorow

boreal iron
#

Hmm Iโ€™m gonna develop a new loop method to be faster lmao

tulip ledge
quartz kindle
#

well rip

tulip ledge
#

haha

boreal iron
#

๐Ÿ˜…

tulip ledge
#

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

boreal iron
#

Have a good one

tulip ledge
#

Let's continue this tmrw

boreal iron
#

Funny day tho

#

Gonna leave the highway to get work ... see ya

quartz kindle
#

i could add a cheat

#

that makes it much faster

#

but it would be cheating

#

lmao

tulip ledge
#

I mean there are no rules tho

#

Its just get the required output in the fastest time possible

quartz kindle
#

i mean

#

it would be cheating the test itself

tulip ledge
#

?

#

Just when u test it for loop it 999999 times

boreal iron
#

Would du u mean? Just hammer a return in the first line?

quartz kindle
#

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

boreal iron
#

Which would win the competition but actually wonโ€™t be used later in his code

tulip ledge
#

Oh no ye it needs to achieve the same in 1 run

quartz kindle
#

exactly

boreal iron
#

Ok letโ€™s continue this tomorrow as u said already, Iโ€™m off

tulip ledge
#

Ight imma put away my phone before my mom catches me cya tmrw o/

quartz kindle
#

see ya

boreal iron
#

@earnest phoenix just a quick question - ur always coding on ur mobile phone?

earnest phoenix
#

Yes

unreal token
#

Bruh how lmao

earnest phoenix
#

Because god mind

boreal iron
#

God damn, makes u a winner in a different category of this competition

earnest phoenix
#

@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

boreal iron
#

Think heโ€™s off now

earnest phoenix
#

Oh wait we run it 999999 times

#

Lemme see

quartz kindle
#

lmao im doing it too

#

both of your functions are equal at 1450-1500ms

#

mine is slower by ~150ms

#

let me try something new

earnest phoenix
quartz kindle
#

(im using a slightly larger data set btw)

earnest phoenix
#

I broke the record

#

Record broken

quartz kindle
#

a string with 5 items and an array of 3 objects

earnest phoenix
#

Yes

#

What did you use

placid iron
#

plot twist

#

voltrex just uses a super computer

#

so ofc they have a faster result

ancient nova
#

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

earnest phoenix
#

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

ancient nova
#

@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

earnest phoenix
#

discord.js?

ancient nova
#

yes

earnest phoenix
#
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();
}```
ancient nova
#

alright, thank you

#

let me try it

sudden geyser
#

I don't think you need the .array() call btw

earnest phoenix
#

You need it, or else it doesn't work

sweet sand
sudden geyser
#

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?

earnest phoenix
#

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 OMEGALUL

#

Just kidding, i will do a simple iteration

ancient nova
#

it worked @earnest phoenix

earnest phoenix
#

@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 dblpat

#

@earnest phoenix You might have been requiring /app/index.js directory from somewhere but it can't find it

sudden geyser
#

Yeah, since it extends Map which is an Iterator which is why I was confused

earnest phoenix
#

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

snow urchin
#

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?

sudden geyser
#

I think the field is called embeds

earnest phoenix
#

.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

snow urchin
#

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`
                    }]
                });
earnest phoenix
#

Did you try what i said

snow urchin
#

?

viscid gale
#

question, does it count as advertising to paste the link for a github u have?

earnest phoenix
#

Oh it's a webhook nvm, it has to be an array @snow urchin

snow urchin
#

Oh it's a webhook nvm, it has to be an array @snow urchin
@earnest phoenix what has to be an array

earnest phoenix
#

[embed]

snow urchin
#

F

sudden geyser
#

@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.

snow urchin
#

So I can use an empty string, then the above, but with [embeds]

sudden geyser
#

I don't get what you mean by "but with [embeds]"

snow urchin
#

embed*

sudden geyser
#

If embed is an object, yes. If it's a MessageEmbed, no.

snow urchin
#

ye, its an object

earnest phoenix
#

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

eternal osprey
#

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

earnest phoenix
#

Map all IDs and use fs to create a stream and put them in a file

sudden geyser
#

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
#

@earnest phoenix i reuploaded the repo and it worked

#

Nice

#

weirdchamp but it worked

#

no sense at all

quartz kindle
#

lmao

earnest phoenix
#

Wtf

quartz kindle
#

the last value is wrong

#

let me fix

earnest phoenix
#

Am i hallucinating or is that real

#

Nah it's probably level 69420 photoshop

viscid gale
#

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

boreal iron
#

lmao u guys are still battling

viral timber
#

Does anyone know if heroku stopped working as discord bot host service?

earnest phoenix
#

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

viscid gale
#

Does anyone know if heroku stopped working as discord bot host service?
@viral timber so u just didnt like host it urself?

#

strange

viral timber
#

I know itโ€™s just for trying the bot, and I still have hours

earnest phoenix
#

Self host is worse

viscid gale
#

xD jkjk not everyone will have it on the mercy of their laptop

quartz kindle
#

@earnest phoenix there was a bug

viscid gale
#

self host, well if electricity goes then yea

earnest phoenix
#

@quartz kindle Oh so you beat my function by 300ms?

quartz kindle
#

something like that ye

earnest phoenix
#

Time to write a better one

viscid gale
#

what r yall racing about?

quartz kindle
#

let me test yours again

faint prism
#

Efficiency

viscid gale
#

ooh a challenge????

#

yeaaa ik... about what

#

what result or function they tryin to see who cud get done more efficiently?

earnest phoenix
#

@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

viscid gale
#

add items to inventory huh

quartz kindle
#

@earnest phoenix looks broken

faint prism
#

how efficient is find()?

earnest phoenix
#

Wot

viscid gale
#

can i get an example of the params pls

#

i wanna join :}

faint prism
#

with a for { Array.find() } wouldn't it be O(N^2)?

earnest phoenix
#

@quartz kindle It's not broken, i used itemId not itemid

quartz kindle
#

ah

#

lemme fix

viscid gale
#

can i get an example of the params pls
..^^

boreal iron
#

Somewhere Around there

#

Should be self explaining

quartz kindle
#

@earnest phoenix still not working for me lul

viscid gale
#
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
#

@earnest phoenix still not working for me lul
@quartz kindle What's the output?

quartz kindle
#

"0,1,2:NaN,3,4:NaN"

faint prism
#

O(N^2)

quartz kindle
#

im also using itemid as number btw

#

not strings

#

but i can change it

earnest phoenix
#

Tim, itemId should be strings in my function lol

#

The original idea was itemId as string and amount as number

boreal iron
#

Yeah since he just used numbers as placeholders

#

Expect the itemid to be a real string

sweet sand
quartz kindle
earnest phoenix
#

Huh, it only took me 1300ms to execute it 999999 times

quartz kindle
#

wait, i removed the string = function()

earnest phoenix
#

Hmm

#

I think Array.prototype.find() is slow

sweet sand
#

Someone help me?
every time i log in this happens

quartz kindle
#

@earnest phoenix your previous version

viscid gale
#

addItemsToInv([{ itemid: "2", amount: 1 }, { itemid: "1", amount: 2 }], "1:4,2:3") = "0,1"

earnest phoenix
#

@quartz kindle What was the previous version again?

viscid gale
#

this is gonna take me a bit to understand FOR SURE what's going on LMAO

quartz kindle
#

lmfao

earnest phoenix
#

What the fuck did you use

quartz kindle
#

@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(",");

}

boreal iron
#

@viscid gale go to the message I mentioned and take a look at the convo between ChickenDev, Voltrex and me

earnest phoenix
#

Hmm

quartz kindle
#

@boreal iron what was your version of the function?

boreal iron
quartz kindle
#

oh mb

boreal iron
#

I linked my function a few messages above

#

Oh still in clipboard

quartz kindle
#

ah found it

boreal iron
#

But remember it will not result items in the string argument if they do not exist in the array

hollow sedge
boreal iron
#

Which was an issue of misunderstanding on my side

quartz kindle
#

ye i saw it now, it only returns changes

boreal iron
#

Not sure test it out Cloudfox

quartz kindle
boreal iron
#

Canโ€™t test it atm

hollow sedge
#

alright

boreal iron
#

@quartz kindle gonna fix that tomorrow and beat you lmao

hollow sedge
#

nvm

boreal iron
#

Oh tomorrow is already today nvm

#

At least in my time zone

quartz kindle
#

@boreal iron xD

boreal iron
quartz kindle
#

lmfao

boreal iron
#

Oof thatโ€™s getting difficult

slender thistle
#

What in the name of my disappearing api.html is going on here

boreal iron
#

U better donโ€™t think about it

slender thistle
#

True

boreal iron
#

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

viral plover
#

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.

quartz kindle
#

international feeding

proven lantern
#

what does it look like when it works and doesn't work?

faint prism
#

What are you all doing? sorting?

viral plover
quartz kindle
#

we should post the sample input and desired output and have a performance ranking of the different functions made by people

boreal iron
#

Hmm later that day

#

Think you can add lots of blocks on the benchmarking site

#

Just renaming the functions to our Discord names

proven lantern
#

i would win

quartz kindle
#

actually

#

make it a hidden ranking

#

where we cant see what other people did

#

we can only see its performance

boreal iron
#

Think thereโ€™s not much to more to optimize seeing the last results

quartz kindle
#

so we can try guessing what other people did and try to beat them

proven lantern
#

@viral plover the resolve() method should pass the thing you want the promise to return

boreal iron
#

Hmm a funny idea tho Tim

#

We should do that

viral plover
#

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.

drifting wedge
#

if i have a clear command
does it like get denied?
i dont really have a ratelimit thing

reef carbon
#

<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.

ionic dawn
#

yeah the image should load

#

if the image route is correct ofc

silver lintel
#

if i have array ['thing1', 'thing2', 'thing3'] how would i enter it in a function so it would be function(thing1, thing2, thing3) {}?

earnest phoenix
#

hi

#

is there giveaway bot which make me control the winners

#

@silver lintel

silver lintel
#

so biased giveaways?

#

and this isnt the channel to ask

#

and dont mention people

earnest phoenix
#

ok

#

but some moved me there lol

ionic dawn
#

function (value1, value2, value3){
value1 = array[0]
}

#

or somethin like that?

#

idk

silver lintel
#

can i use like function.apply(array)?

#

does that work?

earnest phoenix
#

and this isnt the channel to ask
@silver lintel where to ask

viral plover
#

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.

quartz kindle
#

@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

earnest phoenix
#

@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 OMEGALUL

quartz kindle
#

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

earnest phoenix
#

Yea

#

But idk why we are doing a competition anyways OMEGALUL

quartz kindle
#

for fun

#

and for my ego boost

#

lmfao

earnest phoenix
#

And to see who's da big brain

#

But does it matter really OMEGALUL

quartz kindle
#

does anything matter really?

#

i made another one using different methods, still not good as the first one tho

earnest phoenix
#

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?
quartz kindle
#

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

earnest phoenix
#

thank you

#

@quartz kindle Clap

quartz kindle
#

xD

earnest phoenix
quartz kindle
#

why client.emit("ready", client);?

earnest phoenix
#

idk, help me

quartz kindle
#

remove that

earnest phoenix
#

remove that
@quartz kindle Can you check my message again?

quartz kindle
#

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

earnest phoenix
#

Can you edit it and send it to me?

quartz kindle
#

no sorry

proven lantern
#

can i update the typing status for my bot in a channel? so it says BOT is typing... in the channel

blissful coral
#

Doesn't this mean I exceeded the total logins

#

in a day

quartz kindle
#

@proven lantern yes

#

@blissful coral not necessarily

blissful coral
#

It works on my other bot same sharding

#

but this one doesn't

quartz kindle
#

do you have fetchAllMembers on?

blissful coral
#

No

proven lantern
#

@quartz kindle does discordjs have a function that lets me set it?

quartz kindle
#

add a client.on("debug") in your shards

#

see what they log

#

@proven lantern yes

#

although djs's version of it is weird af

blissful coral
#

what is the -- for pm2 to not auto restart

quartz kindle
#

tbh the entire "typing" api is weird af

proven lantern
#

i was looking at Channel first

quartz kindle
blissful coral
earnest phoenix
#

client.emit(<event>, callback) @blissful coral

#

This is how it works

blissful coral
#

ah

#

I don't know where the error is

#

So I do it for each one?

earnest phoenix
#

It literally says

blissful coral
#

I see I see

earnest phoenix
#

222th line on bot.js

#

PepegaBlind

blissful coral
#

Which is

#
client.on('debug')
#

I noticed

#

What I did

quartz kindle
#

just do client.on("debug",console.log)

#

i didnt sent the full version assuming you knew how to use it lul

blissful coral
#

Yeah fuck pm2 autorestart

#

LMAO

quartz kindle
#

yup, limit exceeded xD

proven lantern
#

await msg.channel.startTyping(); blocks forever. lol

quartz kindle
#

exactly

#

thats why i said djs's version of it is weird af

proven lantern
#

that is many confuse

quartz kindle
#

yup

proven lantern
#

5 confusing 3 me