#development

1 messages Β· Page 158 of 1

sharp geyser
quartz kindle
#

ayyy

earnest phoenix
#

πŸ‘€

sharp geyser
#

Actually

#

just noticed something

#

It will always be 1 socket no matter if they supply otherwise cause of this dumb error TypeError: Cannot read properties of undefined (reading 'sockets')

#

I don't see why options isn't properly being attached

#
import { EventEmitter } from 'events';
import { SocketManager } from './';
import { IClientEvents, IClientOptions } from '../';
import { GatewayIntentBits } from 'discord-api-types/v10';

export declare interface Client {
    on<K extends keyof IClientEvents>(event: K, listener: (...args: IClientEvents[K]) => void): this;
    once<K extends keyof IClientEvents>(event: K, listener: (...args: IClientEvents[K]) => void): this;
    emit<K extends keyof IClientEvents>(event: K, ...args: IClientEvents[K]): boolean;
    off<K extends keyof IClientEvents>(event: K, listener: (...args: IClientEvents[K]) => void): this;
    options: IClientOptions;
    socketManager: SocketManager;
    token: string;
}

export class Client extends EventEmitter {
    public socketManager: SocketManager;
    public token: string;
    public options: IClientOptions;
    constructor(token: string, options: IClientOptions) {
        super();

        this.token = token;

        this.socketManager = new SocketManager(this);

        this.options = options;
    }

    public async login() {
        await this.socketManager.connect();
    }
}

Anything you guys can see that I seem to be missing cause this looks fine, so I don't think this is the root cause

#
    constructor(client: Client) {
        super();

        this.client = client;

        this.sockets = this.client.options.sockets ?? 1;
    }

this is whats in SocketManager where the error is occuring

earnest phoenix
#

Oh

sharp geyser
#

funny enough in Socket which requires SocketManager to use the client values it works fine

#

only SocketManager gives issues

earnest phoenix
#

You're assigning the options after passing it to the SocketManager

sharp geyser
#

yea?

#

Whats wrong with that

earnest phoenix
#

I don't think you understood, you're trying to access the options property in the constructor of the SocketManager class, but it doesn't have a value yet, so you'd have to assign the options property and then pass it to the constructor

sharp geyser
#

I see

#

I can likely move it to my #createSockets method

#
    #createSockets() {
        this.sockets = this.client.options.sockets ?? 1;

        for (let id = 0; id < this.sockets; id++) this.socketStore.set(id, new Socket(id, this));
    }
#

Would this be fine?

earnest phoenix
#

Why not just do this in the Client constructor?

this.options = options;

this.socketmanager = new SocketManager(this);
sharp geyser
#

OH

#

thats what you mean

#

Actually that makes sense

earnest phoenix
#

What did you think I meant? lul

sharp geyser
#

idk why it took you to say that to get it

sharp geyser
#

I just brain farted there

#

Makes sense now that you pointed it out that SocketManager was trying to use it before it was assigned which I thought you meant in the SocketManager class itself not in client

earnest phoenix
#

Heh it happens

sharp geyser
#

Oh shoot

#

I just realized something else I made a goof of

#

😩

#

using a normal for loop to loop through the shards to connect wont work

#
for (const [id, socket] of this.socketStore) {
            const shard_bucket = id % session_start_limit.max_concurrency;
            const previous = bucket[shard_bucket];
            const current = Date.now();
            if (current - previous < 5000) {
                setTimeout(() => {
                    this.connect();
                }, 5000);
            } else {
                bucket[shard_bucket] = current;
                await socket.connect();
            }
        }

Unless im mistaken, this will loop through all the shards and connect the first one, but once it reaches the second shard in the loop it wont work cause 5s hasn't passed.

#

Actually wait no, it should work cause I call the this.connect method again

#

so its recursive and will keep calling until all shards are connected but because of what I am doing this is bad

#

each time the bucket variable is overwritten so any previous shards recorded as being connected will be gone, I need to make it a class variable

#

or no I can't 😩

lyric mountain
sharp geyser
#

hm?

lyric mountain
#
this.connect()
  .then(...)
#

there's a lib called promise-cascade or smth

soft mirage
#

Hello guys this is my brother bilo

lyric mountain
sharp geyser
lyric mountain
#

well, it wont, it'll just ensure it doesn't try to connect the next shard before the first finishes

#

isn't this what u want?

earnest phoenix
#

Are you trying to wait 5 seconds after the previous shard has connected? I don't exactly know what you're trying to do here

sharp geyser
#

so if 5s hasn't passed when those shards connected than it should continue to check if 5s has passed until it finally has before connecting the next shards

sharp geyser
#

sorry wrong part

earnest phoenix
sharp geyser
#

Not really

#

tim told me thats how he did it and I thought it'd be fine to do so for now which in truth it is

#

but I realize I wanna implement the full thing right away to get it over with

#

Yet I don't know how i'd go about doing so

sharp geyser
#

cause if they are trying to load multiple shards and only able to concurrently load 1 shard every 5s then id % concurrency will always = 0

#

so every shard will be the same modulo id so it should wait 5s between in shard, yet it doesn't seem to be doing that, it simply just doesn't load any shards now

earnest phoenix
#

Basically:

import { setTimeout as setPromisedTimeout } from 'node:timers/promises';

...

if (current - previous < 5_000)
  await setPromisedTimeout(5_000);

// Connect the shard here
sharp geyser
#

I indeed got it from tim :p

earnest phoenix
#

If the time set for the previous shard bucket is less 5 seconds then it's highly likely that the next shards in the shard bucket have a value of less than 5 seconds, so doing that will wait the amount of time necessary for it to be higher than 5 seconds and for the next ones to be available for connection

sharp geyser
#

I see

#

I should also call the connect method in the timeout part no?

earnest phoenix
#

Although actually you should just hardcode waiting for 5 seconds just in case, not the diff, let me edit

#

There we go

earnest phoenix
sharp geyser
#

hum

#

Maybe im not understanding the code properly

#

cause to my understanding the bucket will hold all shards that can currently be identified which mind you depending on their max_concurrency can be 1-16

earnest phoenix
#

Basically:

  1. Get the previous shard bucket time value
  2. Is it less than 5 seconds?
  • Wait 5 seconds to let the next set of shards become available for concurrent connection
  1. Connect current shard
sharp geyser
#

So if only 1 shard is in the bucket, it'll load, but now the bucket is empty and won't be filled again cause its not filling it later

sharp geyser
# earnest phoenix Basically: 1. Get the previous shard bucket time value 2. Is it less than 5 sec...
    async connect() {
        if (this.socketStore.size <= 0) this.#createSockets();
        const { session_start_limit }: APIGatewayBotInfo = await fetch('https://discord.com/api/v10/gateway/bot', {
            headers: {
                Authorization: `Bot ${this.client.token}`,
                'Content-Type': 'application/json',
            },
        }).then((res) => res.json());

        const maxConcurrency = session_start_limit.max_concurrency;

        this.#bucket = Array(maxConcurrency).fill(0);

        for (const [id, socket] of this.socketStore) {
            const shard_bucket = id % session_start_limit.max_concurrency;
            const previous = this.#bucket[shard_bucket];
            const current = Date.now();
            if (current - previous < 5_000) {
                await setPromisedTimeout(5_000);
            }
            this.#bucket[shard_bucket] = current
            await socket.connect()
        }
    }

