#development

1 messages · Page 1743 of 1

craggy pine
#

not the token obv.

wheat mesa
#

(Again)

glad cobalt
#

it is

wheat mesa
glad cobalt
#

I never changed it

#

when i go to the red line it says '}' expected

wheat mesa
#

Then you’re missing a }

craggy pine
#

expected = missing

glad cobalt
#

sheeeeee

#

i have all

#

to a set

#

same error

sudden knoll
#

can you show the code?

craggy pine
#

You'll need to paste your code again as you have it now

glad cobalt
#

I might be blind

#

but ok

#

`client.on("message", async message => {

if(message.author.bot) return;
if(message.channel.type == 'dm') return;

if(message.content.startswith(prefix)){

  const args = message.content.slice(prefix.length).trim().split(/ +/);

  const command = args.shift().tolowerCase();

  const commandToRun = client.commands.get(command)
  if (!commandToRun) return;
  try {
      commandToRun.run(client, message, args);
  } catch(error){
     console.log(error); 
  }
}

}`

craggy pine
#

client.on("message", async message => {

    if(message.author.bot) return;
    if(message.channel.type == 'dm') return;

    if(message.content.startswith(prefix)){

      const args = message.content.slice(prefix.length).trim().split(/ +/);

      const command = args.shift().tolowerCase();

      const commandToRun = client.commands.get(command)
      if (!commandToRun) return;
      try {
          commandToRun.run(client, message, args);
      } catch(error){
         console.log(error); 
      }
    }
}

glad cobalt
#

how tf

craggy pine
#

We told you how to do that many times.

wheat mesa
#

3 backticks, not 1

glad cobalt
#

9h

#

ohhhh

wheat mesa
#

There you go

craggy pine
#

but

glad cobalt
#
ig
craggy pine
#

three backticks with js after the first 3

umbral zealot
#

May I?

sudden knoll
#

you're missing a parenthesis

craggy pine
umbral zealot
#

The following trick is a lifesaver, so pay attention: Your code editor is trying to help you. Whatever editor you're using, clicking on any (and I mean any) separator token such as parentheses, square brackets, curly braces, double and single quotes, will automatically highlight the one that matches it. The screenshot below shows this: the bottom curly brace is selected, and it shows the one on top by surrounding it with a square. Learn this, and how different functions and event handlers "look" like. Even in long bits of code, this works. If you don't have a proper editor, here's a guide: https://discordjs.guide/#/preparations/setting-up-a-linter

craggy pine
#

good ^ example

umbral zealot
#

@glad cobalt you should probably consider the possibility that making bots with little to no javascript experience is like trying to make a Salmon Soufflé with zero kitchen experience having never opened an oven in your life. It's hard. So unless you're exceedingly autonomous (which you're clearly not, sorry), you're going to just keep stumbling through like a drunk sailor.

Please, take the time to learn the language first.
Resources: #development message

sudden knoll
#

or pick up python which is practically english

glad cobalt
#

I don't like python

umbral zealot
#

Python and JavaScript are about as equal as you can get in terms of complexity.

wheat mesa
#

Meh I don’t like python either

sudden knoll
#

I like python

umbral zealot
#

If you want to say you like JavaScript, then please go learn it.

umbral zealot
glad cobalt
#

I understand js some what but I'm very tired and i want to sleep but i want to get this done

wheat mesa
#

The language is intuitive, but I just don’t like the idea of indentation controlling behavior of all of your code

craggy pine
#

A wild shiv is speaking.

sudden knoll
#

they're both well documented though so either is a good choice

wheat mesa
#

Seems easy to mess up

sudden knoll
deep mantle
umbral zealot
#

Go to bed.

glad cobalt
#

I've been up for 16 hours

umbral zealot
#

Yeah so go sleep.

#

It`s much easier to pick things up in the morning.

glad cobalt
#

ok

wheat mesa
#

Programming is not very easy to do sleep deprived

#

Computers are very picky

#

Messing up small things means 1 or more errors usually

glad cobalt
#

yes

#

🛌

slender thistle
sudden knoll
#

lmao

#

that's just excessive

wheat mesa
#

Ew

slender thistle
#

2D arrays in list comps ftw lmfao

sudden knoll
#

making a nice string there

slender thistle
#

Indeed 😛

sudden knoll
#

list and dict comps are pretty nice though

hollow crystal
#

can anyone help me with noumenon please

slender thistle
#

They really are

wheat mesa
slender thistle
#

Oh, you want 5D?

#

Sec

#

Or, rather, give me like 30 minutes

wheat mesa
#

2d array - square, 3D array - cube, 4d array - I have no idea what’s going on anymore and my brain breaks down

sudden knoll
#

4d = cube with little lists inside each tiny cube, 5d = cube with little tables in each tiny cube, 6d = cubeception

wheat mesa
#

pepowot too much thinking for me

wheat mesa
#

Agh

#

I’ve seen that before

#

Elegant, yet a lot of effort put into a simulated ASCII donut

sudden knoll
#

lmao, best kind of code

wheat mesa
#

Art

sudden knoll
#

time consuming and functionally pointless

wheat mesa
#

I love code like that but I would never be able to dedicate that much time and thought to something functionally pointless like that

slender thistle
wheat mesa
#

AH

frigid mountain
#

Error means what?

wheat mesa
#

Exactly what it says

#

The npm module “node-fetch” is not installed

#

Make sure it’s in your dependencies in your package.json file

earnest phoenix
#

Do npm install node-fetch

wheat mesa
#

That too

opal plank
# slender thistle Should be 5D?
let arr = [1,2,3,4];for (let i = 0; i < 5; i++) oneMorePlease(arr);function oneMorePlease(array:Array) {  let _temp = [];  for(let e of array) _temp.push(new Array(e));  array = _temp;}
wheat mesa
#

burn it

slender thistle
#

One-liners ftw

opal plank
#

oh, you want one liner?

#

fine

slender thistle
sudden knoll
#

upto_10_until_100 = [x for x in first_list[:10] + second_list[:100 - len(first_list[:10])]]

opal plank
#

@slender thistledone

sudden knoll
#

lmao java syntax ftw

slender thistle
#

LMFAO ERWIN

#

I will strangle you

opal plank
#

not like urs is any more readable than mine

slender thistle
rocky hearth
#

python uses 4 spaces per tab. Can we change it to 2

slender thistle
#

Literally just have your IDE convert tabs to 2 spaces?

#

PEP8 suggests 4 spaces though

sudden knoll
#

that's what I was thinking

rocky hearth
sudden knoll
#

so it looks nice

slender thistle
#

Because if there's no standard to follow, shit's gonna go downhill with people trying to come up with their own styling

sudden knoll
#

1 space indentation

#

imagine

slender thistle
#

LMFAOOOOOOO

#

That doesn't seem to make the class JSON serializable, unfortunately

sudden knoll
#

just wondering, but couldn't you use pickle for python serialization?

slender thistle
#

Extra dependency

sudden knoll
#

okay, that's a fair reason

slender thistle
#

I guess I'm making my own encoder

sudden knoll
#

lol

slender thistle
#

It's either the fact that I'm dumb as hell or this crap is more complicated than differential equations for me

sudden knoll
#

yup I don't want to look at that

earnest phoenix
#

-upto

prime mist
#

I guess a deployment is fine if you only need 1 replica.

But if you want more redundancy you would need to switch to a stateful set.

clear marlin
dense spire
#

whats a good way to store python functions with certain parameters until i want to use them later (whenever that happens to be)

#

I know you can store them separately but id like to store them together if possible

rocky hearth
#

u mean together in same file?

dense spire
#

?

#

during runtime

#

i want to store a collection of different functions

#

with specific parameters depending on the user

#

then have them run in a specific order

#

so i want to know what the best way to store a function and its parameters if possible

rocky hearth
#

can we return a function from a function? in python.

#

if yes, then u can learn about currying

dense spire
#

you can return a blank one

#

but id like to keep my parameters in there without actually running the function till i need it

#

if possible

#

just want to know if it is or not

rocky hearth
#

python do support higher order functions. So you can call a funciton with the parameters u want to save. and return another funciton with the save parameters

dense spire
#

cant say this is what im looking for

#

The functions im storing dont return anything, they simply all edit the same collection of information

rocky hearth
#
function saveA(a) {
  return function (b) {
    return a+b
  }
}

const fun = saveA(10);
const result = fun(20)
dense spire
#

But im putting them in a queue so that they dont try to edit at the same time

rocky hearth
#

Here I'm saving the number 10, for later use.

#

later I can call, fun with some other number
here, the result will have the sum of 10 and 20

sudden knoll
#

why don't you just make locks?

#

asynchronous locks

dense spire
#

do tell

sudden knoll
#

wdym

dense spire
#

what do those do?

#

I've been trying out different ways so ill be glad to try to implement anything better

sudden knoll
#

a lock is an object that a thread needs to acquire before executing, so you can lock a function until it acquires the lock and when it's done it'll release it for the next thread that needs the lock

dense spire
#

how does that retain order?

sudden knoll
#

the order of threads trying to get the lock is the order

opal plank
dense spire
#

:^)

opal plank
#

good choice

dense spire
#

Wei Hilichurl

#

Big boss CEO

opal plank
#

lul

#

aaaaaah the suspense

#

not sure imma be able to sleep today

earnest phoenix
eternal osprey
#

hey i am about to switch my application to either mysql or mongodb as i was using json at first

opal plank
eternal osprey
#

tho, would this require me to change the whole code structure?

sudden knoll
#

not completely

#

you'll have to think about relationships and nested stuff tho

dense spire
#

im using mongo DB rn. Pretty simple stuff. I changed over from a differnt DB so i had to change a bunch but also took the time to restructure my code to make it neater and more consistent

opal plank
opal plank
#

database calls are completely different from fs.reads/writes

dense spire
#

id say its simplifying it

sudden knoll
#

which is best, postgres, mysql, or sqlite?

opal plank
#

an ORM might be ur best bet, though i personally dislike it

#

postgres(100% biases)

sudden knoll
#

rn i'm using postgres

#

cool

opal plank
#

postgres or cassandra

#

redis/keydb for hyper performance with cluster

eternal osprey
#

discourages me to move on

opal plank
#

but i dont think theres anyone here with a need for 500k+ ops/s

opal plank
#

i dont give false hope

#

@sudden knoll

sudden knoll
#

damn

opal plank
#

postgres + keydb

#

postgres for what needs to be accessed only once or twice, and keydb for memory

#

storage / memory, respectively

sudden knoll
#

looks like imma move to keydb

#

lmao

opal plank
#

would not recommend unless you have a need for it

sudden knoll
#

time for some rewrites

opal plank
#

going overkill isnt always the best option

sudden knoll
#

well, project is relatively small, so I think postgres'll be fine for storage

opal plank
#

i say that even though i've futured proof my bot to fucking coorporation levels

lusty quest
#

i use Redis for Caching MongoDB querys

#

works quite good

opal plank
#

redis is an absolute god

#

no need to step up with keydb

#

though personally, overkill good

lusty quest
#

just get a dual Socket Epyc System with 128 Cores and 2TB ram and use it to Host a Discord Bot that is in 5 Guilds

eternal osprey
#

my bad, i actually use localstorage to save balance info of casino constants

opal plank
#

reduce in database calls in exchange for having a fast memory db

opal plank
#

does that count as overkill?

lusty quest
#

nah its reasonable depending on the Bot

#

if you run like 50 Shards its fine

#

or use AI to classify images

opal plank
#

i run 4 shards

#

i still need to add the shard status ngl

#

been in the back burner for a long ass time

lusty quest
#

for the size of my bot ive also run a bit Overkill hardware, but who cares, you have space to grow

opal plank
#

this ^^

eternal osprey
#

how would i link my localstorage to another bot instance?

quartz kindle
#

localstorage? wat

opal plank
#

wdym?

quartz kindle
#

localstorage is for browsers

opal plank
#

i think they mean a non local database?

#

ssh tunneling ftw

eternal osprey
#

i am using localstorage to save info in a particular folder

opal plank
#

use a database

#

cuz thats what its meant to be used for

#

aint gonna do some janky ass things as trying to fs.readFile() on an ssh tunnel

lusty quest
#

if you cant afford a database, MongoDB is aviable for free

opal plank
#

most databsaes are free

#

sqlite

eternal osprey
opal plank
#

postgres

#

mysql

lusty quest
#

well free hosted

opal plank
#

no need to buy anything

#

where you even hosting ur bot?

eternal osprey
#

But i will have to rewrite everything and holy shit i am not in the mood for it

#

galaxygate

opal plank
#

then you already have a vps

#

why not host psotgres there?

lusty quest
#

but i do not recommend it, Atlas is overpriced. to get the same features as Self hosted you pay like 60$/Month

eternal osprey
#

okay i will have a good look at the docs and try mongodb

quartz kindle
#

just use sqlite damnit

#

you dont need anything more than thT

opal plank
quartz kindle
#

anything else is overkill

lusty quest
#

postgres looks sexy, atleast the comparison to Mysql ive read.

opal plank
#

thats the point, fuck scaling, do it once and enver worry about scaling again

lusty quest
#

nah just use a Cassandra Cluster to store Guild Configs

quartz kindle
#

scaling that youll never need

opal plank
#

cassandra is pog tho

#

unironically

opal plank
lusty quest
#

well one reason why Discord uses it now, after they hit the limits of MongoDB

opal plank
#

whats the point of making an app if you cant even see a future for it?

sudden knoll
#

KeyDB is pretty cool ngl

opal plank
#

told ya

quartz kindle
opal plank
#

i mean code wise tho, not actually specs

#

sharding/databases/etcs

lusty quest
#

i pay for a 64GB Ram Server for a 270 Guild bot, so i guess im close

earnest phoenix
#
client.user.setActivity("PUBG MOBILE", { type: "STREAMING" })```
This is not working for me. It is showing playing instead of streaming.
opal plank
#

in fairness, my argument is kinda nill

#

since sqlite would likel ynot struggle at all

quartz kindle
#

chosing your db software doesnt fall into code-wise

autumn kestrel
#

i have to check if my boy has some permissions on a discord server

quartz kindle
#

its specs

sudden knoll
#

sqlite is nice and easy to setup

opal plank
#

discord isnt that active to make sqlite be limited by query's calls/

sudden knoll
#

i recommend

opal plank
sudden knoll
#

but now that I see KeyDB.....

lusty quest
#

when ive started with js and discord bots, ive used Enmap as a sqllite wrapper, worked but ate a lot of ram

opal plank
#

i started with a basic json db for channel configs to test out, but was shot down 2 days after by a friend(same one that's allowing me to use their servers) to use proper dbs

#

its good to get scolded by veteran devs

quartz kindle
sudden knoll
#

I agree

opal plank
lusty quest
#

the thing is, most bad but somehow popular guides out there suggest a json db from the start

#

bcs its "easy and cheap"

sudden knoll
#

it's for beginners I assume

opal plank
#

popular =/= good

lusty quest
#

its bad practise

quartz kindle
opal plank
#

fortnite is popular for example, and we all know its rep

lusty quest
#

wtf?

opal plank
lusty quest
#

the thing with fortnite is the playerbase not the game

sudden knoll
#

Epic Games is big brain tho

opal plank
#

second: would you still tell people who know jack shit about coding, not even how if's, else's and functions work to use a json db?

sudden knoll
#

marketing-wise at least

quartz kindle
sudden knoll
#

ppl probably use json dbs so they don't have to learn another language

opal plank
#

back when i started the json db i didnt know shit either, i was asking for specific questions without context.
such as: How do i save a file locally? and not Whats the best way to save channel settings?
which lead to me start using json as a db. Luckily i had some veterans to gimme a hand and put me in the right path, i cant thank them enough

lusty quest
#

ive started making bots with some knowledge about databases prior and the power behind them. also used to make small Addons for Gmod in Lua. so i knew pretty much at the beginning i want a Database, and not some stupid file storage

opal plank
#

so i wasted about a week at most using json

#

but that was a good experience to learn how fs works

#

cant say it was a complete waste of time either

#

but its much better to listen from experienced devs rather than waste the time yourself to eventually learn it

#

its like skipping school and going for a try-and-error approach

quartz kindle
#

i never thought my bot would ever grow, so i dindt care much at the beginning

lusty quest
quartz kindle
#

becausebof how niche it is

opal plank
lusty quest
#

my larger bot is also quite niche, also havent grown in like 7 or 8 Months.

#

tried to get ideas for other bots, but what i came up with for now is sort of already there

quartz kindle
#

reading github then: holy shit this is so advanced, i dont understand anything...

reading github now: holy shit this code is so bad, what an idiot...

opal plank
#

my issue is the other way around

#

im TOO creative

lusty quest
#

im creative like a Brick

opal plank
#

i keep on getting a shitton of amazing ideas that would take a long time to put

lusty quest
#

but for some reason im not bad in CAD

sudden knoll
#

you mean like autodesk?

lusty quest
#

as example

#

but im more used to Solid Works

#

i wish a license would not cost 3k€/Year

sudden knoll
#

i was just confused at the jump from coding to CAD

quartz kindle
#

blender >

sudden knoll
#

lmao

lusty quest
#

blender is not CAD

#

blender is modeling software

quartz kindle
#

but it can be used as such

lusty quest
#

yesnt

sudden knoll
#

you could, but you could also use a json db to store info

opal plank
lusty quest
#

proper CAD software gives you stuff like calculations for mechanical Stress, flow simulations and other fancy stuff

opal plank
#

this is all i gotta say for licensing

quartz kindle
#

lel

sudden knoll
#

doesn't mean you should

opal plank
#

take it as you will

quartz kindle
opal plank
sudden knoll
#

I thought you were about to say something

#

and that was a lead up

opal plank
#

no, that would be against tos

#

im just sending a cute parrot

#

take it as you will

lusty quest
#

but i sort of want to get into Machine Learning, already know a real world use case i could use it. but then again, im not sure if the efford for it would be worth it

quartz kindle
#

just add more if elses

sudden knoll
#

fax

#

neural networks are overrated

#

more binary

#

although that is what it is at the core

eternal osprey
#

hey is there any way to migrate localstorage to mongodb?

lusty quest
#

nah its for detecting damage on Plastic parts produced with Injection Molding. my idea would be that the Part will get taken out of the Injection molding machine by a robot (already happens in my Company) and then exposes it to a camera, from there just some machine Learning hackery to see if there are defects, like the mold where not entirely filled, damage on the Mold, maybe the part broke apart while getting ejected.

lusty quest
sudden knoll
#

ohh so image processing

lusty quest
#

ye

sudden knoll
#

very nice

lusty quest
#

also it would be relatively cheap to make, a nvdia Jetson is like 40€

sudden knoll
#

I'm about to write a script that'll write my getters and setters for me

#

because aghghgh

lusty quest
opal plank
#

wouldnt a camera or OCR be almost as slow?

lusty quest
#

why?

opal plank
#

the only downside it'd see would be the initial cost of a 3d scanner

lusty quest
#

we got a 3d scanner last week lol

sudden knoll
#

1 image would be faster than a 3d scanner

opal plank
#

put it to good use

sudden knoll
#

or multiple images

lusty quest
#

but for making a 100% check using a camera is cheaper

eternal osprey
opal plank
#

well yeah, thats what i said

lusty quest
#

also we would then need like 20 3D scanner to cover every production line

opal plank
#

the only downside is cost

#

the issue is dealing with reflections and accurace with a normal camera

lusty quest
#

so suggesting to buy 20 10k€ 3D scanner vs buying 20 Nvdia Jetson for 40€ each and a Camera

opal plank
#

you'd prob want something cheap like an infrared camera to make sure it gets depth

sudden knoll
lusty quest
sudden knoll
#

lol

#

okay

opal plank
#

fair point

sudden knoll
#

was wondering if there were any speed reasons or smthn

opal plank
#

i literally sent you something that does almost a million ops/s

lusty quest
#

Mongo is easier to scale tho, also you might get better Read I/O if you set it up correctly

sudden knoll
#

don't worry, I'll get to KeyDB eventually

#

rn have no need for that tho

opal plank
#

prob best to stick with redis then

opal plank
lusty quest
#

for now i have a single MongoDB instance that gets cached by redis.

sudden knoll
#

just trying to push out something functional before I get reviewed

opal plank
#

if i were you, i'd stop relying on bot guides

lusty quest
#

but i could run 3 Mongo instances in a replica set and use the secondary nodes for reading and the primary for writing

deep mica
#

aga

eternal osprey
deep mica
#

bana bir yardım edin

#

discord.js modulü yok diyor ama var

opal plank
opal plank
deep mica
#

ı have discord.js modul

#

but

lusty quest
#

did you have it installed?

opal plank
#

def not

sudden knoll
#

transferring to a SQL database is pretty simple if you know what your columns'll be

eternal osprey
opal plank
#

and which db did u choose

lusty quest
#

just make a loop and read the stuff in your old db and write it in the right format in the new DB

opal plank
#

^^

#

basically this

lusty quest
#

atleast this is how i did it with my migration

opal plank
#

the only different is if you're using a document or relation based db

sudden knoll
#

don't know how else you'd do it

opal plank
#

manually

sudden knoll
#

lmao

boreal iron
lusty quest
#

being stupid, dumping the Old DB, opening the file in Notepad and then copy/paste it into the new DB

sudden knoll
#

nah, just throw away all the currently stored info and hard reset

#

no issues then

opal plank
#

its not my time being wasted, so i really wouldnt care if someone did that

#

THOUGH

#

speaking of idiocy

#

i did copy over 500 numbers manually

boreal iron
#

Imagine adding 4kkk lines manually

sudden knoll
#

lmao

opal plank
#

to convert a Buffer response to see wtf was the error cominbg from

#

it was on console

#

and i didnt have access to the error anymore

sudden knoll
#

that is highly unfortunate

opal plank
#

guess who opened console and copied the numbers one by one into an eval command to convert that buffer into json object

pale vessel
#

not you

opal plank
#

100% not me

pale vessel
#

yep

opal plank
pale vessel
#

Not Erwin

opal plank
prime mist
#

You got your intern to do it?

opal plank
#

definitively

sudden knoll
#

now that's big brain

lusty quest
#

the most satisfying thing ive did in a while, Automatic offsite Backups for my Database, once a week i run 2 scripts on my server. 1 Dumps my MongoDB into a file. the 2nd Script uploads it to a Google Drive

opal plank
#

i did a smarter move later down the line tho

#

i made VSC full screen and changed the output port to 20%

#

so i could copy the whole BufferArray in one go

lusty quest
#

also have automatic managing of old files, if the backup is older than 14 days it gets deleted

opal plank
#

backups is for the smart kids, we dont do that here sire

lusty quest
#

well have fun loosing all the configs of your Bot

#

bcs the Datacenter burns down

opal plank
#

imagine using a db that isnt acid compliant

prime mist
#

Lol. Backups are for people who don't want to mess with Murphy's Law

opal plank
#

all 3 servers are in the same center either way

#

not gonna backup over 15gb of data locally

boreal iron
#

Imagine using non-redundant setups

lusty quest
#

lol just pay google 3€/Month to get 200GB offsite Backup space

sudden knoll
#

with murphy's law, the backups'll get corrupted too

opal plank
#

bold of you to assume i have money for that brain

lusty quest
#

or get google enterprise stuff and create 5 accounts to get 1PB of storage

opal plank
lusty quest
#

then rent a cheaper server

#

64GB ram would work for you too i guess

quartz kindle
#

back the fuck up

#

:^)

lusty quest
#

idk if you know the game Robocraft, but they got almost entirely nuked by the OVH fire, luckly they had a offsite backup

opal plank
#

all 3 are in the same center though

lusty quest
#

why?

opal plank
#

why wouldnt it?

prime mist
#

For my day job I run a kubernetes cluster with 100s of workloads. I have learnt the hard way that you need to cover your ass.

lusty quest
#

sure better latency, but the risk would be way to high

opal plank
#

theres a server for the database, one for the bot, and one for another thing

opal plank
#

each one of those is a physical rack

#

not a vm

lusty quest
#

dude if the center catches fire every machine is toast in there

opal plank
#

yeah, the only thing saved is the code on github

#

the user data would indeed be lost

lusty quest
#

just spend like 3$ or so on cloud storage to have some sort of offsite backup

quartz kindle
#

get fireproof ssds

opal plank
lusty quest
#

they wont withstand the hell

opal plank
#

the whole room is ventilaed and cooled down iirc

lusty quest
#

my company burned down back in 2013 and the fire managed to melt 0.5mm thick steel

quartz kindle
#

they will if you coat them with nasa grade anti heat material

opal plank
#

dip them in non conductive water

sudden knoll
#

actually, water without any minerals is the best insulator, so maybe

quartz kindle
#

put tbe entire datacenter underwater

opal plank
#

yeah

quartz kindle
#

loke a nuclear reactor

lusty quest
opal plank
#

pure water

copper cradle
lusty quest
sudden knoll
#

gotta live 3 hrs away then

prime mist
lusty quest
quartz kindle
#

lmao

lusty quest
#

and the risk that both catch fire the same day is relatively low

copper cradle
#

never mess with murphys law

#

it's the same as getting killed by a cow, it's low but never 0

stiff lynx
lusty quest
#

this is also an argument to make backups lol

stiff lynx
lusty quest
#

nice i see nested events

copper cradle
stiff lynx
stiff lynx
#

const codm = message.guild.roles.cache.find(role => role.id=== '<roleid>');
Will work?

#

all dead :/

prime mist
#

If you have the role ID already, you can use the get method.

stiff lynx
prime mist
stiff lynx
#

const codm = message.guild.roles.cache.get('<roleid>'); ?

prime mist
#

Urgh, I'm not a fan of discord.js. It feels over engineered.

#

And then you take at look at their source code, and it feels like spaghetti.

opal plank
#

most of the stuff is unoptimized and it tries to wipes people's ass for you

stiff lynx
#

nope it doesnt work

opal plank
#

out of curiosity

#

you are indeed changing <roleid> for the ACTUAL id right?

stiff lynx
#

ok, I'm not the best at coding and I'm actually dumb, but not this dumb

opal plank
#

just making sure, we do get those people here quite often

#

that would work if there was a role with that id there

#

if its returning undefined it means theres no role with that id

stiff lynx
#

const minecraft = message.guild.roles.cache.get('841574598969655347');

opal plank
#

.get() returns either a <role> or undefined

prime mist
#

Have you tried console.log ing the variable?

stiff lynx
#

but I have a question

opal plank
#

that syntax is correct

stiff lynx
#

whait

#

if instead of creating a variable with the id

opal plank
#

you can just console.log() that

stiff lynx
#

I put the id directly when it gives the role?

opal plank
#

console.log(message.guild.roles.cache.get('841574598969655347'))

earnest phoenix
#

best anti nuker bot

stiff lynx
#

await reaction.message.guild.members.cache.get(user.id).roles.add(minecraft);

opal plank
#

again

opal plank
stiff lynx
opal plank
#

imagine if get() returns undefined (aka theres no role with that id there)

stiff lynx
#

should work?

opal plank
#

<undefined>.roles

#

this will yield an error

stiff lynx
#

I'll try

opal plank
#

check if it exists before continuing

stiff lynx
# opal plank check if it exists before continuing

},
2021-05-11T08:31:51.509277+00:00 app[Worker.1]: id: '839900642722185248',
2021-05-11T08:31:51.509277+00:00 app[Worker.1]: name: 'CODM',
2021-05-11T08:31:51.509277+00:00 app[Worker.1]: color: 1002225,
2021-05-11T08:31:51.509277+00:00 app[Worker.1]: hoist: false,
2021-05-11T08:31:51.509277+00:00 app[Worker.1]: rawPosition: 10,
2021-05-11T08:31:51.509277+00:00 app[Worker.1]: permissions: Permissions { bitfield: 103927361 },
2021-05-11T08:31:51.509278+00:00 app[Worker.1]: managed: false,
2021-05-11T08:31:51.509278+00:00 app[Worker.1]: mentionable: false,
2021-05-11T08:31:51.509278+00:00 app[Worker.1]: deleted: false
2021-05-11T08:31:51.509278+00:00 app[Worker.1]: }

