#development

1 messages · Page 1367 of 1

rocky hearth
#

Can I also extend Object?

quartz kindle
#

yes

rocky hearth
#

wooh!! that is cool

earnest phoenix
#

Array chunking function
1:

function chunkArray(array, splitBy) {
    let thisArr = array;
    let newArr = [];
    for (let i = 0; i < thisArr.length; ++i) {
        let cAL = Math.ceil(parseInt(thisArr.length) / parseInt(splitBy));
        let nac = new Array(cAL);
        for (let j = 0; j < parseInt(cAL); j++) {
            nac[j] = thisArr.slice(0, parseInt(splitBy));
            thisArr.splice(0, parseInt(splitBy + i));
        }
        newArr.push(nac);
    }

    return newArr[0];
}```

2:
```js
function chunkArray(array, splitBy) {
    return Array.from({
            length: Math.ceil(array.length / splitBy)
        }, (a, r) => array.slice(r * splitBy, r * splitBy + splitBy));
}```
@quartz kindle Which do you think is the fastest
rocky hearth
#

obj.isEmpty() 😎

#

will that also work for class instances?

#

If I extend Object, how node will use mine extended Object?

quartz kindle
#

@earnest phoenix the first one looks very wrong

#

what is the function supposed to do exactly?

#

chunkArray([1,2,3,4,5],2) = [[1,2,3],[4,5]]?

fierce shell
#

Looz

earnest phoenix
#
chunkArray([1, 2, 3, 4, 5], 3); // [ [1, 2, 3], [4, 5] ]```
quartz kindle
#

ah so splitBy is max items per chunk

earnest phoenix
#

Yes

quartz kindle
#

still the first one looks very wrong, looks like it would produce duplicated results

earnest phoenix
#

It doesn't lmao

#

@quartz kindle can you check you DM for once

quartz kindle
#

i dont help people in dms

earnest phoenix
#

😦

#

@quartz kindle bro <html> link

quartz kindle
#

did you google "html img tag"?

earnest phoenix
#

ya cant find any thing

quartz kindle
earnest phoenix
#

Oo

rocky hearth
#

lol

sudden geyser
#

Google is your best friend.

#

Learn to abuse him

rocky hearth
#

*it

drifting wedge
#

how can i make an html js function to show html

earnest phoenix
#

Wot

drifting wedge
#

and how can i use switches with js to use mongo

rocky hearth
#

inject html code in a string, to dom elements

earnest phoenix
#

@quartz kindle Did you figure it out yet

rocky hearth
#

if that works, than whats the issue?

quartz kindle
#

@earnest phoenix the first one modifies the original array

#

the second doesnt

earnest phoenix
#

@earnest phoenix the first one modifies the original array
@quartz kindle But which is faster?

quartz kindle
#

i would say the second should be faster

#

because the first looks weird

earnest phoenix
#

(First is faster somehow LULW)

quartz kindle
#

how did you measure it

earnest phoenix
#

Measure how fast it's?

quartz kindle
#

yeah

#

because the first one is deleting the original array

earnest phoenix
#

Calling both 999999 times LULW

quartz kindle
#

just to make sure repeated runs are not being made to an empty array

still merlin
#

Code it

#

What lib?

rocky hearth
#

search djs guide

surreal sage
#

How to catch errors without using try...catch?

rocky hearth
#

discord.js

surreal sage
#

@covert gale use if() and see if the message author id is the same as yours

#
if (message.author.id === "...") {
    /* code */
}```
still merlin
surreal sage
#

How to catch errors without using try...catch?

quartz kindle
#

@earnest phoenix the first one is 3 times slower for me

#

lmao

sudden geyser
#

do logical checks beforehand, promises over throwing, etc.

quartz kindle
surreal sage
#

@sudden geyser u talking to me?

sudden geyser
#

yes

surreal sage
#

no idea what ur talking abt

sudden geyser
#

How to catch errors without using try...catch?
?

surreal sage
#

yea

#

do logical checks beforehand, promises over throwing, etc.
@sudden geyser no idea what this is about

quartz kindle
#

there are only 2 ways to catch errors
try catch for sync code
.catch for async code

#

there isnt any other way to catch errors

#

unless you use something hacky like a global promise rejection handler

#

which is a bad idea

surreal sage
#

i found it

harsh blade
#

When i react to my suggestion, it should change the message to be "accepted" but nothing happens wheni react. no errors in console too
Heres the code for the reacting stuff

surreal sage
#

thanks

harsh blade
sudden geyser
#

Logical checks = checks you do before doing the actual thing that may throw.
Promises over throwing = myPromise().then(...).catch(...)

surreal sage
#

didn't work oop

#
async function sendTheTestMessage() {
                    collected_v1.first().mentions.channels.first().send(
                        new Discord.MessageEmbed()
                            .setTitle("Test Message")
                            .setColor("#738ADB")
                    )
                }

                sendTheTestMessage().catch(err => {
                    console.log(true)
                })```
#

i'm trying to let it detect a error

quartz kindle
#

@harsh blade you're still not showing where you're getting emojiKey from

surreal sage
#

i'm trying to let it send in a channel it cant send it and let it give it a error it can detect*

quartz kindle
#

@surreal sage the promise is being left in the limbo

#

you need to return the promise to catch it from outside the function

surreal sage
#

what

#

what

#

what do you want me to return

#

want me to put return infront of collected_v1?

harsh blade
quartz kindle
#
function a() {
  asyncFunction()
}
function b() {
  return asyncFunction()
}

a().catch() // error catch of undefined
b().catch() // works
#

if you dont return anything, it returns undefined by default

#

and cant use .catch on undefined

surreal sage
#

ah

#

works

#

thank you!

quartz kindle
#

@harsh blade is the emoji removed?

#

when you react

harsh blade
#

nope

surreal sage
#

@quartz kindle Now it's in a catch block, how do i stop the whole code?

quartz kindle
#

what do you want to stop? show code

