#development

1 messages · Page 1501 of 1

quartz kindle
#

all instances of A have the same prototype

#

so when you do instance.something() you're doing A.prototype.something.call(instance)

mellow kelp
#

oh yeah the prototype thing

#

now it makes more sense

quartz kindle
#

all class methods are stored inside the prototype, and all class instances share the same prototype

#

so the functions are all the same, but they are called with different this

rocky hearth
#

and how the inheritance work?

quartz kindle
#

there are 4 functions that override the this variable, .call() .bind() .apply() and function declaration

#

an extended class with new methods will create a new prototype that is a merge of both prototypes

blissful coral
#

Confusion for noobies

quartz kindle
#

but the functions in the prototype are still references, not copies

crimson vapor
#

hello Extreme

blissful coral
#

Hi

crimson vapor
#

we are learning about memory in js

#

and how its kinda smart

mellow kelp
#

yea

quartz kindle
#

js is very smart

mellow kelp
#

its all coming together

quartz kindle
#

sometimes too much smart

crimson vapor
#

you think?

heavy anchor
#

On today’s TimTalk?

blissful coral
#

Js is to smart

mellow kelp
#

js is too smart

#

but also really dumb

cinder patio
#

V8* is smart

crimson vapor
#

Extreme

#

you in eastern time or central time?

#

@blissful coral

earnest phoenix
#

js still flops in GC

blissful coral
#

Central

#

I’m in biology rn

rocky hearth
#

what is this GC?

cinder patio
#

garbage collector

rocky hearth
#

so y its bad in it?

crimson vapor
earnest phoenix
#

this is the reason why chromium eats so much memory, really bad garbage collection

crimson vapor
#

oh

#

thats an issue with V8?

cinder patio
#

mhm

crimson vapor
#

is there any way to manually gc?

#

or do it better

cinder patio
#

you can manually sweep it

crimson vapor
#

or thats just built in to V8

earnest phoenix
#

switch to c++

cinder patio
#

yea if you really want performance

#

or fork v8 and add manual memory management instead of gc

earnest phoenix
#

modern languages take away the pain of managing memory

#

that's a selling point for a lot of them

cinder patio
#

though c++ also has ways of making memory management easier... shared and unique pointers

umbral zealot
#

for deleted message you don't have a web process running.

#

😂

near stratus
#

f I announced my app name literally

earnest phoenix
#

having an automatic GC doesn't mean lesser performance though, it just needs to be done properly

for example .net5 has an insanely good GC, knowing when to dispose objects, when to spawn objects on the heap etc

near stratus
#
at=error code=H14 desc="No web processes running" method=GET path="/" host=app.herokuapp.com request_id=dbc0b235-6844-44cc-93db-f894e7b9a1d3 fwd="37.69.201.69" dyno= connect= service= status=503 bytes= protocol=https
umbral zealot
#

ok well, you do'nt have a web process running 👍

mellow kelp
#

your app must have a web process

near stratus
#

it has

umbral zealot
#

what does your Procfile look like?

near stratus
#

worker: node index.js

#

like this

mellow kelp
#

that's a worker process

near stratus
#

And my index.js contains

server.all('/', (req, res) => {
    res.send('Plubin is up');
});
server.all('/favicon.ico' , (req,res) => {
    res.send('Not provided');
});
server.listen(PORT, () => {
    console.log(`Server is up on port : ${PORT}`);
});
near stratus
mellow kelp
#

yeah

near stratus
#

This person just died

mellow kelp
#

you'd have to split your server and bot into two processes

#

well

#

at least if you also got a bot running or something

near stratus
mellow kelp
#

k

near stratus
mellow kelp
#

oh k

#

then you gotta add a web process to your Procfile to run the server

crimson vapor
#

whats server.all vs server.use?

mellow kelp
#

server.all is just for that route

#

server.use is for the route and every of its sub-routes

crimson vapor
#

hmm

#

oh

#

makes sense

mellow kelp
#

yea

#

@near stratus for a favicon you probably just wanna use server.get

#

i mean, no one's gonna try to make a delete request to your favicon

crimson vapor
#

I might KEKW

near stratus
#

@mellow kelp thanks it works now

mellow kelp
weary widget
#

does anyone know how axios works? im trying to make a command that calls an external api but i keep getting this error

quartz kindle
#

data[0] is undefined

weary widget
#

wait it works if i just do res not res.data[] thanks

mellow kelp
#

you probably have a syntax error right before that

shrewd creek
#

@bot.command(name='botusers', help='only vissible to devs')
@commands.is_owner()
async def botusers(ctx):
await ctx.send(f'{len(bot.guilds)} server count')
await ctx.send (f'{sum([g.member_count for g in bot.guilds])} user count' )
await ctx.send([m.name for m in bot.guilds] )
await ctx.send ([g.name for g in bot.users] )

this gives me names of users form every guild

but is there a way to isolate and get the name list for a given guild name??

#

guys??

slender thistle
#

what in the living fuck

#

Create one big string and send it once instead of sending separate 4 messages

shrewd creek
#

lol

slender thistle
#

Also what do you mean by that

earnest phoenix
#

they're probably going to exceed 2000 char limit with the last two messages

slender thistle
#

Names of members of a specific guild?

shrewd creek
#

yea

slender thistle
#

Which guild specifically?

slender thistle
shrewd creek
#

like if my bot is there in a server ; bot

i shold be able to get the names of botusers foronm that guild alone like
#botusers bot.. should bing me the names

earnest phoenix
#

keep in mind that multiple guilds can have the same name

#

you should use the guild id instead

shrewd creek
#

hmm

#

so how do i write a code to get it with server id

#

await ctx.send ([g.name for g in bot.users] )

tired panther
#

can you set more than one key in a map

earnest phoenix
#

yes

#

if you're asking more than one same key, no

#

it will be overwritten