#

it is all right

#

most stupid thing I've ever said

opal plank
#

what exactly is the error tho?

#

this whole time you asked "will this work"

#

and not what the actual error you're encountering

stiff lynx
#

it doesnt assign the role

opal plank
#

does the user exist in the server?

stiff lynx
#

the embed, the reactions works, but no role

opal plank
#

idk if d.js allows for you to pass a role

stiff lynx
opal plank
#

just pass an id

#

if the user left? idk if you are collecting reactions on the go or not

prime mist
stiff lynx
opal plank
#

pass in a string instead

#

or na ojbetc

#

ugh, let me check the shitty djs docs

#

1 sec

prime mist
#

Then you are probably short circuiting in one of those if statements.

opal plank
#

nope

stiff lynx
opal plank
#

you can pass a string instead

#

@stiff lynxtry <member>.roles.add('<roleid>')

prime mist
#

If the add operation was failing, then you would see an error. Because there is no error, it is likely not even being executed.

Tried putting console.log("adding role") right before you add the role, and see if it prints.

stiff lynx
#

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'guild' of undefined

opal plank
#

then theres ur error

stiff lynx
#

with the ID instead of variable it give me this

opal plank
#

where do you use .guild in that code?

#

show us the whole thing

stiff lynx
#

this is the whole code