surreal sage
#
                async function sendTheTestMessage() {
                    return collected_v1.first().mentions.channels.first().send(
                        new Discord.MessageEmbed()
                            .setTitle("Test Message")
                            .setColor("#738ADB")
                    );
                }

                sendTheTestMessage().catch(err => {
                    setup.edit(
                        new Discord.MessageEmbed()
                            .setTitle("Logging Setup")
                            .setColor("#738ADB")
                            .setDescription("The bot wasn't able to send a message in <#" + collected_v1.first().mentions.channels.first().id + ">.\nTry fixing the permissions.")
                    )
                })```
#

I want it to stop after the .edit function is called

#

return; doesn't work

quartz kindle
#

you cant

#

async code runs in parallel do the rest of your code

#

you need to bring it back to the main code by using await

#

and using try catch

surreal sage
#

That didn't work

#

Already told you

quartz kindle
#

then you did it wrong

#

show what you did

#

@harsh blade does the console.log(emojiKey) work?

surreal sage
#

i just did js try { /*code*/ } catch (err) { /*code*/ }

#

the error is the DiscordApi something

#

this one

midnight blaze
#

c est bien ca, mon pot

quartz kindle
#

show the code you put in there

#

because promises can only be caught by try catch if they are awaited

#

if they are not awaited, try catch wont catch it

surreal sage
#

ok nvm

harsh blade
#

@harsh blade does the console.log(emojiKey) work?
@quartz kindle Nope

surreal sage
#

jesus christ

midnight blaze
#

montre le

surreal sage
#

also

quartz kindle
#

@harsh blade do you have any error in your logs?

cloud pebble
#

About how long did it take you guys to get the members intent? Just wondering cos I can’t release an update without it DogeKek

harsh blade
#

Nope

surreal sage
#

why does it allow this: ```js
.then(somethin => [

])instead of js
.then(somethin => {

})```

harsh blade
#

no errors

surreal sage
#

vsc doesn't give a error to that

quartz kindle
#

@surreal sage the first one tells the function to return an array

surreal sage
#

so you could basicly const or var that function and get a array?

quartz kindle
#

yes

#

arrow functions dont need a full function block to work, they have a shortcut to immediately return a value

#

for example (a => true) returns true, the same way as (a => { return true }) does

ancient nova
#

guys how long does ytdl error 246 rate limit last

#

does it block your ip forever?

midnight blaze
#

forever

quartz kindle
#

no idea

ancient nova
#

WAIT REALLY?

midnight blaze
#

your ip get deleted

ancient nova
#

no

#

it doesn't

quartz kindle
#

likely a few hours

ancient nova
#

oh that's good

#

I'm not sure why I got that error though

#

I switched to a vps from self hosting yesterday

harsh blade
#

Also. when running status command, it cant find my staff role? how can i use the ID of that role? any help?

ancient nova
#

and I got that error

#

I've never had that issue while self hosting the bot

earnest phoenix
#

@earnest phoenix the first one is 3 times slower for me
@quartz kindle Oh, yea i tested it incorrectly lol (I made both of the functions, but the first is old, guess when i writing the second one i was evolved)

ancient nova
#

does anyone know why that might be?

earnest phoenix
#

I also thought the second one would be a lot faster

solemn latch
#

Ratelimits are just ratelimits

#

You'll get them anywhere you pass a ratelimit

ancient nova
#

but the thing is, I never had that issue before switching to a vps

#

and I'm pretty sure after switching not many people used the music commands

solemn latch
#

🤷‍♂️

ancient nova
harsh blade
#

my bot can't get my staff role info. any help? i wanna use the ID instead of the role name

ancient nova
#

I literally have no idea

#

and I'm crying inside already

#

I tried everything

solemn latch
#

Music bots commonly get ratelimited

#

Its part of having a music bot

ancient nova
#

I've read that 429 error is blocking your IP permanently

#

is that true

solemn latch
#

Look at the YouTube api ratelimits

quartz kindle
#

@earnest phoenix should we try to make it even faster?

#

lmao

earnest phoenix
#

A competition? Hell yea

ancient nova
#

@solemn latch but do you have any idea why did it rate limit just after switching to a vps

harsh blade
solemn latch
#

Well, ips are not use once and done. Someone had your vps's ip before you. @ancient nova
Maybe that ip was used for a music bot too and got ratelimited before you got it 🤷‍♂️

#

Or people ran a few thousand songs after you swapped to a vps

ancient nova
#

so

solemn latch
#

Again, ratelimiting is super common in music bots

ancient nova
#

using a vps doesn't give you privacy

solemn latch
#

You'll have to deal with this frequently

#

Nothing on the internet is private

#

The ip you have now is only yours now however

#

It was someone elses.

ancient nova
#

you make me think that self hosting was safer than using a vps

solemn latch
#

This is true at home too

ancient nova
#

so the ip the vps gave the server now is only mine?

solemn latch
#

Right now it is yes. Assuming its a proper vps

ancient nova
#

I see

#

I'll try waiting til the rate limit expires

solemn latch
#

Before you had it, someone else rented it. Its how the internet works for everyone

ancient nova
#

if I get rate limited again

#

I'm gonna switch back

#

to self hosting

solemn latch
#

Music bots get ratelimited a lot either way

#

And you'll need to deal with it either way

ancient nova
#

it was worse, and used a lot of my pc's space but at least I didn't get rate limited

quartz kindle
solemn latch
#

The ratelimits the exact same no matter where you host it

earnest phoenix
#

🗿 What the fuck

ancient nova
#

but I never was rate limited while self hosting

quartz kindle
#

idk

ancient nova
#

that is the thing that makes me mad about being rate limited

quartz kindle
#

let me check if there is anything wrong lmao

harsh blade
earnest phoenix
#

How can i set the transparency of rectangle in canvas?

quartz kindle
ancient nova
#

I'm gonna go try a few more things, I'm pretty sure if I make a new key using a different IP then the rate limit will reset

quartz kindle
ancient nova
#

I'll try that

earnest phoenix
#

thank you @quartz kindle senpai

#

its work

harsh blade
#

TIm can u help

ancient nova
#

tim is getting overwhelmed lol

quartz kindle
#

@harsh blade your code is very confusing and all over the place, there could be many errors elsewhere

#

add more console.logs and see until where the code works

pale vessel
#

@quartz kindle can you try this?```js
function chunk(arr, max) {
const newArr = [];
arr.map((x, y) => y == 0 ? newArr.push([x]) : y % max ? newArr[newArr.length - 1].push(x) : newArr.push([x]));
return newArr;
}

chunk([1,2,3,4,5,6,7,8,9,10,11], 4); // [ [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ], [ 9, 10, 11 ] ]```

quartz kindle
pale vessel
#

lmao

quartz kindle
#

i did some changes to mine

earnest phoenix
#

Wtf

#

HOW

BOTTOM TEXT

#

🗿

quartz kindle
#

lmao

#

let me try something else

pale vessel
#

what about this ```js
function chunk(arr, max) {
const newArr = [];
arr.map((x, y) => y % max ? newArr[newArr.length - 1].push(x) : newArr.push([x]));
return newArr;
}

chunk([1,2,3,4,5,6,7,8,9,10,11], 4); // [ [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ], [ 9, 10, 11 ] ]```

quartz kindle
pale vessel
#

🗿

quartz kindle
#

i tried something else and got this

#

lmao

pale vessel
#

wack

quartz kindle
#

so i guess my first idea still wins by far

pale vessel
#

what about this eval ```js
function chunk(arr, max) {
return arr.reduce((x, y, z) => z % max ? [...x.slice(0, -1), [...x[x.length - 1], y]] : [...x, [y]], []);
}

chunk([1,2,3,4,5,6,7,8,9,10,11], 4); // [ [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ], [ 9, 10, 11 ] ]```

#

this is funky af

#

i'm just keen to see the numbers

quartz kindle
#

lmao

pale vessel
#

nice

#

is .concat() faster?

quartz kindle
#

doubt it

#

havent tried using it

cinder patio
drifting wedge
#

guys

#

luca is chad

faint prism
#

Would it be faster to start from the end of the array

quartz kindle
#

@cinder patio can you paste it as text so i can run it here?

cinder patio
#
function chunk(array, amount) {
  const res = [];
  for (let i = 0; i < array.length; i += amount) {
    if (i > array.length) i = array.length;
    res.push(array.slice(i, i + amount));
  };
  return res;
};
quartz kindle
#

lmao what

cinder patio
#

Maybe my PC is faster in general

quartz kindle
#

ye probably

cinder patio
#

give me your function

quartz kindle
#

whats your browser?

cinder patio
#

Chrome

earnest phoenix
#

He just has a better gaming chair

quartz kindle
#

this is mine

#
function chunkArrayTim(array,splitBy) {
    let a = [[]];
    for(let i = 0; i < array.length; i++) {
        let index = a.length-1;
        let item = array[i];
        if(a[index].length === splitBy) {
            a.push([item]);
        } else {
            a[index].push(item)
        }
    }
    return a;
}
pale vessel
#

a

cinder patio
pale vessel
#

how do i become an epic coder

quartz kindle
#

interesting

#

i read somewhere that array.slice() has heavy optimization implications

#

im using brave browser, array.slice() is extremely slow for me

earnest phoenix
#

I wasn't expecting that kind of thing to be that fast

#

Bruh moment

cinder patio
#

oo maybe

quartz kindle
#

let me test on anothe rbrowser

#

MS edge

#

LMFAO

pale vessel
#

slow boi

quartz kindle
#