From my current code to me it looks like thats not what happens tho

#

To me it looks like it Loads the bucket, identifies the shard and stops

pale vessel
#

unrelated but is that content type really necessary when it's a GET request

sharp geyser
#

likely not, force of habit tho

lyric mountain
#

after I spent 3 hours debugging a delphi webserver, I always add User-Agent and Content-Type headers

#

regardless of whether they're needed at all

pale vessel
#

yeah, some APIs refuse to respond or errors if you don't set a user agent header

#

ESPECIALLY GitHub

lyric mountain
#

lmao

pale vessel
#

learned that the hard way

lyric mountain
#

what agent do u use? Mozilla/5.0?

pale vessel
#

"yes"

#

any text works

lyric mountain
#

lmao no way

earnest phoenix
# sharp geyser ```ts async connect() { if (this.socketStore.size <= 0) this.#create...

The shard bucket contains all of the shards that can be connected, with the rate limit key assigned to each of them obtained from shard_id % max_concurrency (shown in the official Discord documentation, the one you linked)

For example, let's say you have 32 shards, the shard bucket would be:

shard_id: 0, rate limit key (0 % 16): 0
shard_id: 1, rate limit key (1 % 16): 1
shard_id: 2, rate limit key (2 % 16): 2
shard_id: 3, rate limit key (3 % 16): 3
shard_id: 4, rate limit key (4 % 16): 4
shard_id: 5, rate limit key (5 % 16): 5
shard_id: 6, rate limit key (6 % 16): 6
shard_id: 7, rate limit key (7 % 16): 7
shard_id: 8, rate limit key (8 % 16): 8
shard_id: 9, rate limit key (9 % 16): 9
shard_id: 10, rate limit key (10 % 16): 10
shard_id: 11, rate limit key (11 % 16): 11
shard_id: 12, rate limit key (12 % 16): 12
shard_id: 13, rate limit key (13 % 16): 13
shard_id: 14, rate limit key (14 % 16): 14
shard_id: 15, rate limit key (15 % 16): 15
shard_id: 16, rate limit key (16 % 16): 0
shard_id: 17, rate limit key (17 % 16): 1
shard_id: 18, rate limit key (18 % 16): 2
shard_id: 19, rate limit key (19 % 16): 3
shard_id: 20, rate limit key (20 % 16): 4
shard_id: 21, rate limit key (21 % 16): 5
shard_id: 22, rate limit key (22 % 16): 6
shard_id: 23, rate limit key (23 % 16): 7
shard_id: 24, rate limit key (24 % 16): 8
shard_id: 25, rate limit key (25 % 16): 9
shard_id: 26, rate limit key (26 % 16): 10
shard_id: 27, rate limit key (27 % 16): 11
shard_id: 28, rate limit key (28 % 16): 12
shard_id: 29, rate limit key (29 % 16): 13
shard_id: 30, rate limit key (30 % 16): 14
shard_id: 31, rate limit key (31 % 16): 15

Now we iterate through all 32 shards and do the following:

  1. Obtain rate limit key (in this example of 32 shards, if the previous rate limit key was 31, it would go back to 0 with the calculation we do)
  2. Get the previous time set in shard bucket with the rate limit key
  3. If the previous time set is less than 5 seconds, not enough time has passed to start connecting the next set of shards, so wait 5 seconds
  4. Overwrite the previous time set in the shard bucket with the current time we calculated
  5. Connect the shard
lyric mountain
#

did u really type that on mobile?

sharp geyser
earnest phoenix
#

Of course

sharp geyser
#

Voltrex is the god of js

#

he can type it on a samsung smart fridge

earnest phoenix
#

I mean, what do you expect when I maintain Node.js, V8, LLVM, and more on a phone

pale vessel
#

that one was to bypass CF, it worked

