#development

1 messages · Page 85 of 1

sudden geyser
#

You could try wrapping the p and Button.Danger in a div then use your flex justification

surreal sage
#

I'll try using tar -xvzf instead

neon leaf
#

this is the alert component

sudden geyser
#

then you probably want the p to take up the rest of the space in the box

neon leaf
#

if you mean add text-left w-100 then that also doesnt work

sudden geyser
#

no

#

that's fixed

neon leaf
#

so w-[100%]?

#

well both dont work

sudden geyser
#

no

#

you need to tell the individual flex item to take up the rest of the space

#

flex-grow may be something

neon leaf
#

thanks!

sudden geyser
#

you may also need to get rid of the centering you're doing in your alert since the text will be centered otherwise

neon leaf
#

items-center is vertical

sudden geyser
#

really? I didn't know that

neon leaf
#

yeah, justify-center is horizontal

lyric mountain
#

not always vertical/horizontal, but cross-direction/same-direction

craggy pine
#

Any idea to why 'user' would be null

        {
            name: 'play',
            category: "Plalist",
            description: 'Play your current select playlist OR a specified playlist title or id',
            type: 1,
            options: [
                {
                    name: 'user',
                    description: 'The user who owns the playlist you want to play',
                    type: 6, // user
                    required: true
                },
                {
                    name: 'playlist',
                    description: 'The playlist you wish to play',
                    type: 3, // string
                    required: true,
                    autocomplete: true
                }
            ]
        },

the options

#
    autoComplete: async(client, interaction, config, db) => {
        switch (interaction.options.getSubcommand()) {
            case "play":
                {
                    console.log(interaction.options.getUser('user')) //null
                    const focusedValue = interaction.options.getFocused();
                    let search = focusedValue.length === 0 ? client.database(`SELECT * FROM playlists WHERE owner_id = ${user.id}`, false, true)  : client.database(`SELECT * FROM playlists WHERE title LIKE "${focusedValue.toString()}%" AND owner_id = ${user.id}`, false, true)
                    let choices = await search;
                    await interaction.respond(choices.map((choice) => ({name: choice.title, value: choice.playlist_id})))
                }
            break
        }
    },
#

Autocomplete

viscid gale
#

javascript making me go insane again

viral badge
#

check speed of concat method

viscid gale
#

gimme examples if I missed.. going raw is fast, even with numbers, but the difference is notable between numbers and strings in concat and it's slower overall

lyric mountain
viscid gale
#

alr, elaborate

lyric mountain
#

js does some optimization when u repeat the same task many times

sudden geyser
#

use a benchmarking library instead

#

or program

lyric mountain
#

meaning u wont get real performance of given task

sudden geyser
#

to get a rough idea of what the performance is like

lyric mountain
#

I mean, it'll show mostly incorrect results

sudden geyser
#

you're not about to figure out what optimizations your cpu is doing

lyric mountain
# viscid gale :/

ur repeating the same task 500m times, JIT will inline it almost always

#

plus, ur not restarting the runtime after each task, meaning commonly used methods will get optimized during previous execution

viscid gale
#

took away one "0" from the other tests above

I get what u saying I ain't saying "u mad"
I'm just saying that if I run the same test the same amount of times to separate functions I can compare them

lyric mountain
#

benchmarking involves very strict environments to assert two tests are done with the exact (or as exact as possible) same starting conditions

viscid gale
#

I mean.....

lyric mountain
#

those numbers mean nothing

viscid gale
#

the point of science is for things to be reproducible, I'm not trying to measure my cpu, just seeing what function is faster

lyric mountain
#

yes, and u wont that way

#

because the tests aren't sterile

viscid gale
lyric mountain
#

a common optimization done during runtime is to calculate only once and return the same value for the remaining iterations

#

if all input values are the same

viscid gale
lyric mountain
#

the results mean nothing if the experiment is done wrong

viscid gale
lyric mountain
#

still

#

I gave only one example, it ain't the sole optimization done by jit

#

you'll never get correct results without correct tests

viscid gale
#

idk why you insist that running 2 functions a couple million times and seeing roughly a consistent difference means nothing

lyric mountain
#

because that's how it is

viscid gale
lyric mountain
#

how hard is to understand that one call might influence future calls?

viscid gale
#

in application, things aren't run in sterile environments

#

so actually, why would u test them there.. when your intent is to have something be faster in application

lyric mountain
#

yes, that's why u test in a separate environment

lyric mountain
#

it's like testing which car is the fastest but in a crowded road

viscid gale
lyric mountain
#

see the car example

viscid gale
#

u can say "yea it should sail" but the proof is the application

lyric mountain
#

if ur gonna test which car is the fastest, you'd do it in a straight, empty and controlled space

sudden geyser
#

you really just want a controlled experiment man

viscid gale
sudden geyser
#

I think the console test is fine as is for small cases like this

#

by small cases I mean as a trivial test

#

a proper benchmarks tries from a fair state and controls certain variables

#

but most people aren't going to go through the effort for such a thing

#

so I think the console test or using a library / program is fine

lyric mountain
#

well, there's a site for that

viscid gale
#

oh, so all of this was for advertising?

#

🗿

lyric mountain
#

nope

sudden geyser
#

a test also tries multiple times and measures differences

#

which helps remove noise

#

usually

viscid gale
#

well it'd be rather difficult to say how much ms it takes for the function that small to execute

lyric mountain
#

that's why u force a bigger test

viscid gale
lyric mountain
#

no, to strain-test

viscid gale
#

u were saying this isn't a good way to measure that

#

the entire time

lyric mountain
#

