#development

1 messages · Page 150 of 1

wooden jungle
#

I did it

rustic nova
#

remove the depend_on of the database from bot then

wooden jungle
#

HttpGet

sharp geyser
#

seems like database will already shut down if bot does

lyric mountain
#

I'm not telling u to send a request from the code

sharp geyser
#

since it already depends on it

lyric mountain
#

I'm telling u to send a raw request

#

as in, barebones

wooden jungle
#

How

lyric mountain
#

wget is a program

wooden jungle
#

Ohh ok

lyric mountain
#

idk, what OS are u hosting the bot in?

sharp geyser
#

haku they are using bdscript do you think they know how?

wooden jungle
#

Bdfd

lyric mountain
#

bdfd also hosts bots?

deft wolf
#

It's phone app

#

Yea, you watch ads for credits

#

Iirc

wooden jungle
#

Bdfd is an app that can host and create custom command

lyric mountain
#

well, then that makes thing more complicate

small tangle
#

both depends on bot, but the services keep on running

lyric mountain
#

as idk any good app to send http requests

wooden jungle
sharp geyser
#

this is why I dont help people who use bdfd

rustic nova
small tangle
#

the same

rustic nova
#

gimme a sec

#

lemme try that on my vps

deft wolf
lyric mountain
#

from a hindsight there's nothing there to cause an Unauthorized response

small tangle
#

according to the docs depends on only say the startup order on up and the shutdown order on down, but has no effect when a specific service exits

rustic nova
#

it should

#

if the depends_on service exists, the one that has the depends_on should shutdown too

small tangle
#

i mean thats my intuition too

#

but my docker container says a different thing dogkek

rustic nova
#

sus docker rn

#

or you do have to do that passthrough of the socket

small tangle
#

or just use --abort-on-container-exit i suppose

sharp geyser
#

could always have your bot call to a service outside the container to call docker compose down for ya trollface

small tangle
#

but is it such a niche use-case?

sharp geyser
#

I don't suppose many want to actually do something like this

#

then again I could be wrong

#

most projects i've seen that use docker just let it happen if a service goes down

#

they don't bother bringing the entire container down and just wait for the service to come back up

rustic nova
#
Stops all containers if any container was stopped. Incompatible with -d
#

yeah nah this sounds like the only solution

small tangle
#

sad

#

thanks for the input tho blanketJam

rustic nova
#

or use --exit-code-from to directly specify the container

#

Return the exit code of the selected service container. Implies --abort-on-container-exit

#

it does the same behaviour as abort-on-container-exit, but iirc allows you to set which container it should use

#

so docker compose up --exit-code-from bot

small tangle
#

it would be nice to have something like this in the yml file

commands:
  up: docker compose up --exit-code-from bot      

so i dont forget the flag

rustic nova
#

actually re-checking the docs, this would only fire on a none-null return value

#

none-zero

small tangle
#

so --abort then

rustic nova
#

shrug no clue anymore KEKW

small tangle
#

xD

rustic nova
#

or pass-through again

small tangle
#

i mean it works alr with it

rustic nova
#

though tbf, it does sound sus when the database just gets shutdown through that

#

does it properly shutdown or just the container killed

small tangle
#

im just perfectionistic and was trying to found a more elegant solution

#

wait

#

i mean looks gracefully to me

#

lemme check logs

#
  • received fast shutdown request
  • aborting any active transactions
  • background worker "logical replication launcher" (PID 32) exited with exit code 1
  • shutting down
  • checkpoint starting: shutdown immediate
  • checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.015 s, sync=0.007 s, total=0.052 s; sync files=2, longest=0.004 s, average=0.004 s; distance=0 kB, estimate=0 kB
  • database system is shut down
rustic nova
#

looks fine yeah

#

you want a different name for that option dont you

small tangle
#

why abort and not just stop

rustic nova
#

exactly lmao

#

shutdown

small tangle
#

aborting sounds not really gracefully to me

rustic nova
#

sounds aggressive yes

small tangle
#

in the end, i still can use docker stop from outside in case i forget. its not like i want to shutdown the container 50 times a day. in the perfect world once its configured it should run till infinity Clueless

#

im just using this project to get a better understanding / knowledge of docker blanketJam i copied it over to my pi and it worked 1st try so thats a nice feeling

rustic nova
#

yup thats the magic of docker

small tangle
#

and the build times are now much faster bc i added another layer which just download my projects dependencies and since they dont change often they are cached once i rebuild it with changed code

dense musk
#

Nice

sharp geyser
#

@lyric mountain Love how Optional lists aren't a thing in prisma

#

so its basically requiring that Nutritional Facts exist on the table, yet what if its a product thats not edible, it wont have that

lyric mountain
#

can't u have an empty list?

#

ah wait, I get what u mean

#

this can be solved by putting the foreign key on Nutritional Facts instead of Product

#

actually, it has to be there, I kinda messed up on the example

sharp geyser
#
model Item {
  Id                 Int              @id @default(autoincrement())
  UPC                Int
  ProductName        String
  ProductDescription String
  AveragePrice       Int
  Edible             Boolean
  NutritionFacts     NutritionFacts[]

  @@unique([UPC])
}

model NutritionFacts {
  Id          Int         @id @default(autoincrement())
  Ingrediants String
  Amount      Int
  Component   Component[]
  ComponentId Int         @unique
  Item        Item        @relation(fields: [ItemId], references: [Id])
  ItemId      Int

  @@unique([ItemId])
}

model Component {
  Id              Int            @id @default(autoincrement())
  NutrtionFact    NutritionFacts @relation(fields: [NutritionFactId], references: [ComponentId])
  NutritionFactId Int
}
#

This is what I have so far

#

I could technically just assign an empty list to those inedible products

#

I also am going to rename Item to Product as it makes more sense

#

but ignore that

lyric mountain
#
model Item {
  Id                 Int              @id @default(autoincrement())
  UPC                Int
  ProductName        String
  ProductDescription String
  AveragePrice       Int
  Edible             Boolean

  @@unique([UPC])
}

model NutritionFacts {
  Id          Int         @id @default(autoincrement())
  ProductId   Int         @id
  Ingrediants String
  Amount      Int
  Component   Component[]
  ComponentId Int         @unique
  Item        Item        @relation(fields: [ItemId], references: [Id])
  ItemId      Int

  @@unique([ItemId])
}

model Component {
  Id              Int            @id @default(autoincrement())
  NutrtionFact    NutritionFacts @relation(fields: [NutritionFactId], references: [ComponentId])
  NutritionFactId Int
}
sharp geyser
#