tired panther
#
client.react.set(msgid, { ///this saves the msgid in a map to prevent a fetch
      guildid: guildid,
      msgid: msgid, 
      reaction: emoji , 
      roleid: roleid,
      dm: dm
    });
``` link mgsid + emoji as key
#

I want to delete the map entrie with msg id 01929 but with the emoji 🤑

#

is it possible, without a for loop

last geyser
#

Anyone know of any way to embed the top.gg reviews section into another site without using iframes?

#

is it available via the api or something?

earnest phoenix
solemn latch
#

I dont believe anything with reviews are available via the api.

earnest phoenix
#

you can use message id + emoji string as the key and then just delete the same thing

umbral zealot
#

Pretty sure you'd have to scrape the reviews

earnest phoenix
#

which is going to be hard since top.gg uses cloudflare

last geyser
#

mmmm

#

that kinda sucks

earnest phoenix
tired panther
earnest phoenix
#

what

last geyser
#

I wonder if I could just fetch it using the URL the browser fetches from

earnest phoenix
#

no

#

quite literally

#

combine them in a string

tired panther
#

uff

earnest phoenix
#

234703377999593472 + 😆 -> "234703377999593472😆"

umbral zealot
tired panther
last geyser
#

No, it fetches /js/reviews.js, which I also assume then fetches another external URI

#

I could be wrong though

umbral zealot
#

no that`s javascript

earnest phoenix
umbral zealot
#

not data

last geyser
#

eh the js is obfuscated anyway

umbral zealot
tired panther
umbral zealot
#

So scraping would be the only way

last geyser
#

ah, that sucks

last geyser
#

Well, this is going to be interesting

tired panther
umbral zealot
#

In JS, puppeteer can do that in a jiffy

last geyser
#

tbh I could just cut out the reviews div and slap it in my page

earnest phoenix
umbral zealot
#

yeah sure just grab .reviews_wrapper 😄

last geyser
#

ah yeah thats a thing

#

cheers

umbral zealot
#

captcha? Thonk

last geyser
#

I mean

#

if I fetch it from my site via js

earnest phoenix
#

cloudflare will throw a captcha at you if your requests are sus

last geyser
#

then do it entirely client side

#

I highly doubt that it'll captcha me

#

even if it does, I could just fallback to iframing it

umbral zealot
#

It certainly won't if you do, say, a cache that refreshes only once an hour or twice a day or something

last geyser
#

Well yeah, I just remembered CORS exists and might become a problem

#

so client-side might not be entirely viable

mellow kelp
#

freakin cors

gilded olive
#

F

ember vale
#

How 2 code 4 dummies?

solemn latch
#

im sure the company that makes those books have one on programming.

neon turret
#

hey, how do I get the code for this description in a good looking position?

solemn latch
#

Well, youd have to decide that.

earnest phoenix
#

set a div's position to absolute and do whatever you want

#

and also increase its z-index

shrewd creek
#

how to get names of bot users in a server using server id?

tired plaza
#

Does anyone know how to check channel permissions for the bot on discord.js

mellow kelp
#

client.guilds doesn't have a get method

earnest phoenix
#

<Client>#guilds is a manager

#

Access it's cache property

mellow kelp
#

you're probably looking for client.guilds.cache.fetch(id)

mellow kelp
mellow kelp
#

oh wait

tired plaza
#

