#development

1 messages · Page 1706 of 1

unreal estuary
#

ok

#

1 sec

lyric mountain
#

add background-color: 'red' to the body

#

so I can see the body dimensions

unreal estuary
#

it doesnt cover the full page

lyric mountain
#

hm

unreal estuary
#

red background

lyric mountain
#

yeah, the body is fine

#

ah wait

#

wait wait wait

unreal estuary
#

ok

lyric mountain
#

try putting inside a div

unreal estuary
#

the footer? ok

lyric mountain
#

no, everything

#

nvm

#

forget that, am forgetting body is treated as a div too

#

hm

#

set the footer's bg color to be red

#

remove the body red color

unreal estuary
#

oh its at the bottom now lol

#

wanna know why it didnt work

lyric mountain
#

welcome to WebDev™️

#

the place where you can't debug because stuff is alive

earnest phoenix
#

does anybody know how to make for loops faster in python

quartz kindle
#

why are they slow?

earnest phoenix
#

because im pulling and adding to my database

quartz kindle
#

then the problem is not the loop its what you're doing inside the loop

earnest phoenix
#
for a in range(amt):
    cash(ctx.author.id, "wallet", item_info["sell_value"])
    info = await database.find_one({"id":ctx.author.id})
    ritem(ctx.author.id, item, info["inv"])
#

im adding cash, getting whats in the database again, then removing an item

tired panther
#

how important is a tos for bots?

earnest phoenix
#

but in remove item its another loop

#
def ritem(id, ite, inv):
    c = -1
    for a in inv:
        if a == ite:
            c += 1
    database.update_one({"id": id}, {"$pull": {"inv": ite}})
    for a in range(c):
        database.update_one({"id": id}, {"$push": {"inv": ite}})
#

is there a better way to pull items?

quartz kindle
#

theres always a better way

#

for example, update_many

#

assuming you're using mongo

earnest phoenix
#

yeah

quartz kindle
#

if you need to make multiple database operations, always try to make as many as possible in a single query

earnest phoenix
#

ive searched the entire mongo docs but i cant find any better way to pull 1 item at once

#

because the inventory array is like ['item', 'item', 'item', 'item', 'item', 'item', 'item', 'item', 'item', 'item', 'item', 'item', 'item', 'item', 'item', 'item', 'item', 'item', 'item', 'item2', 'item2', 'item2', 'item2', 'item2', 'item2', 'item2', 'item2', 'item2', 'item2', 'item2', 'item2', ]

earnest phoenix
unreal estuary
#

no

#

its even worse

#

the footer was a div with the id "footer"

#

in the css i just put footer not #footer

earnest phoenix
unreal estuary
#

i fixed it already but thanks

earnest phoenix
#

I need help with mongo db

so if the entire array was ['item1', 'item1', 'item1', 'item1']
i want it to become ['item1', 'item1', 'item1']
but "$pull":{"array":"item1"} makes it []

quartz kindle
#

are those items exactly equal to each other?

earnest phoenix
#

yeah

quartz kindle
#

then why not use an object with a count?

#

then you can just increment/decrement the count

earnest phoenix
#

using an array is easier

ember wedge
#

can't you just slice the end off?

earnest phoenix
#

because theres 20+ items

ember wedge
#

or reduce the array

earnest phoenix
#

and adding that to the db would fill it up like crazy

earnest phoenix
ember wedge
quartz kindle
#

using an object would be much easier and would not fill it like crazy

ember wedge
#

isn't the whole point of mongo that you use objects?

quartz kindle
#

instead of [item1,item1,item1,item1,item2,item2,item2,item2,item2] you have [{item:item1,count:4},{item:item2,count:5}]

#

which one is easier?

ember wedge
#

more importantly which is smaller

quartz kindle
#

or even better {item1:{count:4},item2:{count:5}}

ember wedge
#

you could even have the items array inside the object and count it after

#

but it would be better to not do that

quartz kindle
#

or even {item1:4,item2:5}

earnest phoenix
#

nvm

ember wedge
#

indeed

earnest phoenix
#

all i would do is
list = info['array']
list.remove(item)
await database.update_one({"id":id}, {"$set":{"array":list}})

#

thats a way ig

cinder patio
#

Listen to Tim

#

Using arrays will take a ton of space later on, plus deletion is slow

#

just have a counter

#

for each item

#

and increment/decrement it when needed be

#

and if you still want to use arrays, use pop to remove the last element

lyric mountain
quartz kindle
#

well yeah but hes probably using "item1" as the full name/id of the item

#

unless he has a map/dict for it

cinder patio
#

those are placeholders most likely

lyric mountain
#

ik, just joking on how you went compressing the json like 7zip when seein a text file

quartz kindle
#

xD

#

well if you want to go further

#

a4b5

#

:^)

cinder patio
#

If you want to go even further

exotic lotus
#

Any pending questions related to discord.js? yawn
Im bored so came here to timepass

cinder patio
#

0x0 0x4 0x0 0x5

#

store each counter as a 16 bit number

quartz kindle
#

sure

cinder patio
#

in a buffer

quartz kindle
#

if you're sure no number or id will ever exceed 16 bit

queen timber
#

hey guys

quartz kindle
#

my binary serializer is based on 16 bit units

#

i do exactly that

cinder patio
#

nice

quartz kindle
#

some datatypes have overhead tho

#

strings have a 16bit unit reserved for its length

#

same for bigints and buffers

cinder patio
#

makes sense, my custom bytecode interpreter works exactly the same

#

16bit for array length too

#

only 8bit for args though

#

unsigned ofc

quartz kindle
#