browser optimizations >>>> code optimization

solemn latch
#

Just convince all your users to use the right browser

quartz kindle
#

xD

#

well if we're gonna do performance competitions like this, i guess we need to have separate rankings for every single browser

pale vessel
#

yes, fastest IE benchmark

quartz kindle
#

by second method that uses array.slice()

#

this got 600ms on brave

earnest phoenix
#

@quartz kindle Try this

function chunkArray(array, splitBy) {
    let bruh = 0;
    return array.reduce((acc, current, i) => acc[bruh].length === splitBy ? (acc.push([current]), bruh += 1, acc) : (acc[bruh].push(current), acc), [
        []
    ]);
}```
quartz kindle
#

@earnest phoenix interesting

earnest phoenix
#

1 second? Fuck that's worse go back

quartz kindle
#

but its fast in brave/chrome

#

lmao

#

almost as fast as mine and google's

#

edge is just shit

earnest phoenix
#

The one google showed is from stack overflow lmao

quartz kindle
#

lmao

cinder patio
#

it's not?

earnest phoenix
#

[I literally see it everywhere]

pale vessel
#

more like a general concept

cinder patio
#

yea... it's a common way to it

earnest phoenix
#

Yea but talk about original

pale vessel
#

i mean if it's fast...

#

why do you want it to look unique

earnest phoenix
#

¯\_(ツ)_/¯

drifting wedge
#

how do i get input from an html form with wtforms flask and put it into python

#

ping with resposnesss

solemn latch
#

I've noticed a trend.
Theres actually a ton of python users here. But none of them sit here to help each other.

#

Python users don't like helping each other KEKW

drifting wedge
#

i do sometimes!

solemn latch
#

Most of the time i see you answering a question its because you where here asking a question yourself

#

I make sure to go out of my way to come here and help. Seems tim and a few other js users do.

woven burrow
#

it sad that I use a mobile app to develop my bit lmfao

#

*bot

amber sedge
#

Python users don't like helping each other KEKW
@solemn latch lol truth

#

But I am js guy.. not python so no worries

earnest phoenix
#

it sad that I use a mobile app to develop my bit lmfao
@woven burrow Discord Bot Maker or something?

#

Can someone help me im trying to get my bot dm's to go into a channel in my discord. Im kinda lost on how to do that. Thanks

amber sedge
#

it sad that I use a mobile app to develop my bit lmfao
@woven burrow btw I host my bot on my mobile

woven burrow
#

@woven burrow Discord Bot Maker or something?
@earnest phoenix yes DBD

amber sedge
#

Can someone help me im trying to get my bot dm's to go into a channel in my discord. Im kinda lost on how to do that. Thanks
@earnest phoenix what language ?

drifting wedge
#

alr python nerds ping me for help

solemn latch
#

Kek

woven burrow
#

@woven burrow btw I host my bot on my mobile
@amber sedge what app?

earnest phoenix
#

{I literally coded my entire bot on mobile}

#

English

solemn latch
#

Ay

amber sedge
#

@amber sedge what app?
@woven burrow in mobile terminal

#

English
@earnest phoenix ok get Outta here

woven burrow
#

Mhmm

solemn latch
#

Best programming language

#

English

earnest phoenix
#

Bruh lmao, joke .js
Have not been asleep sorry

amber sedge
#

Try using listeners on ur bot dms and send the same in channels

#

Ig

#

I'm not that expert

#

Sorry

solemn latch
#

You can just check if the type is a dm

#

On any message

lethal pine
#

Hey can somebody help me how to add mongodb in discord.py

amber sedge
#

Try using listeners on ur bot dms and send the same in channels
@amber sedge it's like say command

earnest phoenix
#

Imagine quoting yourself

drifting wedge
#

@solemn latch noone ever needs help with python

#

thats why

#

check if guild is none

earnest phoenix
#

Hey can somebody help me how to add mongodb in discord.py
If no one needs help with python then is this guy a joke to you

drifting wedge
#

who is he

#

i dont see it lol

#

ping meeeee for python helpppppppp

earnest phoenix
solemn latch
#

Kek

cosmic forum
#

If anyone needs any hosting for their bot, feel free to DM me. I have an Ubuntu server ready.

pale vessel
#

too nice

solemn latch
#

Ay

young flame
#

hhhhhh

#

@cosmic forum sure

solemn latch
#

I bought a vps server and didn't want it within 10 minutes and I still don't feel comfortable giving it to random people

young flame
#

that's very generous of you

solemn latch
#

So it'll sit there doing nothing

young flame
#

yeah

#

maybe when my self hosting fails

#

but right now it hasn't failed me because my has been online for over a month lmao

pure lion
#

Is there a way to implement a music seek on ffmpeg

solemn latch
#

Probably

#

position (input/output)
When used as an input option (before -i), seeks in this input file to position. Note that in most formats it is not possible to seek exactly, so ffmpeg will seek to the closest seek point before position. When transcoding and -accurate_seek is enabled (the default), this extra segment between the seek point and position will be decoded and discarded. When doing stream copy or when -noaccurate_seek is used, it will be preserved.

young flame
#

woo is my dev senpai now smh

earnest phoenix
#

you need to keep a copy of the buffer/stream in your code and feed that to ffmpeg, ffmpeg can't receive signals but stdin, stdout and stderr

#

you would be seeking the local copy ofc

#

granted you can always just kill ffmpeg and spawn it with the arg woo sent

solemn latch
#

Seems fine to me no problems killing it every time

lethal pine
#

hey is there any plugin like nodemon for python

pale vessel
#

pm2

cosmic forum
#

@cosmic forum sure
@young flame Alright

restive furnace
#

@cosmic forum for real lol?

cosmic forum
#

yea

quartz kindle
#

the whole message or just the embed from it?

lyric mountain
#

get the message attachments -> foreach -> is it a MessageEmbed? -> delete

earnest phoenix
#

Message attachments does not include embeds

restive furnace
#

how could i parse this type of content into a map requester|example content|example2etc.

#

(i know i could just use json, but the clientside language is c++ and i don't really want to use 3rd module for that)

lyric mountain
#

Message attachments does not include embeds
oh yeah, just checked, embeds have their own space

bleak crypt
#

I want to code a bot that allows admins to add league of legends players. The bot will autoassign roles depending on the rank of the players.

earnest phoenix
#

Discord has told me that it cannot activate member intents and I have come to ask what you recommend me to make databases for members

bleak crypt
#

Ranked Solo
Gold 4

verbal kayak
#

parah

bleak crypt
#

The bot should then autoassign Gold role on the discord server

#

Lets say every 24h the bot will go in and update the page then renew the role (if needed)

#

Is this possible?

earnest phoenix
#

@drifting wedge Do you have any cheat-sheet/article that helps with array manipulation like array[::1] and stuff since I dont really understand those

#

I understand say array[1] but dont understand the ones where [::] is used

drifting wedge
#

1 sec lemme find something

quartz kindle
#

@bleak crypt its possible if the user runs a command and informs their league username and region

#

otherwise no

drifting wedge
#
a[::-1]    # all items in the array, reversed
a[1::-1]   # the first two items, reversed
a[:-3:-1]  # the last two items, reversed
a[-3::-1]  # everything except the last two items, reversed```
quartz kindle
#

account integrations are not accessible by bots, only through oauth2

drifting wedge
#

@earnest phoenix

earnest phoenix
#

So [::1] just clones the array?

quartz kindle
#

sqlite, mysql, postgre, mongodb, etc

earnest phoenix
#

With better-sqlite3 you can also?

umbral zealot
#

yes, that's sqlite.

bleak crypt
#

It should update the profile, and then assign a role

quartz kindle
#

you need to scrape the website

#

op.gg doesnt provide an api