Wait what

lyric mountain
sharp geyser
#

Why are you removing NutritionFacts from Item?

lyric mountain
sharp geyser
#

Wouldn't that break any link it has?

lyric mountain
#

if it works like JPA, then it'll automatically create a FK there if u declare on Item

#

run it and see how it generated the structure

sharp geyser
#

Error validating field `Product` in model `NutritionFacts`: The relation field `Product` on model `NutritionFacts` is missing an opposite relation field on the model `Product`. Either run `prisma format` or add it manually.
It has to have a field referencing NutritionFacts on Product

#

Item -> Product just now so don't get confused

lyric mountain
#

yes, I meant run your own code

#

to see how it generates the db structure

sharp geyser
#

gotcha

#

ight

#

let me do that rn

#

Product table

lyric mountain
#

yeah that's fine then, use the array thing

sharp geyser
sharp geyser
lyric mountain
#

it automatically creates the FK

sharp geyser
#

I will set a default of [] then

lyric mountain
#

aight

#

that actually makes sense, as a product cannot have null components

sharp geyser
#

cannot set a default on a relation field

#

😩

lyric mountain
#

but it can have no components

sharp geyser
#

looks like I will do it manually then

lyric mountain
sharp geyser
#

wdym

lyric mountain
#

like, just declare the column normally

sharp geyser
lyric mountain
#

NutritionFacts NutritionFacts[]

#

as u did up there

sharp geyser
#

Yea you can do that

lyric mountain
#

does this error?

sharp geyser
#

nah

#

doing @default([]) after does

#

cause I wanted to be lazy

#

and let prisma handle it for me

lyric mountain
#

but u dont need to declare a default do u? it'll be empty by default already

sharp geyser
#

Will it?

lyric mountain
#

I think so

sharp geyser
#

I mean we'll find out eventually

sharp geyser
#

@lyric mountain

return this.prismaService.product.create({
            data: {
                ProductName: "",
                ProductDescription: "",
                UPC: 1234545,
                AveragePrice: 16,
                NutritionFacts: {
                    create: {
                        Amount: 100,
                        ComponentId: 1
                    }
                },
                Edible: false
            }
        })

Look at how prisma creates things

#

Ima have to do a lot more logic ofc cause that specific ingrediant might not exist in the database yet

#

Oh god wait haku

lyric mountain
#

hm?

sharp geyser
#

I just realized, I will have to loop through the nutrition stuff and get each ingredient individually and check if it exists in the db before either creating it or assigning it to the NutritionFacts for that product

#

So many db calls

lyric mountain
#

u dont really need to

sharp geyser
#

oh?

lyric mountain
#

you see, you cant use a nonexistent component

#

the db will simply reject it because of the foreign key

#

if ur using a dropdown you already have a list of available components, if they somehow try to use an invalid component the product wont be added

#

that's the magic of constraints

sharp geyser
#

Ah right what was I thinking

#

So then I can just create the product then modify the NutritionFacts array to add on those components

#

or is there a better way?

#

Cause i'd still have to end up looping through the selected components, also if they are adding a product and they have an ingredient that doesn't exist yet they have to add it somehow

lyric mountain
#

on JPA I simply commit the entity with the collections populated and it simply generates the INSERT queries

#

try comitting a product with all facts added to it to see what happens

#

without saving the facts individually

sharp geyser
#

I don't actually have any components yet 👀

#

I gotta add some first

lyric mountain
#

add some bogus ingredients

sharp geyser
#

yep

#

Oh wait, won't this cause issues

lyric mountain
sharp geyser
#

Just realized that a component relies on it being connected to a Nutrition Fact

lyric mountain
rustic nova
#

+1

#

always use for work

lyric mountain
#

the FK is on facts, not on component

lyric mountain
sharp geyser
rustic nova
#

lipsum good for text fillers yes

#

but mock data generation, mockaroo

lyric mountain
sharp geyser
#

Yea thats my point

lyric mountain
#

since it wont be linked to a single fact

sharp geyser
#

😩

#
model NutritionFacts {
  Id          Int         @id @default(autoincrement())
  Amount      Int
  Component   Component[]
  ComponentId Int         @unique
  Product     Product     @relation(fields: [ProductId], references: [Id])
  ProductId   Int         @unique
}

model Component {
  Id              Int            @id @default(autoincrement())
  ComponentName   String
  NutrtionFact    NutritionFacts @relation(fields: [NutritionFactId], references: [ComponentId])
  NutritionFactId Int
}
lyric mountain
#

ah, there it is

sharp geyser
#

Likely to do with @relation on Component

lyric mountain
#

remove the last 2 lines

#

it shouldn't have any reference to facts

sharp geyser
#

But it also can't just Component Component[] on fact

#

the other table has to have something

rustic nova
#

like what type of format

sharp geyser
#

prisma models

lyric mountain
#

a fact would have only 1 component

rustic nova
sharp geyser
#

so it should be a one to one

rustic nova
#

meanwhile I'm doing that

CREATE TABLE xyzabcdefg

lyric mountain
#

many facts can refer to one component

sharp geyser
#

I have no idea how to setup a many to one relation in prisma

#

I'd assume it'd be the opposite

lyric mountain
#

just remove the array thing

#

it should be automatic

sharp geyser
#

Yea thats not how prisma works

lyric mountain
#
model NutritionFacts {
  Id          Int         @id @default(autoincrement())
  Amount      Int
  Component   Component
  ComponentId Int         @unique
  Product     Product     @relation(fields: [ProductId], references: [Id])
  ProductId   Int         @unique
}

model Component {
  Id              Int            @id @default(autoincrement())
  ComponentName   String
}
sharp geyser
#

yea no prisma requires something to be referencing NutritonFacts on the other side

lyric mountain
#

hm, that might make things complicated then

sharp geyser
#
model NutritionFacts {
  Id          Int       @id @default(autoincrement())
  Amount      Int
  Component   Component @relation(fields: [componentId], references: [Id])
  ComponentId Int       @unique
  Product     Product   @relation(fields: [ProductId], references: [Id])
  ProductId   Int       @unique
  componentId Int
}

model Component {
  Id             Int              @id @default(autoincrement())
  ComponentName  String
  NutritionFacts NutritionFacts[]
}

prisma out here auto putting shit in as well

#

Actually this makes sense what prisma did

#

in this way a Component can be linked to many NutritionFacts

#

Unless im reading it wrong

lyric mountain
#

technically yes, but one-way relationships are the proper way for such cases

sharp geyser
#

well Idk how to do the proper way with prisma

lyric mountain
#