sharp geyser
#
Received Hello. First heartbeat in 27583ms (Interval - 41250ms
Identifying (Shard: 0)
Logged in
Received Hello. First heartbeat in 37942ms (Interval - 41250ms
Identifying (Shard: 2)
Received Hello. First heartbeat in 12313ms (Interval - 41250ms
Identifying (Shard: 1)
Logged in
Logged in
Received Hello. First heartbeat in 32946ms (Interval - 41250ms
Identifying (Shard: 3)
Received Hello. First heartbeat in 619ms (Interval - 41250ms
Identifying (Shard: 4)
Logged in
Sending Heartbeat
C:\Dev\shensuo\src\core\client\socket\Socket.ts:47
                if (!(data && data.d && data.op)) return Promise.reject(new Error('INVALID_REQUEST_SENT'));
                                                          ^
Error: INVALID_REQUEST_SENT
    at Socket.#send (C:\Dev\shensuo\src\core\client\socket\Socket.ts:47:59)
    at Timeout._onTimeout (C:\Dev\shensuo\src\core\client\socket\Socket.ts:119:16)
    at listOnTimeout (node:internal/timers:573:17)
    at processTimers (node:internal/timers:514:7)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

it was working till it wasn't

#

I think I know what happened

#

It was likely trying to send a heartbeat

#

I think sending heartbeats while sharding is different

lament rock
#

simplify your logic to

if (!data || !data.d || !data.op) ...
#

wont fix it but got damn do I hate if (!(expression))

sharp geyser
#

Actually I don't think heartbeating with shards is any different

lyric mountain
#
if (!data?.d || !data?.op) ...
lament rock
#

Optional chaining isnt in a lot of node distributions. I know someone who still uses v12

sharp geyser
#

I would never

lyric mountain
#
if (!Object.keys(data == null || typeof data !== "object" ? {} : data).some(k => ["d", "op"].includes(k))) ...
lament rock
#

if data is undefined, that will throw an error pretty sure

lyric mountain
#

there

lament rock
#

Null coalescing was added around the same time as optional chaining

lament rock
#

use logical or instead

#

null is typeof "object"

pale vessel
#

yeah was about to say

lament rock
#

my brother in christ

sharp geyser
#

yet idk why its being set as 0 to begin with

#

nvm I do

lament rock
#

The d for heartbeat has to be your last received s

sharp geyser
#

yea

#

which if you didn't receive one should be null by default

#

yet I stupidly made it 0

earnest atlas
#

Hello acafcalm

sharp geyser
#

wait what

#

Maybe that isn't the issue?

#

yea no its an issue with sending the heartbeat but why

#

😩

#

Oh im fucking dumb

#

!null -> true so ofc its going to error cause it fulfils the condition

sharp geyser
#

😩

#

it looks so weird

#

Time to use it

lyric mountain
#

because for js everything is a map

sharp geyser
#

fair enough

lyric mountain
#

arrays? map
strings? map
numbers? believe it or not, map

#

boolean? yep, you get it

sharp geyser
#

why does that make sense

earnest phoenix
#

oldEyes?

sharp geyser
#

oldEyes

lyric mountain
sharp geyser
#

Wtf

earnest phoenix
#

What Kuu's snippet does is just check if those keys are present in the object

lyric mountain
#

in a very convoluted way

earnest phoenix
#
if (
  data == null /* compares to both null and undefined */ ||
  !('d' in data && 'op' in data)
) { ... }

// or

if (
  data == null ||
  !('d' in data) ||
  !('op' in data)
) { ... }

// though doesn't matter
sharp geyser
#

Sharding is interesting

#

Should I also add auto sharding which will use discord's recommended shard #?

earnest phoenix
#

Yeah

#

Most people use auto shard count anyway

sharp geyser
#

Alright

#

actually would doing this

for (let id = 0; id < (this.sockets === 'auto' ? shards : this.sockets); id++)
            this.socketStore.set(id, new Socket(id, this));
``` be better than doing a if/else?
earnest phoenix
#

The second clause of a for loop is evaluated on each iteration so I'd recommend putting that outside the loop, basically assign the value to a variable

#

Even though it'll most likely be optimized anyway, you should try to put such evaluation outside just in case

sharp geyser
#

I see

#

Thank you volty

surreal sage
#

I ordered an additional IP address at my vps provider
The server lost its internet connection and I'm connected via VNC
Netplan isn't installed for some reason
Can some1 help me out?

earnest phoenix
#

You're welcome Misty

surreal sage
surreal sage
#

contabo

sharp geyser
#

Okay

#

ubuntu?

surreal sage
#

wont be expecting a response at 11pm

#

20.x

sharp geyser
#

Did you get an email from them when they finished setting up your ip?

surreal sage
#

Yes

#

Netmask: 255.255.192.0
Prefix: /18

sharp geyser
#

Okay, did you read the part where they don't auto configure the ip for you so you must do it yourself

surreal sage
#

I know

#

I tried to

#

Netplan isn't installed for some reason

#

Something happened and now it doesn't have an internet connection

sharp geyser
#

when you were doing these configurations did netplan apply work?

surreal sage
#

No

#

Command not found

sharp geyser
#

okay, so what did you do during this that caused you to bork your vps

surreal sage
#

I have no idea

#

I modified the netplan file

sharp geyser
#

without running netplan apply it won't change anything even if you reboot

surreal sage
#

yeah

#

i edited it

#

rebooted

#

thats all

#

since netplan didnt work

sharp geyser
#

Then you did something else

surreal sage
#

let me list all the commands i did

sharp geyser
#

are you able to show your current netplan file

surreal sage
#

yes

sharp geyser
#

show it

surreal sage
#

blurring cuz im a lil monkey

#

all the commands I did in order, and response if needed

#

nano /etc/netplan/01-netcfg.yaml
netplan apply
- netplan: command not found
netplan
- netplan: command not found
netplan generate
- netplan: command not found
sudo apt install netplan
- unable to locate package
(cleared out my screen sessions as they were not used, all weren't running anything)
sudo reboot

#

that's literally it

earnest phoenix
#

Simply download the Netplan .deb file on a machine that has internet connection, move it to the VPS using something like SFTP, and run sudo dpkg -i <path/to/.deb/file>

surreal sage
#

I can't move it over as it isn't connected to the internet

#

It's a vps

#

I only have vnc access rn

sharp geyser
#

as long as the vps is on, you should be able to SFTP into it no?

surreal sage
#

nope

#

connection timeout

#

just tried

#

same /w ssh

sharp geyser
#

I mean you could try to do a recovery or wipe the vps shrug but I don't think thats needed

#

there is probably some other underlying issue here

surreal sage
#

Yeah

#

(I don't have a copy of the files)

#

(+ no snapshots)

sharp geyser
#

what does your firewall look like might be you fucked up your config there somehow?

#

run ufw status

surreal sage
#

how can i rescale in vnc

#

cuz it's more lines than I can see

#

cant scroll

sharp geyser
#

just show what you can ig

#

I don't use vnc so idk

surreal sage
sharp geyser
#

assuming your ssh port is still 22 then yea you should be able to ssh into it

surreal sage
#

It doesn't have a connection to the internet

#

The VNC server is on a different machine

#

Who is just relaying the inputs and ouputs

sharp geyser
#

I just don't get how your vps could not have internet access, I don't think contabo even allows you to fuck up that badly

surreal sage
#

well shit happened 😭

#

3 folders i care about

sharp geyser
#

How certain are you that its a internet issue, what happens if you try installing a package or whatever

#

or even using curl

surreal sage
earnest phoenix
#

What happens when you run the following in order?

$ sudo apt update
$ sudo apt full-upgrade
$ sudo apt install netplan.io
surreal sage
#

good luck getting past #1

earnest phoenix
#

The package may hopefully be cached, try the third command

surreal sage
#

sent in a support request ig

earnest phoenix
earnest phoenix
#

Try changing that to 8.8.8.8

neon leaf
#

who told me this was correct like 4 months ago? cat

class PassThrough64K extends Duplex {
    constructor() {
        super({
            read() {},
            write(chunk: ArrayBuffer) {
                let chunkCount = Math.ceil(chunk.byteLength / size(64).kb()), index = 0
        
                while (chunkCount) {
                    this.push(chunk.slice(index, index + size(64).kb()))
                    index += size(64).kb()
                    chunkCount--
                }
            }
        })
    }
}```

it seems like its just forgetting some chunks
#

probably just last or first

surreal sage
neon leaf
#

ooh

tulip ledge
#

How hard did u mess up? Haha I’d like to know so I don’t do the same πŸ’€

surreal sage
#

Creds

#

Nothing sensitive on there besides a website or two

#

Changed it right before

#

But yeah waiting rn

#

I will be forwarding your email to our technical department for further investigation. You will receive an answer as quickly as possible, but in the meantime, we kindly ask for your patience.

#

ok then

spark pebble
#

How can you DM user who adds bot to the server? Apparently you can only do it via audit log? 🀷

#

Which I don't believe, cos bot would need access to view audit log, which doubt.

rustic nova
#

you can figure out which user invited a bot

#

that requires viewing the audit log

#

so yes, that is not possible without audit log perms

lament rock
#

Alternatively, there's the oauth2 flow iirc

rustic nova
#

you can do a bit of trickery and include a oauth that tells

#

yeah that

#

tells your bot when it was invited successfully

spark pebble
#

Ahh okay, that sounds better, ty

spark pebble
rustic nova
#

nah

#

just look into how oauth on discord works

spark pebble
#

okay ty πŸ™‚

#

this just scared the ||SHIT|| out of me

#

thought I got banned or summin 🀣

lament rock
#

They dont notify you for that

#

you just cant login anymore

spark pebble
#

sorry wrong channel*

#

oh lmao, never been banned tbh

lament rock
#

good lad

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

spark pebble
sage bobcat
#

One message removed from a suspended account.

spark pebble
#

you've lot the plot

sage bobcat
#

One message removed from a suspended account.

sage bobcat
warm surge
#

lmaooo

sharp geyser
sage bobcat
#

One message removed from a suspended account.

warm surge
#

same

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

spark pebble
quartz kindle
#

cursing is an expression of freedom and also tension release

#

very healthy

#

with that said, heres some blyat cyka jobani urod idi nahui pidar cyka :^)

#

and also some jebo te tri silosa zita zrno po zrno in za vsako zrno tri picke materine

#

and also some portugal caralho!!

sharp geyser
#

GatewayEvents[data.t!] returns undefined

import { MessageCreateHandler, GuildCreateHandler } from '../';

export const GatewayEvents: Readonly<Record<string, Function>> = Object.freeze({
    MESSAGE_CREATE: GuildCreateHandler,
    GUILD_CREATE: MessageCreateHandler,
});

Am i misinterpreting how Object.freeze works?

#

I now know the reason is because of hows it typed ig

#

but still

#
export const GatewayEvents = Object.freeze({
    MESSAGE_CREATE: GuildCreateHandler,
    GUILD_CREATE: MessageCreateHandler,
});

even as this it gives an error that type any cannot be index by type string

lament rock
#

children of the frozen child can still be edited tho

sharp geyser
#

I dont see how this pertains to my issue of not being able to index the Object once its been frozen via a string because of how stupid typescript's type safety is

#
TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Readonly<{ MESSAGE_CREATE: (client: Client, data: GatewayGuildCreateDispatchData) => void; GUILD_CREATE: (client: Client, data: GatewayMessageCreateDispatchData) => void; }>'.

This is the error, ig I forgor to post the new one

lament rock
#

You can't edit a frozen object

sharp geyser
#

Im not trying to πŸ’€

#

Im trying to ACCESS it

lament rock
#

you can cast the key as string

sharp geyser
#

bruh

#

I tried

#

😭

lament rock
#

thing[key as keyof typeof thing]

sharp geyser
#

But no matter what its undefined then

lament rock
#

Then the key you're using doesn't exist in the Object

#

alternatively, use Object.getProperty

sharp geyser
#

it does tho πŸ’€

#

GUILD_CREATE most definitely exists

#

unless we're both blind

wheat mesa
#

Have you tried logging what data.t actually is

sharp geyser
#

yea

#

its GUILD_CREATE

wheat mesa
#

Are you sure

#

Like 100%

sharp geyser
#

I mean, I console logged data.t

#

so yea

#

I console log it as each event is passed through

#

READY -> GUILD_CREATE

wheat mesa
#

Have you perhaps considered that you don’t have a READY prop 😭

sharp geyser
#

I would if not for my switch case already handeling READY so the default doesn't care about that specific event

lament rock
#

if READY is logged as an attempted key access, then it's no wonder you'd get undefined

sharp geyser
#

What

#

Have you been paying attention to what i've wrote

lament rock
#

Loosely.
When you go to access the GatewayEvents, I'd just double, nay, triple check what your accessing is valid

sharp geyser
# sharp geyser READY -> GUILD_CREATE

If you are referring to this, this is simply the chain that events get logged top level, not inside my switch case. My switch case already handles ready event triggers and default takes care of the rest

#

Actually it doesn't even seem to be a problem with that

#

I might just be dumb and trying to do the impossible

lament rock
#

wdym

sharp geyser
#

Well I indexed it myself with a key and it still returns undefined despite it 100% existing

#

so doesn't seem to be an issue with using data.t at all

lament rock
radiant kraken
#

insane

radiant kraken
lament rock
#

They insist something else handles ready

sharp geyser
#

Because it does

sharp geyser
# lament rock

Anyways, my values are exported functions which likely aren't allowed to be done this way

sharp geyser
#

my god

#

im done

radiant kraken
#

oh okay

sharp geyser
lament rock
sharp geyser
#

Yea well then I have no idea why my strange case is happening

#

despite everything it claims it is undefined so i give up

lament rock
#

provide more code and I'll take peek

sharp geyser
#

Idk what other code you want

#

those are literally the only 2 things that contribute

lament rock
#

like where you access the Object

sharp geyser
radiant kraken
sharp geyser
#

where are you seeing this at

radiant kraken
#

the line you've just showed?

sharp geyser
#

youre seeing wrong

radiant kraken
#

i know

#

i'm just telling you to log the whole object

sharp geyser
#

I mean if indexing GUILD_CREATE makes it return undefined then it would just be an object with the values being undefined

#

such as this

radiant kraken
#

then the constants you define are probably undefined

sharp geyser
#

Unless im not able to reference a function like how I am

radiant kraken
#

since looking from your codebase structure

#

i can see why you could mistake to things might not exist

sharp geyser
#

hm?

radiant kraken
sharp geyser
#

yea

#

what about it

#

its a barrel file

radiant kraken
#

you probably forgot to export/import those handler functions somewhere

sharp geyser
#

if I did that typescript would be erroring even before everything else

kind lily
#

is it allowed to join discord servers that your bot is in using the bot to generate the invite link?

sharp geyser
#

Nope

kind lily
#

oo

radiant kraken
#

i doubt that the constants are randomly set undefined during runtime

#

it's most likely undefined from the very beginning

sharp geyser
#

Highly possible, but I don't see how

radiant kraken
#

or something related

sharp geyser
#

Again I don't see anywhere im doing such a thing

kind lily
# sharp geyser Nope

@sharp geyser can u refer me to where it says this because I can't manage to find it

radiant kraken
#

since client is imported before socket

#

since iirc node reads JS files line-by-line, ordering of imports matter, no?

#

@sharp geyser

sharp geyser
#

yea I think you're right

#

as importing directly from the handlers file seems to work fine

radiant kraken
sharp geyser
#

yea

#

I know

sharp geyser
wheat mesa
sharp geyser
#

Idk why importing from a barrel file causes issues

#

but directly importing from the folder where those handlers are works fine

#

This is an issue in production as well if said issue occurs for people when importing things

radiant kraken
#

or something idk

#

@earnest phoenix

radiant kraken
sharp geyser
#

No

radiant kraken
#

sad sdSadge

sharp geyser
#

I think internally I should just import directly from those files until some contributor figures it out trollface

radiant kraken
#

frfr

#

codebase design should be for later

sharp geyser
#

Cause my dumbass can't tell why doing so from the root folder which exports everything from those folder/subfolders anyway breaks

#

Anyway

#

Events work :)

radiant kraken
#

nice

sharp geyser
#

Now to pain stakingly write out the classes that model the data sadge

radiant kraken
#

good luck on writing your own discord framework, as an ex-discord lib dev, you're in for such a ride

sharp geyser
#

I've done it before but gave up cause I saw no one using it

#

Its a struggle when you try and do it properly

#

with a gap of 6 months from coding any proper project

radiant kraken
#

why would they use any other third party library

sharp geyser
#

because mine isn't as cancer as discord.js ||this is false but dont tell them||

radiant kraken
#

frfr

sharp geyser
#

ugh writing out classes is annoying and I could probably be doing this in a much better way but meh

marsh lark
#

You'd love Java thinking_smirk

sharp geyser
#

I do like java actually

#

I just hardly use it so im not as good with it

marsh lark
#

Tbf most of my Java experience was school and minecraft

sharp geyser
#

I've never had an actual teacher teach me any programming

#

its all self taught, which explains why im so bad at it trollface

radiant kraken
#

Java is a decent language

marsh lark
#

I also learnt Javascript & TS fully self taught, and the only programming knowledge I had before that was Scratch (and like hello world python)

radiant kraken
#

self taught >>>

sharp geyser
#

Im not cause I am the kind of person that strives when things are explained to me like im 5 years old

radiant kraken
#

my school doesnt have a computer science subject

#

they neglected my passions

sharp geyser
#

Now for some reason im not receiving message content despite having it enabled on the bot page and asking for the intent when identifying

#

😩

marsh lark
#

Are you subscribing to the intent?

sharp geyser
#

Yep

#

I faced this issue before but I don't remember what I did to solve it

#

32769 is the sum of GUILDS + MESSAGE_CONTENT

#

thats what is being sent to discord

lyric mountain
#

It's a whole different experience

#

Schools usually constrain you to java 8

wheat mesa
lyric mountain
#

Which is bad

wheat mesa
#

You should be using bitwise OR

#

Technically it shouldn’t matter if the bits are unique but just to make sure

marsh lark
#

32769 is correct

wheat mesa
#

GuildMessages

#

Should probably add that one in

marsh lark
#

Thats for receiving messages no?

#

You dont need it to fetch or recieve message context menu interactions

lyric mountain
#

Adding bitflags usually works but yeah, don't do it as you might spend hours debugging to know why it isn't working

wheat mesa
#

He’s asking about message content

marsh lark
#

Yes

#

Which is why you don't need guild messages

#

You just need message content

lyric mountain
#

U don't receive messages without guild message intent

marsh lark
#

When did misty ever say about receiving messages

wheat mesa
sharp geyser
lyric mountain
#

Message content allows reading the messages, guild messages enables receiving message events

wheat mesa
#

Enable GuildMessages

sharp geyser
#

why are there so many intents for messages bruh

wheat mesa
#

Assuming you’re trying to get the event here

radiant kraken
#

you cant get message content without guild messages in the first place

lyric mountain
sharp geyser
#

thank you guys

lyric mountain
#

Or purely a lurker like topgg bot

sharp geyser
#

πŸ˜”

radiant kraken
#

how

sharp geyser
#

GuildMessages only relate to guild events

marsh lark
#

Guild messages is just for receiving messages

#

You can still fetch messages without it

sharp geyser
#

DirectMessages is for recieving the message events in dms

lyric mountain
#

U can't read messages u never receive

#

I mean, u can, if u fetch them

sharp geyser
#

MessageContent is simply just giving you the content of the message but you can still receive them

lyric mountain
#

But how will u get the id?

marsh lark
#

A user can specify it

radiant kraken
lyric mountain
#

Also how would it even work practically?

marsh lark
lyric mountain
#

A bot without guild messages is a blind bot

marsh lark
#

And somehow they still work

#

woah

lyric mountain
#

First, no http bots

#

They're called slash applications, they work though webhooks

marsh lark
#

You can replicate http bot behaviour even with gateway, you can simply just don't subscribe to any intents

marsh lark
lyric mountain
#

Second, they don't need message content either, as they always have the content of the command

lyric mountain
#

U only need an application

#

All bots are applications, but not all apps are bots

marsh lark
#

well ok

lyric mountain
#

An example would be a "bot" that you add to the server, without inviting

#

Those are pure applications

marsh lark
#

how do you add a bot without inviting

lyric mountain
#

You use the interactions scope without bot

#

The bot member never gets added

#

But the commands do appear

#

Some bots use this, usually mod bots

#

Or third party service bots

sharp geyser
#
Message {
  client: <ref *1> Client {
    _events: [Object: null prototype] {
      ready: [Function (anonymous)],
      messageCreate: [Function (anonymous)],
      debug: [Function: log]
    },
    _eventsCount: 3,
    _maxListeners: undefined,
    socketManager: SocketManager {
      _events: [Object: null prototype] {},
      _eventsCount: 0,
      _maxListeners: undefined,
      client: [Circular *1],
      socketStore: [Store [Map]],
      sockets: 'auto',
      [Symbol(kCapture)]: false
    },
    token: 'goodluck',
    options: { intents: [Array], sockets: 'auto' },
    [Symbol(kCapture)]: false
  },
  data: {
    type: 0,
    tts: false,
    timestamp: '2023-08-15T02:53:35.098000+00:00',
    referenced_message: null,
    pinned: false,
    nonce: '1140840675059695616',
    mentions: [],
    mention_roles: [],
    mention_everyone: false,
    member: {
      roles: [],
      premium_since: null,
      pending: false,
      nick: null,
      mute: false,
      joined_at: '2022-03-28T05:04:40.163000+00:00',
      flags: 0,
      deaf: false,
      communication_disabled_until: null,
      avatar: null
    },
    id: '1140840684996272178',
    flags: 0,
    embeds: [],
    edited_timestamp: null,
    content: 'asdasd',
    components: [],
    channel_id: '974091097661923448',
    author: {
      username: 'misty.dev',
      public_flags: 64,
      id: '957347862314905610',
      global_name: 'Misty',
      discriminator: '0',
      avatar_decoration: null,
      avatar: 'b00572d12f19c17564a3f57c783a3e3a'
    },
    attachments: [],
    guild_id: '957867801119449109'
  }
}

Look at my totally complete message struct that I definitely wasn't too lazy to split into its own fields and not classify the data under a data prop

marsh lark
#

You have the content here

#
content: 'asdasd',
sharp geyser
#

yep

#

cause I asked for it

#

:p

marsh lark
#

oh you solved it?

sharp geyser
#

yea

#

Im showing off my awesome Message class

#

:)

marsh lark
#

what'd you do

sharp geyser
#

just asked for the GuildMessages intent

#

forgor to do that

marsh lark
#

are you listening to messages

sharp geyser
#

rn I am receiving messages yea

marsh lark
#

oh yeah then you need guild messages

sharp geyser
#

I know

marsh lark
#

i thought you meant you were receiving messages as an empty string

sharp geyser
#

πŸ’€

#

nah

#
data: {
    type: 0,
    tts: false,
    timestamp: '2023-08-15T02:53:35.098000+00:00',
    referenced_message: null,
    pinned: false,
    nonce: '1140840675059695616',
    mentions: [],
    mention_roles: [],
    mention_everyone: false,
    member: {
      roles: [],
      premium_since: null,
      pending: false,
      nick: null,
      mute: false,
      joined_at: '2022-03-28T05:04:40.163000+00:00',
      flags: 0,
      deaf: false,
      communication_disabled_until: null,
      avatar: null
    },
    id: '1140840684996272178',
    flags: 0,
    embeds: [],
    edited_timestamp: null,
    content: 'asdasd',
    components: [],
    channel_id: '974091097661923448',
    author: {
      username: 'misty.dev',
      public_flags: 64,
      id: '957347862314905610',
      global_name: 'Misty',
      discriminator: '0',
      avatar_decoration: null,
      avatar: 'b00572d12f19c17564a3f57c783a3e3a'
    },
    attachments: [],
    guild_id: '957867801119449109'
  }

look at all this data I have to parse down

marsh lark
#

is that not just api raw data

sharp geyser
#

yep

marsh lark
#

so what'd you have to parse lol

sharp geyser
#

Im turning it into my own Message class that way I can better interact with the data

marsh lark
#

so like djs?

radiant kraken
#

nope

sharp geyser
#

or like any sane discord library

#

imagine interacting with the raw data 24/7

radiant kraken
#

djs has its own classes for every API datatype

marsh lark
#

yeah

radiant kraken
#

misty is just using the raw data

lyric mountain
#

It's fuckin raw

sharp geyser
#

Im trying to make this as light weight as possible when it comes to this kind of stuff

marsh lark
#

have you heard of @discordjs/core

sharp geyser
#

I could even build a framework into the lib itself or make a standalone framework that requires the lib idk yet

sharp geyser
radiant kraken
sharp geyser
#

idk anything bout it

radiant kraken
#

was really fun

sharp geyser
#

it's fun

#

but not to the scale im trying to go

#

where you constantly need that data to be interactive with other parts of the app

#

it's better to have a class

marsh lark
#

discordjs/core is basically an api wrapper that returns raw data, but includes gateway + rest unlike discordjs/rest

sharp geyser
#

makes sense

#

mind you discord.js devs despite their clusterfuck of managing the lib are like 100x smarter than I am so despite how messy their code looks it works

radiant kraken
#

@sharp geyser just steal my old discord library code mm_giggle

sharp geyser
#

My code is the dumpster trash version of djs mmLol

radiant kraken
#

its absolutely barebones

sharp geyser
#

Mine was barebones until I started adding client stuff and rest api onto it

#

not to mention volty helped me with the sharding part

#

:p

#

thank god he did cause that was going over my head

radiant kraken
#

best library

sharp geyser
#

tiny-discord is the most performant barebones lib i've seen ngl

radiant kraken
#

frfr

#

tim the goat

sharp geyser
#

Okay thats enough programming for a bit

#

ima take a break

radiant kraken
sharp geyser
#

I should make the support server for this lib that will never see anyone's code base one day

sharp geyser
radiant kraken
#

keyword: tried

#

couldn't get OpenSSL's websockets to work

#

i was basically copying DPP's code lmao

sharp geyser
#

Lmfao

marsh hazel
#

Lmfao

compact pier
#

How can I listen for log file and log the line that being added?

#
  watchFile(__dirname + '/log.txt', async (curr, prev) => {
    console.log(`the current mtime is: ${curr.mtime}`);
    console.log(`the previous mtime was: ${prev.mtime}`);
    const logFileContent = await readFileSync(__dirname + "/log.txt", { encoding: "utf8" });
    console.log(logFileContent);
  })

Tried something like this, but it will just log the whole file everytime

lament rock
#

Split by \n and log the last entry

quartz kindle
#

that will still load the whole file every time tho

compact pier
#

I figured it out

#

by comparing the line

#

everytime there will be a new log line

#

so I will use console.log(newLog.slice(oldLogLines.length, newLogLines.length))

earnest phoenix
# radiant kraken <@456226577798135808>

Order of imports in JavaScript depends on the module resolution you're using, if you're using CommonJS then the order always matters, if you're using ES Modules however, synchronous modules' order is guaranteed but if the module being imported is asynchronous then the order cannot be guaranteed so you'd have to be careful with that (though you rarely have to care about import order)

Note that an asynchronous module is an ES Module that uses features like TLA (Top-Level Await)

earnest phoenix
#

And you're awesome, nully

slender wagon
#

has anyone here ever used terraform

radiant kraken
slender wagon
#

love is not allowed in development

earnest phoenix
earnest phoenix
frosty gale
neon leaf
#

how can I make this work using only typescript types?

type Data = {
  okay: {
    mhhh: 12
    ok: 'hi'
    e: {
      g: 1
    }
  }
}

type Keys = ???
// 'okay.mhhh' | 'okay.ok' | 'okay.e.g'

type KeyData<Key extends Keys> = ???
// KeyData<'okay.ok'> - 'hi'
marsh lark
#

I don't think that's possible using dot notation in a string

neon leaf
#

it is possible sir, ive seen it before but cant find the link anymore

#

type recursion

marsh lark
#

You can do Data[okay][ok] though

neon leaf
#

yeah thats not what I want

#

I know that

marsh lark
#

Actually it might be with newer typescript

sharp geyser
#

I am confusion, largely cause im not fully awake yet

marsh lark
sharp geyser
sharp geyser
#

https://npmjs.com/package/dot-prop might also be an option tho idk your use case here

marsh lark
#

They were asking for a typescript type

sharp geyser
#

ok

#

dk why you'd want a type to do that

marsh lark
#

Me neither

#

Β―_(ツ)_/Β―

neon leaf
#

type safe translations

grim aspen
#

i wouldn't worry too much on it. let them do them

neon leaf
#

now the question is just how do I reverse it πŸ€”

lusty quarry
#

Hello i have question with any npm package i can make vote reward command

brisk light
spark flint
#

actually lemme read thatthing KEKW

#

you are being ratelimited

#

sending too many requsts

brisk light
#

Yea but i tried after several hours and it still shows the same

spark flint
#

yes

#

its a 24h ban

brisk light
#

Ok :/

lavish fern
#
PS C:\Users\darkxx\OneDrive\Darkxxweb\XYRIS BOT> node index.js
>>
C:\Users\darkxx\OneDrive\Darkxxweb\XYRIS BOT\index.js:7
    Intents.FLAGS.GUILDS,
            ^

TypeError: Cannot read properties of undefined (reading 'FLAGS')
    at Object.<anonymous> (C:\Users\darkxx\OneDrive\Darkxxweb\XYRIS BOT\index.js:7:13)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47

Node.js v18.17.1
PS C:\Users\darkxx\OneDrive\Darkxxweb\XYRIS BOT> ```

how am gonna fix this error?
deft wolf
#

I guess it's discord.js v14 right?

sharp geyser
#

What is the difference between extends and implements when using classes. I sort of get that extends basically inherits all that the class is and implements doesn't necessarily do that rather it seems to only take on some stuff (idk)

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

lavish fern
marsh lark
#

I blame Discord for poor ansi colour handling

frosty gale
deft wolf
frosty gale
#

discord.js eats 8gb ram for breakfast

#

yum yum

nocturne flint
#

Any one here how kn how to convert image to text in python

marsh lark
#

Knowing python it probably has a built-in OCR package blob_bongos

rustic nova
#

close, but no

steep jay
#

Hi, do you have any VPS recommendations which has perfect internet speed but not expensive?

rustic nova
#

cheap ones will always have fair usage

#

and being limited a bunch

#

though you can try this out

#

and just compare the prices with eachother on higher networks etc

steep jay
rustic nova
#

I'm using a dedicated server from hetzner right now, which costs around 34 Euros

#

so at least on their dedis they're good

steep jay
#

alright ty!

deft wolf
#

It's almost 100mb/s

steep jay
deft wolf
#

No, this is something different

steep jay
#

ah ok

rustic nova
# deft wolf

if thats on a vps, then you're likely limited on traffic instead

#

or this is heavily limited on fair use

deft wolf
#

Yea, 1tb/month

rustic nova
#

Yeah

#

unlikely to reach that though

#

unless you provide content that might easily exceed that

steep jay
deft wolf
rustic nova
#

this for example is how much I use on:

  • docker containers running several discord bot
  • several nginx-related elements
  • a VPN running on my server that I have 2 laptops locally connected to
steep jay
lyric mountain
#

tf happened aug 6 2023

deft wolf
lyric mountain
#

I cant take a site with that name seriously lmao

frosty gale
#

"elon musk is the most intelligent person on earth" πŸ€“ πŸ€“ πŸ€“ πŸ€“ πŸ€“ πŸ€“ πŸ€“ πŸ‡ πŸ‡ πŸ‡ πŸ‡ πŸ‡

rustic nova
#

Haha funny 24th letter go brr

sage bobcat
#

One message removed from a suspended account.

frosty gale
eager latch
dry imp
wooden ember
#

mmm I love the fact that I need like 1 gb of dependancies just to make d.js voice work

#

size on disk i mean not downloaded thank god for compression

spark pebble
#

I already know the answer, but I'm just triple checking @commands.is_owner is the bot owner, and not server owner, right?

surreal sage
#

how can I do this in node
I'm a bit too dumb

#

Ok I have a way

#

nvm

lyric mountain
surreal sage
#

nah I got it

#

Encrypt with aes

#

Get the src string's hash

#

Attempt to decrypt the encrypted string
Check if its hash matches

wicked perch
#

where to download ram

wooden ember
#

can some one please tell me why installing node packages keeps un installing my allready installed ones?

wicked perch
#

So if you do node install discord.js for example.. it replaces the old one

wooden ember
#

thats stupid

wicked perch
#

It isn't

#

it's just updating it

wooden ember
#

if i install discord.js I dont want it uninstalling ytdl-core for no reason

wicked perch
#

It shouldn't do that

wooden ember
#

all of these where isntalled minutes ago and the bot ran perfectly for once

#

and now its all fucked

#

again

wicked perch
#

So if you install only canvas, it doesn't work?

#

Try node list

#

npm list*

wooden ember
#

canvas didnt work befor but was installed

#

something about esm module bla bla

wicked perch
#

Try downloading a previous package

wooden ember
#

I dont use that command so dont mind if it doesnt load

#

I did but that was broken from the newer version of node

wicked perch
#

You downloaded a package made for ts

#

and ur using js

#

Yea, that's an issue from canvas

wooden ember
#

yeah but anyway is there a setting to make node leave my already installed packages alone instead of deleting them?

wicked perch
#

It shouldn't do anything with the rest tho

#

what command did u use to install

wooden ember
#

npm i libsodium-wrappers was the last npm command I entered

#

did that cuz apparently its a dependancy for discord voice that doesn't install automatically

wicked perch
#

weird idk

wooden ember
#

whats the lowest audio quality d.js suports?

#

bot used to work at the default setting but now my internet seems to be worse

#

i set it to 32Kb atm and that kinda works but only if i mute myself

#

mmm I don't think anything is changing set it to 16Kb/s and its still struggling and I know my internet isnt that bad

#

thatr and it doesn't sound like 16Kb audio either

#

connection.subscribe(player, { bitrate: 16000 }); is this the correct method?

#

hmm the source is 16kb and the quality isnt too great

#

i set it to 8kb and its still droping packets

#

the hell is happening

#

is there a global bandwitch setting thats just set to always use a sertain amount of bandwidth?

#

cuz audio streams used to work fine even on my potato internet

#

any one have any ideas? I gotta sleep now so if you guys got anything please ping me and I'll get back to you, thanks.

rustic nova
#

if it's dropping packets, it's likely due to the bandwidth of the host

keen olive
#

Bruh

deft wolf
wooden ember
#

it used to work fine did they change the way they stream audio and it uses more data now or something or is this just another "just get better internet you idiot" moment

#

see my internet is usually half a Mb up so this is better than usual and way more than enough for an 8Kbps stream

#

I know this speed test is gonna make everyone here cringe lmao

earnest phoenix
#

Choose the ones that are the most performant

wooden ember
#

I wound up just using libsodium-wrappers

#

that installed fine

earnest phoenix
#

For example, instead of libsodium-wrappers, use sodium

#

It's much more performant and efficient

wooden ember
#

yeah i did the oposite cuz sodium just wouldnt install

earnest phoenix
#

How so?

wooden ember
#

spammed the cli with loads of errors from the install script not running right

#

I cant remember entirly

earnest phoenix
#

You most likely just don't have something installed that's required, try it again and tell us the errors

wooden ember
#

I will in a bit cant turn the server on right now as I have thing to do in a sec

#

Ill get back to you in a bit

eternal osprey
#

in js, a forEach is non returnable right?

#

Like:

array = [1,2,3,4];
let k = array.forEach((el) => {
if(el === 1)
return "el_found"
})
console.log(k)``` -> undefined
#

oowh damn so that's why we have .find

cinder patio
#

if you don't need the element itself you can use some

frosty gale
#

probably not

marsh lark
wheat mesa
#

What?

#

No. Not at all.

marsh lark
#

map() is almost identical to forEach() except that it returns the value you returned in the function

#

in an array

quartz kindle
#

not exactly

#

.map returns a new array with every single value replaced by the value returned for each index on each iteration

#

its like transforming an array into a different array

marsh lark
#

Yeah and a side effect of that is you get to iterate through the array

#

which is what forEach does

quartz kindle
#

its not a side effect, its its purpose, its what it was made for

marsh lark
#

well yes

deft wolf
quartz kindle
radiant kraken
#

if you want to use return at this point just use a classic for (value of array) {}

marsh lark
quartz kindle
#

for >>> for of

lyric mountain
#

farofa

quartz kindle
#

de frango

radiant kraken
radiant kraken
quartz kindle
#

you would for performance sensitive scenarios

#

which is rare in js but it does exist

wheat mesa
#

Isn’t for of faster though since it uses iterators?

quartz kindle
#

nop

#

iterators are slower

wheat mesa
#

Damn

quartz kindle
#

for is pure flow control

#

iterators are more complex structures

lyric mountain
#

me when "p" breaks

quartz kindle
#

xD

radiant kraken
#

at this point just use node-gyp if you want performance sensitive loops mmLol

quartz kindle
#

phone keyboard without autocorrect

quartz kindle
#

to be worth the overhead

radiant kraken
#

i wouldnt really say that its very slow

quartz kindle
#

well its at least an order of magnitude slower

#

if not several

radiant kraken
#

well

#

then rewrite everything in cpp

#

ezpz

quartz kindle
#

or rust

#

:^)

radiant kraken
#

based

#

@earnest phoenix tim is now a rustacean poggythumbsup

quartz kindle
#

shhh

#

dont wanna upset our cpp lord

radiant kraken
#

nah

#

he would be happy actually

lyric mountain
#

from a legless rat to orange crab

marsh lark
deft wolf
#

For let i guess

marsh lark
#

the only for loops i know of are for in and for of

lyric mountain
#
for (let i = 0; i < smth; i++) {
  ...
}
deft wolf
#

Yea

#

I was typing this

marsh lark
#

ah

lyric mountain
#

hard to think of any iterating loop that'd be faster

#

while would be faster, but u cant use it for accessing anything without an iterator

radiant kraken
#

comparing between while and for is pointless

#

since their speed difference are merely just in microseconds

wheat mesa
#

I thought that for loops internally got transformed into while loops anyways

lyric mountain
#

they are

#

the difference is that for inherently gets an iterator, while while doesn't, so people might argue it's faster but also considerably less useful (alone) if ur iterating something

earnest phoenix
radiant kraken
#

now its your turn

earnest phoenix
earnest phoenix
wheat mesa
#

Ah

#

I thought most languages transformed for loops to while loops in the AST because it’s easier to just have one structure to represent both of them instead of having another unique statement variant

radiant kraken
radiant kraken
earnest phoenix
wheat mesa
#

yeah they're the exact same output with different labels, neat

earnest phoenix
radiant kraken
radiant kraken
earnest phoenix
#

Too bad that it's merely a distraction, I attached it somewhere interesting trollcube

radiant kraken
#

i wonder where sdTroll

neon leaf
#

is there something wrong with this ffmpeg command? im converting a 800mb webm to mp4 and its already taking over 15min

lyric mountain
#

800mb is pretty big

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

neon leaf
#

I mean its at 20min now

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

lyric mountain
#

also memory and disk

neon leaf
#

AMD Ryzen 9 5900X

sage bobcat
#

One message removed from a suspended account.

lyric mountain
#

how much memory?

sage bobcat
#

One message removed from a suspended account.

neon leaf
#

32gb

sage bobcat
#

One message removed from a suspended account.

lyric mountain
#

and disk?

neon leaf
#

what do you want to know about disk

lyric mountain
#

hdd or ssd, read/write speed

sage bobcat
#

One message removed from a suspended account.

neon leaf
#

nvme ssd

sage bobcat
#

One message removed from a suspended account.

lyric mountain
#

the slowness come from reading -> decompressing -> decoding -> recoding -> compressing mostly

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

neon leaf
#

I think im just gonna throw out webm then

sage bobcat
#

One message removed from a suspended account.

neon leaf
#

is any other format this slow too?

sage bobcat
#

One message removed from a suspended account.

lyric mountain
#

it's not the format, it's just that both sides are heavily compressed

neon leaf
#

hm

lyric mountain
#

webm is great for web, so it has to be small and fast-loading

neon leaf
#

I guess ill just add a background job for this then

#

so the user doesnt have to wait like 30+min

lyric mountain
#

well, you can assign more cores to ffmpeg no?

neon leaf
#

It almost has all already

lyric mountain
#

u can also use fast mode, which will probably result in poor quality x compression ratio, but it'll be fast

wooden ember
#

thats the other bit

lyric mountain
#

love this

wooden ember
#

yeah I saw that too

#

lmao

neon leaf
#

I mean what would be the best for what im making? Its a invite only image / video uploader / sharer

lyric mountain
#

apparently, it's not finding some directory

lyric mountain
wooden ember
#

I would asume it means this directory

neon leaf
#

I need to convert to mp4 so that it properly displays on all devices / embeds

lyric mountain
#

make the service only accept mp4s

neon leaf
#

well

#

hm

lyric mountain
#

for a service you'll never have enough processing on a single machine

neon leaf
#

I mean I have multiple machines

lyric mountain
#

ffmpeg has an option to spread the task over many machines

#

oh nvm, it depends on other softwares

earnest phoenix
wooden ember
#

how would I fix that?

earnest phoenix
#

Simply install g++: sudo apt install g++

wooden ember
#

what is g++ for then?

#

I thought that was a c++ compialer too

earnest phoenix
#

I'd highly recommend installing build-essential, it'll install everything needed for proper compilation

wheat mesa
#

compiling C++

#

and linking it

earnest phoenix
#

G++ is a C++ compiler (part of the GCC compiler)

wooden ember
earnest phoenix
#

Well it seems like the "development tools" group on Fedora doesn't install GCC nor G++

wooden ember
#

how odd

wheat mesa
#

it might install clang instead or something

earnest phoenix
#

Run sudo dnf install gcc gcc-c++

wooden ember
#

I think I manually installed G++ for something else if I remember correctly but I really don't know, this is a minimal install of fedora server

wheat mesa
#

granted I would think npm would be smart enough to check for that installation

earnest phoenix
#

I don't know why the hell the Fedora repository maintainers named G++ as gcc-c++

#

No other Linux distribution does that

frosty gale
wheat mesa
#

Probably some stupid name conflict with internals or something lmao

frosty gale
#

"it worked if it ends with ok"

wooden ember
#

Fedora do be kinda funky sometimes

#

I used to use centOS but we all know where thats gone

#

tryed rocky but it didn't like my server

earnest phoenix
#

Why not use Ubuntu?

wooden ember
#

I did for a while but its, eh I dant really articulate it well but its does a bunch of stuff on its own and takes a bit to confugure the way I want

#

like auto updates where a pain cuz my internet is bad and it would randomply just use it all

#

I will probably just use debian next time as some of the packages I use are instanely outdated and dont work properly on rehl based systems

lyric mountain
#

u can limit bandwidth on ubuntu

earnest phoenix
# wheat mesa granted I would think npm would be smart enough to check for that installation

npm uses node-gyp to build/compile stuff, but it doesn't automatically check for all installed C/C++ compilers (most build tools don't either), they basically check for the system default but that can easily be changed using alternative links and symlinks, as well as environment variables that point at the compilers (like CC for the C compiler, and CXX for the C++ compiler)