nice

#

i use 5 bits for data type and 11 bits for object keys

cinder patio
#

my interpreter turns objects into arrays

#

honestly a serializer can pull that off too ^

placid meadow
#

u made an interpreter fued ?

#

i love making those

cinder patio
#

yeah but it's bad

#

I'm planning on rewriting it

placid meadow
#

i could give you my code (working code) that could help ya

#

u want that ?

cinder patio
#

No need I know how to make it better 😉

placid meadow
#

@cinder patio mine was made to do 2d charts from equations

cinder patio
#

Mine's a programming language

placid meadow
earnest phoenix
#

What if I only know some properties of an object and i dont know the rest of the object shape. What type would i use for a parameter like that in typescript?

cinder patio
#

Everything was going well until I started writing the parser / compiler

#

then I gave up

#

I didn't like the architecture the project so I'm starting over

placid meadow
#

well you know where to find me 😉

earnest phoenix
#

my computer is having such a stroke

quartz kindle
cinder patio
quartz kindle
#

object keys are a sequence of strings identified by an index

#

then object values have a data type and the index identifier in their overhead

earnest phoenix
#

owo what's unknown

quartz kindle
#

unknown is unknown

placid meadow
#

unknown data type ? 😛

earnest phoenix
#

can i do that

cinder patio
#

ts magic

#

yeah

earnest phoenix
#

because deno lint is yelling at me for any

cinder patio
#

yeah use unknown

earnest phoenix
#

thx

#

also ive been solving 37 problems with my lib today from deno linter even though i saw them way before

#

dont ask why i didnt fix

ember wedge
#

anyone ever generated clients from .xsd files?

cinder patio
earnest phoenix
#

should i use erlpack instead of json for the websocket

cinder patio
#

but that requires both sides knowing the object structure

cinder patio
earnest phoenix
#

hmm

#

ight

#

but i dont know anything about how to use it yet

cinder patio
#

copy from d.js lol

earnest phoenix
#

lol

#

how are you playing a game while talking about deserialising objects

cinder patio
#

I'm a wizard

earnest phoenix
#

thanks ts

TS2571 [ERROR]: Object is of type 'unknown'.
    `https://discord.com/api/v8/interactions/${d.id}/${d.token}/callback`;
                                                       ^
    at file:///home/aatif/Desktop/programming/SlashDeno/test.ts:36:56
cinder patio
#

don't make properties you know unknown :p

#

because they aren't

fervent goblet
#

How long can a message go until it can't be edited?

austere zealot
#
@client.command()
async def disable(ctx):
    async with asqlite3.connect(db_path) as db:
        async with db.cursor() as cursor:
            await cursor.execute("SELECT enabled FROM welcome WHERE guild_id = ?", (ctx.guild.id, ))
            result = await cursor.fetchone()
            command = client.get_command("welcome")
            print (result)
            if result == ('1',):
                await cursor.execute("UPDATE welcome SET enabled = False WHERE ?", (ctx.guild.id, ))
                await db.commit()
                command.update(enabled=False)
                await ctx.reply("Welcome Message disabled!")
            elif result == ('0',):
                await ctx.reply("The welcome Message is already disabled")
            else:
                await cursor.execute("INSERT INTO welcome(enabled, guild_id) VALUES(?,?)", (False, ctx.guild.id))
                await db.commit()
                await ctx.reply("Welcome Message disabled!")

how do i make this command per server?

earnest phoenix
fervent goblet
#

ah i c

#

nice

earnest phoenix
#

forever in the sense until the heat death of the entire fucking universe

quartz kindle
earnest phoenix
#

I give up

ember wedge
earnest phoenix
#

time to make another interface

cinder patio
#

I don't know how zlib streaming works

cinder patio
austere zealot
cinder patio
#
interface Obj {
  [key: string]: unknown,
  token: string
}
quartz kindle
#

the lookup table is sent in the payload so that both compressor and decompressor know the structure

earnest phoenix
#

...

#

that's what i said

ember wedge
earnest phoenix
ember wedge
#

oh here await cursor.execute("SELECT enabled FROM welcome WHERE guild_id = ?", (ctx.guild.id, ))

#

just repeat that in ur welcome command

austere zealot
#

ok

ember wedge
#

and if it's 0 return the function

earnest phoenix
#

well i found the type for the payload

#

:)

ember wedge
#

and it's disabled in the db?

austere zealot
#

no its enabled

ember wedge
#

what is the result this gives?
await cursor.execute("SELECT enabled FROM welcome WHERE guild_id = ?", (ctx.guild.id, ))
result = await cursor.fetchone()

austere zealot
#

('1',)

ember wedge
#

doesn't that mean the command is enabled?

austere zealot
#

it does

ember wedge
#

so then it should run the command

#

if it's not that just return;

#

and the command won't run any further?

austere zealot
#

lmao now its not working

queen timber
#

you messed it up

earnest phoenix
#

do i need to learn how to use default exports

import { Snowflake } from "../typedefs/Snowflake.ts";
import { Token     } from "../typedefs/Token.ts";
import { Member    } from "./Member.ts";
import { User      } from "./User.ts";
earnest phoenix
#

who cares

#

¯_(ツ)_/¯

#

not me

queen timber
earnest phoenix
#

well i sometimes have multiple related interfaces and types in the same file so ill need to remember to use default export in one file and {} in the other

#

and i have a heckload of typedefs to write so

queen timber
#

ok

earnest phoenix
#

all of these plus moar

austere zealot
#

can you use enabled=True for per server commands?

austere zealot
queen timber
austere zealot
#

i already fixed it lul