okay thanks ive been checking for the guilds p[ermission

mellow kelp
#

yeah guilds are cached

earnest phoenix
#

<Collection>#fetch() isn't a thing

mellow kelp
#

forgot i was using cache

#

my bad

#

client.guilds.cache.get

earnest phoenix
#

<Client>#guilds#cache returns a collection, use <Collection>#get() on it

#

did you login?

distant cobalt
#
const channel1 = message.mentions.channels.first()
message.channel.send(channel1)``` how do you have the command include a mention?
solemn latch
#

command include a mention?

distant cobalt
quartz kindle
#

how did you create client?

distant cobalt
#

if you're using a command handler, you don't need to define client. put message infront of client to define it

solemn latch
tired plaza
#

what permissions does my bot need to send a message, is it just SEND_MESSAGES?

#

cause im getting a error saying missing permissions

crimson vapor
#

EMBED_LINKS if you use embeds

#

what is the error exactly?

umbral zealot
#

It also needs permission to view the channel.

crimson vapor
#

oh that too

umbral zealot
#

as in, you can't send a message where you don't have rights to view that channel, that wouldn't make much sense ^_^

tired plaza
#

but if the bot cant view the channel how does it know the message was sent?

#

but it was missing EMBED_LINKS

quartz kindle
#

thats wrong

tired plaza
#

still missing one permission but idk what it is

quartz kindle
#

client doesnt exist in discord.js
Client exists

#

and Client is a class so you need to instantiate it but you probably already have an instance, so you shouldnt even be trying to instantiate it again

drifting wedge
#
    let id = document.getElementById("id2").value;``` the func accesses elements in the dom, it needs to be in the top or bottom of thr html?
#

in head or bottom of body?

pale vessel
#

always bottom of body

tired plaza
#
          return reject(new DiscordAPIError(request.path, data, request.method, res.status));
                        ^

DiscordAPIError: Missing Permissions
    at RequestHandler.execute (D:\Bots\Ranger(V1.4.4)\node_modules\discord.js\src\rest\RequestHandler.js:170:25)
    at processTicksAndRejections (node:internal/process/task_queues:93:5) {
  method: 'post',
  path: '/channels/691253619797786635/messages',
  code: 50013,
  httpStatus: 403
}```
is the error i get
pale vessel
#

you need to make sure everything loaded first

drifting wedge
#

alr

pale vessel
#

like last time when someone asked you to use onload, you could have just put your code on the bottom and it would have worked

drifting wedge
#

also, i made the func async but its really not updating

#

i updated the file in the webserver

pale vessel
#

again, check your console

drifting wedge
#

but the website isnt updating? do i shift f5?

#

i did

pale vessel
#

nothing?

#

go to errors

drifting wedge
#

function edit_bio() { < website
async function edit_bio() { < code

#

it does give errors

#

profile.js:4 Uncaught SyntaxError: await is only valid in async function

pale vessel
#

try shift f5 then

#

it shouldn't cache it though

drifting wedge
#

it still does

pale vessel
#

wasn't it ctrl f5?

#

i just use ctrl chift r

drifting wedge
#

i did it

#

still didnt update

#

waddafuck

pale vessel
#

it's not uploading correctly then

tired plaza
drifting wedge
#

i nano the file and it says async

#

like the file itself is async

quartz kindle
#

text? image? audio? link?

tired plaza
#

text

quartz kindle
#

only text?

tired plaza
#

embed

quartz kindle
#

embed needs EMBED_LINKS permission

#

files need ATTACH_FILES permission

tired plaza
#

does it need permission to access channel id or anything

quartz kindle
#

no

drifting wedge
#

profile.js:4 Uncaught SyntaxError: await is only valid in async function

function edit_bio() { so its not updating

#

does fetch HAVE to be await?

#

@pale vessel

tired plaza
quartz kindle
#

.cache.get

tired plaza
#
//////Modules//////
module.exports = {
 name: 'setlogs',
 execute(message, client, fs) {
//////Permissions//////    
 if (message.channel.permissionsFor(message.member).has("SEND_MESSAGES")){
  if (message.channel.permissionsFor(message.member).has("VIEW_CHANNEL")){
//////Main-Code//////
  let fullCommand = message.content.substr(9)
  if (fullCommand == "false"){
   message.channel.send("Logs have been Disabled") 
   client.Server ["Log" + message.guild.id] = {
    logchannel: "false"
   }
   fs.writeFile ("./data/Server.json", JSON.stringify (client.Server, null, 4), err => {
   if (err )throw err; 
    console.log("Server Data Updated "+message.guild.name);
   });
 }else{
   client.Server ["Log" + message.guild.id] = {
    logchannel: message.channel.id
   }
   fs.writeFile ("./data/Server.json", JSON.stringify (client.Server, null, 4), err => {
   if (err )throw err; 
    console.log("Server Data Updated "+message.guild.name);
   });
   message.channel.send(`<#${message.channel.id}> Set as Log Channel`)
  }
  }}
}};```
pale vessel
#

You can use .then()

#

But that's not the problem

#

Your website isn't updating

drifting wedge
#

mhm

#

i think imma just put code in script

quartz kindle
tired plaza
earnest phoenix
#

I’ve been trying all day to figure out why it’s not working ^ no it’s not my command handler

cinder patio
#

It's Number

#

with a capital N

pale vessel
#

do you not have console

earnest phoenix
#

@pale vessel no

#

@cinder patio it’s not working my man

cinder patio
#

show your code now

earnest phoenix
opal plank
#

weird choice to do Number() and not parseInt but okay

crimson vapor
#

is there a difference?

opal plank
#

not sure myself

pale vessel
#

Number parses floats as well

crimson vapor
#

well actually here parseInt would be better

#

but realistically is there a difference?

pale vessel
#

No

cinder patio
#

you can't delete 3.5 messages so yeah parseInt is better in this case

opal plank
#

thats some poor handling

#

check NaN too

earnest phoenix
#

So what’s the problem you guys see?

opal plank
#

all 3 of the above

earnest phoenix
#

Lines? Lol

opal plank
#

read

lament rock
#

You don't check for if the amount is NaN or if the amount is < 1

cinder patio
#

and you are not rounding it

#

or using parseInt

opal plank
#

^^

lament rock
#

You also cannot pass a float. Number parses floats like Google mentioned

opal plank
#

floats, round, nan and natural numbers

earnest phoenix
#

So

opal plank
#

fix all those

cinder patio
#

also learn how to view the console

#

google around

#

there's definitely a way

opal plank
#

^^

#

or use an eval

#

dump the error in chat

#

¯_(ツ)_/¯

earnest phoenix
#

(Number, args[0]);

lament rock
#

What?

opal plank
#

............

#

all i can say at this point is:

pale vessel
#

amazing

earnest phoenix
#

Lol..

opal plank
#

@earnest phoenix Before you make a Discord Bot, you should have a good understanding of JavaScript. This means you should have a basic understanding of the following topics:

  • proper syntax
  • debuging code
  • basic features (vars, arrays, objects, functions)
  • read and understand docs
  • nodejs module system

As much as we d like to assist everyone with making their bots, we rarely have the time and/or patience to handhold beginners through learning javascript. We highly recommend understanding the basics before trying to make bots, which use advanced programming concepts.

Here are good resources to learn both Javascript and NodeJS:

Javascriptinfo: https://javascript.info/
Codecademy: https://www.codecademy.com/learn/javascript
FreeCodeCamp: https://www.freecodecamp.org/
Udemy: https://www.udemy.com/javascript-essentials/
Eloquent JavaScript, free book: http://eloquentjavascript.net/
You-Dont-Know-JS: https://github.com/getify/You-Dont-Know-JS
NodeSchool: https://nodeschool.io/
CodeSchool: https://www.codeschool.com/courses/real-time-web-with-node-js
Evie s Accelerated JS: https://js.evie.dev/

Please take a couple of weeks/months to get acquainted with the language before trying to make bots!

pale vessel
#

That was fast

opal plank
#

cuz my bot has handy tags

lament rock
#

self bot!!!

opal plank
#

imagine removing my bot from here when its basically replacement of r.danny mmulu

earnest phoenix
#

Sigh...I come here for help but instead get the documents..

opal plank
#

you welcome

sudden geyser
#

You need to help yourself before we can help you.

cinder patio
#

we can't help you unless you show us logs

earnest phoenix
#

Alr

lament rock
#

It'll help you in the long run to read documentation and actually gain knowledge of the language. You would not have asked this question if you knew effective logic and debugging procedures

earnest phoenix
opal plank
#

nice, error cut in half

#

that shows a lot

earnest phoenix
#

Bruh

lament rock
#

That doesn't provide the error. The actual error is at the top of the stack

earnest phoenix
opal plank
#

MESSGAE_CREATE

earnest phoenix
#

Now? Happy

cinder patio
#

still nope

opal plank
#

does your bot even have permission to send messages?

lament rock
#

still not it

earnest phoenix
#

Bruh, yes @opal plank

lament rock
#

That's just the bottom of the stack where Discord.js checks for if stuff is cached

earnest phoenix
#

@lament rock tahts why I’m confused it’s now showing any error

cinder patio
#

give us the entire error already

opal plank
#

thats all io could guess from half the error

cinder patio
#

it is

earnest phoenix
#

Let me try again

lament rock
#

The error is there. Scroll up in the console

cinder patio
#

what you are trying to send is literally the error

opal plank
#

HALF of it*

#

and the least useful half of it

earnest phoenix
lament rock
#

deleteCount is not defined

#

lol

opal plank
#

reading do be hard sometimes

earnest phoenix
#

LOL

cinder patio
earnest phoenix
#

@opal plank yea on iOS yes

opal plank
#

upperCase

#

deletecount

#

not deleteCount

#

js is case sensitive

earnest phoenix
#

Oops..

#

Js you sensitive idiot

#

Lol

opal plank
#

just code in SQL, problem solved

earnest phoenix
#

@opal plank can it be used on iOS?

opal plank
#

im gonna pretend i didnt read that

mellow kelp
#

JUST 'code' IN 'sql'

lament rock
#

iOS sandbox do be strong though

earnest phoenix
#

Ayy worked guys :)!

#

Hm what if i want it embed?

#

Isn’t it

opal plank
#

then you send an embed

earnest phoenix
#

message.send.(embed) right?

cinder patio
#

try it

opal plank
#

tias

lament rock
#

You have to define embed

earnest phoenix
#

Alr, lemme try

opal plank
earnest phoenix
#

@opal plank lmao I love this meme

opal plank
#

same

earnest phoenix
#

Let’s Try 😎

#

Bruh nope didn’t work

#

Let’s see the error

cinder patio
#

of course it didn't

#

learn to code

#

at least learn the basics

umbral zealot
#

We keep trying...

opal plank
earnest phoenix
#

Lol

true ravine
#

I've just put my bot on github, and I want to be able to clone the repo on another device to work on it there. How should I handle the dependencies in node_modules? Should I upload them to the repo or is there some other preferred way?

mellow kelp
#

always ignore node_modules

#

thats what lockfiles are for, to keep track of dependencies and stuff

cinder patio
#

All the node modules are listed in package.json. Push your package.json and IGNORE the node-modules folder

#

after you clone, do npm i to download all the modules

true ravine
#

Yeah I've ignored them at the moment as I hadn't seen other repos with the folder

#

Oh yeah npm i

#

Thank you

earnest phoenix
#

We keep trying but always get the documents

earnest phoenix
#

Anyone help? @ember atlas

#

WTF

#

What just happened..

cinder patio
#

you shouldn't have leaked your token

ember atlas
#

Can you not

true ravine
#

This man is a madman

earnest phoenix
#

I’m sorry I didn’t

sterile lantern
#

uh

#

did you leak ur token?

earnest phoenix
#

How... no I didn’t

sterile lantern
#

what vps are you using?

crimson vapor
#

reset the token

#

lol

#

repl

earnest phoenix
#

I did but wtf

sterile lantern
#

and do that in the me-

#

are you using repl??

crimson vapor
#

yes

sterile lantern
#

i mean

#

.env

earnest phoenix
#

Ye..

sterile lantern
#

are you using .env

crimson vapor
#

.env or config or string

sterile lantern
#

or your bot security is at risk

earnest phoenix
#

Holy fuck man

opal plank
#

did we just witnes someone logging onto his bot and tagging everyone on every server?

earnest phoenix
#

That gave me a shitty shock

#

it could've been worse

#

@opal plank yes holy fuck how..

sterile lantern
#

is ur bot public?

earnest phoenix
#

No, holy wtf

sterile lantern
#

like do you use it in multiple servers?

#

oh

#

then its not that bad

opal plank
earnest phoenix
#

i've seen people fully atomic bomb tokens, delete and ban everyone in every guild lmfao

sterile lantern
#

how tf

earnest phoenix
#

@earnest phoenix lmao right when I got pinged I check the coding

sterile lantern
#

do you delete a guild?

#

as a bot??

earnest phoenix
#

i meant delete all channels

sterile lantern
#

o

#

lmao

earnest phoenix
#

The most weird part is I don’t have coding that can do that

dusty orbit
#

h

earnest phoenix
#

you leaked your token

sterile lantern
#

you should switch to .env

#

in your .env file:

earnest phoenix
#

how many times do you have to be told

#

@sterile lantern I will

umbral zealot
sterile lantern
#

token=token

#

then

umbral zealot
#

They just wrote their own code.

sterile lantern
#

in your index:

opal plank
#

^^

earnest phoenix
#

Then how can it be secure? @sterile lantern

opal plank
#

bruh

#

do you even read?

sterile lantern
#
require('dotenv').config();
client.login(process.env.token)```
#

