#development

1 messages ยท Page 1440 of 1

crimson vapor
#

sad

opal plank
#

do undefined.prototype.[null] see what happens pls

slender thistle
#

return ""

opal plank
#

i wonder if you can even do retarded shit like that

earnest phoenix
#

Error moment

opal plank
#

idk if js shields against smart idiot devs

#

smart for knowing what prototype even does

quartz kindle
#

undefined has no prototype

opal plank
#

stupid for doing idiot stuff

#

what about true/false?

earnest phoenix
#

Neither null

opal plank
#

trying to cause errors when undefined happens

earnest phoenix
#

Everything other than undefined and null has a prototype, i think

opal plank
#

true false dont

#

nor process

#

i just tried

#

there goes my idea of fucking with every empty array

#

can i legit not break shit with this?

quartz kindle
earnest phoenix
opal plank
#

oh good call

earnest phoenix
#

Wait what does Boolean.prototype.valueOf() even do

quartz kindle
#

returns the value

#

lol

opal plank
#

e.eval true.constructor = () => {return false};

#

this doesnt work and im sad

crimson vapor
#
       let dbData = readDB();
        dbData[collection][key] = data;
        writeDB(dbData);``` how can I make this look nice?
earnest phoenix
#

Uhh, is it not nice enough?

reef carbon
#

Uh oh no pg_hba.conf entry for host "71.234.227.103", user "root", database "exo", SSL off
This is what I get when I try to connect to my ubuntu postgresql database from popsql
does anyone know why?

crimson vapor
#

true

lyric mountain
#

Configure your hba file

#

It's in etc/postgresql/

#

Ig

#

On the bottom add 0.0.0.0 host

crimson vapor
#
const fs = require('fs');
const path = require('path')

class DB {
    constructor(path) {
        this._path = path.resolve(path);
        if(!fs.existsSync(this._path)) throw 'Specified path does not exist.'
        try {
            this._data = JSON.parse(fs.readFileSync(file, 'utf8'));
        } catch (err) {
            this._data = {}
            fs.writeFileSync(file, '{}', 'utf8');
        }
    }

    readDB() {
        try {
            return JSON.parse(fs.readFileSync(this._path, 'utf8'));
        } catch (err) {
            throw 'An error occured when reading from the DB\n' + err;
        }
    }

    _writeDB(data) {
        if(!data) throw 'Tried to write to DB without any data.'
        try {
            data = JSON.stringify(data);
            fs.writeFileSync(path.resolve(__dirname, 'tmp/data.json'), data);
            fs.renameSync('tmp/data.json', this._path)
            return true;
        } catch (err) {
            throw 'An error occured when writing to the DB:\n' + err;
        }
    }

    saveToDB(collection, key, data) {
        if(!collection) throw 'Tried to save to DB without a collection name'
        if(!key) throw 'Tried to save to DB without a key'
        if(!data) throw 'Tried to save to DB without an data'
        let dbData = readDB();
        dbData[collection][key] = data;
        writeDB(dbData);
        return true;
    }

    clearDB(boolean) {
        if(boolean !== true) throw 'Tried to clear DB without a true boolean.'
        writeDB({})
    }
}```
#

I think it looks good

reef carbon
quartz kindle
crimson vapor
#

fuck

lyric mountain
#

Follow digital ocean steps, their setup tutorial is good af

crimson vapor
#

ty

reef carbon
lyric mountain
#

Search in Google

crimson vapor
#

changed it to databasePath

lyric mountain
#

It'll be first 2 links

quartz kindle
#
if(!fs.existsSync(this._path)) throw 'Specified path does not exist.'
        try {
            this._data = JSON.parse(fs.readFileSync(file, 'utf8'));
        } catch (err) {
            this._data = {}
            fs.writeFileSync(file, '{}', 'utf8');
        }
``` you're throwing an error if it doesnt exist, then creating it if it doesnt exist
crimson vapor
#

o

lyric mountain
#

Postgresql setup ubuntu VERSION

crimson vapor
#

true I just assumed it was checking it had a readable data

#

ok I gtg eat

#

@ me if you have any other changes

reef carbon
#

this one?

lyric mountain
#

Oh my

#

Yes, it's that one

reef carbon
#

@lyric mountain It doesn't say anything about pg_hba.conf

#

it's just like how to create users, table, databases, etc

reef carbon
#

yeah

#

maybe it's the wrong article @lyric mountain

lyric mountain
#

What are you trying to setup?

reef carbon
#

my pg_hba.conf and postgresql.conf file to allow connections from popsql

lyric mountain
#

Did u follow their setup steps?

#

No need to ping btw

reef carbon
#

ok

#

I'll try that out

#

would the hostname of my database be the ip address?

#

@lyric mountain

lyric mountain
#

It'd be 0.0.0.0 ig

reef carbon
#

oh ok

lyric mountain
#

To accept all incoming connections

reef carbon
#

no but like in my popsql connection page

lyric mountain
#

Use 127.0.0.1 if you want to accept only local connections

reef carbon
#

I have popsql on my computer and the database is on my vps

lyric mountain
#

0.0.0.0 then

reef carbon
#

but then how would it know what vps to connect to?

#

wouldn't it need the vps ip

lyric mountain
#

The config would be in the vps

#

In your pc it'd be the vps' ip

reef carbon
#

ok

#

this is my pg_hba.conf connection section

lyric mountain
#

That'll accept only ipv6

reef carbon
#

I added host all all ::/0 md5

#

oh

lyric mountain
#

Use 0.0.0.0

reef carbon
#

0.0.0.0/0 ?

lyric mountain
#

No, only 0.0.0.0

reef carbon
#

ok

#

Uh oh connect ECONNREFUSED 207.246.87.164:5432 this is what I'm getting from popsql

lyric mountain
#

Is port 5432 open?

reef carbon
#

how do I check if it's open?

lyric mountain
#

Ufw status

reef carbon
#

it says status: inactive

#

should I do ufw allow 5432? I don't remember the exact command.

lyric mountain
#

You're running without firewall then

#

Well, idk if Ubuntu has another kind of built in firewall

#

Apart from ufw

reef carbon
#

I don't think it does

#

so how do I enable 5432?

lyric mountain
#

Anyway, that ain't the issue then

reef carbon
#

oh ok

lyric mountain
#

Hm

#

Have you configured your postgres config file

#

?

reef carbon
#

I can't connect to the database from psql either

lyric mountain
reef carbon
reef carbon
#

which part do you want to see?

lyric mountain
#

Is your postgres a fresh install?

reef carbon
#

no not really

#

probably like a week old

lyric mountain
#

That looks like some missing file

reef carbon
#

it'll work if I change it back

lyric mountain
#

If you do sudo -i -u postgres then psql does it connect?

reef carbon
#

no

#

same error

lyric mountain
#

Probably corrupted files then

#

Either that or missing

#

Export the database then try reinstalling it

reef carbon
#

it was working before btw

#

before I added 0.0.0.0

lyric mountain
#

Did u restart postgresql service?

#

To apply changes

reef carbon
#

yeah I think so

lyric mountain
#

Comment the 0.0.0.0 line to see if it works again

reef carbon
#

it's systemctl restart postgresql right?

lyric mountain
#

That's one weird error you're getting

#

Yes

reef carbon
#

yeah it works

#

it's something with the 0.0.0.0 line

#

that's causing it to break

lyric mountain
reef carbon
#

oh ok

lyric mountain
#

That's my hba file

reef carbon
#

I'll add that

lyric mountain
#

Wut

#

Discord spontaneous spam again

reef carbon
#

@lyric mountain it worked! Thanks!

lyric mountain
#

Yw

sterile lantern
#
 if (!args[1]) return message.reply("Not a valid code.")
    db.fetch(`premium_code`)
    if (args[1])```