earnest phoenix
#

do not use long variable nam-
discord:

queen timber
queen timber
earnest phoenix
#

idk

#

ask discord

queen timber
#

ok i did not use long variables

earnest phoenix
#

@queen timber i found an even longer name

#

ApplicationCommandInteractionDataResolved

queen timber
#

wow

#

@earnest phoenix

earnest phoenix
#

adverts

#

ban

queen timber
#

lol

hallow raptor
queen timber
#

hey

hallow raptor
#

What's ur bot can do

queen timber
#

it can level up members in your server

hallow raptor
#

Plzzz

earnest phoenix
#

this channel is not for chatting about bots

queen timber
#

i will dm you

earnest phoenix
#

nor is it for begging people to join your server

hallow raptor
queen timber
#

he asks like he is mod

earnest phoenix
#

wait there are no mods online in this channel rn. THIS CHANNEL IS OURS NOW

queen timber
#

lol

snow urchin
#

how could I use regexp to replace only ;, () and []

#

so far I have ([^a-zA-Z0-9 ])+, but that stops when it reaches a letter
I want for example lala (olol);[] to change to lala olol

earnest phoenix
snow urchin
#

that stops once it hits a letter

earnest phoenix
#

huh

snow urchin
earnest phoenix
#

bro

#

you should use g flag instead of +

#

add the flag after the closing / like so: /g

pale vessel
boreal mantle
#

Hello,
I currently can't start my bot (no ready event emitted), is there someone with the same problem ?

lament rock
#

shouldn't the + also go in the capture group since it would capture 1 letter only and there would be a ton of capture groups if the global flag is enabled

earnest phoenix
#

How I can do a img to svg? MegaThonk

pale vessel
#

why?

lament rock
#

I don't think there is a clean way to convert an image to svg since svgs consist of geometric objects. Your image would lose a considerable amount of quality if it's detailed

umbral zealot
#

There's some tools from Adobe that can do that though

lyric mountain
#

also inkscape

zenith terrace
#

anyone know why VSC is showing this, it was working fine yesterday but now it doesn't wanna work

ember wedge
#

looks like nodejs isn't installed

#

or it's not configured in your path

#

try typing node -v in a terminal

zenith terrace
#

see you didnt read what I said, it was working fine yesterday but today it isnt, which indicates nodejs is installed but today I cannot use node

cerulean wharf
#

Hello! do you guys have a tutorial on how do i make people react with an emoji and then a role is assigned? a role like age, sex, etc.
it's something i can make with a bot?

earnest phoenix
lost wadi
#

Hello, can you help me?
How do I get the last image sent on the channel?

cerulean wharf
ember wedge
#

I think carlbot does it?

earnest phoenix
#

Zira too

#

But idk because i use my own bot

ember wedge
#

same

cerulean wharf
#

that's fancy, one day i'll make it to dev bots. Thank you guys

opal plank
#

well fuck

#

this is not what you wanna see in logs

#

@quartz kindle do you perhaps know a way to check if the thread is getting clogged or something that might be causing misses in acks?

#

dunno if theres a profiler for that

#

best i can think of is try to run a while() loop for a couple dozen minutes and check if theres latency

quartz kindle
#

looks like normal reconnects?

opal plank
#

THAT many?

#

wot?

quartz kindle
#

every shard will reconnect at least once every 4 hours

opal plank
#

nono

#

let me give you a bigger scope

#

@quartz kindle

#

these are just READY events

#

shards going brrr

quartz kindle
#

idk then could be discord having issues

opal plank
#

are you having that?

craggy pine
#

I don't think our bot is having a stroke atm with that. Thinkies

opal plank
quartz kindle
#

let me check

crimson vapor
opal plank
#

i assume i probably left some very amazingly good code there that might be clogging it enough to miss some acks

opal plank
crimson vapor
#

strange ass terminal

#

wait which one did you think I was asking about kekw

opal plank
#

how so?

crimson vapor
#

that

opal plank
#

oh, thats postgres

quartz kindle
#

looks normal to me

crimson vapor
#

man

opal plank
#

im really not sure they should be reconnecting that often

#

thats once every 30m on urs tim

#

this is 30 every 30 minutes

quartz kindle
#

well idk

crimson vapor
#

yikes your bot ok?

opal plank
#

clearly not

quartz kindle
#

try with a barebones bot

#

same token

opal plank
#

recieved a couple reports yesterday about it being offline on some guilds

#

did a bit of digging and found that out

#

having logs does make everything easy to monitor

#

i really dont think its a connection issue

#

im willing to bet its my pristine code

lament rock
#

Might not be heartbeating correctly

quartz kindle
#

does detritus log heartbeats?

opal plank
#

i think it might

quartz kindle
#

someone else was having an issue like that today

opal plank
#

it re-emits all events

quartz kindle
#

not receiving heartbeat acks

opal plank
#

i think theres a ack event emitter

#

let me check rq

#

that would be under shard i assume

crimson vapor
#

erwin what format do you use for your date for the logs?

opal plank
#

only thing i see is messageAck

#

but thats for nunce i assume

lament rock
#

If you fail to receive an ack, then you may not be sending one in the first place since Discord's ws will still send an ack in a service outage.
Although, there is the rare case ws connections become zombified and acks won't appear even if sending heartbeats. In which case, the socket should be closed and reconnected immediately

#

for it to appear this many times seems very sus

#

I had this issue before and it was a pain

#

Turns out, was a logical error on my end with my gateway lib

opal plank
#

cake did patch something i found accidently yesterday

#

and i just updated it to the beta branch with the patch

#

but he's not having any issues on his bot either