bruh

#

do you not know what .env is

earnest phoenix
#

Yes, but if I do it how can it be like secure

sterile lantern
#

.env will always be a private file

earnest phoenix
#

Yes @sterile lantern I got it

umbral zealot
sterile lantern
#

so even if your project is public

#

they cannot access your token

#

if its in the .env file

earnest phoenix
#

I already done it @sterile lantern

sterile lantern
#

alright

#

make sure to change your client.login function

#

to

#

client.login(process.env.token)

earnest phoenix
#

In .envy right?

#

.env*

sterile lantern
#

no..

#

in .env you ONLY put this:

#

token=tokenhere

#

nothing else

earnest phoenix
#

The weird part is I’ve already done it..

#

So I have no idea how they got my token

sterile lantern
#

did you change your client.login function??

earnest phoenix
#

Hm, I don’t think

sterile lantern
#

thats probably why

#

make sure to add this:

earnest phoenix
#
require('dotenv').config();
client.login(process.env.token)```
sterile lantern
#

client.login(process.env.token)

earnest phoenix
#

So I put this in index?

sterile lantern
#

no dont put it together

#

in your index.js

earnest phoenix
#

Oh ok

sterile lantern
#

where you do

cinder patio
#

maybe you gave it to someone

sterile lantern
#

const discord = require('discord.js');

#

under that

#

put

#

require('dotenv').config();

cinder patio
#

while you were asking for help

earnest phoenix
#

@cinder patio same

#

@sterile lantern Alr

sterile lantern
#

yes

#

perfect

earnest phoenix
#

And then in the env I do this

sterile lantern
#

wait

#

no

earnest phoenix
#

TOKEN=.....

sterile lantern
#

why did you requrie it at the end

#

require*

#

in your code

#

index.js

#

on the top

#

where you require your packages

#

put the require dot env there

earnest phoenix
#

Oh my bad lol

umbral zealot
#

javascript is case sensitive so you need to put TOKEN in both places or token in both places, you can't mix the cases

sterile lantern
#

and then in .env make sure its
token=here

#

yeah lowercase if you do process.env.token

#

or uppercase if you do process.env.TOKEN

earnest phoenix
sterile lantern
#

oh

#

my god

trim saddle
#

@weak parrot you have big brain smarts right

weak parrot
#

Depends

earnest phoenix
#

@sterile lantern you said top-

trim saddle
#

why do you have the require under all the code

sterile lantern
#

i said at the very top

earnest phoenix
#

Ooh my bad LOL

sterile lantern
#

where you require your packages..

wheat jewel
#

Hey I'm transfering from quickdb to mongo and I'm wondering how I would do this

So I do item = args[0]
And thatll get me the first arguement:
I would just do:
```db.set(${reciever.id}${item}s, newrecieverinv);