#

if(!reaction.messsage.guild) return;

#

there is the error line

opal plank
#

either message or reaction.message is undefined

#

add this ontop of ur code

#
if(!message || !reaction?.message) return console.log('Something was undefined, canceling')```
opal plank
#

actually

#

there

#

yeah

#

right under the async function

prime mist
#

Where is execute being called from? Is it even the right arguments?

stiff lynx
#

UnhandledPromiseRejectionWarning: ReferenceError: reaction is not defined

opal plank
#

oh

#

right

#

reaction isnt up there

#

my bad

stiff lynx
#

lol

opal plank
#
if(!message) return console.log('Message was undefined, canceling')```
#

change it to this

#

and then

#
if(!reaction?.message) return console.log('Reaction.message was undefined, canceling')```
#

and then this here

stiff lynx
#

quick recap, one under the param at the top and the second one there?

opal plank
#

yeah

prime mist
#

Go learn typescript lol. The compiler would have warned you by now.

opal plank
#

THIS ^^^^^^^^^^^^^^^^

#

1000000% this

#

typescript is javascript, but better

#

and use detritus.js instead of that shitty ass discord.js lib

boreal iron
#

Omg there we go

zenith terrace
#

theres the "use this"

stiff lynx
#

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'guild' of undefined
When I add the reaction

opal plank
#

did you restart the bot?

#

also

#

you did add it ABOVE where i said right?

#

it should be under user.bot

#

also also

stiff lynx
opal plank
#

@stiff lynxu added the first but not the second

#

i sent you 2

#

even got an arrow showing where you wanted to put that in

stiff lynx
#

if(user.bot) return;
if(!reaction?.message) return console.log('Reaction.message was undefined, canceling')
if(!reaction.messsage.guild) return;

opal plank
stiff lynx
#

I copied it from there lol

prime mist
#

I would first console.log all the arguments passed to execute to figure out exactly what you are dealing with.

opal plank
#

not here

stiff lynx
opal plank
#

i see the first but not the bottom one

#

also

#

someone fucking slap me

#

what is this my dude

#

you're creating a new listener on every command?

opal plank
#

you're literally making a memory leak in ur code

#

use that command 25 times

#

see what happens

#

jsut trust me

#

trigger that 25 times

stiff lynx
#

tell me and not make me try lol

opal plank
#

everytime you run that command, you add another listener to your client, not only ONE, but 2

#

you should only EVER make ONE listener

#

this is oversimplifying, but for the sake of simplicity, im saying that

stiff lynx
#

I'm sorry, maybe I'll trigger u, but what is a listener?

opal plank
#

client.on()

#

that listens to an event

#

messageReactionAdd

#

messageReactionRemove

stiff lynx
#

ok

#

AND THERE ARE 2

#

srry for caps lock

prime mist
#

You will need to track the state of each message somewhere.

opal plank
#

basically it'll likely crash and error with a error 1 when you clçick that reaction 25 times

#

or command

stiff lynx
opal plank
#

you'll get this

#

MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 event listeners added. Use emitter.setMaxListeners() to increase limit

#

actually

#

its 11 not 25

#

you only want ONE

#

never put listeners in ur commands

prime mist
#

Unless you use once

opal plank
#

useless here

prime mist
#

But that won't work here, because the reaction could be for another message

opal plank
#

once() is not guaranteed to be the reaction from the message they're expecting

stiff lynx
#

I asked up if I should I create this in my events folder

#

because how I fix this

opal plank
#

if someone told you to do what you did, feel free to tell them they are dumb

#

best approach would be attaching a map to your client

#

and checking for active messages

#

or, better yet

#

use discord.js collectors

opal plank
#

never watch youtube videos

stiff lynx
#

but why

#

I feel dumb in reading docs

opal plank
#

read thgat

signal estuary
#

How do I get the version of discordjs?

opal plank
#

too lazy to copy paste

opal plank
#

tl;dr, rely on docs

#

not on videos/guides

#

guides can also be on that lower end of the spectrum

#

for example

#

you using discord.js

#

therefore you should be using this

#

holy shit its 6am

prime mist
#

To make your code work, you will need either a database to track state between restarts, or the simple option is put something in the embed to track it.

opal plank
stiff lynx
opal plank
#

been awake all night tho

dense spire
#

uh my code is saying syntax error with this line even though i didnt change anything

bot = commands.Bot(f"{pre}", case_insensitive=True)
zenith terrace
stiff lynx
opal plank
zenith terrace
#

big people

opal plank
opal plank
stiff lynx
#

I'm doing JS

#

years ago I did C++ and C#

#

and the teacher never said to read docs

cold meteor
#

Docs are big important

opal plank
#

ur teacher sucks then

stiff lynx
cold meteor
#

How the hell u gonna understand how an API works thrn?

#

Or how to communicate with it

opal plank
stiff lynx
cold meteor
#

If u dont read docs?

#

I-

#

WHAT

opal plank
#

sarcasm

stiff lynx
#

I'M TELLING THE TRUTH, NOT SARCASM

cold meteor
#

I

#

Im baffled

#

I self taught myself to code in 4 languages and even i know what thr fuck an api is.

#

@stiff lynx i think you gotta demand a refund ftom that school man

stiff lynx
#

this Is not the problem, the problem Is the teacher, the teacher says to you

#

"do this this and this"

#

but I agree that u never learn

prime mist
#

Google is a great teacher

stiff lynx
#

the most difficult program that I did Is sum of every Number before an input Number

cold meteor
#

No offence, but like, coding also comes from learning by doing stuff ureself and exploring what you can do.

#

So something tells me u didnt code outside of that class

stiff lynx
#

my bot isnt trash

cold meteor
#

I never said that?

stiff lynx
#

no, Just saying

cold meteor
#

My bot is getting added to a server with 10k members tje moment it gets verified by discord but u kno

prime mist
prime mist
#

Google shows results from stack overflow lol

cold meteor
#

@stiff lynx u know what a cog is right?

opal plank
#

they are js

#

not py

cold meteor
#

Oh oof

stiff lynx
#

but I tryied to read the docs, but for example, when I have to do reaction.message.guild.members.cache how can I get the order from the docs

cold meteor
#

Nvm then

opal plank
#

users outside of py wont generally know what a cog is

cold meteor
#

^^

opal plank
#

guild => members

stiff lynx
#

cache Is like a map, right?

#

and also fetch Is somrthing similar

cold meteor
opal plank
#

in order of what you're looking

cold meteor
#

Me rn

opal plank
#

starting with reaction

#

thgen we go to message

#

see where im going with this?

#

you follow the chain

#

but you are stuck in the last part

#

which is members

stiff lynx
#

so It Is All connected by a gerarchy

opal plank
#

which is here

#

yeah

prime mist
#

@stiff lynx in all seriousness, you should give Typescript a go. A type system is actually useful for learning.

opal plank
#

also, yeah

#

try using typescript

cinder patio
#

guys he barely knows js

opal plank
#

lax ts

#

will likely help

#

so he doesnt need to learn how to deal with interfaces/typesa

#

just abuse the intellisense

stiff lynx
cold meteor
#

@cinder patio hes been to school for coding apparently

#

We trusr he knows the basics

opal plank
#

fucking

#

@stiff lynx

#

check this one

#

look at all the errors it gives you

#

and the auto complete

stiff lynx
opal plank
#

learning comes from putting ur hands on code

boreal iron
opal plank
#

getting it dirty

opal plank
boreal iron
#

Speaking about auto complete

cold meteor
#

Nothing wrong with auto complete

boreal iron
#

Imagine using npp and have to type each letter yourself... that’s hard work KEKW

stiff lynx
#

@opal plank but now, my question Is, how I fix my reaction role HAHAHAHA

prime mist
#

JavaScript has auto completion too, so this is a moot point for typescript.

boreal iron
#

The coding language doesn’t matter...
The app supports auto completion because it can interpret the language

#

Knows it’s syntax and reads your opened files, defined functions etc.

stiff lynx
#

message.member.roles.add('roleid');
this could work, without the client.on

prime mist
#

Best thing about type systems is saving your ass from null and undefined.

They are the devil in disguise.

boreal iron
#

Literally available for each shitty app, probably even notepad (not plus plus)

#

undefined... well then switch to PHP

prime mist
#

I spent a couple years wasting away my life with WordPress. That stuff haunts you. Never again.

boreal iron
#

Well that’s your own fault wasting time with trash like that, don’t blame PHP for it

prime mist
#

Hah yeah. It paid the bills.

boreal iron
#

Just remember all the hours I spent to remove malware and try to improve the security just for the next WP update adding 100 new vulnerabilities

#

Only because that dumb retard I helped wasn’t able to setup a new forum or choose a different software for his community notlikenoot

prime mist
#

Laravel doesn't seem half bad. But yes. Once you have been burned by the PHP CMSs like WordPress and Drupal etc. You don't go back.

cinder patio
prime mist
#

Been trying to improve memory usage in a Discord client I have been working on. Turns out upgrading node from 12 to 14 makes quite a big difference! Before / after:

prime mist
#

Yeah, that's on our company cluster.

fringe coyote
#

Not sure if this is the right channel sorry, but i'm writing an API for webhooks there doesn't seem to be any well defined guide on authorisation, can you tell me if there's a good RFC you use or a guide which states that all webhooks use an auth header by standard?

stiff lynx
#

anyone that know a bot that gives roles after reaction? IDK how to do this by myself

prime mist
fringe coyote
prime mist
fringe coyote
prime mist
fringe coyote
boreal iron
#

Yeah... you create you webhook service and receive a JSON string

prime mist
#

Every implementation differs a little.

The industry standard is usually to sign the payload with a shared secret, then the signature is sent in the headers.

stiff lynx
#

In the docs I can find how can I send a message with the bot everytime a youtuber uploads a video?

opal plank
stiff lynx
opal plank
#

google it

#

like i said, i could answer it

#

but you need to grab a bit of independence

boreal iron
opal plank
stiff lynx
#

webhook is a connections between discord and another platform?

boreal iron
opal plank
#

in a way, yes, kinda

#

webhooks trigger whenever a service pings them

#

and then you process it as you need it

#

as they come basically

#

just look up youtube webhooks

stiff lynx
opal plank
#

you're looking at the shitty way

#

you dont need to use IFTTT

#

you CAN

#

but youtube should have some webhooks by themselves

proud lark
#

i literally use repl.it to code my bot lol

zenith terrace
#

ok

opal plank
#

not sure thats a thing to be proud of, but okay

boreal iron
#

Stop being lazy... code the stuff for him and let him copy and paste it Erwin

opal plank
#

now u help em

proud lark
#

lul

boreal iron
#

Need to google first what YouTube is

zenith terrace
#

whats youtube

#

also whats discord

boreal iron
#

Never heard of it waitWhat

stiff lynx
#

guys, they asked me to add my bot but them want a message every time they upload an video

#

but it really worth it?

#

because u can do this with webhook directly

#

or not?

half bear
#

up again

slender thistle
#

I just want to make my DataDicts serializable so that people can use them as dicts

#

And why I don't want to just make my own encoder for it is because it seems pointless if I can make the class serializable for the json module

earnest phoenix
slender thistle
#

Dumb me

stiff lynx
#

guys how can I do an advanced command handler? the one with commands oredered by category in different folders?

slender thistle
#

Correct, that's a letdown to my English language. What I meant is that if users wanted to serialize an instance of DataDict, they can do that without extra shenanigans

#

Like dd.dict or custom encoder

stiff lynx
#

2021-05-11T11:03:07.095857+00:00 app[Worker.1]: (node:4) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.
2021-05-11T11:03:07.095874+00:00 app[Worker.1]: (Use node --trace-deprecation ... to show where the warning was created)

#

info about this?

slender thistle
#

I've been going over Google for a long while and got no real answer that really assisted my question at hand: "How to make a class JSON serializable without implementing any additional methods like to_json"

errant perch
#

bot.user.setStatus(“idle”) isn’t working for me, any ideas?

earnest phoenix
#

So, in short, you wanted to make an object subscriptable as if it was a dict? Didn't the implementation we've talked in #topgg-api suffice? Why does this need to be serializable? To get passed on as the body when sending requests?

slender thistle
#

Mostly, but also to work with, say, json.dumps

#

And I mean being able to do json.dumps(dd) instead of accessing __dict__

eternal osprey
#

hey

#

i am trying to connect my vsc to mongodb

#

which connection method should i use?

cinder patio
#

you don't connect vsc to mongodb

#

vsc is a text editor

earnest phoenix
earnest phoenix
errant perch
earnest phoenix
#

You need to paste it in ready event

earnest phoenix
errant perch
#

You can’t change the status anywhere but there?

earnest phoenix
#

You can change with eval command

errant perch
#

I set the status in the ready event and nothing changed

#

Still says online

#

It’s not a big deal don’t worry about it

earnest phoenix
#

Yeah ik lol

errant perch
#

Actually it just changed never mind lol

earnest phoenix
#

NVM😅

errant perch
#

It takes a while

#

Well thanks anyway lol

earnest phoenix
#

Np

#

:)

eternal osprey
#

hey

#

const economy = require('../economy'). I am calling economy which is in my /schemas folder:

#

why can't it reach the economy.js?

zenith terrace
#

you are trying to get a file only, and the code cannot detect it inside the file

#

const economy = require('../schemas/economy')

crystal wigeon
#

has anyone used fastify?

crimson vapor
#

@opal plank can you help me with some ts?

crystal wigeon
#

show the schema file?

earnest phoenix
umbral zealot
#

"enable guilds.json in your invite link"? what does that mean

#

Oh you mean guild.join scope?

earnest phoenix
#

Yrs

#

yes*

#

Lol

#

Typo

umbral zealot
#

You can't get someone to join directly from an invite link. You would have to go through an oauth system.

#

However, you can redirect them to a discord invite after, using the redirect_uri system

earnest phoenix
#

Oh Ok Ty!

past dove
#

Any help please ?

#

discord.js 11.5.0

cinder patio
#

v11 doesn't work anymore

#

you need to rewrite your bot to v12

earnest phoenix
past dove
#

So if i will change discord.js to 12.5.1 its will work ?

earnest phoenix
#

Well some will work and some will not

past dove
#

thx

earnest phoenix
#

np

rocky hearth
#

u hv to rewrite ur whole bot in djs12. which will take some time

tacit sequoia
#

But v11 is broken lol

gray bronze
#

I am having trouble with CSS

#

<style>
body {
background: url('https:// i.imgur.com/Uqdu35r .png ')
}
</style>

That doesnt work for me

zenith terrace
#

try .entity-wrapper

gray bronze
#

Still not

#

Any other idea?

zenith terrace
#

uh no

gray bronze
#

Okay thx tho

earnest phoenix
gray bronze
#

Thats so you dont see the image

#

And now the image repeats itself

earnest phoenix
#

May we see how it exactly looks like?

gray bronze
#

Sure

#

Give me a min

#

Site doesnt always show updated version to me

#

@earnest phoenix

slender thistle
#

background: url(...) no-repeat

glad cobalt
#

I fixed my error and the bot runs fine but when I do my command it says

gray bronze
glad cobalt
#
(node:163) UnhandledPromiseRejectionWarning: TypeError: message.content.startswith is not a function
(node:163) 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:163) [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.
slender thistle
#

Try it, Crystiq

earnest phoenix
#

.startsWith

slender thistle
#

Use the Preview button

glad cobalt
#

._.

pale vessel
#

StartsWith()

gray bronze
#

Preview doesn't show any image at all

pale vessel
#

oh right, JavaScript

glad cobalt
#

yes

#
tolowercase is not a function
gray bronze
#

ToLowercase

glad cobalt
#

sheeeee

#

now it's green

gray bronze
#

So its correct

pale vessel
#

Yes

slender thistle
#

toLowerCase?

gray bronze
#

Flaze it doenst work

pale vessel
#

It doesn't?

#

Try shiv's solution

gray bronze
#

Nope

pale vessel
gray bronze
#

Im talking about the CSS lol