like, the component doesn't need to know where it's used, it's used only for lookup

#

gave a search, apparently prisma doesn't suppose one-ways

sharp geyser
#

I guess I will do it this way then

#

if it works it works

lyric mountain
#

in the abscence of the correct option, pick the least wrong mmLol

#

-- sun tzu

sharp geyser
#

I follow him every day prayge

small tangle
#

why tf are powershell aliases so scuffed

#
Function dockerCompose { docker compose up --build --abort-on-container-exit }
Set-Alias -Name up -Value dockerCompose

bash be like alias alias_name="command"

lyric mountain
#

even on batch it was easier

#

doskey alias_name="command"

#

but ofc, they made sure to make everything more complicated on pshell

small tangle
#

and its weird that all commands and keywords are capitalized

lyric mountain
#

oh that's cuz c# (which inherited from VB)

small tangle
#

fair

#

but idk on command line im so used to being everthing lowercased

lyric mountain
#

as it was on batch (cmd)

small tangle
#

but at least i have my alias now blanketJam

sharp geyser
#

just use cmd then

small tangle
#

tbf i like the powershell 7 shell itself

lyric mountain
sharp geyser
#

I don't even use pshell for that

#

I use cmd

slender wagon
#

Is ngrok the best choice when testing webhooks locally?

#

Or is there something else

lyric mountain
#

webhooks or websocket?

#

cuz for webhooks u can just wget localhost

slender wagon
#

well i am connecting to a third party webhook basically i make the initial post request with the signature

#

this is for sellix

pale vessel
#

you could also connect it to a domain/subdomain and never have the need to change the url in the developer portal

slender wagon
#

hmmm i see

#

i went with ngrok lol

#

it's doing something at least

neon leaf
#

how can I make the last element(s) in the css grid that dont fill the entire page be extended to their max?

#

I currently have this classname (tailwind) grid gap-2 grid-cols-[repeat(auto-fit,minmax(min(28rem,100%),1fr))]

neon leaf
#

so grid is not the right answer at all

lyric mountain
#

yep, grids follow a fixed row-column structure

#

if you want a flexible layout, go flex

#

to force the "columns" to divide the available space equally u simply need to use the same flex weight on all elements

#

rows with only one element will automatically fill the available space, as there'll be none to share with

neon leaf
#

what properties exactly do I need for this to work with flex?

lyric mountain
#

flex: 1

#

with 1 being the weight

neon leaf
#

on the items?

lyric mountain
#

yep

#

which number u use doesnt matter, but using different numbers for items will change their "share" ratio

neon leaf
lyric mountain
#

you also need a minimum width for the elements, else they'll just squeeze together

#

width: 50% for example

#

if they still dont wrap, try this property

#

but they should without it

neon leaf
#

im really horrible at advanced css (if that even is lmao), im still at the same point as the screenshot

lyric mountain
#

start by setting a min-width for your cards (the message things)

neon leaf
#

alr

#

what should I set that to? I just set it to 10rem now

lyric mountain
#

if you want 2 columns, it must be at least half of the available space

#

well, technically at least 34%

neon leaf
#

I want it to detect how many columns fit, a card (in my case) technically should only have a max width, if there isnt enough space for a third the two cards will just share all space in that row

lyric mountain
#

aight, so add more cards there

#

only 3 wont be enough with 10rem min

#

alternatively just shrink ur window

#

flex should push the last card to the bottom row

neon leaf
lyric mountain
#

hm

#

set flex-grow: 1

neon leaf
#

is already

#

on the items

lyric mountain
#

it was supposed to grow then

#

what did u set the max width to?

neon leaf
lyric mountain
#

try removing it to see if anything happens

neon leaf
lyric mountain
#

hm

#

press f12 and scroll over flex attributes, see which one affects the card

#

select the card first ofc

#

also, you wont be able to use max-width anyway as it'll prevent the lone card from growing to fill it all

#

but u can set the max width on the text itself

rustic nova
#

can someone elaborate how the fuck I can RewriteCond something like *-deployment.example.com

#

or tell me a different apache2-like shit that does it easier

neon leaf
#

I have to apply the stuff to the <Link>

lyric mountain
#

link?

neon leaf
lyric mountain
#

ahh, the thing is wrapped in a link

rustic nova
# lyric mountain wdym?

goal is right now:

I want to be able to catch-all *-deployment.example.com, which would be handled by another app from mine that allows me to handle several domains for testing

#

the important part is not that

#

the important part is: how can I use RewriteCond to allow me to proxyPass that to another internal IP and not if it doesnt match

neon leaf
#

now I have this

rustic nova
#

already tried some braindead thing like

  RewriteCond %{HTTP_HOST} ^(.*)-deployment.example.com$ [NC]
  
  # Proxy pass the request to the appropriate server
  ProxyPass / http://10.10.10.100:1337/
  ProxyPassReverse / http://10.10.10.69:1337/

#

otherwise I'll just jump over to nginx and start using that

lyric mountain
#

never used apache so idk, but yeah nginx is usually easier to setup that

rustic nova
#

cool cool

lyric mountain
neon leaf
#

why? I need it so the text and image are seperated

#

also I forgot to move the flex-1

#

it now looks like this

rustic nova
#

cant you just flex-wrap the whole container, then set a fixed width of 50% (for each element)?

lyric mountain
#

flex is hard to get right without some experimentation on inspect element

rustic nova
#

this

#

agreed

lyric mountain
sharp geyser
#

flex is just hard to begin with

lyric mountain
#

but rows with remaining space must be filled by elements

rustic nova
#

yup thats possible with flex-wrap

#

or just not with tailwind dunno

#

managed to do that within bootstrap

neon leaf
#

well you can force tailwind to use any value

lyric mountain
#

try flexwrap then

sharp geyser
#

bootstrap is as old as time itself

neon leaf
rustic nova
neon leaf
rustic nova
#

I've tried sveltekit btw

#

I dont like the concept of client side rendering ngl

#

yes dynamic content

#

but

frosty gale
#

client side is less load on server ig

neon leaf
#

ill just keep it on grid for now. too tired

frosty gale
#

but I prefer ssr because its also a lot more secure since for example you can more easily choose whether confidential info gets transmitted to the client or not

#

some hybrid libraries are unclear on what info remains server side and what gets sent to the client which is extremely unsafe

lyric mountain
#

better than grid as it'll at least adjust based on screen width

neon leaf
#

grid does too

#

atleast I forced it to

sharp geyser
#

just like how I force others to do my css

neon leaf
#

good idea

#

but I dont know anyone thats good at css

#

so I have to force myself