#

99.99999999% sure its something on my code

lament rock
#

could also be sending an invalid payload tbh. I think that also immediately closes your socket connection

crimson vapor
#

detritus moment

eternal osprey
#

hey hey!

#

How do i get the highest value (an integer) in a text file?

#

js btw

quartz kindle
#

how are these values separated?

crimson vapor
lament rock
#

read the file and encode it to UTF-8, then split the string contents using a regex with the global and multi-line flags which captures \d+ then sort that Array normally and return the first result

#

Might have to map the string Array and call the NumberConstructor on each entry though

eternal osprey
#

like this

#

so i already have parted the file so it only takes the 2nd part of the lines (the values)

#

just need to get the highest integer

lament rock
#

my way wouldn't work out too well then, I suppose since it would capture IDs

quartz kindle
#

read file -> split by new line -> sort by second word converted to number

opal plank
#

aight i got it to log

#

its likely gonna spam the living shit out of my console

#

but fuck it

craggy pine
#

console go brr

eternal osprey
#

so it only gets the values. That is already done

quartz kindle
#

so you dont need the id that belongs to that value?

opal plank
#

though i havent seen anything get logged yet

eternal osprey
pale vessel
#

Probably array.map(Number).sort()?

quartz kindle
#

well if you have an array of numbers

#

you can use Math.max(...array)

eternal osprey
#

i can access the 2nd values of each line using m[1]

eternal osprey
#

Thanks

opal plank
#

so, how often do acks happen again?

quartz kindle
#

every 40 seconds or so

opal plank
#

hmmm something is off then

crimson vapor
#

is it only some shards or all shards?

opal plank
#

all of them reconnect at some point, but its been specifically shard 1 being borked

crimson vapor
#

I mean I get my bot on 1 shard reconnecting every once in a while

#

so thats normal

#

ig

#

but not all the time

#

which is your issue

eternal osprey
#

Okay wait i am actually a bit confused right now

opal plank
#

its legit reconnecting every 2 minutes

crimson vapor
#

do you not log disconnects?

crimson vapor
#

oh

#

is that a verbose log?

opal plank
#

in my terminal i just log when shards are ready

crimson vapor
#

ah

opal plank
#

its my terminal, yes

crimson vapor
#

ok makes sense

eternal osprey
#

this is what the text file contains of. How can i get the max value of the second part only (so the values, not the snowflakes)?

crimson vapor
#

can you send a picture of the file?

#

oh wait

#

nvm

#

so its an array of arrays?

eternal osprey
#

yeah it is

quartz kindle
#

that way you can use sort

crimson vapor
#

sort rather than reduce?

#

wouldn't sort be inefficient

quartz kindle
#

array.sort((a,b) => Number(a[1]) - Number(b[1]))

#

you can also use reduce yes

#

if you only want one value

crimson vapor
#

the max would only be ne tho

eternal osprey
#
const array1 = [1, 30, 4, 21, 100000];
array1.sort();
console.log(array1);
// expected output: Array [1, 100000, 21, 30, 4]
``` I don't quite get why the sort is returning these values in this specific order.
crimson vapor
#

it sorts by strings

#

so the first char

opal plank
#

sort weith a > function

crimson vapor
#

is sorted by char code?

opal plank
#

sort(a,b => b > a)

crimson vapor
#

sort((a, b) => b > a)

quartz kindle
#

the sort function expects a number return no?

crimson vapor
#

hmm

umbral zealot
#

yes it does

opal plank
#

okay now im confused

#

oh right

#

a-b

umbral zealot
#

arr.sort( (a, b) => b - a) works

opal plank
#

nothing

#

its been 13 minutes already

crimson vapor
#

using npm, what would make a package have its own node_modules folder

#

im having an issue where the imports are different and therefore typescript is erroring

opal plank
#

wot?

crimson vapor
#
src/bot/worker.ts:17:109 - error TS2345: Argument of type 'import("/home/million/discord/terano-rose/node_modules/discord-rose/node_modules/discord-api-types/v8/payloads/user").APIUser' is not assignable to parameter of type 'import("/home/million/discord/terano-rose/node_modules/discord-api-types/payloads/v8/user").APIUser'.```
#

the issue from what I can see is that the latest version isnt installed there, causing an inconsistency with the types

quartz kindle
#

a package has its own node_modules folder when it has dependencies

umbral zealot
#

lololol typescript 😛

crimson vapor
quartz kindle
#

also

#

the paths are wrong?

#

one is /v8/payloads

#

the other is /payloads/v8

crimson vapor
#

ig different versions

#

perhaps restructured it? im not sure

opal plank
#

imagine changing folder structures

crimson vapor
#

is there a reason why some required packages would be in the main node_modules while others are in another package's node_modules?

vivid fulcrum
#

dev dependencies ig

crimson vapor
#

its put in as a regular dependency tho

opal plank
#

you're a regular dependency

quartz kindle
#

probably if the same dependency is not used anywhere it will be in the base folder

#

if the same dependency is used more than once, then it will be inside their modules if the versions are different

vivid fulcrum
#

and this is why yarn is superior

quartz kindle
#

yarn v2 can go fuk itself

vivid fulcrum
#

true

#

it's messy

quartz kindle
#

looks great on paper but breaks literally everything

#

i lost intellisense

#

and could not even build native modules anymore

crimson vapor
quartz kindle
#

nah hes an irregular dependency

opal plank
#

fighting against detritus do be hard sometimes

#

also laughed way too hard on that

pine quarry
#

(node:2243) UnhandledPromiseRejectionWarning: Error [TOKEN_INVALID]: An invalid token was provided.
?