#

kinda stuck here

#

im trying to make it so it checks if args 1 is a valid premium_code

#

nvm

#

how come this happens

#

if (!args[1]) return message.reply("You did not specify your code!");

lyric mountain
#

Because args[1] is null

sterile lantern
#

oh

#

its

#

args 0 im so dumb

lyric mountain
#

Well, at least if you used traditional args splitting

#

Yep, that

sterile lantern
#

how come this doesnt work

#
 db.delete(`premium_code`, args[0])```
#

its letting me claim the code multiple times

#

also, even if i generate more than one code, it overrides

lyric mountain
#

It overrides because it can only have one key-value pair

sterile lantern
#
 const pcode = db.fetch(`premium_code`)
    if (!args[0]) return message.reply("You did not specify your code!");
    if (args[0] != pcode) return message.reply("Not a valid code.");
    if (args[0] === pcode) return message.channel.send("You have sucessfully redeemed your code.");
    let user = message.author
    db.set(`premium_${user.id}`, "true")
    db.delete(`premium_code`, args[0])
}```
#

full code

#

oof

#

how would i make it so

#

it does like

#

code1, code2

#

etc

#

or actually

lyric mountain
#

You need to store an array in that key

sterile lantern
#

multiple values

lyric mountain
#

Or csv

#

Or json array

#

Well, you choose it

sterile lantern
#
 let pcode = makeid(20)
    db.set(`premium_code`, pcode)
    message.author.send('Here is your premium code: ' + pcode)

}```
#
function makeid(length) {
   var result           = 'PREMIUM-';
   var characters       = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
   var charactersLength = characters.length;
   for ( var i = 0; i < length; i++ ) {
      result += characters.charAt(Math.floor(Math.random() * charactersLength));
   }
      return result;
}```
#

thats what i have rn

lyric mountain
#

That'll override

sterile lantern
#

hmm

#

db.add

#

well

lyric mountain
#

One key-value

#

No exceptions

sterile lantern
#

oof

#

how would i make it so it increments

#

so like

#

code1 - code

#

code2 - code

#

etc

lyric mountain
#

You need to store as an array

sterile lantern
#

well tbh even if i did do that

#

id have to fetch all codes in redeem

#

how would i do that

lyric mountain
#

You ๐Ÿ‘ store ๐Ÿ‘ an ๐Ÿ‘ array

sterile lantern
#

wait

sudden geyser
#

I question if that makeid function is very secure

sterile lantern
#
db.set('myItems', ['Sword', 'Lock'])
// -> ['Sword', 'Lock']

db.push('myItems', 'Dagger')
// -> ['Sword', 'Lock', 'Dagger']```
#

wdym secure?

sudden geyser
#

eh nvm

sterile lantern
#

it just generates a code lol

sudden geyser
#

was thinking of something else

lyric mountain
#

You could just generate a hash from the timestamp or something

#

But that's another story

sterile lantern
#

o i have an idea

#

db.push('premium_codes', args[0])

#

im pretty sure

#

that would work

lyric mountain
#

No

#

Still a common key-value

#

Imagine thw following

#

Your premium-key is a cup

#

You can only put one juice in it

sterile lantern
#

o

lyric mountain
#

To put another juice you need to empty the cup first

#

OR you use an array, which would be a multi-fruit juice

#

Still one juice, but N fruits

placid iron
#

this is giving bigint errors

#

but i thought the LEAST would stop that

#

can someone please help ๐Ÿ˜ฉ

sterile lantern
#

would i just do

#

array.push

#

idk

#

if i made an array

placid iron
#

what

bold granite
#

HOW TO RANDOM AN ARRAY

#