wooden ember
#

true but that would be global and a pain in the ass when installing things cuz id have to remove the limit and put it back

#

I liked centOS cuz it just did what I wanted and just worked

earnest phoenix
#

There are third-party tools that can auto update stuff for you but Ubuntu will never do that on its own

wooden ember
#

well it started using internet for no reason and I was not sshed into the machine and when i did there where system prosseses using bandwidth conected to ubuntu repositories

#

I never set it to do that and every time it did I just turned off the machine and turned it back on and it would fix it for a week or so

#

micht have been something I installed but never worked that one out

earnest phoenix
#

That's either your VPS provider doing some unusual stuff or you probably configured something incorrectly that checks in with the Ubuntu repositories for unknown reasons

#

What was your VPS provider that you tried Ubuntu on anyway?

eternal osprey
#

suppose i make an embed ephemeral, and in click on its button, can i somehow still edit the message?

#

and what if the embed was already edited

#

like, interaction.message.editReply() upon buttonclick?

earnest phoenix
#

Yes you can edit ephemeral messages, doesn't matter if it was already edited

rustic nova
#

lol

wooden ember
#

lmao

wooden ember
#

its not as bad as it looks its got a dual core athlon and 4gb of ram

#

ddr2 ram

#

but its good enough fro what i use it for

earnest phoenix
wooden ember
#

shhhhh Don't tell then its the backup server they wont notice

marsh lark
#

Maybe will last as a backup server for a minute if we're being generous

wooden ember
#

I miss using that as my main server but even after powersaving optimisations it still would cost like Β£300 to run yearly

lyric mountain
marsh lark
wooden ember
#

I dont have anything to mesure it but at idle a rough calculation based on psu inefficiency and components was something like ~50w

#

that was the "worst case senario" that i went off of

#

cuz it was closer to 40w

#

but I have an extra audio card and the psu is only 20 pin and I think predates the 80+ standards

#

but its made by FSP and its really heavy so its not gonna expload (I hope)

marsh lark
#

have a fire extinguisher nearby just in case ablobsweats