db.set(${giver.id}${item}s, newgiverinv);```

How would I do this with mongo?

 result = await userSchema.findOneAndUpdate({ userid : userID }, {item : value    }) 
           
```but that doesnt work because it tries to set `item` to `value`
Do I have to make an if else statment for each item?
earnest phoenix
#

So all of the 3 lines at the top? @sterile lantern

#

Lr just the package one

sterile lantern
#

just the last two

earnest phoenix
#

Ok

sterile lantern
#

i mean

#

no

#

the const discord

#

and reuqire one

#

require*

#

leave the client.login there

trim saddle
#

@weak parrot uhhh how do you see if a permission is in a set of permissions

weak parrot
#

No clue KEKWlaugh

earnest phoenix
#

bitwise AND

wheat jewel
#

Anyone here use mongo?

sterile lantern
#

no

#

well i dont

#

some other people do

earnest phoenix
#

This at the end and those other at the top

trim saddle
#

i'm reading the docs

sterile lantern
#

yes thats fine

earnest phoenix
#

you just have to use bitwise AND

sterile lantern
#

now stop ur project

#

and run it agian

earnest phoenix
#

on your permissions

#

Alr

lament rock
#

if ((bitfield & permission) == permission) return true
else return false

trim saddle
crimson vapor
#

oh no

#

its a mod bot

earnest phoenix
#

@sterile lantern so uh how is my file private? And yea it’s working,

#

Only I can view it? And also the other that are helping me code it?

#

Or only me

lament rock
#

check what the keyword this is referring to. If you're nesting it somewhere this.client is defined, this might be referring to the arrow function

sterile lantern
#

only the people that are in the project and have edit permissions

crimson vapor
#

ready event is likely not a class

sterile lantern
#

so if you didnt add anyone then only you

crimson vapor
#

if it is my bad

sterile lantern
#

quite frankly,

#

i think repl makes it so only project owner can see .env

#

regardless of collabs

crimson vapor
#

yep

#

no

#

no teams can see it

sterile lantern
#

collabs can?

#

oh

#

rip

earnest phoenix
#

a sample of that is also in the docs

#

i think

trim saddle
lament rock
#

That statement wasn't meant for you, skull lmao

trim saddle
#

wh-

lament rock
trim saddle
#

i see but i still get false

lament rock
#

they're parsing from API

trim saddle
#

none of this is coming from the api yet

#

this is local testing

lament rock
#

Oh?

#

I see

earnest phoenix
#

discord's api will never return perms like that

#

Bruh, now my bot is not working

lament rock
#

They return a string which you can convert to a BigInt which is recommended

earnest phoenix
#

Help me someone

trim saddle
#
class PetalsPermissions<K extends keyof guildPermissionsType> {
    permissions: bigint
    constructor(perms: bigint|K[]) {
        switch (typeof perms) {
        case "bigint":
            this.permissions = perms
            break
        case "object":
            let n = 0
            Object.keys(guildPermissions).map(p => n = n | guildPermissions[p])
            this.permissions = BigInt(n)
            break
        }
    }
    // @ts-ignore
    get toJSON() {
        const d = {}
        Object.keys(guildPermissions).forEach(gp => {
            d[gp] = Boolean((this.permissions & BigInt(guildPermissions[gp])) == this.permissions)
        })
        return d
    }
}

this is the entire class

opal plank
#

is discord having a stroke?

#

or is it me?

crimson vapor
#

not you

opal plank
#

legit not getting post system messages

crimson vapor
#

discord is high or something

opal plank
#