is it ```js

const result = array[Math.random((Math.floor()* array.length))]

#

why that doesnt work

sudden geyser
#

Math.floor and Math.random should be swapped.

#

Math.floor rounds a number down. Math.random generates a random decimal point between 0 and 1 (exclusive).

#

You also don't need two parentheses (()) around your multiplication. Only one.

sterile lantern
#

im still confused on how to add multiple values to premium_code

#

if i were to make an array

#

how would i have it set in the db

#

idk

carmine summit
#

How do I check if there is a duplicate array in an array?

#
[[1,2][3,4][1,2]] //true```
quartz kindle
#

there is no easy way to do that if the arrays are separate references

#

you'd need to do something like map(x => x.join())

sudden geyser
#

You'd need to iterate over every element in the inner arrays and see if they end up matching

#

It's painful

sterile lantern
#

wait what if i used better-sqlite 3

#

and made a table

sudden geyser
#

Or flat map, then iterate with the index to see if the other array has the same value

sterile lantern
#

and stored the codes in the table

#

then checked for the codes in the table

#

doubt thatd work tho

carmine summit
#

How do I check if an array is inside an array?

sterile lantern
#

i- what?

#

an array inside of an array

#

interesting

carmine summit
#

yes?

#

for coordinates storing?

#

x and z

#

?

quartz kindle
#

@sterile lantern data is serialized when stored to a database, meaning an array or object must be converted into a json string

sterile lantern
#

so does that mean i cant check for codes

#

in the table

quartz kindle
#

of course you can

#

you just need to think in terms of stringified data

#

but if you1re going for SQL, its better to create a table for it, and add each code as a separate row

sterile lantern
#

sql is sqlite or are those different

quartz kindle
carmine summit
#

array sucks

quartz kindle
#

you will need to convert the arrays to strings and then use indexOf or includes

#

or use .some()

#

for example

#

[[1,2],[2,3]].some(x => x.join() === "1,2") // true

#

its not that arrays suck, its how arrays work in js

carmine summit
#

right

quartz kindle
#

each array is a reference to some data in memory

#

two different arrays are two different locations in memory, even if their contents are exactly the same

carmine summit
#

wont that return a false positive?

lyric mountain
carmine summit
#

[[1,2][3,4]].some(x => x.join() === "2,3") // true

lyric mountain
#

But it's goddamn powerful

quartz kindle
carmine summit
#

alrighty

#

thanks

sterile lantern
#
let array = ['pcode',];
let string = array.join(',');
db.set('premium_codes', string);```
#

i made an example thingy

#

but

lyric mountain
#

Yeah, that's a CSV array

sterile lantern
#

only issue is

#

how exactly would it add more codes to the array?

lyric mountain
#

You just need to split it for usage

sterile lantern
#

and would that update the db automatically?

quartz kindle
#

no

lyric mountain
#

A csv is a simple collection of strings separated by commas

#

value1,value2,value3...

#

To extract an array from that just split by commas

sterile lantern
#

hm so

#

on a code generated

#

we

lyric mountain
#

Then push the new key to the array

sterile lantern
#

push the key yep

#

but that wouldnt update the db

lyric mountain
#

And join with commas again

sterile lantern
#

automatically

#

would it?

lyric mountain
#

No

#

It'd be a separate object

#

You need to save to db each time you modify it

sterile lantern
#

aaa this is complex

lyric mountain
#

Not at all

quartz kindle
#

you could simply make the code itself part of the key

sterile lantern
#

part of the key?

quartz kindle
#

and store a placeholder value

#

like this

sterile lantern
#

OHH yeah ik what u mean code(code here), "not claimed"

#

or honestly

#

what if i just store the code

#

with not claimed as a value

#

and check if that is in the db

quartz kindle
#
let newcode = "abcdef"
db.set(`codes_${newcode}`, true);
#

if(db.get("codes_abcdef")) { do something and then delete it }

sterile lantern
#
 let pcode = makeid(20)
    db.set(`code_${pcode}`, "not claimed")```
#

maybe i shouldnt use pcode twice one sec

quartz kindle
#

once a code is used to you delete it? or do you keep all used codes saved?

sterile lantern
#

delete

#

well

#

since im using place holder

#

ill probs just set it to claimed

quartz kindle
#

then you dont need "not claimed", its easier to just set it to true

sterile lantern
#

o

#

ok

#

ill do that then

lyric mountain
#

Pro tip: don't delete such stuff from database

#

You might need it afterwards

sterile lantern
#

wait for what tho

#

aight that works tysm

#

ill just set the code to "false"

lyric mountain
#

There's a reason why big businesses will keep all your input data even if you "delete" or replace it

#

Be it for analysis or defense against complaints

earnest phoenix
#

or just selling it mmLol

#

i love how companies are legally required to say they protect your data and don't share it with anyone

#

but we all know that behind the curtains it's being sold and shared with other companies & services

#

cough discord

crimson vapor
#

@quartz kindle could you explain what a .d.ts is used for and how to write it

#

or anyone tbh

carmine summit
#

How do I check if an array inside an array has a duplicate?

[[1,2],[3,4],[3,4]] //true
[[1,2],[3,4],[5,6]] //false
crimson vapor
carmine summit
sonic lodge
#

write your own function that compares two arrays

crimson vapor
carmine summit
#

@quartz kindle Can you help me on how to check if there is a duplicate array in an array of arrays

sonic lodge
#

write your own function that compares two arrays, then use it to compare the arrays in the first array of arrays to the second array of arrays

crimson vapor
#

that solution is a good one

#

loop through every value

#

add the value to an array

#

check if the array has the value

#

if it does return true

#

otherwise return false

cerulean ingot
#

nyone know how to fix this??

crimson vapor
#

do you host the site?

carmine summit
#

How do I check if an array inside an array has a duplicate?

[[1,2],[3,4],[3,4]] //true
[[1,2],[3,4],[5,6]] //false
cerulean ingot
#

i think it has to do with ssl

vague imp
#

What's the use of lavalink?