umbral zealot
#

Your bot token was invalid.

pine quarry
#

but i delete

#

my bot is offline

umbral zealot
#

... ok well clearly you deleted something you shouldn't have, and your token is not loading, then

crimson vapor
opal plank
#

you know what doesnt have 1/5th of the functionality of?

crimson vapor
#

discord-rose

#

:loli_dance:

pine quarry
#

I renewed my token but the error continues

opal plank
#

also last time i check that barely passed as "docs"

#

just letting you know @crimson vapor

#

it was legit 3 pages

crimson vapor
pine quarry
#

@umbral zealot

umbral zealot
pine quarry
#

okey

opal plank
#

WEW

umbral zealot
#

your index.js specifically

crimson vapor
#

bro

opal plank
#

you really taking that as docs?

crimson vapor
#

they work

opal plank
#

then so does detritus

pine quarry
crimson vapor
#

lol

opal plank
#

i mean ACTUALLY WRITTEN docs you dork

crimson vapor
#

berry is just lazy

#

they will be betetr

#

no one writes docs???

opal plank
#

d.js does

crimson vapor
#

its all done with jsdoc

opal plank
crimson vapor
#

tho

umbral zealot
crimson vapor
#

they just actually do shit

#

because they have so many fucking people

quartz kindle
#

hey i write docs

umbral zealot
#

I doubt top.gg is sending the exact same token error as discord.js

opal plank
#

"docs"

crimson vapor
#

Tim you're amazing tho

opal plank
#

more like bibbles

quartz kindle
#

yes

pine quarry
#

what should I do

opal plank
#

those types are insanely big

quartz kindle
#

my .d.ts is 3.5k lines long

#

and still not finished

crimson vapor
#

just use ts

#

smh

quartz kindle
#

its not the ts

opal plank
#

imagine not using ts to generate it for you

quartz kindle
#

its the doc

crimson vapor
#

yea

opal plank
crimson vapor
#

so just use ts

umbral zealot
opal plank
#

its cpp

#

he cant

crimson vapor
#

then you don't need to write the functions 2s

#

oh

#

right

quartz kindle
#

its the jsdoc thats big

#

i'd have to write it regardless

#

even if i used ts

#

i do have some stupidly large types, but 80% of the bulk is jsdoc

#

ts cant generate those for me

pine quarry
opal plank
#

ts is super good but its not omnipotent yet*

umbral zealot
#

yes. all. the whole thing.

pine quarry
#

too long

umbral zealot
#

no it's not.

opal plank
#

wrong reply?

pine quarry
#

just made a problem today 30 minutes ago

quartz kindle
#

oh shit

#

sorry

opal plank
#

my whole bot is considered a problem

#

welcome to the club

crimson vapor
#

I am the problem

umbral zealot
quartz kindle
crimson vapor
#

lol

opal plank
#

there we go tim

umbral zealot
#

If you knew where the error was you wouldn't need to ask us about it now would you? 😉

opal plank
#

well its looking better now

umbral zealot
#

For the 3rd time YES

opal plank
#

but evie

#

the whole thing?

pine quarry
#

okey 1 min i send the document

umbral zealot
#

christ it's not even that hard to just CTRL+A CTRL+C then just CTRL+V here. smh

opal plank
#

was hoping for token, disspointed

umbral zealot
#