#

but ideally you could use the riot api directly, which is what op.gg does in the first place

snow urchin
solemn latch
#

Feels lazy man

snow urchin
rocky hearth
#

Callum, what theme is that??

snow urchin
#

help me for the answer!

#

😄

restive furnace
#

sqlite, mysql, postgre, mongodb, etc
yo..u sa..id m..m..mysql?

snow urchin
restive furnace
#

is it lazyRouter?

snow urchin
#

is what lazy router?

#

u see the code

#

u see the error

bleak crypt
#

@quartz kindle Do you know someone who would be able to script it for me?

snow urchin
#

Callum, what theme is that??
@rocky hearth Atom one dark

quartz kindle
#

@bleak crypt many people here are more than capable enough, however the goal of this channel is to help developers with their own projects, so for example we could help you make it yourself. But if you're looking to hire someone, you need to go through other places, like other discord servers or even something like fiverr

snow urchin
#

or my dms

lyric mountain
#

sqlite would definitely be a go-to for member caching

#

it's absolutely as lightweight as you can get

quartz kindle
#

^ +1

#

you know, since better-sqlite3 is full synchronous, you can actually hack discord.js collections to use it

lyric mountain
#

I wonder what's the black magic behind sqlite

solemn latch
#

its ite

lyric mountain
#

like, compression but keeping IO speed?

quartz kindle
#

caching and indexing magic

restive furnace
lyric mountain
#

loop through it putting entries in a map

willow mirage
#

anyone know how to register a .js.org domain

lyric mountain
#

if c++ has something akin to java's stream then you can re-map it

#

anyone know how to register a .js.org domain
@willow mirage it'd be .org in this case

restive furnace
#

prob

lyric mountain
#

cname

restive furnace
#

just go make pr into the repo @willow mirage

solemn latch
#

intresting

willow mirage
#

@restive furnace i did, but didn't get it

solemn latch
#

then you cant make one if you got denied for one

earnest phoenix
#

u guys think this will work to auto update the status and the bot page on site?

restive furnace
#

@willow mirage then ur website is not hosted on github or has no content

willow mirage
#

@restive furnace no i mean

#

i dunno how to start

restive furnace
#

check up the tutorial on the js.org

willow mirage
#

yes did

#

but didn't get it

#

smh

restive furnace
#

its really clear

#

make website hosted on github, make a pr

karmic compass
#

does anyone know what this might mean? ```js
UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_CALLBACK]: Callback must be a function. Received Promise { <pending> }

solemn latch
#

callback must be a function, you cannot use a pending promise

willow mirage
#

nvm

#

imma use freenom

karmic compass
#

callback must be a function, you cannot use a pending promise
@solemn latch ```js
async function setStatus() {
const obj = await fetch('this url is replaced by a private one').then(x => x.json())
let newStatus = obj.displayStatus
client.user.setActivity(newStatus, { type: "PLAYING" })
}
setInterval(setStatus(), 20000)

#

how can i fix that in the context of this function?

quartz kindle
#

remove the ()

#

from setStatus

karmic compass
#

ah

willow mirage
#

or