#

I can directly play songs with ytdl

#

Why user user lavalink?

cerulean ingot
#

could someone help if they have a chance

crimson vapor
#

are you using nginx?

cerulean ingot
#

yes

crimson vapor
#

check to make sure you aren't redirecting to ssl on ssl or something

#

make sure you aren't redirecting more than once

cerulean ingot
#

im using cloudflare if that means anything

crimson vapor
#

It shouldn't

cerulean ingot
#

i also dont know much about this at all

#

hmm

#

idk

#

what should i check

crimson vapor
#

tbh not sure

#

what did you change to create the error

#

nginx or code?

#

or just setting up

cerulean ingot
#

id have to ask the person who changed it

#

i know it had to do with

#

changing from certbot to ssl certificate

crimson vapor
#

oh

cerulean ingot
#

but he messed up somewhere

crimson vapor
#

im not sure then

#

someone more knowledgeable than me might

cerulean ingot
#

do you know anyone that could help me?

crimson vapor
#

Tim could probably but he is still afk

cerulean ingot
#

idk who tim is

#

but ill try to contact them

#

thank you

crimson vapor
#

do you know nginx woo?

solemn latch
#

i know a touch

cerulean ingot
#

woo, do you know anything about this

solemn latch
#

looks like a redirect loop? maybe? ๐Ÿคทโ€โ™‚๏ธ

cerulean ingot
#

this occurred when changing from certbot to ssl certificate

#

i didnt do it

solemn latch
#

do you have a redirect, pointing to a redirect, that redirects to the first redirect?

cerulean ingot
#

but whoever did messed up

#

i dont think so, this all worked before he did this

#

changed it

solemn latch
#

you dont happen to have a git(or other version control) of the changes he did?

cerulean ingot
#

i do not think so

#

this is on a vps

#

its also new

vague imp
#

Why are you forwarding it tk same url

solemn latch
#

^

vague imp
#

With $1

cerulean ingot
#

whcih one

vague imp
#

See the pic

cerulean ingot
#

i did

#

also, its not the same

vague imp
#

Delete thise

#

Those

#

They are same

cerulean ingot
#

no they arent

vague imp
#

Yes

#

No not that

#

you are in endless loop

cerulean ingot
#

also, this was all working until he did something with ssl

#

oh

#

where

vague imp
#