client.login(process.env.token); <---- so this is your login, right? In your file called exactly .env do you have a line that says ```
process=YOURTOKENHERE

???
#

or does it say PROCESS= maybe?

pine quarry
#

yes

#

i have a env

#

it's all written there

umbral zealot
#

trick question, it shouldn't say process

#

are you actually reading my questions correctly?

#

What does the .env file say? Show it, except for your actual token

pine quarry
#

okey

#

1 min

#

env folder

opal plank
#

so

umbral zealot
#

is that heroku

opal plank
#

u hid ur discord token

#

but not the others?

umbral zealot
#

doesn't matter, they're partial so it's fine

opal plank
#

in fairness they are clipped

#

yeah

pine quarry
#

what should I do

umbral zealot
#

is that heroku

pine quarry
#

no

umbral zealot
#

well either that's not saved, or the system isn't injecting the env values correctly, because this should all work

pine quarry
#

It started causing problems just 30 minutes ago
When I delete modules, it still gives an error

umbral zealot
#

Well undo what you did 30 minutes ago then?

#

lol

pine quarry
#

not working

#

:/

umbral zealot
#

are you sure you're copying the BOT TOKEN and not, like, the client secret?

pine quarry
#

yes

umbral zealot
#

¯_(ツ)_/¯

opal plank
#

have you tried a small bot?

umbral zealot
#

try reducing the code to just a core, basic example bot code and going from there

#

afaict all is correct, so...

#

maybe talk to your hosting support

vivid fulcrum
#

make a request manually with the token

#

if it doesn't work, then your token is incorrect

earnest phoenix
#

hello, How do you remove a user’s access to a folder on debian 10?

pine quarry
#

I solved the problem

#

oh thanks

earnest phoenix
#

For those who cannot open the file

opal plank
#
const client = new (require('discord.js').Client)();
client.on('ready', => console.log('ready'));
client.on('debug',console.log);
client.login(process.env.token);
#

or try that ^^

pine quarry
#

FetchError: request to https://top.gg/api//bots/stats failed, reason: Client network socket disconnected before secure TLS connection was established
why

#

:(((((

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

vivid fulcrum
#

yup

sage bobcat
#

One message removed from a suspended account.

vivid fulcrum
#

i requested it

sage bobcat
#

One message removed from a suspended account.

vivid fulcrum
#

since i lost access to it

opal plank
#

you can request deletion but not access?

vivid fulcrum
#

yes

#

discord logic tm

sage bobcat
#

One message removed from a suspended account.

opal plank
#

so they can delete the account knowing you're the owner, but cannot restore your access

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.

#

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.

#

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.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

opal plank
#

you know what?

#

fuck it

#

im dumpign everything in console

#

EVERYTHING

#

tired of this hide and seek shit with bugs

green kestrel
#
		if (command == ".voicetest") {
			dpp::snowflake channel_id;
			ss >> channel_id;
			bot.log(dpp::ll_info, fmt::format("Starting voice test! Channel: {} Guild: {}", channel_id, event.msg->guild_id));
			if (channel_id) {
				dpp::DiscordClient* dc = bot.get_shard(0);
				dc->ConnectVoice(event.msg->guild_id, channel_id);
			}
		}
		if (command == ".noise") {
			/* This assumes that there is one shard and the voice channel's guild is is on it. 
			 * Only for testing purposes, DO NOT make this assumption in the real world!
			 */
			dpp::DiscordClient* dc = bot.get_shard(0);
			dpp::voiceconn* v = dc->GetVoice(event.msg->guild_id);
			if (v && v->voiceclient && v->voiceclient->IsReady()) {
				v->voiceclient->SendAudio((uint16_t*)noise, noise_size);
			}

silly question... how understandable is this to non c++ devs? just wondering how easy it's going to be to convert people over :laughing:

vivid fulcrum
sage bobcat
#

One message removed from a suspended account.

green kestrel
#

hmm you could have a dict of objects keyed by id

#

with a run method

vivid fulcrum
#

definitely

#

they said they want to nest

#

ig you can just create more dicts

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.

vivid fulcrum
#

oh

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.

#

One message removed from a suspended account.

vivid fulcrum
#

you'll have to hardcode them, otherwise how would you check for them

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

umbral zealot
vivid fulcrum
#

but like brain suggested

#

dictionaries can lessen the pain

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

umbral zealot
#

in fact it looks like normal JS except all the random extra pointless syntax

#

What is this, haskell?

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.

umbral zealot
#

What's with languages having syntax that looks like the authors rolled their face on the keyboard when they wrote their parser?

sage bobcat
#

One message removed from a suspended account.

umbral zealot
#

:: >> -> * ?

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

umbral zealot
#

not really

#

but dpp::voiceconn* v = dc->GetVoice(event.msg->guild_id); just looks like js with extra shit syntax to it tbh

umbral zealot
#

I know I'm speaking from the position of a JS dev that's never done real programming, but still

sage bobcat
#

One message removed from a suspended account.

umbral zealot
#

What does dpp:voicecon * v do

#

typecasting?

dusky sundial
#

cpp looks scary until you learn it

quartz kindle
#

well php also uses -> for class properties and methods

green kestrel
#

the older languages have cleaner syntax because they're simpler, look at basic, COBOL, Fortran

dusky sundial
#
  • is used for pointers
umbral zealot
#

yeah and I hate php too lol

quartz kindle
#

xD

cinder patio
sage bobcat
#

One message removed from a suspended account.

umbral zealot
#

like this is, what, const voicecon = msg.guild.voiceConnection; ?

quartz kindle
#

the stupidest thing ever is php using / for namespaces in classes

#

lmao

green kestrel
sage bobcat
#

One message removed from a suspended account.

quartz kindle
#

pointers... references on crack
that was a good one

umbral zealot
#
const voicecon = msg.guild.voiceConnection; 

dpp::voiceconn* v = dc->GetVoice(event.msg->guild_id);

like I said, from my point of view, it looks like programming with a lot of extra random syntax characters

green kestrel
#

that code gets the current voice client for a guild and sends audio to it

umbral zealot
#

hold SHIFT, hit a bunch of numbered keys, there's your syntax. But this isn't a CPP thing, haskell is even worse in that regards

#

and I think Rust too but I'm not sure.

quartz kindle
#

well they're all low level langs

cinder patio
#

:: is getting a type from a namespace, -> is to access properties through pointers

green kestrel
#

so yes it's exactly like the js above it

umbral zealot
#

haskell be like ```hs
eventHandler :: Event -> DiscordHandler ()
eventHandler event = case event of
MessageCreate m -> when (not (fromBot m) && isPing (messageText m)) $ do
_ <- restCall (R.CreateReaction (messageChannel m, messageId m) "eyes")
threadDelay (4 * 10^6)
_ <- restCall (R.CreateMessage (messageChannel m) "Pong!")
pure ()
_ -> pure ()

quartz kindle
#

what does <- do

umbral zealot
#

I have absolutely no idea

green kestrel
#

that doesn't look so ugly to me

quartz kindle
#

lmao

umbral zealot
#

why is there _ <- and _ -> ?

cinder patio
#

That's why I dislike purely functional langa

opal plank
#

js is fun cuz its human redable

umbral zealot
#

like I don't get it

cinder patio
#

Cause of this

green kestrel
#

method call by the look of it

opal plank
#

its not a shitton of operators cuz you have no idea what they do

dusky sundial
#

RAPID is a fun programming language, you just need a $40k robot to use it

quartz kindle
#

try brainfuck

green kestrel
#

the arrow is pointing at the object it acts on

umbral zealot
opal plank
#

^^

green kestrel
#

I don't like how js builds objects

#

its more like a functional programming language than an object oriented one

#

you basically put a lambda in a dict lol

quartz kindle
#

yup

#

js in a nutshell

cinder patio
#