lyric mountain
neon leaf
#

who?

sharp geyser
#

sayuri

#

cosmic

lyric mountain
#

the only person in the jail

sharp geyser
#

haku

#

he is cheap

lyric mountain
#

nah, I'm no good at css

sharp geyser
#

but you're cheap

neon leaf
#

I still cant quite decide whether a person being good at backend or a person being good at frontend has a better experience making projects

wheat mesa
#

Sayuri is good at both

#

😎

neon leaf
#

If those were a skill I would be invested 65% backend, 35% frontend

wheat mesa
#

I’d be 80/20 if we get to choose

sharp geyser
#

I'd just hire people

wheat mesa
#

Atm I’m probably like 99/1 lol, I need to do more frontend

sharp geyser
#

I would do frontend

#

but I dont have the patience

lyric mountain
#

I prefer backend as I dont need to care about tastes

#

but I can do both

scenic kelp
neon leaf
#

most backend devs can do both

lyric mountain
#

every dev is fullstack anyway

scenic kelp
#

you kinda need to be able to do both

lyric mountain
#

and you'll do fullstack but be paid for only one of the stacks

scenic kelp
#

how do you learn how to develop a backend without having a front end or vice versa

rustic nova
wheat mesa
#

I suck at frontend, I could do it but it would require me to learn boring frontend stuff 😭

rustic nova
#

of course having a backend handling stuff with auth

scenic kelp
#

sveltekit is weird but svelte itself i enjoy a lot

neon leaf
#

Im currently doing more frontend because my head is on fire trying to make my database proper, most endpoints already exist and work but there is no ui

scenic kelp
#

i think i might try and write a chat app finally

#

basically a rite of passage at this point

wheat mesa
lyric mountain
scenic kelp
#

i mean yeah but they're dependent on each other

#

not much point to writing a backend if a frontend doesn't or won't exist

wheat mesa
#

Frontend should be able to call backend functions but the frontend shouldn’t manage much data itself other than displaying it

scenic kelp
#

what the frontend needs dictates the backend's features

neon leaf
#

my newer projects look like this

wheat mesa
#

I really need to get back into programming, no good projects though and very little motivation

scenic kelp
#

me asf

wheat mesa
#

I’ve been too burnt out bc of job + figuring out college

neon leaf
#

I lose motivation after like 2 weeks and I gain it back because I have not alot else to do currently

scenic kelp
#

another reason why i wanted this laptop is that hopefully it'd motivate me to code more in my downtime where i'd otherwise just be laying in bed scrolling socials

earnest phoenix
#

My bot keeps going offline randomly and I don't know why lol

rustic nova
#

we dont know either shrug

#

maybe provide some code or errors or anything

earnest phoenix
#

Found the problem, all good

#

Was a stupid mistake

eternal osprey
#

always get this stupid error when installing canvas

#

or any fucking useful package using node-gyp

earnest phoenix
#

Permission Denied maybe it's because of that?

#

Linux right?

eternal osprey
#

no shit but i am unsure how to fix it

eternal osprey
earnest phoenix
#

Okay

#

Phew, I'll have a look

eternal osprey
#

sudo npm install canvas --save -g

this works -> but eventually it doesn't show up as installed in my node_modules.

sudo npm install canvas fucking doesn't.

earnest phoenix
#

lmao

lyric mountain
earnest phoenix
#

Yes, but sometimes it works like this, so it's usually like this for me (win11)

lyric mountain
#

yes, but that's not what I mean

#

if it install globally, it wont be in node_modules

earnest phoenix
#

I hope my bot is accepted I put many hours into it 🥲

earnest phoenix
rustic nova
#

holy fuck nginx was easy to understand

#

2 hours and everything moved over

#

damn

midnight marsh
rustic nova
#

I was crazy once

#

they put me in a room

midnight marsh
#

No

rustic nova
#

a rubber room

midnight marsh
#

Nooooo

rustic nova
#

a rubber room with rats

#

YOU STARTED IT KEKW

midnight marsh
#

Stop

#

Shit

#

😂😂😂

rustic nova
#

excuse me?

#

theres a @fs in sveltekit that exposes my filesystem?

#

at least on the dev instance using npm run dev

#

but still

#

why

#

literally exposing my whole deployment path

spark flint
#

lmfao

#

sEcUrItY SPEKULAYSUN

rustic nova
#

this is tbf

#

another mood killer for using sveltekit

frosty gale
#

i mean dev mode is designed to make everything easier so it would make sense to expose that

#

if it exposes it in production mode then thats a bigger issue

rustic nova
#

ye

digital swan
#

Could fs not just be used for hot reloading

sage bobcat
radiant kraken
slender wagon
#

Yall got any suggestions how to get started on DevOps

dry imp
#

whats devops

frosty gale
#

i still dont know what devops is

#

i think its some buzzword for some stack of development

quartz kindle
#

im not sure either but i think its related to system administration

#

like running linux and shit

#

examples of devops things:

Coding. Code development and unit testing.
Build. The process of continually integrating work from multiple developers.
Test. Continuous testing and reporting of defects and risks.
Packaging. ...
Change Management. ...
Configuration. ...
Release. ...
Service Level Objectives.

radiant kraken
neon leaf
#

what lib (js/ts) should I use for a very basic discord bot that will be in 1 server?

#

it should be a relatively lightweigth lib

radiant kraken
neon leaf
#

doesnt exist

pale vessel
neon leaf
#

tims lib?

#

@quartz kindle whats your opinion on your own lib

pale vessel
#

discord.js-light is just a bunch of monkey patches, I don't recommend you using it

quartz kindle
#

my bot currently uses it

pale vessel
#

I've also used it in the past and it was quite stable (after reporting a bug and testing many times)

neon leaf
#

using your own lib is always a sign of safe to use for me because if the owner discovers a bug while using its (often) fixed fast

#

ill try it

#

Ill only use very basic features anyway

pale vessel
#

don't think it's on npm yet so you have to use the repo url

neon leaf
#

tim, do you have some basic starting code

pale vessel
#

just create the shard and the rest client

#

there's typings too so you can look at those if you don't want to see the long js code

neon leaf
#

yeah but I am quite confused

quartz kindle
#

it doesnt do any processing like djs does, so you have to reference the discord api directly

#

s is the sequence number
t is the event name
op is the operation type
d is the json data of the event

#

you can ignore the sequence number, its handled internally

#

you can also ignore op

#

just use t and d

#

t will be strings like "MESSAGE_CREATE"

#

and d the event data

neon leaf
#

ah ok

#

could have better names :P

slender wagon
#