like ```js
let a = "";
for (const i in [0..10000]) {
a += Math.floor(Math.random() * 10);
}

console.log(a);

viscid gale
#

why would I try to see which of these things are faster that exist all over in something bigger

lyric mountain
#

because...nevermind, do what you will, if u want to 1 + 1 = 3 so be it

viscid gale
viscid gale
lyric mountain
#

as I said, do what you will, I can't convince u to do a proper test so there's no point in attempting to

wheat mesa
#

console.timeStart/timeEnd is half decent for measuring times quickly, but there’s a lot of complex engine things happening in the background without a proper testing environment

spark flint
#

copilot is no longer included with student pack

#

🫡

lyric mountain
#

Write a plugin to integrate chatgpt

quartz kindle
quartz kindle
#

in order to defeat the amazing js optimizer, you need to introduce things that are orders of magnitude slower than the things you actually want to measure

#

which makes measuring even more stupid, because at that point you're basically benchmarking a big ass code with a small needle somewhere inside, and trying to get the timing of that needle

lyric mountain
#

I suppose u could switch for a string literal then

quartz kindle
#

in the first code, the array is actually initialized as a small number array, then the inner array is unpacked and the other numbers are added, completing the small number array

#

in the second code, the array is initialized as a blank array, so it has an unknown/mixed type under the hood, then when the numbers are added, the array remains a mixed type

#

the js engine does these weird shenanigans with arrays

#

js arrays have many different types under the hood

viscid gale
#

hmmmm

quartz kindle
#

of course the difference also comes from the number of items being unpacked from the inner array, less numbers to unpack will be faster

viscid gale
#

ik ik, but I also was noting that yes, adding values then a ...array was different from plain ...array

#

that's pretty dang cool

quartz kindle
#

still is really weird that the performance hit is so big

#

but yes, if you can, initializing a non-empty array will always be faster than an empty array

viscid gale
#

nah, the numbers being that wildly different mean nothing according to someone else 😔

quartz kindle
#

since it gives the engine an array type hint

viscid gale
#

k jokes aside I was shocked at it tho

#

a while back I remember the ... being slower than using a for loop to begin with

#

so I thought "ah lemme just make a full spread function that'd be faster" which led to me testing that specific case and being like "what the hell"

quartz kindle
#

hahah

#

actually let me test this deeper

#

holy wow

#

this code [...[1,2,3,4,5]] generates this bytecode

#

very simple, very straight forward

#

but this code [1, ...[1,2,3,4]]

#

generates this...

#

lmfao

#

from this point of view, the first code should be faster, but i guess the second code has so much more information provided that gives the engine a lot more things to optimize there

#

also the last part makes it seem like (im no expert in reading these, so correct me if im wrong voltrex), in the second case, the inner array is not actually unpacked into the outer array, but rather the outer array will hold references to the inner array instead

#

so both arrays remain separate in memory

earnest phoenix
#

What's happening here is that the first code ([...[1, 2, 3, 4, 5]]) is the exact same as [1, 2, 3, 4, 5] because it unenrolls the spread call as it has no effect here, resulting in a minimal bytecode, however in the second one ([1, ...[1, 2, 3, 4]]), it goes a lot deeper as it looks up in the target object's descriptors (all objects and literals has their own internal slots) as to what appropriate behavior it has for a spread call, which in itself generates it's own bytecode

quartz kindle
#

lmao

#

my thinking was that maybe if the second code keeps both arrays separate in memory and just references them it can skip the concatenation in the first code, thus it becomes faster, but if the first code does not actually concatenate anything like you say, then im at loss for an explanation here

earnest phoenix
#

It's the complete opposite for me

#

You folks may be using a version of V8 that had a regression for this specific case

quartz kindle
#

chromium 107.0.5304.88

#

let me test on node too

#

indeed, node 19.3 gives a different result

earnest phoenix
#

Chromium 107 uses a version of V8 that has a regression

quartz kindle
#

reminder to always test weird things on more versions xD

viscid gale
#

@viscid gale

earnest phoenix
#

Yep, we merged the patched V8 release in the Node.js v18 releases

viscid gale
#

just pinging myself so I can search for this ping later

#

really bloody interesting things

quartz kindle
#

so basically all my previous explanations were wrong, so never mind me

#

haha

viscid gale
#

it happens

quartz kindle
#

i was right on one thing tho, but i got it the other way around actually

#

on the dev tools memory inspect, [...[1,2,3,4,5]] is the one that actually shows it being a full SMI array

#

whereas [1, ...[2,3,4,5]] does not, indicating its a mixed type array

viscid gale
#

ahhhhhhh

earnest phoenix
#

Yes, there are wrapped type hints for spread calls on elements with other types

#

We do everything we can to optimize as much as possible™️

quartz kindle
#

the first one takes 44 bytes, the second one takes 100 bytes

#

this is another js secret that most people do not know, identical objects in js can have very different memory usages, depending on how they were created

viscid gale
#

so far I'm only using the spread function (for loop that does [...array]) for that case only and another case where I say [1,...array] I leave it

#

1 is shorter than a word that makes human sense and it could be shared over a websocket an ungodly amount of times

quartz kindle
#

use compression :^)

#

zlib stream is great for websocket

viscid gale
#

much to think on, gn 👋

wheat mesa
#

I guess it’s time… I’ve gotta swap back to djs

lament rock
#

why

quartz kindle
#

fuc djs lol there are so many js libs now a days

#

raw is best

wheat mesa
#

And I definitely don’t want to be writing my own raw lib

#

I would never get anything done

#

Unless someone has a better suggestion, I’m gonna have to use djs

#

Or I could fork detritus but that’s kind of a complex lib

quartz kindle
#

im adding something pretty cool to my raw lib, an actual disabled events option

#

that prevents the event from even being parsed into json

#

by matching the event name when still in binary data

#

my benchmarks showed a 10x performance boost for disabled events

sudden geyser
#

some person in this channel I can't remember the name of wrote a fairly interesting library

#

thought it was tom

#

yes, not tim!

quartz kindle
#

tom and jerry

spark flint
#

Tom and Jerry more like Tim and Berry

quartz kindle
#

berry the platypus?

sudden geyser
#

oh his name was actually tim

#

timsmart

#

the library is called droff

lament rock
#

I've been also maintaining some low level Discord libs myself

#

pain in the ass

quartz kindle
#

xD

#

btw papi im finally adding a string/bigint etf option

#

because of you

lament rock
#

Good

quartz kindle
#

no more being stuck with bigint ids only

lament rock
#

shit was so confusing

quartz kindle
#

indeed

lament rock
#

what was the nail in the coffin?

quartz kindle
#

now if only i can figure out the most annoying problem of all

#

snake case or camel case

#

_<

lament rock
#

PascalCase ftw

quartz kindle
#

because discord uses snake case

lament rock
#

this shit is now C#/Java

quartz kindle
#

and i want it to be 1:1 to the discord api docs

lament rock
#

discord used to be backed by py

quartz kindle
#

but then my own extras on top, if they are pascal it gets weird

#

if they are snake, its also weird

#

i cant decide

lament rock
#

no casing

#

no underscores

#

justwordsstrungtogetherlikethis

quartz kindle
#

hahahah

lament rock
#

How about dynamic keys and the user can decide

quartz kindle
#

for example what looks/feels better```js
{
large_threshold: 500,
disabled_events: ["PRESENCE_UPDATE"]
}

or

{
large_threshold: 500,
disabledEvents: ["PRESENCE_UPDATE"]
}

lament rock
#

Thats something I have yet to see

quartz kindle
#

large_thresold is an api option so it has to remain snake

lament rock
#

Just have a set of internal keys and dynamically set the prototype of classes based on options

quartz kindle
#

lmao

lament rock
#

It could work tho

#

like I prefer camelCase

#

but jimmy bob here might want snake

#

Im so inconsistent with my shit tho. I use snake case in C#

#

its the most cursed shit

quartz kindle
#

do i just duplicate all of it on intellisense and coalesce the case in the actual code?

#

lmao

lament rock
#

What I'd do which might be reasonable is have different entry points for cases and dynamically assign to class prototypes based on some value you can bounce around

#

instead of using the syntax sugar for classes

#

that way you can have 1 code base with internal keys

wheat mesa
lament rock
#

discord.js is a memory leak itself

sudden geyser
#

learning new things is fun though

#

*usually

next storm
#

Hey, I need a help. I tried to make a website and it's working good, it's made in html. I tried to use express and made a basic file in which I putted this```js
const express = require('express');
const app = express();
const path = require('path');
const router = express.Router();

router.get('/', function (req, res) {
res.sendFile(path.join(__dirname + '/index.html'));
});

router.get('/invite', function (req, res) {
res.sendFile(path.join(__dirname + '/invite.html'));
});

router.get('/support', function (req, res) {
res.sendFile(path.join(__dirname + '/support.html'));
});

router.get('/vote', function (req, res) {
res.sendFile(path.join(__dirname + '/vote.html'));
});

app.use('/', router);
app.listen(433);

console.log('Running at Port 433');``` but when I'm opening the website, it's showing it without the components, it's showing just like a blank website with just normal fonts written and with no images