And that's why I like it

#

a lot

green kestrel
#

can end up with some very unreadable structures

quartz kindle
#

i like it because its super hackable

green kestrel
#

I like js for web front-end

quartz kindle
#

i hate front-end

green kestrel
#

where it belongs lol

quartz kindle
#

not anymore

#

:^)

opal plank
#

can we speak about ts?

quartz kindle
#

no

opal plank
green kestrel
#

to me, node is like one day someone woke up and thought

"today I'm going to take that tractor engine and put it in my Ferrari. and then use it as a generator to power my washing machine using a million hacky little dependencies made and maintained by strangers..."

quartz kindle
#

if its stupid but it works then its not stupid

vivid fulcrum
#

node is really only powerful in the UI department

#

i'll take node for UI apps over any other language anytime

#

for anything else, it's a nono

green kestrel
#

three words: npm is-even module.

umbral zealot
#

JS is more starting with a tractor then slowly adding more power, nitro, redoing the body, redesigining the transmission, and then eventually after a decade, you have something closer to a ferrari than your starter tractor, Brain. 😛

cinder patio
#

node.js is just V8 out of the browser

green kestrel
#

npm is ass

quartz kindle
green kestrel
#

node I can accept as an idea that works

#

but npm is just full of junk

#

like PHP composer is

cinder patio
#

I mean you don't have to use the trashy packages

vivid fulcrum
#

it doesn't cache properly

#

that's the major problem

green kestrel
#

you don't know if you are though

#

import one and it depends on a billion more under the hood

vivid fulcrum
#

and the reason why dependencies of your dependencies of its dependencies install their dependencies

cinder patio
#

Generally downloads and github stars are a pretty good indicator

green kestrel
#

that then depend on more still

quartz kindle
#

most of the time i end up building my own modules rather than using stuff from npm

#

except basic things like websockets and http

earnest phoenix
#

One moment @green kestrel, u are the developer of triviabot

quartz kindle
#

yes he is

earnest phoenix
#

Wow, I am quite new to this

#

I'm developing my first bot and let's see what happens

quartz kindle
#

good luck ;)

earnest phoenix
#

Ty

cinder patio
#

Okay so do you guys think... js would work without a gc... imagine js with manual memory management

vivid fulcrum
#

your average node dev doesn't know how to spell their own name

#

there wouldn't even be memory to manage KEKW

cinder patio
#

KEKW true

quartz kindle
#

i think js could work well with manual memory

vivid fulcrum
#

considering it's really running on cpp

quartz kindle
#

its already a super simplified language, it could use some mechanism to create super simplified memory management

vivid fulcrum
#

if they just exposed the apis

#

it could be very useful

#

for people who actually know what they're doing

quartz kindle
#

well technically you already have buffers

green kestrel
quartz kindle
#

which is kinda the same as malloc

cinder patio
#

Yeah but I don't think having both a gc and manual memory is a good idea

quartz kindle
cinder patio
#

How would that work

quartz kindle
#

node has tcp but not websocket according to rfc etc

#

so i rather use the ws package from npm

#

because icba making rfc stuff

cinder patio
#

Buffers still get gc-ed

green kestrel
cinder patio
#

but I guess you can allocate memory via them so that's kinda low-level

quartz kindle
#

i think ive seen something like that

#

buffers are garbage collected if you lose the reference to them

#

but if you create global buffers then no

green kestrel
#

@quartz kindle having spent 36 hours making voice I'm sick of looking at RFCs lol

cinder patio
#

well yea isn't that the case for all objects

green kestrel
#

I've had to delve into opus, RTP, and all sorts

quartz kindle
#

ye

#

rfc overcomplicates everything

#

because of compatibility constraints

#