riverhost.xyz/* contain all sub url

#

Including $1

cerulean ingot
#

where is this

#

im confused

#

sorry

vague imp
#

1st and 3rd

#

Also https doesnt matter much

#

Change https with nginx

#

Not dns redirect

cerulean ingot
#

dont know how

south harness
#

how to set background colour of the bot page?

cerulean ingot
#

@blissful axle (pinging other dev)

crimson vapor
#

Woo still here?

cerulean ingot
#

ill turn the page rules off and see what happens

#

still doesnt work

solemn latch
#

i may be sup.

crimson vapor
#

ok do you know anything about .d.ts?

solemn latch
#

i dont know much about typescript

crimson vapor
#

oof

#

I want to write typings for my code

#

which is in js

cerulean ingot
#

i wish i knew this

#

um weird

#

when i use www.

#

is this a page rule problem?

#

or a dns record

crimson vapor
#

page rule

cerulean ingot
#

or nginx

crimson vapor
#

wait

#

nginx

cerulean ingot
#

k yeah bc it was working

crimson vapor
#

wait page rules is cf

cerulean ingot
#

was

crimson vapor
#

yeah that is nginx issue

cerulean ingot
#

yeah

#

hmm

#

yeah i think so

vague imp
#

You haven't set domain in nginx

#

You need to config it

cerulean ingot
#

how do i do that?

#

sorry, i dont know about this

vague imp
#

Wait a min

cerulean ingot
#

i didnt do this part of the website

vague imp
#

First you redirect all port 80 to https

carmine summit
#

How do I check if an array inside an array has a duplicate?

[[1,2],[3,4],[3,4]] //true
[[1,2],[3,4],[5,6]] //false
cerulean ingot
#

wdym

vague imp
#

Port 80 is http

#

Port 443 is https

#

Since redirecting port don't work

cerulean ingot
#

idk how to config nginx tho

#

so how do i do that

vague imp
#

You will have to edit nginx config

cerulean ingot
#

where?

vague imp
#

To setup these

cerulean ingot
#

sorry for all the dumb questions

solemn latch
crimson vapor
#

@carmine summit loop through the array

earnest phoenix
#

@carmine summit what language?

carmine summit
#

js

earnest phoenix
#

bet

vague imp
#

@cerulean ingot use search engine according to your need

#

If you fail let me know

#

First try

#

It's easy

cerulean ingot
#

no i just dont know how to get to nginx config

vague imp
#

You are using which os?

cerulean ingot
#

linux

#

on my vps

vague imp
#

usr/nginx/sites-available/

#

The default file is config

cerulean ingot
vague imp
#

Its outside root

#

Click on /

cerulean ingot
#

ohhhh

crimson vapor
#
for(let i = 0;  i <= array.length; i++) {
  if(secondaryArray.includes(array[i])) return true
  secondaryArray.push(array[i])
}
return false;``` @carmine summit
cerulean ingot
#

thanks

#

um i dont have a nginx file

#

im using the pterodactyl panel for this website

cerulean ingot
#

if i do domain it is a never ending loop

delicate shore
#

Hey

cerulean ingot
#

and i can see it loading bc its redirecting so much

rotund vale
#

Get Hey

delicate shore
#

how to get name of guild which has X number og users or more

cerulean ingot
#

huh

unreal cliff
#

what library do you use?

rotund vale
#

He uses discord.js

unreal cliff
#

which version

earnest phoenix
#

got a question

delicate shore
#

yes s s s s s s s. s

#

v12

unreal cliff
#

ok cool

vague imp
#

@cerulean ingot search where is nginx located

unreal cliff
#

maybe

client.guilds.cache.filter(guild => guild.memberCount > 400000)
delicate shore
#

thakns

vague imp
#

The subtle art of using a search engine

earnest phoenix
#

question

#

i use py byw

unreal cliff
#

that returns an array

earnest phoenix
#

how do i make i a variable

#

i am doing for i in range(amount)

vague imp
#

It's there on top

cerulean ingot
#

omg i finally found it

#

thanks but i got it

#

/etc/nginx

#

dont have any idea what to do though :)

vague imp
#

Read jt

#

It's has the config

#

How to do it

cerulean ingot
#

but how come:

delicate shore
#

How to map it

#

wing

unreal cliff
#

it should be an array right?

vague imp
#

@cerulean ingot nginx has a default page setup

delicate shore
#

it returns [object map]

vague imp
#

So you configure it for your website

uneven monolith
#

So i have a staff server where staff has to run a command to accept an application but the user that submitted the application is not in that server because its a staff server. They are in the bots main server tho. If you do client.users.cache.get(user).send(message) it does not work because the bot cant send a dm to a user that is not in the server that the command is executed in so is there a way i can get the server they are in and send them a dm from that server?

discord.js

unreal cliff
delicate shore
#

ok

unreal cliff
#

no wait

uneven monolith
#

tyty

#

ok

unreal cliff
#

.resolve()

#

not parse

uneven monolith
#

ok

#

ty

stone tiger
#

Hi

gilded token
#

Is there a way I can insert an image in the server description ?

uneven monolith
earnest phoenix
#

Can anyone

#

Review my bot

uneven monolith
#

wym?

unreal cliff
#

no im busy

unreal cliff
uneven monolith
#

so if i send a message in that server then will they get cached?

#

like if i were to do a awaitMessages type command

clever vector
#

anybody know how to do the message latency?

cerulean ingot
#

what language

clever vector
#

D.js

cerulean ingot
#

nope

uneven monolith
#

like ping?

clever vector
#

Yes

cerulean ingot
#

@solemn latch do you know any linux?

uneven monolith
#
message.channel.send("Pinging...").then(m =>{
var ping = m.createdTimestamp - message.createdTimestamp;
m.edit(`Ping: ${ping}ms`)
});
clever vector
#

OO ty

uneven monolith
#

np

clever vector
#

@uneven monolith the Message Latency right?

#

TY TY just want to make sure

#

hehe

uneven monolith
#

yeah

#

my bot is a quarter of a second which seems correct

#

idk how you cant test if its right but looking at the code it seems like it cant be wrong

delicate shore
#

Noo

earnest phoenix
#

Does djs not have a latency field in the client?

pale vessel
#

It does have it

crimson vapor
solemn latch
#

you can use the websocket to get the ping

earnest phoenix
#

Is that for the websocket

earnest phoenix
#

then why did he use timestamp comparison lmao

solemn latch
#

for the json db competiton? pogey

crimson vapor
#

idk if there is a competition

#

but I made a good db

pale vessel
#

a

solemn latch
#

nah, i think we force all the best devs to make their own jsondb, and we put them against each other.

pale vessel
#

no space

earnest phoenix
#

lmao

crimson vapor
#

you know what

earnest phoenix
#

the code inspectors arrived

crimson vapor
#

flaze

earnest phoenix
#

lmao

pale vessel
#

yes

crimson vapor
#

pr my code with linting

pale vessel
#

hmmm

crimson vapor
#

tomorrow I will be making an example

earnest phoenix
#

yo

crimson vapor
#

it took me so many git pushes because I don't have node on my pc yet

earnest phoenix
#

question

crimson vapor
#

yea

earnest phoenix
#

do u use py?

crimson vapor
#

nope js

#

@pale vessel are you making a pr?

pale vessel
#

done

crimson vapor
#

so umm

#

yikes

#

should I make different collections different files?

#

seems like a good idea

carmine summit
#

How do I check if an array inside an array has a duplicate?

[[1,2],[3,4],[3,4]] //true
[[1,2],[3,4],[5,6]] //false
crimson vapor
#

I sent a link LOL

#

And then wrote out the code ish

#

loop over the array

#

Add each value to another array

#

Before that check if the array has the value

#

Return true or false

pale vessel
#

Use a for loop

unreal cliff
#
function checkIfDuplicateExists(w){ return new Set(w).size !== w.length }
crimson vapor
#

I forgot about set

#

Wait thatโ€™s big brain is it

#

Can sets have duplicates?

pale vessel
#

no

carmine summit
crimson vapor
#

That was such a good link

#

Showed three methods

ancient dagger
#

Yo guys is sharing code allowed

pale vessel
#

No

ancient dagger
#

Ok

crimson vapor
#

What?

#

So all you need to do is compare a set of an array with the array

#

Thatโ€™s so smart

ancient dagger
#

Lmao

pale vessel
#

holy shit it is

#

Since his array structure is perfect for a map/set

crimson vapor
#

yea

#

sometimes i wonder how people can be so smart

unreal cliff
#

i just got it off of stackoverflow lol

crimson vapor
#

99% of people ik can barely install software without antivirus and people think of ideas like that

#

Ik ik i saw the stack overflow link

#

when I searched the question

pale vessel
crimson vapor
#

Oh

pale vessel
#

Okay never mind that doesn't work

crimson vapor
#

that would have been so smart go

#

Tho*

#

Phones suck

#

What should i name my json DB?

unreal cliff
#

jason

crimson vapor
#

lol

#

But 100% taken already

pale vessel
#
function checkDupes(array) {
    const check = [];
    for (const element of array) {
        if (check.find(x => x.toString() === element.toString())) return true;
        check.push(element);
    }
    return false;
}

checkDupes([[1, 2], [1, 2], [1, 4]]); // true```
#

hmm

crimson vapor
#

good function

#

I should name it: Jason-DB

pale vessel
#

Works for arrays and strings

crimson vapor
#

What about objects

pale vessel
#

jason.db

crimson vapor
#

Oh

#

Better name

#

capital J?

pale vessel
#

capital J feels odd to me

pale vessel
crimson vapor
#

Jason.db jason.db Jason.DB jason.DB

pale vessel
#

jason.db

crimson vapor
#

Ok

unreal cliff
pale vessel
#

Nice

unreal cliff
#

:)

crimson vapor
#

Means I can use it

pale vessel
#

Time to publish one so that you can't use it

crimson vapor
#

poggers

pale vessel
crimson vapor
#

That would suck

#

Bruh typing on phone is hard

trim saddle
#

@pale vessel help writing a lib is hard

pale vessel
#

always has been

trim saddle
#

i assume you don't know anything about it

crimson vapor
#

Lib to connect to discord?

trim saddle
#

yes

pale vessel
#

I made a simple one

crimson vapor
#

Nice

trim saddle
#

i'm only reiceving 3 events from socket

#

HELLO
GUILD_CREATE
READY

#

not getting anything else

pale vessel
#

bro did you specify intents

trim saddle
#

uh what

pale vessel
#

what api version? v8?

trim saddle
#

v6

pale vessel
#

oh

#

try specifying intents

#

under your identify payload

trim saddle
#

hm.

#

nope

#

i don't think it's properly logging in

pale vessel
#

wtf

#

you're worse than me

trim saddle
#

yeah

#

i never did this before

carmine summit
#

Why is it not square anymore when I set it to 15x15, but in 14x14 it works fine? shutup im not a psycho!! im using light mode to count the squares

trim saddle
#

depends on the device?

carmine summit
#

ehhh?

crimson vapor
#

Well make sure you arenโ€™t like concating to a string

trim saddle
#

or the natural message wrap

carmine summit
#

what is the message wrap btw

unreal cliff
#

if 14x14 works then just use that

carmine summit
#

but I wanna use 100x100

unreal cliff
#

just no

#

don't

#

it won't be practical

crimson vapor
#

Use pictures then

#

Canvas go brrrr

carmine summit
#

no pictures

#

no canvas

#

grrr

#

canvas hard

unreal cliff
#

not really

carmine summit
#

grr

#

im trying to make snake game here dud

trim saddle
#

@carmine summit yeah message wrap doesn't fit 100 characters on one line

crimson vapor
carmine summit
#

ah so it will move to the next line at 100 chars

#

okok

#

im sticking to 14x14

unreal cliff
#

dont do it like that

pale vessel
carmine summit
#

btw if i were to use canvas, id have to learn it and have a lot of patience

trim saddle
#

@pale vessel yeah i don't get this

unreal cliff
#
var body = ''
for(lines = 0; 14 >= lines; lines++) {
body += ':black_square::black_square: ...` + '\n'
}
message.channel.send(body)
carmine summit
unreal cliff
#

do my thing

carmine summit
#

weird amirit

#
  let map = [];
  for (i = 0; i < defaultX; i++) {
    map.push("\n");
    for (j = 0; j < defaultY; j++) {
      map.push(["black", i, j]);
    }
  }
  return map;
}```btw heres the code imm using
sick sluice
#

does discord api have endpoint to list all server which has add my bot?

trim saddle
carmine summit
#

hmmmm

#

what if i placed it in a code block

#

:DDDDD

#

it wont text wrap

pale vessel
#

what doesn't work

trim saddle
#

as i said

pale vessel
#

the events?

#

how do you handle your events

pale vessel
#

yes

trim saddle
#
socket.on("message", (d) => {
    const data: object = JSON.parse(d)
    switch (data.op) {
        case 0: console.log(data.t)
        case 10: {
            console.log("HELLO recieved.")
            setInterval(() => {
                socket.send(JSON.stringify({op: 1}))
            }, data.d.heartbeat_interval)
            login() 
        }
    }
})
carmine summit
earnest phoenix
#

eye rape :sadblob:

carmine summit
#

can I do 100x100

#

or better 1080x1080

pale vessel
#

bro break your cases

carmine summit
#

nahh it will go over 2000chars

trim saddle
#

wdym break my cases

pale vessel
#

break;

trim saddle
#

hm

carmine summit
#

its just me being childish

#

whats the sqrt of 2000?

#

no nvm 44x44 is the highest it can get

#

btw do you prefer it raw or in a code block?

trim saddle
#

@pale vessel ah yes

unreal cliff
#

i wouldn't do a grid that large

#

too big for mobile users

trim saddle
carmine summit
#

yeah just saw it on my phone

#

its horrible

pale vessel
#

how????

carmine summit
#

btw how do I get messages by id?

#

whitout channel id

#

if it requires a channel id welp

unreal cliff
#

i don't think you can

carmine summit
#

welp...

#

ima code now bye

pale vessel
carmine summit
#

cached?

#

you mean if its after the bot being run?

#

or cached that if its stored in a variable

#

what do you mean

trim saddle
#

no idea

#

discord started sending a buffer for some reason

earnest phoenix
#

did you enable compression

pale vessel
#

Otherwise you need the channel

carmine summit
#

ok then

#

how do I do that

pale vessel
#
const id = "id";
const message = client.channels.cache.find(x => x.messages?.cache.has(id)).messages.cache.get(id);```
trim saddle
carmine summit
#

thanks for the explaination

pale vessel
#

It finds the channel that has the message and get the message from that channel

trim saddle
#

but still the same events

#

why discord

#

how discord

#

what discord

carmine summit
#
client.channels.fetch(ins.channelId).messages.fetch(ins.messageId)
```Why is this returning undefined?
lucid prawn
#
if(message.content.startsWith(prefix + "userinfo" )){    
    const user = message.mentions.users.first() || message.member.user
    const member = guilds.members.cache.get(user.id)

    console.log(member)

    const embed = new MessageEmbed()
      .setAuthor(`User info for ${user.username}`, user.displayAvatarURL())
      .addFields(
        {
          name: 'User tag',
          value: user.tag,
        },
        {
          name: 'Is bot',
          value: user.bot,
        },
        {
          name: 'Nickname',
          value: member.nickname || 'None',
        },
        {
          name: 'Joined Server',
          value: new Date(member.joinedTimestamp).toLocaleDateString(),
        },
        {
          name: 'Joined Discord',
          value: new Date(user.createdTimestamp).toLocaleDateString(),
        },
        {
          name: 'Roles',
          value: member.roles.cache.size - 1,
        }
      )
earnest phoenix
lucid prawn
#

ik

#

i use guilds alot so idk the problem that why im asking

earnest phoenix
#

๐Ÿ™„

carmine summit
#

how do I remove an object from an array without knowing index

#

@earnest phoenix

earnest phoenix
#

indexOf and find the index

carmine summit
#

then .splice?

earnest phoenix
#

yup

lucid prawn
#

can u help me

#

@earnest phoenix

#

nvm

earnest phoenix
#

huh

terse berry
#

How do I call some code from an other script in index.js using a class?

#

I did require the script in index.js

#
    
    constructor(client, message){
         client_ = client;
         message_ = message;
    }


    startDms(){
        message_.author.send('Hello');
    }
}

module.exports = dms;```

In index.js: `dms.startDms()`

Error I get: dms.startDms() is not a function
#

Does someone know how to do it?

earnest phoenix
#

Please teach me discord.js

earnest phoenix
#

Is there a way i can get the IP address of my heroku application?

earnest phoenix
twilit rapids
#

Read the docs etc

green kestrel
#

lol, im getting an odd pattern in my bandwidth usage of my bot

twilit rapids
#

There's a getting started guide

green kestrel
#

2 and 6pm

twilit rapids
green kestrel
#

half a megabit per second?

twilit rapids
#

that's my seconds btw

#

Not the one in 115k guilds

earnest phoenix
twilit rapids
#

You have to understand that they don't magically appear

carmine summit
#

\โธ๏ธ

#

\โฏ๏ธ

earnest phoenix
#

i need help in using ejs

#

can i use this tag inside head tag in ejs file?
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

carmine summit
#

\โน๏ธ

earnest phoenix
#

@terse berry the method is on the prototype of the class

terse berry
#

Nvm I got it

earnest phoenix
#

also you should create a new instance of it instead of calling the method on the class directly

quick thistle
#

You can use this tag in head.

#

But currently there is latest version of fontawesome

#

5.15.1

earnest phoenix
carmine summit
#

uh

#

dont mind that

quick thistle
#

lol

carmine summit
#

i was just using that for copy/paste

earnest phoenix
#

I've got a question
If I add an event listener for guildMemberAdd will it be fired when the bot itself is added to a server?

quartz kindle
#

No

earnest phoenix
#

well is there a seperate event for when the bot is added to a server

#

Whats wrong here ? <img src="https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.jeep-official.it%2Fmopar%2F404-page-not-found&psig=AOvVaw264By3-yOx6seeyDNEjrGR&ust=1607677264266000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCLD0l9WGw-0CFQAAAAAdAAAAABAD" height="345">

earnest phoenix
#

@earnest phoenix bruh that url is not an actual image

#

it's a redirect with some google tracker salt

#

tfw people can't even steal images from google properly nowadays ๐Ÿ˜”

quartz kindle
#

xD

earnest phoenix
#

Still not working

#

show code

#

Um

dusky marten
earnest phoenix
#

and PLEASE stop using glitch

#

@dusky marten heroku bad

#

Whole code is there

#

@earnest phoenix bruh momenti

#

does that url look normal with two protocols

#

yes, new protocol

dusky marten
#

Error: Unable to retrieve video metadata this is main error in my music bot

earnest phoenix
#

https squared

earnest phoenix
dusky marten
#

ping me if anyone help

earnest phoenix
#

@dusky marten can you send your code

#

on hastebin

dusky marten
#

ok wait

#

Calling `ytdl.getInfo` with a callback will be removed in a near future release. Use async/await. Error: Error parsing info: Unable to retrieve video metadata at getWatchPage (C:\Users\Mukesh\Desktop\hehe\node_modules\ytdl-core-discord\node_modules\ytdl-core\lib\info.js:75:13) at processTicksAndRejections (internal/process/task_queues.js:93:5) at async exports.getBasicInfo (C:\Users\Mukesh\Desktop\hehe\node_modules\ytdl-core-discord\node_modules\ytdl-core\lib\info.js:84:22) at async Map.getOrSet (C:\Users\Mukesh\Desktop\hehe\node_modules\ytdl-core-discord\node_modules\ytdl-core\lib\cache.js:24:19) at async exports.getInfo (C:\Users\Mukesh\Desktop\hehe\node_modules\ytdl-core-discord\node_modules\ytdl-core\lib\info.js:226:14) at async Map.getOrSet (C:\Users\Mukesh\Desktop\hehe\node_modules\ytdl-core-discord\node_modules\ytdl-core\lib\cache.js:24:19) (node:43104) UnhandledPromiseRejectionWarning: Error [VOICE_PLAY_INTERFACE_BAD_TYPE]: Unknown stream type at VoiceConnection.play (C:\Users\Mukesh\Desktop\hehe\node_modules\discord.js\src\client\voice\util\PlayInterface.js:84:11) at play (C:\Users\Mukesh\Desktop\hehe\system\music.js:39:8) at processTicksAndRejections (internal/process/task_queues.js:93:5) (Use `node --trace-warnings ...` to show where the warning was created) (node:43104) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:43104) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

#

this is error

#

it is working properly suddenly this happens

earnest phoenix
#

@dusky marten send your bot code for the command too

dusky marten
#

which code ?

earnest phoenix
#

The code that caused the error

dusky marten
#

no all code is perfect

#

this is main error - Error: Error parsing info: Unable to retrieve video metadata

earnest phoenix
#

bruh

#

if all code is perfect how would there be an error

dusky marten
#

i think there is some update needed

earnest phoenix
#

nope

dusky marten
#

like
updatd of ytdl-core@4.0.3

earnest phoenix
#

@dusky marten why are you messaging me man

dusky marten
#

read bruh plz

#

i cant sent here

#

understand my prob

earnest phoenix
#

i think the problem is that the video link is invalid

dusky marten
#

no i just puted name of song

earnest phoenix
#

ytdl can't search songs iirc

#

you need to pass it a url

dusky marten
#

and it is working and suddenly this happens

earnest phoenix
#

you can use the youtube api to search songs then pass the url to ytdl

#

try running the play command again except send the exact link this time

dusky marten
#

i have all api and etc

earnest phoenix
#

it should probably work with normal links

earnest phoenix
dusky marten
#

it is working properly

#

but today it stucks

#

i sure it needed an updated

#

but idk wht

#

updated

earnest phoenix
#

try updating

dusky marten
#

thats why i send error code

earnest phoenix
#

also @quartz kindle might be able to help you he's a master of programming

dusky marten
#

ohk

#

let him see my error code

past needle
earnest phoenix
#

@past needle that was not the error

dusky marten
#

let me try

past needle
#

?

earnest phoenix
#

that was not the fix for your error

dusky marten
#

oh

earnest phoenix
#

@past needle he sent the async/await warning message along with the actual error

past needle
#

:o

#

@dusky marten can you send me the file music.js lign 39 ,v,

dusky marten
#

k

past needle
#

if you can also 5/6 lignes before & after

#

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

dusky marten
#

@past needle

const { MessageEmbed } = require("discord.js")
const { QUEUE_LIMIT, COLOR } = require("../config.json");

module.exports = {
  async play(song, message) {
    const queue = message.client.queue.get(message.guild.id);
let embed = new MessageEmbed()
.setColor(COLOR);

    if (!song) {
      queue.channel.leave();
      message.client.queue.delete(message.guild.id);
      embed.setAuthor("MUSIC QUEUE IS ENDED NOW :/")
      return queue.textChannel
        .send(embed)
        .catch(console.error);
    }

    try {
      var stream = await ytdlDiscord(song.url, {
        highWaterMark: 1 << 25
      });
    } catch (error) {
      if (queue) {
        queue.songs.shift();
        module.exports.play(queue.songs[0], message);
      }

      if (error.message.includes === "copyright") {
        return message.channel.send("THIS VIDEO CONTAINS COPYRIGHT CONTENT");
      } else {
        console.error(error);
      }
    }

    const dispatcher = queue.connection
      .play(stream, { type: "opus" })
      .on("finish", () => {
        if (queue.loop) {
          let lastsong = queue.songs.shift();
          queue.songs.push(lastsong);
          module.exports.play(queue.songs[0], message);
        } else {
          queue.songs.shift();
          module.exports.play(queue.songs[0], message);
        }
      })
      .on("error", console.error);
  
    dispatcher.setVolumeLogarithmic(queue.volume / 100); //VOLUME
embed.setAuthor("Started Playing Song", message.client.user.displayAvatarURL())
    .setDescription(`**[${song.title}](${song.url})**`)
    
    queue.textChannel
      .send(embed)
      .catch(err => message.channel.send("UNABLE TO PLAY SONG"));
  }
};
#

^^^

feral aspen
#

Question

#

I'm not stupid, but this reset button just refreshes, right?

#

I pressed it once and the data didn't go

quartz kindle
#

@dusky marten you're not using ytdl-core you are using ytdl-core-discord

dusky marten
#

yes

feral aspen
dusky marten
#

so how can i update it

quartz kindle
#

ytdl-core-discord uses ytdl-core v3.4.2
latest version of ytdl-core is v4.1.4

dusky marten
#

so i have to npm i ytdl-core v4.1.4 ?

quartz kindle
#

ytdl-core-discord has not been updated for 2 months, and its github repo was removed

#

ytdl-core was last updated 2 days ago

dusky marten
#

ok so now wht can i do to play songs ?

quartz kindle
#

you need to change your code to use ytdl-core

#

and not ytdl-core-discord

dusky marten
#

really idk how to

quartz kindle
#

read their documentation

dusky marten
#

which ?

quartz kindle
#

ytdl-core

dusky marten
#

k

quartz kindle
dusky marten
#

k thx

timber fractal
#

how can i return the image from the message.author as a small image on my DiscordEmbed?

#

if i use message.author.displayAvatarURL it doesnt send the image but the link

zenith terrace
#

@timber fractal did you add () at the end of URL

stark widget
#

What is the best way to make an online dashboard for a bot?

rustic nova
#

there's no good or bad way, i just suggest getting started

#

start with making simple html etc

earnest phoenix
#

well there is definitely a bad way

#

but there isn't "the best"

rustic nova
#

there's always bad ways, yeah you're right

earnest phoenix
#

python

pale vessel
#

python

#

What do you mean what to do now? You coded that, right?

earnest phoenix
#

yes

#

but

#

class shows

#

unexpected unindent

#

@pale vessel

#

Need help

crimson vapor
#

oof

#

iirc flaze doesnt know py

earnest phoenix
#

F

#

@crimson vapor help me please

crimson vapor
#

I don't know py either

earnest phoenix
#

Anybody knows?

earnest phoenix
#

im messed up with this from 5 hours

earnest phoenix