I have bad news. I have to learn golang

quartz kindle
#

not my fault

radiant kraken
#

haven't touched discord bots in years

radiant kraken
#

and manually handle websockets and shit

quartz kindle
#

its libless for those who dont want to actually do it themselves

#

a libless lib

#

lel

jaunty basalt
#

Can anyone pls explain me what is sharding in a discord bot, and how much time does it take to do?

deft wolf
#

Sharing?

rustic nova
#

you mean sharding

jaunty basalt
#

It was a type error, sorry

#

Can anyone teach me how to do that?
(discord.js)

sage bobcat
#

One message removed from a suspended account.

quartz kindle
jaunty basalt
sage bobcat
#

One message removed from a suspended account.

quartz kindle
#

sharding is recommended at 1500 guilds and becomes required at 2500 guilds

jaunty basalt
#

discord.js

sage bobcat
deft wolf
#

Yea, just type discord.js sharding in google

jaunty basalt
quartz kindle
#

discord.js has two types of sharding, internal sharding and the sharding manager

quartz kindle
#

internal sharding is just an option you put in your discord Client, its very easy to do, takes 5 seconds

#

internal sharding is fine up until about 10-20k guilds

#

depending on how cpu hungry your bot is

#

the sharding manager splits your bot into multiple processes, so depending on what your bot does and how does it work, it may need changes in your code

sage bobcat
jaunty basalt
sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

jaunty basalt
jaunty basalt
deft wolf
#

As Tim wrote, it all depends on how your bot works and what it does

#

In some cases you will have to change the code, in others you won't

quartz kindle
# jaunty basalt So what? That's it? Only I put that code and it's done? Nothing else?

you have to understand that using the sharding manager changes how your bot works, so you have to think about how that can, or not, affect you.
a normal non-sharded bot has everything inside the same process, all guilds, all channels, every thing, is all inside Client, easily accessible.

a sharded bot is different. you will have multiple copies of your bot running at the same time. for example if you have 2000 guilds, the sharding manager will create 2 copies of your bot file, 2 Clients, each Client only has ~1000 guilds, and their channels, members and users. each Client will only have the guilds for that shard and you will not be able to see guilds from a different shard from inside your code.

this is something you have to understand in theory and in concept, before you start working on it in your actual code, so that you dont get lost

rustic nova
#

and sharding is likely not gonna be a requirement you have to make until your bot is like, 200k was it?

#

around-ish 200k

quartz kindle
#

sharding is required at 2500 guilds

rustic nova
#

2.5k then yeah

dense musk
#

How to make money here

quartz kindle
dense musk
craggy pine
#

lol

frosty gale
#

statistics say most gamblers quit before theyre about to win

#

hope i havent just relapsed some gambling addict

sharp geyser
#

I stopped gambling after winning an item in a game that had a 0.001% chance of getting

#

I knew I had to stop cause I would of lost it

sharp geyser
#

Has it always been like this? I thought it would end up being [componentId, amount] of Object.entries(data.NutritionFacts)

#

didn't know the first thing would be a string

#

Also is there anyway I can define what these properties will be called

NutritionFacts?: Array<Record<number, number>>

I feel like Record<number, number> could be anything but I want it to tell me that the key should be a componentId and the value is the amount

earnest phoenix
sharp geyser
earnest phoenix
#

The only keys that are not converted to strings are symbols

sharp geyser
#

why

#

that makes no sense

#

this makes it weird now

earnest phoenix
#

Because numbers as object keys does not make sense, only strings and things like symbols, the other reasons are optimization-related

#

Most programming languages won't allow numbers as keys in objects

sharp geyser
#

grr

#

Well what should I do then, it feels weird having a useless string

#

I'll never need it

earnest phoenix
#

I'm not sure what you exactly mean by a useless string

#

Do you mean that you don't want to use componentId?

sharp geyser
#

By the looks of the screenshot componentId is just the id in the next variable defined

#

so that string is really just rather useless

#

as I need it in a number form not a string

#

and it is a copy of the number that already exists

earnest phoenix
#

Then you can just iterate through the values instead

#

Object.values() exists

#

Replacing that Object.entries() with Object.values() should work with your current code

sharp geyser
#

Type '{ componentId: number; amount: number; }' must have a '[Symbol.iterator]()' method that returns an iterator. can I seriously not [componentId, amount] it

#

I have to just use a variable

#

What does that even do?

earnest phoenix
#

const { componentId, amount } ...

sharp geyser
#

ight but what does wrapping it in [] do?

#

I always knew it was a thing but never actually knew what it does

earnest phoenix
#

Destructuring with [] pulls out elements one by one starting with the first element from an array, meanwhile destructuring with {} pulls out the specified properties from an object

sharp geyser
#

I see

#

so its just destructuring in a loop

compact cradle
lyric mountain
#

[] = positional destructuring
{} = selective destructuring

#

in simple terms

earnest phoenix
#
const foo = [1, 2, 3, 4, 5];

// Notice the hole (, ,)
const [bar, baz, , qux] = foo; // 1, 2, , 4

const quux = {
  qex: 'foo',
  5: 'bar',
  9: 0, 
  0: 1,
  qax: 'baz',
  qix: 'qux'
};

// 9 and qax ignored
const { qex, 5: rux, 0: rox, qix } = quux; // qex: foo, rux (5): bar, rox (0): 1, qix: qux
sharp geyser
#

makes sense

proven lantern
#

why does destructing objects force you to put the... last?

const {one, two, ...theRest1} = {one: 1, two: 2, three: 3} // works
const {...theRest2, one, two} = {one: 1, two: 2, three: 3} // doesn't work
sharp geyser
#

cause then you are basically overriding everything after it in that case iirc

#

which makes no sense

proven lantern
#

objects aren't ordered so order shouldn't change the outcome

sharp geyser
#

read up on that

#

what you are doing is spreading, and spreading at the beginning is basically combining everything at once

proven lantern
#

in my context it's the rest property

sharp geyser
#

what?

lyric mountain
#

spreading/deconstructing is ordered

proven lantern
sharp geyser
#

yea?

proven lantern
#

oops, need the object version

#

i think it should allow the rest property anywhere in an object

#

since order doesn't matter for objects

#

Volltrex

#

fault

lyric mountain
#

how would it be able to get others if it isn't the last element in the destructor?

#

while objects aren't ordered, a destructor is

proven lantern
#

it shouldn't be ordered for objects is what i think

lyric mountain
#

don't think u understand what I mean

proven lantern
#

destructor logic is currently ordered?

#

i see that

#

that's what i'm thinking should change