lament rock
#

its insane how much memory you'd be saving if you just didn't import such fucking large libraries. The module require cache is insanely stupid and comes with a lot of overhead since Discord.js likes to have a ton of files for each thing

quartz kindle
#

i mean

#

thats still nothing compared to the actual discord cache

lament rock
#

I know

#

but they'd save a lot of memory if they used something like tsup

#

for initial import

#

inline src maps are also pretty cool

quartz kindle
#

to make this easy, express has a "static" system for static files

next storm
#

it'll show all the components and images then?

quartz kindle
#

app.use(express.static('folder name'))

#

that will make everything inside a folder you chose marked as a static file, so express will always find them

next storm
#

I've my file structuring like this

wheat mesa
#

Should probably have an src directory

next storm
#

all the css works and all are in assets

wheat mesa
#

Not required but good practice

quartz kindle
#

then make assets your static folder

next storm
#

ok

quartz kindle
#

app.use(express.static('assets'))

next storm
#

oki

#

still not showing the components

quartz kindle
#

the files inside the folder are exposed to the root directory

#

so you have to remove any /assets/... from your html code

#

or do this instead

#

app.use('/assets', express.static('assets'))

solemn latch
#

👀

#

what

next storm
#

worked (:

#

thanks a lot smil

quartz kindle
#

👍

next storm
#

now I've to get it hosted iara_smh

solemn latch
#

It looks like its just static files currently.

Github pages probably would work fine

wheat mesa
#

^

solemn latch
#

yep

next storm
#

oki

violet haven
#

hi

#

got a pb with windows env

#

pGlob doesn't work

#

does someone know how to fix it?

quartz kindle
# violet haven

windows also supports forward slashes, you dont need to use double back slashes

shadow frigate
#

What does one call these?
justTesting vs just_testing?

#

Surely there's a specific name for these

#

Ping me when you respond please, thanks

quartz kindle
shadow frigate
#

Nice one cheers

quartz kindle
#

there are many others as well

shadow frigate
#

pls Advise?

quartz kindle
#

like SCREAMING_SNAKE_CASE that discord uses

shadow frigate
#

What do you personally prefer?

#

What do you think is best practice or is this just a 'case' of personal preference?

quartz kindle
shadow frigate
#

fair enough

quartz kindle
#

but in js/ts most people use the same style as the image above

shadow frigate
#

lol which one

quartz kindle
#

pascal for classes, camel for functions

#

screaming snake for constants

shadow frigate
#

fair enough

quartz kindle
#

js people dont like snake case

shadow frigate
#

I don't utilise these like I should tbf

quartz kindle
#

python people on the other hand use snake case a lot

shadow frigate
#

My code would look cleaner

quartz kindle
#

also web apis are mostly snake case

#

because web data formats often do not differentiate between upper and lower case keys

#

other case styles xD

shadow frigate
#

lmaooo

#

goteem

quartz kindle
#

this one has a cool explanation

shadow frigate
#

lmao fair play, they are pretty good

#

What's your favourite?

tacit sand
#

Hey guys may be the wrong place for this but does anyone have any info on when/if puginator will be available again. Thx in advance

shadow frigate
tacit sand
#

My bad. They have this one listed on their site

deft wolf
#

We don't know

#

Check for yourself

sudden geyser
#

Is there a site that can check what browsers a site (or JS file) is compatible with?

solemn latch
#

A whole file I dont know, but mozilla has information on specific js features iirc

surreal sage
#

Do bytecodes e.g 258 use more bytes (qua size) than their corresponding character?

#

lemme just try sum

quartz kindle
#

are you talking about character encodings?

plain coral
#

who help linux install mysql database phpmyadmin

slender wagon
#

any react folks here?

idle coral
#

Alright so I'm trying to use MongoDB for the first time.

#

^ This is my datasetup file.

#

Then I have one model for my lockdown command. Which looks something like this:

const mongoose = require('mongoose');

const Schema = new mongoose.Schema({
    Guild: { type: String, required: true },
    Lockdown: {
      Enabled: { type: Boolean, default: false },
        Channels: { type: Array, default: [] },
    }
})

module.exports = mongoose.model("lockdown", Schema);
#

For some reason, my error catch returns just "An error occured" not specifying why.

#

My datastore looks like this.

#

Is it correct?

deft wolf
#

Can you hover over const Keyv = require("keyv")?

idle coral
#

To do with TypeScript.

idle coral
sharp geyser
#

That is different than what you said

deft wolf
#

Are you running it on your computer or on a machine?

idle coral
#

Computer.

sharp geyser
#

Okay one thing first

#

Are you sure you are connected to the database?

#

This error usually means that it took to long to respond and find the resource

idle coral
sharp geyser
#

which usually means that its not connected

deft wolf
sharp geyser
#

Also another issue could be due to you trying to use the model before a connection is fully established

idle coral
#

How could that be prevented?

sharp geyser
#

You could use async/await on the .connect which will only continue allowing code to run after the .connect once the promise has been resolved

#

a simple google search provided this stackoverflow page

idle coral
#

Sorry.

sharp geyser
#

You're fine

#

I wasn't hating

wheat mesa
stiff dust
#

Hello Guys I have a problem this is my code and when I add new roles it won't update in data base any idea? 🤔

as you can see in both images from DB second role didn't add (first image is for before add second role and second image is for after adding it)

(first role is added because the code is different for adding when there isn't any role)

quartz kindle
#

that empty array is not connected in any way to data

#

so data.dj.roles will continue to be empty

stiff dust
#

its not empty

quartz kindle
#

you are logging djRoles not data.dj.roles

stiff dust
#

well djRoles is what I want to save 🤔

quartz kindle
#

but you're doing data.save()

stiff dust
quartz kindle
#

so

#

data.save() saves the changes made to data

stiff dust
#

ohhhhhhhhhhhhhhhhhhhhhhhhh

quartz kindle
#

and there are no changes to data

stiff dust
#

wait

#

there is a change PepoThink

#

it was

{
roles: ['id1'],
djOnly: false
}

and now its

{
roles: ['id1' , 'id2'],
djOnly: false
}

#

don't kill me Tim sadBuble

quartz kindle
#
const a = data.a || [];
a.push(1);
console.log(a) // this will always work because its either data.a plus 1, or empty array plus 1
console.log(data.a) // this is different, if data.a existed before, then its data.a plus 1, but if data.a did not exist before, it will continue not existing, because the new array that is created above is separate, and not added to data automatically
stiff dust
idle coral
#

🤭

quartz kindle
#

if data.dj.roles already exists, then your code should work

stiff dust
#

why it don't work

quartz kindle
#

you said it did work?

stiff dust
quartz kindle
#

you said there was a change

stiff dust
idle coral
#
const { mongooseConnectionString } = process.env.mongooseConnectionString
const mongoose = require("mongoose");

module.exports = async () => {
    if (!mongooseConnectionString) return;

    await mongoose.connect(mongooseConnectionString, {
        keepAlive: true,
        useNewUrlParser: true,
        useUnifiedTopology: true,
        useFindAndModify: false,
    })

    return mongoose.connection
};
#

This is located within ./handler/mongoose.js

#

In index.js, I have:

// MongoDB
const mongo = require('././handler/mongoose')
 mongo().then(connection => {
    console.log('MongoDB shard connection successful.')
})
stiff dust
#

Maybe this? @quartz kindle ?

quartz kindle
#

or you have to put all the code inside the .then()

quartz kindle
idle coral
quartz kindle
#

how were you using it?

idle coral
#

Wait just kidding-

#

Blind eyes.

sharp geyser
#

ello tim

idle coral
#

lmfao

quartz kindle
#

ello

idle coral
#

Would it look like that..?

quartz kindle
#

no...

idle coral
#

brotha

quartz kindle
#

im talking about your code that uses mongo

#

like idk how it works, connection.query() or mongo.query or mongo.findOne() idk

idle coral
#

I don't think it's my schema though.

quartz kindle
#

so where you use your schema

#

for example

stiff dust
quartz kindle
#
const schema = new mongoose.Schema()
const model = mongoose.Model(schema)
model.find()
model.save()
``` is that how you are using it?
#

anyway it doesnt matter

#

what matters is that ALL of thay schema model stuff has to happen AFTER the mongo connect fimishes connecting

#

and the problem with a .then() is that it does not make your code wait for that

#

all your code outside of the
.then() continues running before mongo finishes connectong

idle coral
#

In a way though.

#

const model = mongoose.Model(schema)

#

I don't use that though..

#

module.exports = mongoose.model("lockdown", Schema);

quartz kindle
#

just put this ```js
const mongo = require('././handler/mongoose')
await mongo();

#

or in your ready event

hidden gorge
#
const { Client, Events, GatewayIntentsBits } = require("discord.js");
const { token } = require("./config.json");
const clc = require("cli-color");

const client = new Client({ intents: [GatewayIntentBits.Guilds] });

client.once(Events.ClientReady, c => {
    console.log(clc.white(`Logged in as`), clc.red(`${c.user.tag}`));
});

client.login(token);``` Undefined Reading of  `Guilds` at ```js
const client = new Client({ intents: [GatewayIntentBits.Guilds] });```
#

oh fixed it

graceful veldt
#

why not map through all the Intents at once

warm surge
graceful veldt
#
const Discord = require("discord.js"),
client = new Discord.Client({intents: Object.keys(Discord.Intents.FLAGS).map(x => Discord.Intents.FLAGS[x])});
graceful veldt
solemn latch
#

👀 why?

deft wolf
#

Exactly

warm surge
graceful veldt
#

Ik that

#

But this looks kool xd

deft wolf
#

Why all intents?

solemn latch
#

^

#

thats not a good thing

graceful veldt
#

I use all tho

#

💀

quartz kindle
#

ew

warm surge
solemn latch
#

👀 how?

deft wolf
#

But not everyone needs them

warm surge
#

I know

solemn latch
#

if you use all without knowing why you're making a mistake

graceful veldt
#

Idk much abt this but still managed to get, shrug

warm surge
graceful veldt
warm surge
quartz kindle
#

:^)

solemn latch
#

if discord gave me presence intent id still turn it off

graceful veldt
#

good night guys

quartz kindle
#

lmao

deft wolf
solemn latch
#

another good one to turn off

deft wolf
#

Since there are slash commands, struggling to write a text command is not worth the time

#

At least for me

quartz kindle
#

my bot was so much easier to use with text commands xd

#

but then again i didnt actually finish the slash command rewrite yet

#

i just made a make shift solution

#

and its been like that for months now

deft wolf
#

I used to think text commands were better too, until I saw that you can add choices, select channel/user and autocomplete without having to go to much trouble with it

#

It made it a lot easier for me when it comes to writing the bot

boreal iron
#

Sad reality

quartz kindle
#

lmao

wheat mesa
#

Might be kind of a stupid question, but how do I resolve paths properly after my typescript has been compiled?

#

For example, I'm trying to load a .env file where the structure is like ```
ProjectName
| src
| .ts files
| dist
| compiled .js and .js.map files
| .env

#

Nevermind. Got it with process.cwd()

hidden gorge
#

Im trying to add 2 buttons but They wont show.

const { SlashCommandBuilder } = require("discord.js");
const { EmbedBuilder } = require("discord.js");
const { ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js");

module.exports = {
    data: new SlashCommandBuilder()
        .setName("ping")
        .setDescription("PONG!"),
    async execute(interaction) {
        const embed = new EmbedBuilder()
        .setTitle("PONG! 🏓")
        .setDescription("Test Pong")

        const row = new ActionRowBuilder()
            .addComponents(
                new ButtonBuilder()
                    .setLabel("Support Server.")
                    .setURL("https://")
                    .setStyle(ButtonStyle.Link),

             

            );

        const row2 = new ActionRowBuilder() 
            .addComponents(
                new ButtonBuilder()
                    .setCustomId("version")
                    .setLabel("Version: 0.12.3")
                    .setStyle(ButtonStyle.Secondary)
                    .setDisabled(true),
            );   

        await interaction.reply({ embeds: [embed], components: [row] [row2]});
    },
};

wheat mesa
#

because that is definitely not the way to use arrays

#

I'm surprised that even works without errors

hidden gorge
wheat mesa
#

So I'm trying to dynamically import compiled typescript modules, but I seem to run into this error no matter what I try: Error occurred whilst loading events: Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:' and here's the code that causes the issue: ```ts
const events = fs
.readdirSync(path.resolve(__dirname, '../events/client'), { withFileTypes: true })
.filter(file => ['js', 'ts'].some(e => file.name.endsWith(e)) && !file.name.endsWith('.d.ts'));

quartz kindle
wheat mesa
#
const ret: EventImport = await import(path.resolve(__dirname, `../events/client/${file.name}`));
#

as for the type (doesn't really matter here) ```ts
interface EventImport {
default: { name: 'string'; execute(payload: any, client: Client): void };
}

quartz kindle
#

try this file://${path.resolve...

#

whats your node version btw?

wheat mesa
#

18.12.1

#

Now I've got this, and it doesn't load the event as far as I can tell (doesn't execute any of the code in my execute function)

quartz kindle
#

try file:///

#

with 3 slashes

wheat mesa
#

Oh I just realized what's wrong

#

It's got two default props for some reason... ```
[Module: null prototype] {
__esModule: true,
default: { default: { name: 'ready', execute: [Function: execute] } }
}

#

not a big deal but that's very odd

quartz kindle
#

it already has a default one by default

#

you added another one

wheat mesa
#

odd, seemed to work just fine in another project

#

Granted I was using ts-node and ran the ts directly

#

Just gonna keep it that way and just do ```ts
const ret: EventImport = (
await import(file:///${path.resolve(__dirname, ../events/client/${file.name})})
).default;

#

Otherwise ts yells at me

#

working perfectly now!

#

thanks @quartz kindle C:

quartz kindle
#

👍

hidden gorge
#
const { SlashCommandBuilder } = require("discord.js");
const { EmbedBuilder } = require("discord.js");
const { ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js");

module.exports = {
    data: new SlashCommandBuilder()
        .setName("cosmit")
        .setDescription("Cosmit is a "),
    async execute(interaction) {
        const embed = new EmbedBuilder()
        .setTitle("Cosmit")
        .setDescription("yyy")
        .setThumbnail("https://i.imgur.com/vV3C17U.png")
        .setImage("https://i.imgur.com/vV3C17U.png")

        const row = new ActionRowBuilder()
                    .addComponents(
                        new ButtonBuilder()
                            .setLabel("Join Cosmit")
                            .setEmoji("1062180410928414770")
                            .setURL("https://")
                            .setStyle(ButtonStyle.Link)
                            );

  

                            await interaction.reply({ embeds: [embed], components: [row]});
                        },
                    };``` for some reason it wont show the images.
sudden geyser
#

where is the .xyz?

oak cliff
hidden gorge
hidden gorge
oak cliff
#

Every time you make a change to your code you need to restart yes

hidden gorge
#

it didn’t detect permission changes

#

that’s why i restarted

wheat mesa
#

man using djs makes me miss detritus

#

slash commands were so clean in detritus

#

pristine

earnest phoenix
#

how to get topgg token

boreal iron
#

You can get the token only when having an approved bot on the topgg page

#

Editing it will show give you the menu you can navigate through to generate/see your token

boreal iron
bright thorn
#
allowed_mentions.users[SET_TYPE_CONVERT]: Only iterables may be used in a SetType```
#

What is this error

#

Anyone can explain

sharp geyser
sterile brook
#

slash sucks at getting avatarsmmyu

sudden geyser
#

wdym

sterile brook
#

literally what I said

#

Try to get avatar of uncached user

#

This user ID as example u can use:
422088370060263424

earnest phoenix
#

use api to fetch user

#

and get avatar hash

sudden geyser
#

you're using slash commands though

#

discord sends you a user/member map if you say the option is a user

viral badge
sterile brook
sudden geyser
#

don't see how it couldn't be simpler

viral badge
#

wdym getting avatars tho 🤔

spark flint
#

That seems like a code issue, I get user and avatar from slash command user and it works just fine

sterile brook
#

U can get the correct link to avatar, yep, but when I am trying to view it using embed, it's just emptypepe_jail
And no, that's not only for my bot, I also used dyno to get avatar from same user, and result is same, no picture, but the rest info is fine

spark flint
#

Weird

#

Channel permissions maybe?

#

Not too sure

sterile brook
#

Also not, cuz one person avatar displays fine, and the other one is not

#

In same channel

#

Like this

viral badge
#

user.avatarURL()?

#

crazy

sterile brook
#

?

viral badge
# sterile brook

does the person have a custom avatar or is it the discord avatar btw?

#

nvm boomer issue

sterile brook
#

It's his main discord avatar

#

Not custom

deft wolf
#

Then it must be something related to the embed itself

#

Have you tried maybe changing the avatar format, its size or something?

sterile brook
#

Tried using size and not using it

#

Same situation

#

And dyno seems have same issue

#

Using standard .displayAvatarURL() func

deft wolf
#

Okay, have you tried using .avatarURL() instead?

spark flint
#

.displayAvatarURL() returns a discord default avatar if they do not have an avatar

sterile brook
#

avatar on screenshot, that I sent earlier appeared after some time

#

That kinda kekw

#

Changed to .avatarURL, seems working now

deft wolf
#

Images in embeds work terribly strangely

#

You can send 100 identical messages with the same link as an image and 99% chance there will be a message where that link will not load properly

spark flint
#

😍 we love sudden breaking API changes

deft wolf
#

For me, for example, links from imgur don't want to work very well

sterile brook
#

Tested more, no, .avatarURL gives same result

#

I am cursed

spark flint
sterile brook
spark flint
#

I recommend putting a random query on the end

#

?cache=${Date.now()}

#

thats what I do

#

Prevents caching

earnest phoenix
radiant kraken
earnest phoenix
#

standard discord behaviour

sterile brook
#

If that matters, added dynamic: true and size options to displayAvatarURL () and now it works pretty fine

#

For earlier post

radiant kraken
hidden gorge
#

can slash command names have spaces?

viral badge
#

well you can always try it and see 😎

hidden gorge
#

i can’t run my code offline

viral badge
#

well i havent seen a command with spaces yet

spark flint
viral badge
#

however you can use SUB_COMMAND

spark flint
#

but you can technicalyl

#

yeah

#

with subcommand

viral badge
#

it was a pain first time but was pretty easy 🤓

hidden gorge
#

So i have my slash commands separated in folders i have my reply reading ./commands/../${file} idk if this works or not

#

deploy*

deft wolf
#

If you did it correctly then yes

#

You'll find out when you turn on the bot

hidden gorge
#

ok thanks

neon leaf
#

so I had this beautiful package, twin.macro so I can turn a tailwind string into css live, but it doesnt seem to work with nextjs, is there any good alternative?

hidden gorge
#

So i am doing a facts command and i want it to list a fact but it only shows the number

#

im sending the code

#
const { SlashCommandBuilder } = require("discord.js");
const { EmbedBuilder } = require("discord.js");
const { ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js");

module.exports = {
    data: new SlashCommandBuilder()
        .setName("igorfact")
        .setDescription("Sends an Igor Fact"),
    async execute(interaction) {
        let facts = [
            "Burbur Sucks at Fortnite",
            "Cats = Good"
        ]
        let result = Math.floor(Math.random() * Math.floor(facts.length));

    const fact = new EmbedBuilder()
    .setTitle("Igor Fact")
    .setDescription(`${result}`)
   
    await interaction.reply({ embeds: [fact] });
    },  
};
sharp saddle
#
const { SlashCommandBuilder } = require("discord.js");
const { EmbedBuilder } = require("discord.js");
const { ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js");

module.exports = {
    data: new SlashCommandBuilder()
        .setName("igorfact")
        .setDescription("Sends an Igor Fact"),
    async execute(interaction) {
        let facts = [
            "Burbur Sucks at Fortnite",
            "Cats = Good"
        ]
        let result = facts[Math.floor(Math.random() * Math.floor(facts.length))];

    const fact = new EmbedBuilder()
    .setTitle("Igor Fact")
    .setDescription(`${result}`)
   
    await interaction.reply({ embeds: [fact] });
    },  
};
#

@hidden gorge ^

#

ez

sharp saddle
#

lmao

#

np

hidden gorge
#

can’t test it rn

feral aspen
solemn latch
#

Weird 👀

spark flint
#

Make sure you’ve restarted after adding in next.config.js

#

It’s annoying and makes you restart

feral aspen
#

Restarted VSCode?

spark flint
#

No I mean next.js

feral aspen
#

Ohh, fair enough. It works.

spark flint
feral aspen
#

:)

hidden gorge
surreal sage
feral aspen
#

I'm setting up GiscusComment, which is an app in GitHub. How can I retrieve the repository ID and the category ID of a specific repository? (discussions)

earnest phoenix
#

Actually no need to even read anything, type your repository name and it will generate everything for you..

feral aspen
#

I've actually set it up, wrong. It works, now. :)

hidden gorge
#

so my bot has slash commands and im seeing double of a few of my commands how do i fix that?

quartz kindle
hidden gorge
#

my ping is reaching -650ms

let pingms = `${Date.now() - interaction.createdTimestamp}ms.`

        const row = new ActionRowBuilder()
            .addComponents(
                new ButtonBuilder()
                    .setLabel("Support Server.")
                    .setURL("removed")
                    .setStyle(ButtonStyle.Link),

                   
                new ButtonBuilder()
                    .setCustomId("ping")
                    .setLabel(pingms)
                    .setStyle(ButtonStyle.Secondary)
                    .setDisabled(true),
compact pier
#

hell nah

quartz kindle
#

that method of timing will always be inaccurate

hidden gorge
#

what

#

i tried client.ws.ping but i learned v14 doesnt support ws

quartz kindle
#

that method of timing will always yield incorrect results because you are comparing two timestamps of two different machines

#

interaction.createdTimestamp is the timestamp according to the discord server

#

Date.now() is the timestamp according to your computer

#

different computers are almost always out of sync in time

#

you can see it yourself, sometimes the time in your pc and the time on your phone is not exactly the same

#

they are often several seconds off

#

sometimes even a minute or two

viral badge
#

i think a common method is to edit afterwards with the time it took

maiden gazelle
#

does someone know why my embed is not defined

deft wolf
#

You probably didn't import Discord

#

Wait

#

Why do you want to send it before its creation

maiden gazelle
#

huh?

#

wym

deft wolf
#

You send the embed one line higher than you create it

#

The code works top-down

maiden gazelle
#

ohhhh

#

then that was the problem

#

thank you

hidden gorge
hidden gorge
maiden gazelle
#

i just wanted to do that lmao

deft wolf
#

Like the bot-info command where people post the library they use and the specs of their VPS

sudden geyser
#

flexing

#

with slash commands a ping command is especially useless imo

sudden geyser
#

does anyone actually care about bot specs

deft wolf
#

I don't know what's interesting about whether someone's bot has 8gb of ram or 16gb

quartz kindle
#

i did this to flex my ram usage tbh

#

lmao

#

but the statistic command is currently disabled

hidden gorge
#

Can not send an empty message...

const { SlashCommandBuilder, PermissionFlagsBits, Embed } = require("discord.js");
const { EmbedBuilder } = require("discord.js");
const { ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js");


module.exports = {
    data: new SlashCommandBuilder()
        .setName("dm")
        .setDescription("Moderation Command")
        .addUserOption(option => 
            option
                .setName("user")
                .setDescription("Member to DM")
                .setRequired(true))
        .addStringOption(option =>
            option
                .setName("message")
                .setDescription("Message to Picked User"))
        .setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
    async execute(interaction) {
        const user = interaction.options.getUser("user");
        const message = interaction.options.getString("message") ?? "No Message Provided";

        const embed = new EmbedBuilder()
        .setTitle(`You have recived a Message from ${interaction.guild.name}`)
        .setThumbnail(interaction.guild.iconURL())
        .setDescription(`Message: ${message}`)

        await interaction.user.send(embed)
    }    
}```
wheat mesa
#

Keep in mind that this command is a terrible idea

hidden gorge
#

its for support server only

wheat mesa
#

If you have no way to opt out then it’s against TOS to do this iirc

hidden gorge
#

im working on the opt out

maiden gazelle
#
  let link = 'https';
    
  if(!message.content.startsWith(link)) return;
    let embed = new Discord.EmbedBuilder()
    .setAuthor({ name: `SHARK automod`, iconURL: bot.user.displayAvatarURL() })

    .setColor("#2E3192")

    .setDescription(`You cant advertise here.`);
    
    message.channel.send({ embeds: [embed] });
``` can someone please tell me why my anti advertising isnt working
#

when i send something with https it doesnt send the embed

wheat mesa
#

because you inverted the condition

#

You're essentially saying if message.content does NOT start with link

#

oh wait

#

I read that wrong

#

hold on

maiden gazelle
#

Okay

wheat mesa
maiden gazelle
#

just sending a random link

#

like a discord inv

#

or youtube link

wheat mesa
#

discord invites don't always start with https

maiden gazelle
#

ik but the one i sent did

deft wolf
#

Keep in mind that this will only work if the link starts with https. Someone can put a period and spaces and it won't work anymore

#

I would probably use includes instead of startsWith()

maiden gazelle
#

so it is includes(https)

deft wolf
#

includes(link) in your case

maiden gazelle
#

oh yh i forgot

deft wolf
#

Then all messages containing https will be blocked

maiden gazelle
#

it still doesnt work

wheat mesa
#

Do you have code above that? You’re probably returning early somewhere

solemn latch
#

do you have the message intent? 👀

maiden gazelle
#
bot.on('messageCreate', message => {
  if(message.author.bot) return;
  let prefix = '>';
  let MessageAray = message.content.split(' ');
  let cmd = MessageAray[0].slice(prefix.length)
  if(cmd.toLowerCase() !== 'mm'){ if(!message.channel.type == Discord.ChannelType.GuildText) return; }
  let args = MessageAray.slice(1)

  if(!message.content.startsWith(prefix)) return;

  let commandfile = bot.commands.get(cmd);
  if(commandfile) {commandfile.run(bot,message,args)}
    
    
  let link = 'https';
    
  if(!message.content.includes(link)) return;
    let embed = new Discord.EmbedBuilder()
    .setAuthor({ name: `SHARK automod`, iconURL: bot.user.displayAvatarURL() })

    .setColor("#2E3192")

    .setDescription(`You cant advertise here.`);
    
    message.channel.send({ embeds: [embed] });
})
``` this is my message.create event
maiden gazelle
deft wolf
#

Dude

#

You return when the message does not start with a prefix

maiden gazelle
#

no

#

my prefix works perfectly

solemn latch
#

exactly

deft wolf
#

Yes, but what I mean is that if the message doesn't start with a prefix the rest of the code won't work

maiden gazelle
#

oh

deft wolf
#

So your link blocking code won't work if the message doesn't start with a prefix

maiden gazelle
#

how can i fix it

deft wolf
#

It's best to create a new event dedicated to blocking links

#

Because the one you sent is responsible for the commands

maiden gazelle
#

ah

#

how do i need to call that event lmao

solemn latch
#

same as you currently do

#

just a second time

maiden gazelle
#

okay

#

oh wow it works

deft wolf
#

See how simple it is

maiden gazelle
#

yup i didnt taught abt it

#

but 1 more question

#

how can i make it that it deletes the link message that was sent

quartz kindle
#

message.delete()

deft wolf
#

You'll just have to think about it a bit more because I don't know if you really want to block all links or just links from specific domains such as Twitter/Youtube

maiden gazelle
#

all

#

but i can add to my let link = 'https'; just let link = 'https', 'http, 'Https', 'Http', 'discord.gg'

deft wolf
#

Then it should work as you want, but keep in mind this invitation that Waffel sent

maiden gazelle
#

yes

maiden gazelle
#

oh

#

what do i need to do then

deft wolf
#

You'd have to have an array of these links, and you'd have to check if the message had one of them in it

#

You also don't need to pay attention to uppercase and lowercase letters because you can just convert the whole message to lowercase with toLowerCase()

#

Then you will get rid of this Https and Http

maiden gazelle
#

oh okay

solemn latch
#

http covers https too

deft wolf
#

This is also useful in commands because you want your bot to respond to both !ping and !Ping

solemn latch
#

just a side note, if your bot is in a development server with this code it will delete messages without links in them too.

#

http & https is talked about pretty frequently in dev servers.

deft wolf
#

That's true too

solemn latch
#

all images will be deleted too

#

ie

#

^ this would be deleted, since its just a link to an image

maiden gazelle
deft wolf
#

You can also do it this way, but learning how to use arrays is useful

#

A lot of things in discord.js rely on collections and arrays

maiden gazelle
#

i try to make when someone says hey or hi or something like that the bot will say hi back or something but then with random things

deft wolf
#

And that's what arrays are for

#

You can put e.g. 10 different answers in them and then by simple drawing a number from 0 to 9 you can choose the answer

maiden gazelle
#

ummmm

#

when i type https rn or something like that it keeps spamming cant advertise here

solemn latch
#

any chance the bot is activating its own message?

maiden gazelle
#

this is what i have

deft wolf
#

Okay

#

First of all, this let link is bad

#

It will always return the first thing

#

Second, you don't ignore messages from bots

maiden gazelle
maiden gazelle
solemn latch
#

that also doesnt work

#

👀

maiden gazelle
deft wolf
#

Then the bot will not respond to messages from other bots

maiden gazelle
#

okay

#

oh its fully working atm

#

https

#

http works

#

oh nvm

hidden gorge
#

do i add my collector for my buttons in the same file?

deft wolf
#

By works you mean it blocks the link?

maiden gazelle
#

nope it blocks everything

#

even if i say hi

wheat mesa
#

are you using the message.content.includes("something" || "something else")

#

because if you are that's why it's not working

maiden gazelle
#

i do

wheat mesa
#

that's wrong

maiden gazelle
#

what do i need instead

wheat mesa
#
let arrayOfBlocked = ["words", "you want to", "block"];
if(arrayOfBlocked.some(s => message.content.includes(s)) {
  // do stuff
}
``` for example, I don't mean this to be a spoonfeed but this is the way I'd approach it
hidden gorge
#

how do i make it delete a message in dms when i press a button

wheat mesa
#

Of course this is not a hugely desirable as it will block any message that even so much as has this word in a subset of a full word

#

But it seems like what you're looking for

maiden gazelle
#

ig that is what im looking for yes

deft wolf
hidden gorge
deft wolf
#

???

fluid quest
#

How to add the same data(db) in anthor code?
like /setchannel /// set channel for alarm db.set
-- /deletechannel /// delete the channel from db db.delete

solemn latch
#

If your database supports multiple connections you can connect the same way twice.

deft wolf
#

I have a database assigned to my client, so I have access to it wherever I need it

solemn latch
#

I assume by another code they mean another program

deft wolf
#

I thought he meant bot commands and separate files

fluid quest
#

i mean this
send message or set channel discord js
What data I need

solemn latch
#

the channel id is all the data you really need.

eternal osprey
#

does anyone know why i can still vote while not being user1?

#
const filter1 = i =>  i.member.id === gamedatabase[key].user1
          const collector = r.createMessageComponentCollector( {filter1,
            componentType: "BUTTON",
            time: 10000,
            max: 1,
          });```
quartz kindle
#

because filter1 is not a valid collector option

boreal iron
#

Also the component type... a string might not be parsed to the integer anymore by djs

#

Use the expect api value 2 or djs constants

velvet stream
#

Hello guys, how you doin?

sterile brook
#

How i can get this?

let replyObj = await interaction.reply({embeds: [embed], files: [new AttachmentBuilder( pngBuffer, {name: "card.webp"} )], components: [actions], ephemeral: true, fetchReply: true})

Always gives me error: unknown interaction

boreal iron
#

If you can not ensure to respond to the interaction within the 3s limit, than defer the interaction, execute your code (whatever it is since you didn't provide it) then respond by editing the reply (which was the initial deferring)

sterile brook
#

ty

boreal iron
#

More simply, before creating your image or fetching it from an api or whatever you're doing, defer the interaction

#

Then edit the reply once you're ready

sterile brook
boreal iron
#

Ah yeah that's only available for buttons the reset the initial loading state

sharp geyser
#

So I am thinking of possible problems with my original thoughts on a messaging system. What should I do to prevent people from spam sending messages in a chat? Should I implement a queue system that will only send the rest of the messages if they aren't rate limited?

earnest phoenix
sharp geyser
#

That makes more sense

#

Also, what is RabbitMQ? I know its a messaging service type thing but I don't understand what practical use it can be used for

#

I've seen a lot of people use it in their messaging apps

lament rock
#

and also cluster bi directional communication

sharp geyser
#

Mmm

#

I dont quite understand what that means and its practicalities

lament rock
#

I'll give Discord interactions as an example. Your master server receiving HTTP messages can send that message off to RabbitMQ to a specific channel and slaves that listen to that channel can decide who takes care of it probably through identifiers or first come first serve. This way, new slaves can be added to a super cluster without needing to add logic or configuration about new slaves

#

The master can be totally stateless

sharp geyser
#

Okay but why would RabbitMQ be needed for something like that? Couldn't you do the exact same thing without it

lament rock
#

You could if you so desired, but you might need some other intermediary system for relays which is what RabbitMQ is or do peer to peer through configuration which might facilitate a restart among nodes to know who to communicate with

sharp geyser
#

So RabbitMQ is simply a means to broadcast real time data to multiple endpoints?

lament rock
#

Basically. And there are multiple channels which can have their own message queue so slaves can listen to specific ones and be specialized, but all of the messaging being centralized

sharp geyser
#

Mmm so an example would be a channel for specifically handling Discord Interactions

lament rock
#

And another for whatever like communications or receiving gateway events

sharp geyser
#

and those slaves attached to the channel would only process any message sent on that channel ignoring others

lament rock
#

yup

#

there's also acknowledge systems so if a message isn't acknowledged, it's resent

sharp geyser
#

So the master is what a user would request to e.g me sending a message and then it gets sent to the slaves for them to process

lament rock
#

Yup

sharp geyser
#

This makes more sense

lament rock
#

its really scalable

sharp geyser
#

I thought RabbitMQ was just another websocket implementation

#

like the ws lib

lament rock
#

No. WS operates over http which isn't the case with RabbitMQ

#

http has its own overhead

sharp geyser
#

How does RabbitMQ operate?

lament rock
#

Idk what protocol it uses. It might be some UDP backed system

#

verses HTTP being TCP

sharp geyser
#

I need to learn networking ong

#

Seems like a valuable skill

#

I have no idea what TCP and UDP actually are

lament rock
#

most realtime games use UDP because of throughput and having packets being guaranteed to be received isn't totally necessary as rubber banding happens

#

TCP has systems in place to ensure packets are received

#

through acknowledgements

hidden gorge
lament rock
#

You have no idea what you're talking about

sharp geyser
#

even I can tell that is invalid

hidden gorge
sharp geyser
#

I know I do have to open some ports on my linux machine specifying the protocol for my rust server

lament rock
#

totally unrelated to what we're talking about

sharp geyser
#

It uses TCP and UDP, UDP for the game port and TCP for the rcon stuff

#

thats as far as I know what TCP and UDP are tho

hidden gorge
lament rock
#

stuff like movement and such can be shoved on UDP since it needs to have less overhead

#

that contributes nothing to the conversation.

blissful coral
#

Anybody know anything about InfluxDB on linux systems?

sharp geyser
#

What do you recommend me researching btw?

#

I wanna learn more about networking

#

Especially since I plan on doing multiplayer games in the near future

lament rock
#

What aspect tho

#

oh games

sharp geyser
#

Games and just networking in general, especially those on linux systems

lament rock
#

Well. Looking up how to setup UDP connections is handy to know and how you can build on top of it and make use of its throughput should the packets arriving to clients not be critical

lyric mountain
#

TCP: here, please take care of this package, understood?
UDP: here takes this and fuck off

lament rock
#

TCP is still really good though and is more than just message acknowledgements

lament rock
#

Do not try to understand HTTP's systems tho. I made the mistake of trying to write my own client based off raw tcp sockets and I wanted to off myself

boreal iron
lament rock
#

while you're at it, researching micro services is really good instead of going with standard monolithic designs

sharp geyser
#

monolithic meaning? (I know I could google but youre here /s)

lament rock
#

vertically integrated

#

all in the same process

sharp geyser
#

now to google what vertically means in this context

lament rock
#

Spreading the load across multiple machines is horizontal scaling

sharp geyser
#

Oh right

lament rock
#

having everything on the same machine is vertical scaling

sharp geyser
#

Vertical is when you try and beef up the current machine to handle it all right?

lament rock
#

yeah

#

rip in piss wallet

sharp geyser
#

I remember someone mentioning that now

#

they said postgres was horrible at vertical scaling or smth

lament rock
#

a monolith is a single large block of stone. Monolithic isn't exactly the best word to use for vertical, but it's what popped in my mind first

sharp geyser
#

Nah I understand now

#

I should of guessed what i t means since mono means one

lament rock
#

latin go brr

sharp geyser
#

I know hardly any latin

lament rock
#

English is derived from latin

sharp geyser
#

Yes but actual latin is much better

#

I wanna learn old latin

hidden gorge
#

is what i thought of latin for some reason

sharp geyser
#

Periodic table is actually from greece isn't it?

lament rock
hidden gorge
sharp geyser
#

or at least a lot of the scientific naming are from what I recall

hidden gorge
#

i think

lament rock
#

This is getting de-railed

hidden gorge
#

no i think there was a russian scientist

sharp geyser
sharp geyser
hidden gorge
#

yep

hidden gorge
#

oops

#

thanks

sharp geyser
lament rock
#

I need to go back to using RabbitMQ actually

sharp geyser
#

Is RabbitMQ what discord uses or do they use something else?

lament rock
#

and move away from gateway based interactions

#

idk what they use tbh

sharp geyser
#

I know they use a mix of different tech

lament rock
#

All I know is it's an insanely good messaging broker

sharp geyser
#

Ima try it out for my chatting app

#

Oh god docker

#

How the hell does docker work

#

another thing I dont really understand

lament rock
#

I haven't used docker so idk

#

The basic idea is automating app setup and containing it in it's own space in disk/memory/cpu

sharp geyser
#

@lament rock Installing rabbitmq seems tedious

lament rock
#

It was a pain in the ass, but once it's setup, it's good

sharp geyser
#

So wait rabbitmq is not a replacement for a websocket implementation right?

#

It just works hand in hand correct?

lament rock
#

Well I mean it kinda could be

sharp geyser
#

So how would it work exactly?

lament rock
#

Kinda hard to describe other than what I told you

#

Just a socket of sorts

#

but websockets are http

sharp geyser
#

Mmmm

#

So how would i implement rabbitmq in a chatting app efficiently

#

That is my only question now

lament rock
#

Something that involves broadcasting messages to multiple workers

sharp geyser
#

😔

#

This isn't helping me wrap my head around how it works

#

Alright so let me put it this way

#

I would be using a websocket implementation with a rabbitmq implementation as well right?

User Sends Message -> Websocket Transports Message to RabbitMQ -> RabbitMQ process the message -> RabbitMQ sends the message to all clients via the Websocket

This is my understanding of how it works

lament rock
#

websocket is http

#

rabbit mq is not http

#

You are using a UDP socket most likely

#

There are sockets other than websockets

#

just call it some network interface

sharp geyser
south kiln
#
const query = require('samp-query');
const AsciiTable = require('ascii-table');

module.exports = {
    name: 'serverstat',
    aliases: ['player'],
    description: 'Lists all online players if players number is lower or equal 100',
    run: async (client, message, args) => {
        const server = new query('217.106.106.86', 7002);
        const getPlayerList = async(message)=> {
            try {
                await server.open();
                const playerList = await server.getPlayers();
                const table = new AsciiTable();
                table.addRow('Player ID', 'Name');
                playerList.forEach(player => {
                    table.addRow(player.id, player.name);
                });
                const embed = new MessageEmbed()
                .setTitle('Server Players')
                .setColor(0xff0000)
                .setDescription(table.toString());
                message.channel.send({embeds:[embed]});
                server.close()
            } catch (err) {
                console.error(err);
            }
        }
       setInterval(getPlayerList.bind(this), 5000);
    }
}```
#

in this code when is use callback.apply is not a function error

#

any one please help

#

please ping me

earnest phoenix
south kiln
#

wait

south kiln
earnest phoenix
# south kiln

The second parameter of samp-query module's default function (you declared it as query) expects a function

Read:
https://www.npmjs.com/package/samp-query

earnest phoenix
#

Sure but why?

south kiln
earnest phoenix
#

Alright

viral badge
#

samp-query?

hidden gorge
#

I’m getting a Cannot GET /login on my ejs website

<%- include(“./partials/header”); ->
<head>
<title>RocketX Dashboard</title>
<link rel=“stylesheet” href=“/dashboard/public/style.css”>
</head>
<h1>
Title
</h1>
<body>
<h1>Hi</h1>
<button><a  href=“/login”>Login</a></button>
</body>
<%- include(“./partials/footer”); -%>```
solemn latch
earnest phoenix
hidden gorge
hidden gorge
solemn latch
#

so, if you go to localhost:port/login
it loads a page?

solemn latch
hidden gorge
#

idk what’s causing it

hidden gorge
#

how do i make a string option on slash command required?

#

bc i tried .setRequired(true)) but it says invaild

lyric mountain
neon leaf
#

did anyone ever work with chakra ui + nextjs before? Im trying to make color switching look smooth but transition-all doesnt seem to work, is there any other way?

deft wolf
#

You'd need to send the error code and your command code so we can find out more about why it's not working for you

surreal sage
#

HTML page likes to scroll to 0, 0 after an element was added
How do I make it not scroll to 0, 0
scrollY and scrollX are both 0
No height: 100% css rules

#

I've got height: 100vh; shrug

lyric mountain
#

100vh height will make it impossible to ever scroll the page

compact pier
#

How many interaction types are there?

neon leaf
deft wolf
#

Slash commands, buttons, context menus and select menus

#

Thats all i guess

compact pier
earnest phoenix
compact pier
#

I hope, they will add new types to discord

#

like pop ups, looks like modals but don't have inputs

earnest phoenix
#

what would be the point of that, just send an ephemeral message

solemn latch
compact pier
solemn latch
#

More annoying though

#

Pop-ups are the most common reason I close out websites early

compact pier
earnest phoenix
#

couldn't really be abused

compact pier
#

they could have ratelimits

earnest phoenix
#

how would someone abuse them?