my bot is reacting to the joined members but not getting system messages

crimson vapor
#

lol

opal plank
#

taken right now

earnest phoenix
#

@sterile lantern thanks :)!

lament rock
#

I do not believe you since the error states that this.client is undefined

#

log the value of this

#

or assign client to a variable which you can access without needing to access this

earnest phoenix
#

So uh, can someone help? It works and it also does this...

lament rock
earnest phoenix
trim saddle
#

if it's 0 it should be false

lament rock
#

& returns the bit you're checking for if it's in there. Not 0 or 1

#

0 if it is not in there

trim saddle
#

if it's one it should be true

earnest phoenix
lament rock
#

What's the error

earnest phoenix
#

It’s saying there’s a bug for no reason @lament rock

cinder patio
#

still, Skullbite is comparing the result to this.permissions, they should just check if the result is 0 or not

sterile lantern
#

is that a client.on function?

#

that message

#

or is it an error function?

#

like .catch or client.on(ready

grizzled raven
earnest phoenix
grizzled raven
#

oh wait

lament rock
#

If the output doesn't have client as a property, then this.client is undefined like the error suggests and you should assign the client variable to something other than this since this is a funny JS key word which if nested, refers to the scope it's in. In this case, a function or the scope which is calling the function.

grizzled raven
#

oh nevermind i guess it just ignores the * 1

crimson vapor
#
  • 1 is * 1
#

its not ignored

cinder patio
#

5 * 1 = 5

#

any number * 1 = same number

grizzled raven
#

just cause * 1 is 100 and *10 is 928

#

but

cinder patio
#

You are multiplying (4 * 23) by 10

#

which is 920

#

And Math.floor(25 / 3) is 8

trim saddle
#

wouldn't these be 0n if they were wrong...

grizzled raven
#

yeah i got it, just needed to add some brackets

trim saddle
lament rock
#

If the permission was not in the bitfield, the output would be 0n

#

If it was, & returns the permission

earnest phoenix
#

Why is this not working..

crimson vapor
#

what is got?

earnest phoenix
#

Just a package for it

trim saddle
#

all my comparisons are getting bigger than 0

crimson vapor
#

ive never heard of this

cinder patio
#

maybe you should stop copying code and start trying to understand how it works

lament rock
#

probably some obscure http lib lol

earnest phoenix
#

Yea, it’s pretty unknown

crimson vapor
#

use node-fetch

#

or anything popular

earnest phoenix
#

It’s made for

#

So it can’t send different images etc

lament rock
earnest phoenix
#

they've been told to go learn javascript and read useful articles more times than i have fingers on my body

trim saddle
#

hmm

earnest phoenix
lament rock
#

@ mods

trim saddle
#

2147483647n @lament rock

earnest phoenix
trim saddle
#

actually

#

this seems wrong for the one permission i'm using

lament rock
#

How did you get this bitfield?

earnest phoenix
#

i'm popping off on you because you're a help vampire, i have no problems with new people at all, i'm glad to help them whenever i can and it's super nice being able to direct them at docs

you however, actively refuse to read any useful resource that's thrown at you and then complain "WHY THIS NO WORK????" when you found the code in a garbage can equivalent
@earnest phoenix

cinder patio
earnest phoenix
#

codes

#

lol

#

cringe

lament rock
mellow kelp
#

at this point we're the ones making his bot KEKW

earnest phoenix
#

this tbh

trim saddle
#

hm.

earnest phoenix
#

we contributed to your code more than you yourself

trim saddle
#

oh lol

#

i mapped the wrong array

earnest phoenix
#

@earnest phoenix I’m gonna be honest I don’t learn shit from documents I’ve read the documents but don’t understand em

#

because you don't read with understanding

cinder patio
#

I think this channel should be moderated more strictly and people like Partyman should get blacklisted

earnest phoenix
#

you just skim read it

#

and then complain how you don't understand it

#

the type of person who doesn't think while reading a book and then complains the book is shit and doesn't make sense

#

when all you had to do was actively think about what you're reading

earnest phoenix
cinder patio
#

How old are you @earnest phoenix ?

earnest phoenix
#

@cinder patio bruh what’s that kind of question?

trim saddle
#
case "object":
    let n = 0
    // perms: array with permission keys
    Object.keys(perms).map(p => n = n | guildPermissions[p])
    this.permissions = BigInt(n)
    break
earnest phoenix
#

I’m 14

trim saddle
#

@lament rock maybe i'm parsing things wrong

earnest phoenix
#

Almost nearly I’m 13 rn but 14 in 21th February

trim saddle
#

wait...

earnest phoenix
trim saddle
#

FUCK

lament rock
trim saddle
#

don't say anything papi

#

don't.

lament rock
#

Alright

#

I'll spare you the pain

trim saddle
#

thank you.

#

forgot it wasn't actually an object i guess.

lament rock
#

pain

cinder patio
#

what is it 👀 is it because you're mapping the keys

earnest phoenix
#

Ya fucking joking me? Ya telling me I’m under 13 just because I copy n paste codes 🤦‍♂️

#

i cannot explain how much cringe my body felt by reading this message

#

How?..

cinder patio
#

they cannot explain

trim saddle
#

@earnest phoenix in all honesty, you shouldn't be copying without understanding what they mean

lament rock
#

Object.keys(ArrayLike) returns the Array indexes which would still technically be correct if you're accessing Array[key]

earnest phoenix
#

@trim saddle but tf is he saying that I’m underage?

#

notice how i said probably

#

Notice how I said ||stfu||

#

lol

#

i love script kiddies

#

they're amazing

trim saddle
#

wouldn't the Object.keys() for an array just be index numbers

lament rock
#

Ye

#

Log some values to find out :)

earnest phoenix
#

I love fat asses that sit on their chair using their pc’s 24/7 @earnest phoenix

solemn latch
#

i feel insulted

earnest phoenix
#