lyric mountain
#

{ a, ...others, b } considering the example in the image, ...others wouldn't know b isn't part of it (it's not assigned yet)

proven lantern
#

lookahead

lyric mountain
#

yes, but that adds overhead

proven lantern
#

or a flag

lyric mountain
#

the only way to fix this would be to throw ...others as the last element in the destructor, but again, overhead

proven lantern
#

Voltrex could do it

#

when js is being interpreted isn't it read from left to right? so initially it's just gathering symbols on the left side of the =. So it doesn't actually need to destruct until it parses the right side of the =

const {...theRest2, one, two} = {one: 1, two: 2, three: 3}
lyric mountain
#

so ...theRest2 doesn't know there are one and two in front of it

proven lantern
#

why would it stop? it hasn't gotten to the closing }

sharp geyser
#

Why is this even an issue

#

Why would you even want to do this

#

I see no practical usecase here

lyric mountain
#

if the first is a the rest operation, then it'll put all props in it

proven lantern
lyric mountain
#

it doesn't loop twice over the variables, it assigns in-place

proven lantern
#

by that time it has parse the entire left side

lyric mountain
#

not actually

#

I think ur misunderstanding what "parse" is doing here

proven lantern
#

lexical analysis

#

toxenization

lyric mountain
#

it doesn't lexical anything, the code is already compiled (kinda)

proven lantern
#

it's interpreted

lyric mountain
#

lexical and tokenization are things for writing code, not executing it

sharp geyser
#

Voltrex is here to save the day

proven lantern
#

voltrex will explain

#

finally

sharp geyser
#

I mean haku is explaining it perfectly fine

#

you just don't seem to understand 👀

#

btw haku I have a question for you regarding my stuff from earlier

lyric mountain
#
{...theRest2, one, two}

1 - sees a rest operator, puts everything remaining from right side into it
2 - ??
3 - ??

{one, two, ...theRest2}

1 - sees variable, assigns from right side
2 - sees variable, assigns from right side
3 - sees a rest operator, puts everything remaining from right side into it
proven lantern
lyric mountain
#

curly braces are simply enclosing a selective destructor so the runtime knows what to do

#

for example const ...theRest2, one, two wouldn't make much sense to the runtime

proven lantern
#
1 - see const
2 - see { - creating destructor
3 - see ...theRest - add to destructor
4 - see ,
5 - see one - add to destructor
6 - see } -
7 = see =
earnest phoenix
#

There are multiple reasons why we enforce the spread operator to be used as the last in a destructuring statement:

  1. Readability, if it was allowed anywhere in the statement, it makes it much harder for the reader to understand what's even going on because its purpose (in the case of destructuring) is to pack the remaining properties into a variable, which is why only allowing it as last makes much more sense
  2. Performance, allowing this changes the grammar of the destructuring statement drastically, and requires lookbehinds, lookaheads, and traversals since nested destructuring is allowed, which is a very big reason to disallow putting the spread operator anywhere in the destructuring statement
proven lantern
#

i've never done that

sharp geyser
# lyric mountain sure

How do you think I should handle people adding new ingredients to the database? Cause if a product they are adding has an ingredient not yet known in the database it makes it weirder.

earnest phoenix
#

Maybe disallow adding unknown ingredients?

lyric mountain
#

they mean adding new ingredients at all

#

it's a bit complicated, u could technically query the database to check if there's any lowercase no-accent match of the typed name, but wouldn't help against sinonyms

#

but since we're talking about nutritional facts, the names are standardized

queen needle
#

Could use an API or JSON to check against synonyms

lyric mountain
#

u could simply download the complete table from gov site

sharp geyser
#

Oh?

#

That would be helpful for my government if it exists but I don't think it will encompass any ingrediants that are allowed to be used in other countries

#

So sure it would be helpful as a base

lyric mountain
#

by "ingredients" we're talking about nutritional facts right?

sharp geyser
#

No

lyric mountain
#

ah, well

sharp geyser
#

Ingredients are like how there is peach juice in a bottle of Peach Lemonade Calypso

#

something i happen to have on hand

lyric mountain
#

I think those names are also standardized, but will need to check

sharp geyser
#

I don't really like the idea of people having to input the ingrediants themselves tbh

#

but I dont think there is any other way

lyric mountain
#

like "aqua" instead of water, in pretty much every product that contains it

#

they even use "aqua (water)" usually to clarify

sharp geyser
#

some even say "Filtered Water"

earnest phoenix
#

I'm so confused about the actual question, as in people adding new ingredients via a product that includes said ingredients that aren't in the database yet, or just adding new ingredients manually after adding a product that specified that ingredient when it didn't exist in the database?

#

I'm most likely missing something here

lyric mountain
#

something here could come in handy

sharp geyser
#

I don't really know how I should handle adding it

#

whether that be while they are adding the product or making them do it before

lyric mountain
#

search fda site for whether they have an ingredient list

#

then just copypaste the whole thing into the database if there is

sharp geyser
#

yea none of it seems like it will be super helpful just from skimming it

#

basically just guidelines for any company producing food

earnest phoenix
sharp geyser
#

Yea probably

#

I don't see any other way to do it

#

though I wish there was a way that they didn't have to do it themselves, yet there are just too many ingrediants for me to add on my own

proven lantern
sharp geyser
lyric mountain
#

well, that's enough I think

#

if the user needs something that's not in 44 fuckin pages then u could use an approval system

sharp geyser
#

Ahem thats for Over the Counter drugs

lyric mountain
#

ah

sharp geyser
#

God this is really a pain

#

I don't wanna make the end user do so much work

#

but I might have to

sharp geyser
#

That would work

#

tho I would have to scrape it

lyric mountain
#

time to grab wall spatula then and start scrapping

sharp geyser
#

Which is more work than its worth KEKW

#

Ima just do it by hand and suffer

lyric mountain
#

u can select all the text and use regex to extract the lines

sharp geyser
#

I dont know how regex works

#

so by hand it is!

#

Should I include ingrediants as part of Components or should I make it its own field?

earnest phoenix
sharp geyser
#

Actually it should be its own field cause it doesn't tell you the amount of ingredients are in it

wheat mesa
#

You can look up a few basic tutorials and grasp the basics in a few minutes

sharp geyser
#

do I want to tho?

#

not really

sharp geyser
#

I think thats exactly what I need

lyric mountain
#

(add an space between - to prevent excluding composite names)

sharp geyser
#

Listen here buckaroo

wheat mesa
#

As much as I hate regex, it’s super useful for parsing scraped data

sharp geyser
#

I think what voltrex gave me works better anyway

#

if not ima just do that

lyric mountain
#

yeah, an api is more handy

sharp geyser
#

its not an api, its a csv file

#

holy molly

earnest phoenix
#

It comes in both CSV and JSON format

sharp geyser
#

maybe I dont need all this data

#

or I hope

lyric mountain
#

is "bananas" in there?

#

everyone knows the global standard for measuring is bananas

quartz kindle
#

@earnest phoenixwhat is the point of FormData not accepting ReadableStream?

#

like how are we supposed to stream file uploads using mutipart/formdata without loading the entire file in memory

#

or is Blob able to consume a stream without loading everything?

frosty gale
#

i did not enjoy it

sharp geyser
#

@rustic nova why flag my message as spam >:C

frosty gale
#

what i did was split file creation and file upload into 2 api calls

sharp geyser
#

It was simply just a wall of unit measurements

rustic nova
frosty gale
#

first api calls basically says to expect a file to be uploaded

rustic nova
#

good job flagging automod

frosty gale
#

second file streams a blob to the server alone

quartz kindle
#

i mean

rustic nova
#
1000    cubic inch
1000    cubic centimeter
1000    gallon
1000    pint
1000    fl oz
1000    paired cooked w
1000    paired raw w
1012    dripping w
1013    bar
1014    bird
1015    biscuit
1016    bottle
1017    box
1018    breast
1019    can
1020    chicken
1021    chop
1022    cookie
1023    container
1024    cracker
1025    drink
1026    drumstick
1027    fillet
1028    fruit
1029    large
1030    lb
1031    leaf
1032    leg
1033    link
1034    links
1035    loaf
1036    medium
1037    muffin
1038    oz
1039    package
1040    packet
1041    patty
1042    patties
1043    piece
1044    pieces
1045    quart
1046    roast
1047    sausage
1048    scoop
1049    serving
1050    slice
1051    slices
1052    small
1053    stalk
1054    steak
1055    stick
1056    strip
1057    tablet
1058    thigh
1059    unit
1060    wedge
1061    orig ckd g
1062    orig rw g
1063    medallion
1064    pie
1065    wing
1066    back
1067    olive
1068    pocket
1069    order
1070    shrimp
1071    each
1072    filet
1073    plantain
1074    nugget
1075    pretzel
1076    corndog
1077    spear
1078    sandwich
1079    tortilla
1080    burrito
1081    taco
1082    tomatoes
1083    chips
1084    shell
1085    bun
1086    crust
1087    sheet
1088    bag
1089    bagel
1090    bowl
1091    breadstick
1092    bulb
1093    cake
1094    carton
1095    chunk
1096    contents
1097    cutlet
1098    doughnut
1099    egg
1100    fish
1101    foreshank
1102    frankfurter
1103    fries
1104    head
1105    jar
1106    loin
1107    pancake
1108    pizza
1109    rack
1110    ribs
1111    roll
1112    shank
1113    shoulder
1114    skin
1115    wafers
1116    wrap
1117    bunch
1118    Tablespoons
1119    Banana
1120    Onion
9999    undetermined
quartz kindle
#

you're still loading the entre file in memory

sharp geyser
#

@lyric mountain there ya go

quartz kindle
#

on the client side

sharp geyser
#

Aurel posted it for me

#

those are the unit measurements

lyric mountain
#

skin

frosty gale
#

not by doing that

quartz kindle
#

ah yes, banana for scale

rustic nova
#

1120 Onion

lyric mountain
#

THERE IS BANANA

rustic nova
#

Onion for scale

frosty gale
#

because i didnt use form data for the second uplaod api call

#

form data only for the meta data about the file

rustic nova
#

tortilla for scale

frosty gale
#

second only sends a streamable blob

sharp geyser
#

spear

quartz kindle
rustic nova
#

chicken for scale

sharp geyser
#

using fucking weapons for measurements

quartz kindle
#

tbh i dont even need to do this shit

frosty gale
#

but yeah would be nice if form data supported streams

quartz kindle
#

but for some reason i decided i wanted to support both http and fetch

sharp geyser
#

dripping w

#

tf is that

lyric mountain
#

ah yes, I'd like orig ckd g breads please

quartz kindle
#

i can just not use FormData and create my own streamable thing to gie to fetch

lyric mountain
#

that sounds like a shell command

oak cliff
#

Why your message get blocked wtf

sharp geyser
#

i'd like onion bread please

quartz kindle
#

since fetch accepts a readablestream body

sharp geyser
#

big wall of text

oak cliff
#

Oh

#

I couldn't see the reason in the alert and was like wtf

frosty gale
#

i used xhr for file upload because i can track the progress easily

sharp geyser
#

on another note how many bananas are too many

frosty gale
#

with fetch it gets a little complicated with aborts and stuff

quartz kindle
#

i had the brilliant idea of adding support for non-node environments on tiny-discord

#

i am not enjoying it

sharp geyser
rustic nova
sharp geyser
#

I walked 5617.978 bananas today

quartz kindle
frosty gale
#

cant you just use polyfills for stuff like this and fill the rest out

#

dont know lmao

quartz kindle
#

probably

sharp geyser
quartz kindle
#

but idk why i decided to just do it myself

sharp geyser
#

or its just us americans being americans

quartz kindle
#

so add a fetch alternative for when http is not available

wheat mesa
#

How would you trade a kilometer for a banana misty

quartz kindle
#

add DecompressionStream when zlib is not available

#

and crap like that

wheat mesa
#

😭 it’s just the length of the banana

frosty gale
quartz kindle
#

during runtime

frosty gale
#

thats gonna be painful 💀

quartz kindle
#

ye

#

im gonna have to make an event emitter for browsers lol

sharp geyser
quartz kindle
#

im gonna have to separate the emitter from the class

frosty gale
#

what i would do is maybe have some sort of converter which can convert the nodejs code into browser/deno friendly so you have separate libraries for each environment but only need to work on one library

quartz kindle
#

instead of new A(), a.on("bla") its gonna be new A(), a.events.on("bla")

#

so that i can have custom emitters as a construction option

frosty gale
#

also needs to be browser modules friendly lmao

quartz kindle
#

ye

frosty gale
#

assuming youre not bundling everything into one js file

quartz kindle
#

my ETF lib supports cjs esm and udm

#

works in node web bun and deno

#

feels good

#

so i decided i wanted to make all my other shit like that too

#

because it feels cool

#

lmao

sharp geyser
lyric mountain
#

time then

rustic nova
#

scraping government sites

#

sounds illegal ngl KEKW

sharp geyser
#

Honestly it probably is

#

👀

#

Next thing you know the FBI is at my doorstep

lyric mountain
#

well it's not scrapping if u ctrl + S the site

#

jokes aside, simply copy the full list and regex the desired content

#

/^(.+?) - /gm

sharp geyser
#

ighty

lyric mountain
#

might need to hand-process one or other tho, as some have comments

#

/^(.+?)(?: - | \()/gm probably works better for that sense

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

I haven't been able to find any good information as to why it's technically disallowed whatsoever

quartz kindle
#

apparently formdata requires knowing the content length or something

#

anyway im just gonna roll my own multipart encoder

earnest phoenix
quartz kindle
#

rip

quartz kindle
#

types of bacon

#

sure, also trivia and information about different types of bacon

rustic nova
#

who would use a random api either

deft wolf
#

I would probably focus on doing something that would be useful to me or someone I know

#

Then you'll probably find someone else

sharp geyser
#

ye look at me im basically doing @rustic nova bidding while he sits and wait for my api to be done

rustic nova
#

api that responds with teapots

#

and responds with the code 419

#

already exists

#

just make an actual application

#

rather than an api

spark flint
#

problem is there are so many bots

#

why choose yours

#

same with APIs

#

try find if theres a gap to be filled in the market, is there a niche

deft wolf
#

You need to find a very good niche

sharp geyser
#

I know a bot that hasn't been done before well enough

sage bobcat
#

One message removed from a suspended account.

sharp geyser
#

I've done my research

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

sharp geyser
#

Honestly at this point I just make shit to practice

#

:p

#

then dont be concerned about what it is

#

just do it

#

if no one uses it who cares its practice for the thing you want people to use

#

build up your skillset until you're ready to make something that truly matters to ya

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

sharp geyser
#

Also revist old projects

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

sharp geyser
#

Any old projects you've done you can try and make it better

sage bobcat
#

One message removed from a suspended account.

sharp geyser
#

See how you improve

sharp geyser
#

oh no aurel is typing

grim aspen
#

oh no i just made clyde my blackjack bot

#

oh shit this isn't general

rustic nova
#

Where

sharp geyser
#

I saw you typing

#

:C

proven lantern
#

()=>{this} acts different than function(){this}

sharp geyser
#

this is simply a keyword that is basically like the parent. So in a class this would be the class you created and would have access to all those props outlined in said class, same thing with functions

frosty gale
#

why did they have to call it this it literally makes putting it into a sentence hell

#

without quotes it makes it look like youre being very vague

lyric mountain
#

only in js, as this varies on whether ur using arrow or regular funcs

radiant kraken
radiant kraken
hasty nest
#

scraping the mee6 api for fun and profit

wheat mesa
#

Been busy

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

sage bobcat
#

One message removed from a suspended account.

wheat mesa
#

Busy with work 😢

sharp geyser
#

waffle has a woman

#

he needs no bitches

wheat mesa
#

Fax

radiant kraken
#

why would he get zero bitches

#

he has a gf

wheat mesa
#

gf != bitch

radiant kraken
#

still

radiant kraken
sharp geyser
#

thats rude null

glad nacelle
#

Hey

deft wolf
#

Yo

radiant kraken
frail hull
#

Hi all! Please tell me how to make prompts when entering a command?

deft wolf
#

I guess you need to explain it a little better. What prompts are you talking about exactly?

tulip ledge
midnight marsh
midnight marsh
slender wagon
#

Yall ever worked with graphql?

#

and i might need some place to get started with golang

tulip ledge
tulip ledge
slender wagon
#

thanks!

radiant kraken
midnight marsh
radiant kraken
#

you are just dirty minded

earnest phoenix
#

@earnest phoenix you cant press next because its the end!

#

just do all the steps again from the beginning and also read what is written there

plucky hearth
#

Hi

radiant kraken
slender wagon
#

I am learning GO

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

slender wagon
sage bobcat
slender wagon
#

Will look into GO and graphql

#

also into vue

lyric mountain
#

graphql 💀

slender wagon
lyric mountain
#

great to use, awful to implement

slender wagon
#

I'll play around with that too

slender wagon
#

It's not that bad

earnest phoenix
#

It's not terrible but it's definitely not good

slender wagon
#

go automatically adds a space after a comma :0

slender wagon
#

to go through it all

#

oh that's "why it's not good"

tulip ledge
# slender wagon It's not that bad

I learned it cuz I wanted to and really quickly realized that there’s no real use case. For each one there’s a better language to use. I only suggest learning it like in your case when you get employed and their architecture is already written in go

earnest phoenix
slender wagon
neon leaf
#

how do I register context menu commands in discord.js?

#

I already tried putting them into my <Client>.application.commands.set(...)

pale vessel
#

did you set the command type to the proper type?

neon leaf
#

wdym? Im just calling .toJSON() on the builder

warm surge
neon leaf
#

for what?

warm surge
#

i might able to help.

neon leaf
#

its not cause of the handler.

warm surge
#

your command handler*

neon leaf
#

its not cause of the command handler.*

#

its just not registering, nothing to do with my handler

#

the handler handles incoming interactions

#

and it would work if the menus were to register

warm surge
#

Ah

#

I had my handler setup like this

if ([ApplicationCommandType.Message, ApplicationCommandType.User].includes(file.type)){
client.context.set(file.name, file)
} else {
client.SlashCommands.set(file.name, files);
}
slashCommands.push(file)

pale vessel
neon leaf
warm surge
#

ah

#

I don’t use builders for commands

#

i can’t help you with that

thin turret
#

In discord.js, given a bigint, how do I get the string name of the PermissionBitField it resembles?

lyric mountain
#

for example, permission 12 isn't actually the number 12, but 1010 (permissions 2 and 4)

#

if u convert that number u have into binary, you'll get the permission indexes

#

remember it's read from right to left

neon leaf
#
if (12 & 4) {
  console.log('int 12 contains permission 4'(
}```
thin turret
#

I have no clue what that represents

#

in numbers* its the Administrator permission

#

I think Ill just use PermissionStrings distortedpepelaf

lyric mountain
#

as in, 4th permission

#

bitfields aren't meant to be seen in decimal notation

#

bitfields are basically arrays but in a number form

thin turret
#

Thanks, though I'll just use the PermissionString types, I just need a way to define required client permissions for commands before running them

#

Dont know why I jumped to using bigints

lyric mountain
#

bitfields are much more efficient, but d.js will convert permission strings to it anyway

quartz kindle
#

djs uses bitfileds internally

#

it just converts to strings when you want them as strings

rustic nova
#

change my mind