simple js memory management: ```js
global.bufferCount = 0;
global.buffers = {};
function malloc(size) {
const buff = Buffer.alloc(size);
global.buffers[global.bufferCount++] = buff;
return buff;
}
function free(i) {
delete global.buffers[i];
}

#

xD

earnest phoenix
#

a simple question, how much ram is it advisable to have for a discord bot?

opal plank
#

depends

#

on good code or shit code?

earnest phoenix
#

Shit

opal plank
#

aka, on d.js or a good lib?

#

how many guilds?

earnest phoenix
#

Hmm now 10 but i want more so

opal plank
#

i'd say 2gb, 4gb to be safe with a LOT of room for breathing

#

i dont think it'll hit 1gb anytime soon

#

so 2 would be your "good spot"

#

im recommending double so you dont have downtimes in case you need to increase

earnest phoenix
#

Thanks, now my bot have 30MB

#

🥲

#

I think I will have to increase it

opal plank
#

on a reference for you

#

@earnest phoenix

#

2gb ram on detritus.js with 740K users and 5.5k guilds

#

thats why i asked if it was shit code/lib

earnest phoenix
#

Ok, tysm

green kestrel
opal plank
green kestrel
#

2gb is good going

opal plank
#

in fairness

green kestrel
#

for js

opal plank
#

theres a LOT of stuff here

green kestrel
#

especially with caching

opal plank
#

you have to multiply some of the stuff there

#

i got a lot of useless shit

#

image buffers stored

#

2 different entries for each user

#

so a user may end up having 3 different objects

#

one for my cache

#

one for detritus(for discord)

#

and one for genshin

green kestrel
#

you know,.I'd be curious to know how much ram a cached user takes up in discord.js

#

at the ram level natively

opal plank
#

if you were to build a bot on this scale with detritus, you'd be looking at around a gig prob

green kestrel
#

because you got a dict/map for an object with many more inside it

opal plank
#

i could make it a bit lighter by merging it all into a single map

#

instead of 3 different maps for each user-metadata

green kestrel
#

Chrome shows the size of each individual empty array as 32 bytes and the size of each empty object as 56 bytes. hmm @quartz kindle you think v8 is using STL maps and vectors? those sizes sure look like it

opal plank
#

i

#

fucking

#

aaarg

#

okay

#

hear me out

#

the request is sent in buffer format

#

now

#

hear me out

#

without manually copying this like a retard

#

and idk where this is coming from, otherwise i'd be able to add a proper capture block there

#

is there SOMETHING i can do to convert that body into a string?

#

once again, i've already copied 300 numbers before and converted it

green kestrel
#

copy it outta the buffer?

umbral zealot
#

well js has .toString() on Buffer objects...

opal plank
#

dont wanna do it again

umbral zealot
#

lol

opal plank
#

IN CODE

#

yes

#

i got this shit in console

green kestrel
#

I don't get buffer

#

why is it so amazing

opal plank
#

and its tilting me cuz its a promise that i clearly missed

umbral zealot
#

literally thing.request.body.toString() should do the trick, no?

opal plank
#

if i were to convert the buffer i'd get the content which would tell me

#

in code

#

yes

#

i only got this in console

green kestrel
#

its like an array you have to manage yourself that your access to is marshalled beyond usefulness isn't it

opal plank
#

i had plenty of fun doing this before

green kestrel
#

haha

quartz kindle
#

dafuq

green kestrel
#

97, 110, 110

#

this is some text

#

lower case starting with a

#

right?

opal plank
#

fuck it

#

i'll regex it

quartz kindle
#

i mean

#

why not just get the response body as text?

opal plank
#

cuz i dont have access to the code

#

this is only in the logs

#

tim

quartz kindle
#

oh

opal plank
#

help me out here

quartz kindle
#

lmao

opal plank
#

gimme handy regex

#

to remove (\d*[-:])

#

something like that

crimson vapor
#

what the fuck is this

opal plank
#

any digit, greedy, until :

quartz kindle
#

.split("\n").map(x => Number(x.split(";")[1]))

opal plank
#

nono

#

regex

quartz kindle
#

why

ember wedge
#

nono

opal plank
#

imma use vsc to replaceall

ember wedge
#

split

quartz kindle
#

oh

ember wedge
#

oh

opal plank
#

i already got a function to convert all those buffers

ember wedge
#

(\d*:)(\d*)\n

opal plank
#

just need to remove that

quartz kindle
#

try \n\d;

opal plank
#

not there yet

quartz kindle
#

just add the :

opal plank
#

pog

#

mine was right

#

dsa

#

and it died

ember wedge
#

all roads lead to rome

quartz kindle
#

all romes lead to road

modest maple
#

all romes lead to romans

ember wedge
modest maple
#

all romans lead to baths

#

all baths lead to sex

ember wedge
#

romes === sex

opal plank
#

tim lied to me

#

reee

quartz kindle
#

wut

opal plank
ember wedge
#

\n\d*:

opal plank
#

ur regex didnt catch more than 1 digit

sour flame
#

...

opal plank
#

ey pog

#

okay

#

so

#

for future reference

#

you can only copy stuff from the debug console that you see on screen

#

so, if you scroll up, everything that dissapears below wont be copied

#

therefore i pressed ctrl + - a couple dozen times where i could fit everything on the screen

quartz kindle
#

lmao

blissful coral
#

Are you able to get a form element in js and call a submit function on it

#

Don't really know if thats a thing

modest maple
#

just give it an id and get the element

blissful coral
#

I know that part

modest maple
#

if you want to make a submit button either use the linking submit tag or just a seperate button that know's what form it's refering to

blissful coral
#

I got the document.getElementById() part

quartz kindle
#

.submit()

blissful coral
#

👍

opal plank
blissful coral
#

If I have 10000 servers and 10 shards, whats a good amount of clusters to have?

drifting wedge
#

1

blissful coral
#

only 1?

drifting wedge
#

Ye

#

If more maybe 2 clusters

blissful coral
#

When should it be upscaled to 2

drifting wedge
#

But you shouldn't be 1k / shards

blissful coral
#

well how many shards per cluster is optimal?

drifting wedge
#

Maybe 1.5

#

Or 2

blissful coral
#

yeah its a lil over 10k

#

filling up to a 10th shard

drifting wedge
#

Uhh depends on system and shit

#

Uhh I recommend around maybe 5-6 shards then

silk turtle
#

New here

#

What’s this like

drifting wedge
#

2.5k guilds / shard is the perfect amount, but it's the max

#

So like maybe around 2k / shard

#

I would say, around like 14-18ish shards

#

Split in 2

blissful coral
#

kk

drifting wedge
#

But that's already a little overkill

#

You won't need to cluster more

#

For a while

blissful coral
#

weird djs shardingmanager is taking discords recommended shard counts and is putting us at 10

#

for 10k servers

silk turtle
#

Wtf is this

drifting wedge
#

Ah

#

I mean I recommend maybe 1.5-2k

#

Per shard

quartz kindle
#

discord recommends 1k guilds per shard

#

but you can use more

drifting wedge
#

Really!?

blissful coral
#

thought so

#

???

drifting wedge
#

@rustic nova

blissful coral
#

@rustic nova

crimson vapor
#

@rustic nova

blissful coral
#

LOL

rustic nova
#

-b 793233385862332446

gilded plankBOT
#

dblMod Banned urmomsunderwear#2954 (@silk turtle)

quartz kindle
#

Lol

drifting wedge
#

#spamhope