#
setInterval(async() => {
  //code
}, 20000
solemn latch
#

the function may be used elsewhere, which is a common reason for doing it that way. or for cleaner code.

willow mirage
#

well yes

boreal iron
#

@quartz kindle How would u do different regex match statements for one var (effient)?

#
if( preg_match_all( "/(\d+)\s+(.*?):(.*?)\s+([0-9]+)\s+([A-Za-z0-9]{32})\(.*?\)\s(.*)|([0-9]+) players in total/", $data, $match_list, PREG_SET_ORDER ) != false )
elseif( preg_match_all( "/Player #([0-9]+) (.*) \((.*):(.*)\) connected/", $data, $match_list, PREG_SET_ORDER ) != false )

PHP example

#

throwing the result into $match_list and is only available if $data matches the whole regex pattern

quartz kindle
#

i'd figure out a way to do it without regex lmao

#

i hate regex

boreal iron
#

Not possible

#

For this case :/

quartz kindle
#

what is it supposed to do?

boreal iron
#

Checks if a received message (active socket connection) matches the pattern

quartz kindle
#

well yes

#

but like

#

an example of the string its supposed to match?

boreal iron
#

huh... posted the pattern above. lel u really dunno regex smirk

#

one second

#

Player #4 Player name (3) (1.2.3.4:2304) connected

#

Would match pattern 2 (in my example above)

#

It would create a $match_list (PHP) including all match groups I need

#

in this case, the ID (#4) the name (Player name (3)), the IP address and client port

quartz kindle
#

well i would just use a combination of indexOf (or the php equivalent) and string splitting on spaces lmao

boreal iron
#

With this whole complexity it's like impossible to strip/split each received message and check for all patterns

#

Those are just 2 examples... there are more than 14 patterns I have to check

#

And I need each group of each pattern every time if the match is positive

#

Let's ask a different question...

#

Let's say I'm using regex and u don't have to deal with...

#

lmao

#

How would u check if a string.match(pattern); is not null

#

of cause with a statement if(string.match(/pattern/) !== null) { true }

lyric mountain
#

what is sending that message?

boreal iron
#

I'm not wanna call string.match(/pattern/) again if the match is statement is true

#

Isn't there a way in JS like in PHP to define a var inside the statement I can use if statement is true?

#

Like if(result = string.match(/pattern/)) { result }

lyric mountain
#

my question?

boreal iron
#

?

#

my question?
Written a few lines above

lyric mountain
#

where? like, what is sending that connection message?

#

is it a website? a game of yours? another bot?

boreal iron
#

It's not a "connection" message. Just a message received due an emitted event

lyric mountain
#

I get it, but what is triggering it?

#

couldn't you just send a json payload instead of a direct message?

solemn latch
#

the createWebhook method is a promise right?

#

so you need to wait for it to create.

lyric mountain
#
{
  message: "Player #4 Player name (3) (1.2.3.4:2304) connected",
  id: 123,
  name: "Player #4",
  ip: "1.2.3.4:2304"
}
#

something like that

#

then get the attributes directly in the code

solemn latch
#

oh you are, your formatting is just crazy

quartz kindle
#

@boreal iron if(a = something()) a you want to do this in js or in php?

solemn latch
#

i cant with this formatting, i cant even tell whats going on

quick ridge
#

Well, after creating it, I can't delete it @solemn latch

quartz kindle
#

because in js it works fine like that, in php i didnt test

quick ridge
#

I can't delete it gets stuck in creation limit

boreal iron
#

nope, the message is an event reveived due a socket connection to a game server, the game server's protocol send the message and it's impossible to change the message

lyric mountain
#

ah, now we're talking

boreal iron
#

@boreal iron if(a = something()) a you want to do this in js or in php?
@quartz kindle lmao wanna know if that's possible in JS, like in PHP?

rocky hearth
#

can we get data of the user from the game he/she is playing?

quartz kindle
#

@boreal iron yes its perfectly possible

#

it works fine just like that

boreal iron
#

oh

solemn latch
boreal iron
#

didn't test this out yet, lol

quick ridge
#

what is that so ?

lyric mountain
#

that's a delete for the webhook itself

solemn latch
#

your not deleting your webhook, your deleting the webhookclient

quick ridge
#

there are diffrent ?

solemn latch
#

yeah

boreal iron
#

it works fine just like that
@quartz kindle Does a need to be defined outsite the statement? Guessing if(let a = function()) a will trigger an error...?!

lyric mountain
#

webhook is the endpoint
webhookclient is what interacts with it

#

it's like a car and a driver

#

without a car you can't have a driver

quick ridge
#

So what should I do to avoid getting a create webhook limit

lyric mountain
#

but you can have a car without a driver

sweet sand
#

When I use !play, my bot enters the voice channel but does not play the music:

Error: input stream: Status code: 429```
quartz kindle
#

@boreal iron yes, it needs to be defined outside

solemn latch
#

looks like you got ratelimited

sweet sand
#

ok

boreal iron
#

alright

solemn jolt
lyric mountain
#

So what should I do to avoid getting a create webhook limit
@quick ridge in my code I made a getOrCreateWebhook method, to put it in simple terms:

getOrCreateWebhook(String name) {
  //see if a webhook with the specified name exists
  if (exists) {
    return webhook.client
  } else {
    //create webhook
    return webhook.client
  }
}
#

sorry, idk how to write pseudocode

#

this way you'll have only one webhook for each name

solemn latch
#

clearReactions doesnt seem to exist 🤔

#

where did you get that from

humble wasp
#

Idk why this problem is comes

solemn latch
#

pull.config is undefined

solemn jolt
#

where did you get that from
@solemn latch i whrite this in v11

lyric mountain
#

undefined doesn't have a name property

solemn latch
#

v11 is deprecated

solemn jolt
#

But now i change it to v12

lyric mountain
#

v11 is as deprecated as lobotomy

solemn latch
#

okay, clearReactions doesnt exist in v12

lyric mountain
#

one does not simply use v11 code in v12

solemn jolt
#

Idk why this problem is comes
@humble wasp did you try
pull.name

solemn latch
solemn jolt
humble wasp
solemn latch
#

pull.aliases is undefined

solemn jolt
#

@humble wasp can you show me the command handler?

humble wasp
earnest phoenix
#

yoo, I got a quick question, how to check if a certain user in a guild is? (I wanna make a req giveaway system)

solemn latch
#

make sure every command has an .aliases or check if it is defined before running that line @humble wasp

#

if a certain user in a guild is what

humble wasp
solemn jolt
#
if (pull.aliases && Array.isArray(pull.aliases)) { pull.aliases.forEach(alias => bot.aliases.set(alias, pull.name)); }

@humble wasp use this

humble wasp
#

where

solemn jolt
#

Wait

#

And replace it to

if (pull.aliases && Array.isArray(pull.aliases)) { pull.aliases.forEach(alias => bot.aliases.set(alias, pull.name)); }
humble wasp
#

hmmm ok

#

it worked but

solemn jolt
#

it worked but
@humble wasp what?

humble wasp
solemn jolt
#

Go to this line

#

Show me the code

humble wasp
solemn jolt
#

This error in line 21

#

Wait

humble wasp
solemn jolt
#

@humble wasp replace line 22 to

let props = require(`./commands/${f}`);
humble wasp
#

you mean props no proops

#

right&

#

?

solemn jolt
#

Right my wrong

earnest phoenix
#

Instead of all that just do

jsfile.map(file => {
let command = require(`./commands/${file}`);
bot.commands.set(command.help.name, command), (command.help && command.help.aliases || []).map(alias => bot.aliases.set(alias, command.help.name));
});```
humble wasp
#

of all?

#

right?

earnest phoenix
#

No not all

humble wasp
#

Lines

solemn jolt
#

@humble wasp no

earnest phoenix
#

Are you trying to make a help command?

humble wasp
#

Yep

earnest phoenix
#

Say less

humble wasp
#

?

solemn jolt
#
let props = require(`./commands/${f}`);
#

Just need replace in line 21

humble wasp
solemn jolt
#

Did you replace in line 21?

humble wasp
#

yes

solemn jolt
#

Show me

humble wasp
solemn jolt
#

Hmm

#

There is no wrong i thing🤔

stark abyss
#
      message.channel.send(client.guilds.cache.get("773311952247062549").emojis.cache.map(x => x).join(' '));```
Can I set a limit on how many it gets? I only want 10
lyric mountain
#

sublist

unkempt ocean
#

everybody looks offline while checking user's presence. any ideas why?

lyric mountain
#

no GUILD_PRESENCES intent enabled

stable eagle
#
const data = role.members.map(m=>`${m.user.tag} (${m.user.id})`).join("\n"))```

For some reason this code is not showing the all members who have the role, why?
restive furnace
#

@humble wasp thats in the help command right? and help command is already in the commands folder? i suggest you learning relative paths AND also javascript atleast the basic knowledge.

earnest phoenix
#
return message.author.send(fs.readdirSync("./commands").map(command => {
let getCommand = require(`./commands/${command}`);
return Object.entries(getCommand).map(entry => entry[1] ? (entry[0] + ": " + entry[1]) + "\n" : "").join("\n");
}).join("\n"));``` all that could have been this line @humble wasp
#

@stable eagle It only shows the cached members

solemn jolt
#

@earnest phoenix what is the cached member?

earnest phoenix
#

discord.js has managers since the v12 update, it caches everything but slowly

stark abyss
#
   message.channel.send(client.guilds.cache.get("773311952247062549").emojis.cache.map(x => x).join(' '));```
> Can I set a limit on how many it gets? I only want 10
earnest phoenix
#

Array.prototype.slice()

solemn jolt
#

discord.js has managers since the v12 update, it caches everything but slowly
@earnest phoenix about this my bot have a 100 user in 250 server 😂

stark abyss
#

What if I want to divide the total number by 10 like send 10 then send 10 again until done because if i send more then x amount it will be smaller

earnest phoenix
#

I got 350k users in 187 servers

solemn jolt
#

@earnest phoenix ive got too

#

Bot bot don't show user

#

I type

client.users.cache.size
earnest phoenix
#

You have to reduce member count instead of using cache to measure user count

stark abyss
#

What if I want to divide the total number by 10 like send 10 then send 10 again until done because if i send more then x amount it will be smaller

earnest phoenix
#

What if there are 150 roles?

solemn jolt
#

this code is right

client.users.cache.size
quartz kindle
#

@boreal iron depends, not for regex xD

earnest phoenix
#

@solemn jolt Not for getting all users

solemn jolt
#

@earnest phoenix how i can get all user?

earnest phoenix
#
<client>.guilds.cache.filter(g => g.available).reduce((acc, current) => acc + current.memberCount, 0).toLocaleString();```
solemn jolt
#

Ok thank you👍

boreal iron
#

@quartz kindle

        rcon.on("message", async function(msg)
    {
        console.log(msg);
        
        let time = Math.floor(Date.now() / 1000);
        let matches;
        
        msg = msg.trim();
        
        if(matches = msg.matchAll(/(\d+)\s+(.*?):(.*?)\s+([0-9]+)\s+([A-Za-z0-9]{32})\(.*?\)\s(.*)|([0-9]+) players in total/gm))
        {
            for(let match of matches)
            {
                console.log(match);
            }
        }
        
        if(matches = msg.matchAll(/Player #([0-9]+) (.*) \((.*):(.*)\) connected/gm))
        {
            for(let match of matches)
            {
                console.log(match);

                                // process takes ~ 10s
            }
        }
      }

Am I correct... since it's an async function if I receive a message matches pattern 2 (...connected) taking around 10s to process, I can meanwhile reveive another message?

quartz kindle
#

the for loop takes 10 seconds?

#

wat

earnest phoenix
#

Big bruh moment

boreal iron
#

no the code to process the data will take a few seconds

quartz kindle
#

what does the code do?

boreal iron
#

not interessting in this case

quartz kindle
#

it depends on the code

boreal iron
#

just checking and processing a huge amount of data

quartz kindle
#

if the code is sync, it will block the process, regardless if inside an async function or not

earnest phoenix
#

What does that if statement even do

boreal iron
#

since async function(msg) is async it should continue reveiving messages, right?

#

oh

willow mirage
#

help me

boreal iron
#

What does that if statement even do
Just the fastest example I could write, Voltrex

willow mirage
#
div.others {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
}
boreal iron
#

if the code is sync, it will block the process, regardless if inside an async function or not
@quartz kindle hmm, the code will check and validate the regex group matches, and fetches/saves some stuff from/to the database

earnest phoenix
#

Can you show what the regex is supposed to match for example

boreal iron
#

sure one example RCon admin #9 (1.2.3.4:59603) logged in

#

It's receiving event messages prodcasted by the remote connection to a game server

#

It triggers a hell lot of events, players connecting/disconnecting, admin messages, player messages, server status... etc. all being prodcasted to all active remote connections

quartz kindle
#

as long as the database is async, it should be fine

boreal iron
#

not at this point yet... but ok

earnest phoenix
#

async more like the future

boreal iron
#

trying to convert the whole project from PHP to node, since PHP can't handle async

willow mirage
#

anyone help me :/

earnest phoenix
#

PHP is stupid lmao

boreal iron
#

and processing lots of messages will cause PHP to miss messages

#

lel you're just to young... it isn't

willow mirage
#

crying

boreal iron
earnest phoenix
#

Does string.explode() not look like a joke to you

boreal iron
#

it would be $array = explode(" ", $string);

#

lel

#

so no, it doesn't

earnest phoenix
boreal iron
#

not gonna make fun about the function names lmao

slender wagon
#

ejs or pug which one should i go for

earnest phoenix
#

ejs

boreal iron
#

anyway...

#

rcon.on("message", async function(msg) as long as all processes are inside the async function are async, too I'm still receiving messages

#

it doesn't let node wait until the process inside the async is done

#

hmm?

earnest phoenix
#

Do you like, want it to await one function until it's done then go to another?

boreal iron
#

nope, god... no

earnest phoenix
#

Wot

boreal iron
#

imaging receiving 10 messages per second, which takes a few seconds to process each and the code would need a promise for each

#

or 100 messages per second

#

or more

harsh blade
earnest phoenix
#

What exactly doesn't work?

#

Which version of discord.js are you using?

boreal iron
#

Do you like, want it to await one function until it's done then go to another?
@earnest phoenix As said rcon.on("message", async function(msg) needs to handle like lots of msg per second and needs to process the data async (not waiting for the code to end,success)

harsh blade
#

What exactly doesn't work?
@earnest phoenix -close in ticket does nothing but returns that error

earnest phoenix
#

@sand dune Do npm ls discord.js

boreal iron
#

Isn't it client.user.setPresence({ activity: { ... ? Not familiar with djs

earnest phoenix
#
client.on("ready", () =>{
         client.user.setPresence({
            activity: {
                name: "Use f!help",
                type: "PLAYING"
            }
        });
        });```
boreal iron
#

aye it is lmao

earnest phoenix
#

@earnest phoenix As said rcon.on("message", async function(msg) needs to handle like lots of msg per second and needs to process the data async (not waiting for the code to end,success)
@boreal iron Umm, using async in a function that does not resolve a promise is redundant and has not effect, i don't think this will solve, whatever issue you're having

boreal iron
#

Well then... how would u do it?
Imagine rcon.on("message", function(msg) { process msg }); will receive like 100 messages / second... the processing takes a few seconds

#

How to get it async?

crystal wigeon
#

hwo do you set the status to "listening"?

opal plank
#

check the snippet above, change PLAYING to LISTENING

#

¯_(ツ)_/¯

crystal wigeon
#

i tried

#

didnt work

opal plank
#

iirc only WATCHING is not available

cerulean ingot
#

hi
does anyone know how to insert an image with html?
i dont know html but im trying to submit my bot on top.gg and i want to add images

boreal iron
#

<img src="url" alt="" />

cerulean ingot
#

thank you

boreal iron
#

alt = name if url not found

earnest phoenix
#

@boreal iron Processing 100 messages with a sync function is still better, making it async might not be a good idea or just use an efficient code

#

However, sync or async you can't make this faster

opal plank
#

actually, my bad, watching isnt the one

#

@crystal wigeon

boreal iron
#

I fear missing a message if the process takes too long

harsh blade
crystal wigeon
#

it worked

harsh blade
crystal wigeon
#

it took time

#

to reflect changes

earnest phoenix
#

It can't miss a message

harsh blade
#

Any help?

opal plank
#

playing /watching /streaming are the fine ones

#

theres a fourth one

crystal wigeon
#

"LISTENING"

#

its "LISTENING"

opal plank
#

i cant remember which is it thats whitelisted

boreal iron
#

It can't miss a message
@earnest phoenix huh... that's what I don't understand at this point, coming from PHP lmao

opal plank
#

i might be mistaking shit with the user rather than the bot

#

ugh, i cant remember

earnest phoenix
#

All activity types are PLAYING | LISTENING | WATCHING | STREAMING | COMPETING

cerulean ingot
#

is there a way to get an image from my pc to google so i can use it in my html

#

All activity types are PLAYING | LISTENING | WATCHING | STREAMING | COMPETING
@earnest phoenix i dont think COMPETING is one

#

if so thats new

opal plank
#

theres one that cant be used on normal user accounts, i cant remember which

earnest phoenix
#

It's

opal plank
#

i think its watching

#

lemme double check rq

earnest phoenix
#

@boreal iron Node can't miss processing any message unless the event wasn't emitted which can't be the problem of your code

opal plank
#

ah, yes i was correct

#

WATCHING isnt available normally

#

though it is for users

earnest phoenix
#

Watching is still possible

opal plank
#

wrong

#

watching on user account is selfbot

#

or modifications to client

earnest phoenix
#

Hey shitass, wanna see me speedrun "proving you wrong"

opal plank
#

without mods? bet

harsh blade
#

Could someone help me?

boreal iron
#

It can't miss a message
@earnest phoenix Another issue I didn't tell u yet is, at the time the message is received, I'm creating a timestamp which is important to process the message
With a sync function I would receive the first message for example - takes a few seconds to process - then the next message.
But the 2nd message would have a "wrong" created timestamp since the code needed to wait until message 1 is processed.

opal plank
harsh blade
#

i need help with the bot getting role data

boreal iron
#

That's why I thought an async function in this case would solve this issue

#

Processing all incoming messages at the same time

earnest phoenix
#

@opal plank Were you talking about user accounts?

opal plank
#

though it is for users

#

speedrun failed? mmulu

earnest phoenix
#

I thought you were talking to the guy who asked about how he can set the listening activity to the bot

#

Like bots can't set watching activity

#

But you meant user accounts

restive furnace
#

oh so you're not selfbot? list every discord feature.

opal plank
#

i knew it was whitelisted for WATCHING, but i couldnt remember where

earnest phoenix
#

🗿

willow mirage
#

pls help me fix this shit

#
div.others:after {
    content: "";
    display: table;
    clear: both;
}

div.box {
    margin: 10px 0px;
    user-select: none;
    font-weight: 600;
    max-width: 300px;
    float: left;
    width: 33.33%;
}
earnest phoenix
#

Sorry can't unfuck CSS

opal plank
#

cant fuck with CSS 2

willow mirage
#

it is 3*

restive furnace
#

can't list every discord feature with CSS 42

boreal iron
#

@earnest phoenix what about my mentioned case

cerulean ingot
#

sorry another dumb question

earnest phoenix
#

@earnest phoenix Another issue I didn't tell u yet is, at the time the message is received, I'm creating a timestamp which is important to process the message
With a sync function I would receive the first message for example - takes a few seconds to process - then the next message.
But the 2nd message would have a "wrong" created timestamp since the code needed to wait until message 1 is processed.
@boreal iron Timestamps created is always correct, they run on different contexts which isn't related to the first one being processed

cerulean ingot
#

how do i edit the image size in html

#
<img src="https://cdn.discordapp.com/attachments/756294834226069557/773995599677620234/unknown.png" alt="" />

<img src="https://cdn.discordapp.com/attachments/756294834226069557/773995738349961226/unknown.png" alt="" />

<img src="https://media.discordapp.net/attachments/756294834226069557/773995822265663488/unknown.png" alt="" />

<img src="https://cdn.discordapp.com/attachments/756294834226069557/773996024770723840/unknown.png" alt="" />

<img src="https://cdn.discordapp.com/attachments/756294834226069557/773996268841598986/unknown.png" alt="" />```
earnest phoenix
#

Add attribute width and height

cerulean ingot
#

is it an int?

earnest phoenix
#

No

cerulean ingot
#

like 69px

boreal iron
#

better use a style="width: xxx; height: xxx;" tag

#

px, % etc.

cerulean ingot
#

see the thing is

boreal iron
#

Timestamps created is always correct, they run on different contexts which isn't related to the first one being processed
@earnest phoenix Well nope, thought so, too tested it and nope, the timestamp is effected

cerulean ingot
#

i just want to make the images fit

#

look

opal plank
#

using discord as CDN has to be some of the worst ideas you can have

cerulean ingot
boreal iron
#

fit to what?

harsh blade
cerulean ingot
#

like not be all over the place

#

dont know js sorry

boreal iron
#

U cant use JS

cerulean ingot
#

i was talking to @harsh blade

boreal iron
#

Put a line break after each image

cerulean ingot
#

but yeah i dont want the images to be all over the place

boreal iron
#

<br />

#

or 2 <br /><br />

#

however u like

tame kestrel
#

Oh if you want them to be aligned it would be more efficient to use css and create a column flex box or something

harsh blade
#

the error ocurrs when using the command -close

tame kestrel
#

Whatever ur doing .roles on is null

boreal iron
#

@earnest phoenix

    rcon.on("message", function(msg)
    {
        let time = Math.floor(Date.now() / 1000);
        let matches;
        
        msg = msg.trim();
        
        if(matches = msg.matchAll(/(\d+)\s+(.*?):(.*?)\s+([0-9]+)\s+([A-Za-z0-9]{32})\(.*?\)\s(.*)|([0-9]+) players in total/gm)) ...

If let's say the first received message takes 10s to process, the 2nd incoming message would have a timestamp + 10s, which is not correct if for example the 2nd message will be received 1s after the first one

harsh blade
#

Whatever ur doing .roles on is null
@tame kestrel i think the issue is with line 12

boreal iron
#

That's the issue I have to deal with... thought async would solve this

quartz kindle
#

@harsh blade i already told you before how to fix it

harsh blade
#

    let role = message.guild.roles.find(r => r.name.toLowerCase() == config.Ticket_Support_Role.toLowerCase());
quartz kindle
#

the issue is on line 15

#

use member instead of message.member

harsh blade
#

@harsh blade i already told you before how to fix it
@quartz kindle It broke again without any modifications

#

use member instead of message.member
@quartz kindle So just member.roles.sort

quartz kindle
#

@boreal iron async only enables asynchronicity, it doesnt automatically convert your code to async

boreal iron
#

hmm that's what I need to figure out how to deal with

quartz kindle
#

i'd need to see the code in question lol

boreal iron
#

there's no code more yet, as I said I'm converting it to node atm

#

There's no solution to deal with this issue in PHP, that's why I'm moving to JS

quartz kindle
#

then what's taking 10 seconds atm?

#

or was that just speculation?

boreal iron
#

let's say inside the statement if(matches = msg.matchAll(/(\d+)\s+(.*?):(.*?)\s+([0-9]+)\s+([A-Za-z0-9]{32})\(.*?\)\s(.*)|([0-9]+) players in total/gm)) there are 1000 lines of code taking around 5s to process the message

#

of course only if statement is true

harsh blade
#

Thank u sm tim

boreal iron
#

now imagine 2nd and 3rd message are incoming at the same time

#

the statement will also be true for example and each message needs 5s to be processed also

stark abyss
#
[
  '![LoliPat](https://cdn.discordapp.com/emojis/773317088873676822.webp?size=128 "LoliPat") ![LoliPat](https://cdn.discordapp.com/emojis/773317106346229850.webp?size=128 "LoliPat") ![BlushPat](https://cdn.discordapp.com/emojis/773317188811489300.webp?size=128 "BlushPat") ![NezukoPat](https://cdn.discordapp.com/emojis/773317233166123018.webp?size=128 "NezukoPat")  
]```
How would I only get emoji I want to put them into new array because 
  array.push(client.guilds.cache.get("773311952247062549").emojis.cache.map(x => x).join(' '));
that put everything in one element of array
earnest phoenix
#

Wot

crisp fable
#

put array.push into the map

stark abyss
#

like [' LoliPat LoliPat BlushPat NezukoPat ' ] instead of one emoji per element

crisp fable
#

oh

stark abyss
#

that's what happened

crisp fable
#

wait so

stark abyss
#

I don't want that and I tried that it didn't work correctly

crisp fable
#

what do you want it to be?

solemn latch
#

your only pushing one thing, you need to push for each element

stark abyss
#

One emoji in element of array

earnest phoenix
#

Why are you even pushing them anyway?

#

Just map them

stark abyss
#

I wanna be able to do more then that

earnest phoenix
#

[Wot]

grizzled raven
#

with documents looking like ```js
{
arrayObj: [{ IDs: ["123"] }]
}

how would i be able to find with a query if IDs has a particular ID?
stark abyss
#

array.push(client.guilds.cache.get("773311952247062549").emojis.cache.map(x => x).join(' '));
is only one element

earnest phoenix
#

Because you're joining them

solemn latch
#

^

stark abyss
#

oh

quartz kindle
#

@boreal iron it really depends on what the code will do. If its gonna be some super complex math or whatever, then its gonna lock everything up yes, unless you manually split it into parts by using setImmediate, but most likely you will be making IO operations like disk and network, those when run asynchronously wont lock the main thread, so you will be fine

earnest phoenix
#

@grizzled raven Depends on what the query belongs to

#

MongoDB?

boreal iron
#

@quartz kindle @earnest phoenix nvm async is working as it should lmao

harsh blade
grizzled raven
#

@earnest phoenix oh yeah forgot to specify lol

stark abyss
#

okay so I removed join and it now returns the huge object/collection

quartz kindle
#

@harsh blade yes, thats not how find works

boreal iron
#

it really depends on what the code will do. If its gonna be some super complex math or whatever, then its gonna lock everything up yes, unless you manually split it into parts by using setImmediate, but most likely you will be making IO operations like disk and network, those when run asynchronously wont lock the main thread, so you will be fine

yeah atm the code emittes the next message, the timestamp is called

#

logged it now and it's correct

quartz kindle
stark abyss
#

any other ideas?

harsh blade
#

Thanks

#

message.guild.roles.find(r => r.name === "Staff");
Something like that?

quartz kindle
#

yes

boreal iron
#

@quartz kindle

    rcon.on("message", async function(msg)
    {
        console.log(msg);
        
        let time = Math.floor(Date.now() / 1000);
        let matches;
        
        msg = msg.trim();
        
        if(matches = msg.matchAll(/(\d+)\s+(.*?):(.*?)\s+([0-9]+)\s+([A-Za-z0-9]{32})\(.*?\)\s(.*)|([0-9]+) players in total/gm))
        {
            for(let match of matches)
            {
                setTimeout(function() { console.log(time); console.log(match); }, 10000 );
            }
        }
        
        if(matches = msg.matchAll(/Player #([0-9]+) (.*) \((.*):(.*)\) connected/gm))
        {
            for(let match of matches)
            {
                setTimeout(function() { console.log(time); console.log(match); }, 10000 );
            }
        }
    }

Hmm the timestamp is correct and is called right at the moment the message is received even if the message needs (like in my example above) 10s to process

dark steeple
harsh blade
#

Im getting smarter

#

i swear lol

quartz kindle
#

@boreal iron setTimeout doesnt block the code

#

if you want to intentionally block the main thread, use a while loop lmao

boreal iron
#

oh hmm

#

good idea

quartz kindle
#
let time = Date.now() + 10000;
while(Date.now() < time) {}
boreal iron
#

aye

quartz kindle
#

that will give you 100% cpu usage for 10 secs

#

xD

boreal iron
#

ahh np the server can handle stress

harsh blade
#

Do emotes and symbols work in Get role scripts?

#

v11

#

i mean roles.find

feral aspen
#

.

opal plank
#

dotpost

lapis furnace
#

Guys i need a host pls

late light
#

yourself

opal plank
#

do you know how little that narrows it down? @lapis furnace

#

its like asking for a website

#

guys, give me a random website pls

lapis furnace
#

For the bot

opal plank
#

no shit

#

paid?

#

good?

#

free?

lapis furnace
#

Ya

opal plank
#

24/7?

lapis furnace
#

Paid and good

#

Ya

opal plank
#

none of the above?

#

Digital Ocean or preferably AWS

#

those are the ones i'd stick with

lapis furnace
#

Hmm

boreal iron
#

@quartz kindle

rcon.on("message", async function(msg)
    {
        console.log(msg);
        
        let time = Math.floor(Date.now() / 1000);
        let matches;
        
        msg = msg.trim();
        
        if(matches = msg.matchAll(/(\d+)\s+(.*?):(.*?)\s+([0-9]+)\s+([A-Za-z0-9]{32})\(.*?\)\s(.*)|([0-9]+) players in total/gm))
        {
            for(let match of matches)
            {
                while((Math.floor(Date.now() / 1000) - time) > 10) { }
                
                console.log(time);
                console.log(match);
            }
        }
        
        if(matches = msg.matchAll(/RCon admin #([0-9]+) (.*)/gm))
        {
            for(let match of matches)
            {
                console.log(time);
                console.log(match);
            }
        }
    });

1st msg matches statement 1
2nd msg matches statement 2

Shouldn't 1st msg log it's match to the console after 10s?

lapis furnace
#

Imma see

harsh blade
#

If u need free n good dm me

opal plank
#

definetly check AWS before

#

and then get your token stoles

#

free and good no exist, sorry

lapis furnace
#

I know

#

I m not looking for free

harsh blade
#

free and good no exist, sorry
@opal plank Awh ok ill shut down my company then :c

lapis furnace
#

XD

opal plank
#

oh, its YOURS

#

well even more reason to trust it

harsh blade
#

im currently hosting a bot for a guy which is in like 4k guilds

#

he told me xD

lapis furnace
#

Dm

opal plank
#

so you hosting one bot and now is a trustworthy company?

#

sounds about right

quartz kindle
#

@boreal iron < 10 not > 10

#

lmao

opal plank
harsh blade
#

so you hosting one bot and now is a trustworthy company?
@opal plank More like 20-30 atm

boreal iron
#

< 10 not > 10
of fuck... it happend to me, too

harsh blade
#

and around 20 mc servers too

opal plank
#

still small for what a big company is

#

i wouldnt trust a small host

#

specially one that claims to be free and good

harsh blade
#

Thats why we have trustpilot reviews

#

:D

boreal iron
#

@boreal iron < 10 not > 10
@quartz kindle hmm still same result... that's weird at this point

opal plank
#

im not even gonna reply to that

boreal iron
#

@quartz kindle Using while(true) stops the code at this point (to test of course), shouldn't it still receive the next message if async?

quartz kindle
#

no

#

it locks the whole thread

#

async is still single threaded

boreal iron
#

oh but assuming as mentioned above the code takes like 10s would probably lock the thread, too

quartz kindle
#

as i said, the code itself needs to be async

boreal iron
#

ok, taking my example above, how so?

quartz kindle
#

you know about the event loop right?

boreal iron
#

aye

quartz kindle
#

node.js runs on a big event loop

#

on every iteration of the event loop, all the js code that needs to be run will be run

boreal iron
#

yeah that's the reason I have to switch from PHp for this case

quartz kindle
#

once it completes the entire code, it goes to the next iteration and repeats the process

boreal iron
#

yeah... so I'm gonna need async database requests

dusk wyvern
#

@lapis furnace there are some really good tutorials on how to get a free host from WornOffKeys

earnest phoenix
#

When I do )send bruh it doesn't print anything:


@client.command()
async def send(ctx, *, message):
        if ctx.author.id == 726230248315813919:
                await ctx.message.delete
                await ctx.send(message)
        else:
                await ctx.send('Command not found.')
quartz kindle
#

when your js code is synchronous, like while(true), the event loop will not exit until it finishes running the current code

#

so it locks while its waiting for the while loop to complete

#

the entire loop never proceeds until it does

boreal iron
#

yeah ok makes sense now

quartz kindle
#

when you create async code

#

what it does is it marks it as a code that will "complete later"

#

so the event loop starts the async function until it reaches something that tells it to wait

#

when it does, it stops there, and continues to the next iteration of the event loop

#

and on every iteration it will check the asyn function again to see if now it is allowed to continue or not yet

opal plank
#

okay i give up

#

i require assistance

#

wtf is up with presences?

earnest phoenix
#

can someone help me?

#

my code and problem are posted above

boreal iron
#

Alright thx for the explanation

opal plank
#

when the presence array is one, ti detects fine, when its multiple, somehow it doesnt trigger, only when the game ends?

quartz kindle
#

so for example, if you do await new Promise(r => setTimeout(r, 5000))

opal plank
#

exbrain pls

quartz kindle
#

that will tell the code to wait come back 5 seconds later

#

so the code will basically be "can i run it now? no? ok. can i run it now? no? ok", as the event loop continues

#

until 5 seconds pass, and it can finally conitnue the function

dusk wyvern
#

@earnest phoenix what language is that

earnest phoenix
#

python

dusk wyvern
#

ah

#

not very experienced in py sorry :(

opal plank
#

break should escape the scope

earnest phoenix
#

nvm i fixed it

#

i dont need help

opal plank
#

@ tim mmulu

#

legit makes no sense, tis a simple loop

quartz kindle
#

the only way i see it could do that is if the name is not exactly that lmao

opal plank
#

my only assumption is somehow user doesnt exist

#

it always is though

#

ive been logging it

#

i did get a null user at one time though

quartz kindle
#

console.log presence.activities

opal plank
#

dont even know how that was produced tbh

#

yeah thats what im doing

#

still borked

boreal iron
#

@quartz kindle yeah and that’s my current issue with PHP - as it is of course not the right language for this purpose anyways -
It’s running an endless while loop as long as the socket connection is active and fetches each incoming message but if a message is incoming and the code still processes the previous one it just doesn’t react and the event message is missed forever

opal plank
#

the name is fine

#

i see that user can return null but that'd be if the user is not cached /

#

so it makes no sense to bork that way

quartz kindle
#

@boreal iron that shouldnt ever happen, unless php is really that shit

#

because if the thread is locked, the underlying network layer will wait for it

#

the machine's network driver wont feed it data until it can process data

boreal iron
#

There’s not such an event loop

#

There are frameworks like react PHP supporting this but not raw PHP

#

That’s why I’m moving this particular project to JS

#

As long as the process::input (the incoming message) is being processed or read/written all other incoming input is lost

#

Like u would open a file, putting a not-writeable on it’s settings and try to open and write the file meanwhile in a different editor