They’re amazing at coding

#

Like amazing

#

i love fat asses too

#

i like it thick i like it fat yeah

trim saddle
#

well they're stringed so it would still return an undefined

mellow kelp
earnest phoenix
#

Ofc you do

lament rock
#

Oh yeah. I forget Object.keys returns Array<string>

trim saddle
lament rock
earnest phoenix
#

@earnest phoenix Alr I’ll try to learn send me all the important documents only the important ones

trim saddle
#

alright

#

work time

#

bye peoples

lament rock
#

have fun cutie

trim saddle
#

it'll be hard but ok

cinder patio
#

also you can do n |=

earnest phoenix
#

@cinder patio any others?

#

@opal plank typescript is bullying me

#

Just give them rn, since now I’ll go hardcore on them

#

well, vsc theoretically

lament rock
#

If you read all of that and grasp the concepts they teach you, you won't be asking questions like you just asked today

#

TS does like to bully

earnest phoenix
#

** Just give them rn, since now I’ll go hardcore on them**

cinder patio
#

I just gave toy

earnest phoenix
#

and the tsconfig is at the root of the project

lament rock
#

control shift p => restart TS server

opal plank
cinder patio
#

Try closing and opening Vscode, this happened to me once

earnest phoenix
#

@cinder patio so those are the only one?

lament rock
#

that's a good thing to do when TS is being dumb

#

Just restarting TS server is sufficient

earnest phoenix
#

seems to work

cinder patio
#

yea that works too

earnest phoenix
#

thank

lament rock
#

Older versions require restarts more often, but I assume people spring for newer versions anyways

earnest phoenix
#

LOL

lament rock
#

TS bundled with VSCode might be out of date so I just tell it to use npm installed binaries

earnest phoenix
#

hm

#

might be the reason why it broke

#

im running 4.1.3

#

but on an older project everything seems to be fine

lament rock
#

I think that's latest amandathink

earnest phoenix
#

Want me to nitro boost lol?

#

nobody gives a single shit go talk in general

#

nobody gives a shit about your exsictence please go sit on your fat ass

sinful belfry
#

can you both be polite to one another

earnest phoenix
sinful belfry
#

this is not the place to argue, and general conversation should be in #general @earnest phoenix

earnest phoenix
#

@sinful belfry ima be honest his been after me since I came to this channel and I’m tired now

#

And that’s like 9 days ago or something

#

Yea I really am pissed now

sinful belfry
#

im not asking what has happened, im telling you that general conversation should be in #general and you shouldnt be arguing here

#

so please stop

earnest phoenix
#

Alr

lament rock
drifting wedge
#

in python, how can i do like: if "joe" is in this list 3 times, do this

umbral zealot
#

probably regex then count the results.

earnest phoenix
#

Tsk tsk tsk

craggy pine
#

Party, as people said earlier. Please talk in #general if you're not asking or helping for development questions.

crimson vapor
#

how should I access client on a class but if you were to log the class, client would not show up? js/ts

#

would private property work?

#

and how would I do that in js

umbral zealot
#

pretty sure there is a private property on classes.

crimson vapor
#

ik about that on ts but what about js?

lament rock
#

JS doesn't have private properties. You could manage the reference in a variable in the root scope and use a getter to return the value. Getters do not show up in logs

crimson vapor
#

and is private what I am looking for?

umbral zealot
#

Since node 12 and on all recent browser that aren't, like, safari or some other archaic thing 😛

lament rock
#

Hm. Node 12. Not sure why I haven't seen this

#

strange implementation nonetheless

umbral zealot
#

¯_(ツ)_/¯

sudden geyser
#

Safari supports private class fields, but only in technology preview atm

solemn leaf
#
var width = 400, height = 400, buffer = Buffer.alloc(width * height * 4);

for (var y = 0; y < height; y++) {
    for (var x = 0; x < width; x++) {
        var pos = (y * width + x) * 4;
        buffer[pos] = 0;
        buffer[pos + 1] = 10;
        buffer[pos + 2] = 100;
        buffer[pos + 3] = 255;
    }
}

message.channel.send("loading", { files: [buffer] })

It sends the image, but its a jpg that doesnt display anything

drifting wedge
#

for flask
do i use asyncio.sleep or time.sleep?

sudden geyser
#

If you're in an async scope, use asyncio.sleep. If you're in a blocking scope, use time.sleep (which blocks)

mellow kelp
#

so uh

#

is it possible to set a prototype property of a class as an different empty object for each instance?

#

i tried TheClass.prototype.obj = {} but that just passes the same object reference to every instance

earnest phoenix
#

@umbral zealot lmao I thought that said private ass fields LOL

halcyon kite
#

uhh hey guys how do you fetch a channel of ur choice?

silent cloud
#

Yo guys

#

Can somebody help

#

Code part

#

Thats a translate command

#

I have error about results(const) empty

#

But why

tranquil drum
#

What’s the error exactly

halcyon kite
#

ok umm another question
how do i make it so the amount works look heres what happens

#

and here is the code:

#

yeah its big

solemn latch
#

look at the second args value

halcyon kite
#

u mean the args[1]

solemn latch
#

yep

halcyon kite
#

ok

#

hmmm

#

this happens

#

hmm

thick horizon
#

How to have a Range Developer?

earnest phoenix
halcyon kite
opal plank
#

that isnt the code

#

thats the command

halcyon kite
#

ik im sending wait

opal plank
#

do you use visual studio code?

halcyon kite
#

yes

opal plank
#

read that

earnest phoenix
#

Does debugging work in a discord bot code?

opal plank
#

of course

earnest phoenix
#

Oh right

halcyon kite
earnest phoenix
#

You are using args[0]

solemn latch
#

you are using args[0]

#

jinx you owe me a soda

earnest phoenix
#

That takes the command

sudden geyser
#

Looks very repetitive

earnest phoenix
#

You must use args[3]

#

2*

quartz kindle
#

fetching from the db a bunch of times and then never using it

solemn latch
#

or args[1] depending how you define args

earnest phoenix
#

Ya

earnest phoenix
halcyon kite
#

ok

#

hmmm

#

wair

#

i dont need 4 of those fetch

earnest phoenix
#

Lmao

quartz kindle
#

you see that the variables are colored differently?

#

that gray-blue color means the variable is not being used anywhere

earnest phoenix
#

Ya

#

Or readed

#

It's the same thing ikr

halcyon kite
#

annnd nothing happens.

#

items is needed tho

earnest phoenix
#

(It's a suggestion)

halcyon kite
#

hm

quartz kindle
#

you have a CSP header that prevents using external urls as image sources

earnest phoenix
#

xd

halcyon kite
#

this me friend

solemn latch
earnest phoenix
#

Tim our savior

halcyon kite
#

no i am using args[1]

earnest phoenix
#

Use 2

#

I said 2

halcyon kite
#

ok

earnest phoenix
#

1 gets the "pokeball" string

quartz kindle
#

what are you using for webserver?

earnest phoenix
#

Tim you are our savior lmao

quartz kindle
#

whats the webserver software

#

nginx? node?

halcyon kite
earnest phoenix
#

Ubuntu as webserver software?

quartz kindle
#

nginx reverse proxy?

earnest phoenix
#

Is that possible?

halcyon kite
#

this is with args[2]

solemn latch
#

log your args

halcyon kite
#

k

quartz kindle
#

show your reverse proxy config

#

do you have set headers for content security policy?

halcyon kite
#

didnt log

#

oof

craggy pine
#

How did you write your console.log()

halcyon kite
#

tho should i put the thing

craggy pine
#

So that means it never reached that part of the code

halcyon kite
#

yeah

craggy pine
#

so you know it's something before that.

halcyon kite
#

yep

craggy pine
#

Instead of asking for every time it doesn't work, you can play around wit the args[] and whatnot until it does.

quartz kindle
#

why do you have both proxy_pass and proxy_redirect?

craggy pine
#

since you can use console.log() to log each step to figure out where it breaks

halcyon kite
#
if(isNaN(args[1])) {
            message.channel.send("specify a number.")
        }
        if(purchase === 'pokeball'){
            let pball2 = args[1] * 250
            if(amount < 250) return message.channel.send('You do not have enough money to buy this pack/item. Please try another one');
            db.subtract(`money_${message.author.id}`, pball2);
            db.add(`pokeball_${message.author.id}`, args[1]);
            console.log("log1")
            message.channel.send(`You just bought a pokeball pack!`)
        }
#

this is the args[1] part

solemn latch
#

where are you logging it

halcyon kite
#

for pokeball

solemn latch
#

🤔

halcyon kite
#

the console.log

#

afterdb.add

#

it sends the isNaN

#

well not the log part

solemn latch
#

thats in an if statement thats not running and doesnt contains args

halcyon kite
#

in discord it sends isNaN

solemn latch
#

log it outside all if statements, and log the args variable

halcyon kite
#

ok here wait

quartz kindle
#

do you have Content Security Policy anywhere in your nginx configs? even outside of the proxy block?

#

just so we dont add duplcated stuff

halcyon kite
#
if(isNaN(args[1])) {
            message.channel.send("specify a number.")
        }
        console.log("log1")
``` this works
#

it logged

solemn latch
#

log the ARGS

#

so we can see whats in it plox

#

not "log1"

halcyon kite
#

here

#

this is what it logged

#

i said 1 pokeball to buy

solemn latch
#

your args dont seem to be args

halcyon kite
#

yeah ik

earnest phoenix
#

Also, you must use return(?

solemn latch
#

why would you name it args if its not args 🤔

quartz kindle
#

he probably did console.log(args[1])

solemn latch
#

ag

halcyon kite
#

e\

#

e jfnmszlvj

#

this is my brain

earnest phoenix
#

Mm

halcyon kite
#

i swear it has died at this point or it has died before

#

:/

earnest phoenix
#

I think you must use return to prevent executing the rest of the code and getting any error

quartz kindle
#

i was never alive

#

xD

halcyon kite
#

true

earnest phoenix
#

Lol

halcyon kite
#

XD

halcyon kite
#

sad

quartz kindle
#

when they asked you to log args, they meant console.log(args)

halcyon kite
#

ooh

earnest phoenix
#

lmao

halcyon kite
#

im brain ded

quartz kindle
#

so they could see what the variable args looks like

earnest phoenix
#

Ya

#

Show us where is defined arga

#

Args*

halcyon kite
#

there

#

this is log

quartz kindle
#

because once you see how args looks like, then you also see which index is the correct one

#

see, so pokeball is index 0, and "1" is index 1

craggy pine
#

so '1' would bne index 1

halcyon kite
#

ok

quartz kindle
#

so args[1] is correct

halcyon kite
#

ik

earnest phoenix
#

Lol

halcyon kite
#

args[2] was wrong

earnest phoenix
#

Oh

halcyon kite
#

yeah

#

also this sadly was the first error

#

i has encountered with this

#

so ye

quartz kindle
#

in cases like this, you use console.log to see what the code is doing, that way you can simply do the right thing instead of guessing around and blindly trying things

halcyon kite
#

yeah

#

e

earnest phoenix
#

Alright

#

Tim is our savior

craggy pine
#

Welcome to debugging

halcyon kite
#

yes

craggy pine
#

Console.log() is your best friend

halcyon kite
#

tim is savior of my buy cmd

quartz kindle
#

lmao

halcyon kite
#

and console.log() is indeed my best friend for code

earnest phoenix
#

What the hell means "of my buy cmd"?

halcyon kite
#

this is buy command

#

;/

#

cmd = command

earnest phoenix
#

Oh wait

#

Nvm

#

Lol