#development

1 messages · Page 139 of 1

quartz kindle
#

check if one of those is cutting the connection after a timeout

neon leaf
#

cloudflare is but they seem to support sse so I think im doing something wrong

quartz kindle
#

for example in nginx you have proxy_read_timeout and proxy_connect_timeout

neon leaf
#

is set to like 800k seconds

quartz kindle
#

try adding the X-Accel-Buffering: no; header to the nodejs response

#

also Cache-Control: no-cache;

#

your nginx proxy already has these right?

proxy_http_version 1.1;
proxy_set_header Connection "";
neon leaf
#

it has connection upgrade

#

afaik a sse request should instantly show the status in the network dev tab

#

mine just shows nothing (loading)

quartz kindle
#

i believe connection "" is the correct one for persistent connections

neon leaf
quartz kindle
#

the nodejs headers should be ```
'Content-Type': 'text/event-stream',
'Connection': 'keep-alive',
'Cache-Control': 'no-cache',
'X-Accel-Buffering': 'no'

neon leaf
lyric mountain
#

Ur using websocket with nginx?

neon leaf
#

no

#

sse

quartz kindle
#

i found something interesting, might wanna give it a try

#
location / {
    proxy_pass http://localhost:3000;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection '';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
    proxy_buffering off;
    proxy_cache off;
    proxy_read_timeout 60s; # SSE gets sent on whatever interval this is set to
    chunked_transfer_encoding off;
    proxy_set_header X-Forwarded-For $remote_addr;
}
lyric mountain
#

Ah, was gonna ask you whether u get random disconnects from it

quartz kindle
#

more specifically this proxy_read_timeout 60s; # SSE gets sent on whatever interval this is set to

lyric mountain
#

Tried finding the cause for too long already, never discovered why my websockets get dropped after a while

neon leaf
quartz kindle
#

im not sure, but from what that comment says it seems nginx waits for data to come from node, and once it timesout, it sends the data so far to the client

#

and starts waiting again

#

thats what the commend suggests

neon leaf
#

ill try sending pings

quartz kindle
#

even though the timeout suggests it would close the connection

#

try setting the timeout to something like 2 seconds

quartz kindle
frosty gale
#

tf?

#

since when was that a thing

neon leaf
#

since forever

frosty gale
#

why do they only limit it to server-client anyways

#

ws is bidirectional:)

neon leaf
#

you dont always need bidirectional

neon leaf
quartz kindle
#

cool

neon leaf
#

also why is react being so react

#

why 2 requests

#

its in a useEffect

frosty gale
neon leaf
#

I mean yeah they are convenient but to my knowledge relatively resource heavy

frosty gale
#

react rerenders too much

frosty gale
lyric mountain
#

doesn't affect much, aside from the occasional broken pipes, but it's annoying to have the log full of "Client disconnected with reason xxxx"

frosty gale
#

i think os's generally disconnect sockets if keep alives havent been exchanged for 30 minutes more or less?

#

talking about tcp

#

not sure if that may be the case here

#

not talking about websockets but for tcp sockets i make clients exchange "heartbeats" every 2 minutes if a connection has been dormant and it doesnt seem to disconnect me

#

browser might have its own quirks

lyric mountain
#

might be worth to reduce my ping interval to test

frosty gale
#

there really isnt a standardised way to test/see if a tcp connection is properly dead or not so os's just kill them if nothing has been sent/received for a while

neon leaf
#

how tf do I prevent react from making 2 requests? basically tried everything at this point

lyric mountain
#

wdym 2?

neon leaf
#

that subscribe

quartz kindle
#

discord heartbeats/pings every 45 seconds lol

frosty gale
#

bro wants to save that bandwidth

#

people on internet that limits their total download/upload per month thanking kuuhaku rn

quartz kindle
#

make a custom socket where heartbeats only take 1 byte

#

:^)

frosty gale
#

yeah my heartbeats are 1 byte

#

its just a single byte message with '0'

quartz kindle
#

xD

earnest phoenix
quartz kindle
#

via raw tcp right?

quartz kindle
#

because websocket add a lot of overhead

frosty gale
#

i tried setting up keep alives with the c api and they never worked

earnest phoenix
#

Skill issue™️

quartz kindle
#

xD

frosty gale
#

actually my issue was it took the os way too long to disconnect dead sockets with keepalive

#

i think i checked somewhere and found out you cant change it its an os-level thing

quartz kindle
#

obviously fake tho

#

but still funny

hushed robin
#

how do I make a websocket

quartz kindle
hushed robin
#

yea

frosty gale
#

blud CANNOT ❌ wait 30 MINUTES for the os to tell SCHLAWG ✅ 🐶 if a socket is DEAD 💀❌

quartz kindle
#

in the browser you cant

neon leaf
#

why would you want to make one from scratch

hushed robin
#

i don’t want browser

neon leaf
#

then dont use websockets

quartz kindle
#

but in nodejs you can make a websocket implementation using the built in net module

hushed robin
quartz kindle
#

or the http module also works

hushed robin
#

ok

#

is it hard

neon leaf
#

yes

quartz kindle
#

since http uses and gves you access to a instance of a net socket anyways

frosty gale
#

in c the api for connections with tcp is actually very pleasant

earnest phoenix
frosty gale
#

you get functions that block the thread until some data is received and you can send bytes with a simple function

earnest phoenix
frosty gale
#

ubuntu

quartz kindle
# hushed robin is it hard

did you check the code for tiny-discord? the websocket file basically does this, its a custom websocket client using the http module

hushed robin
quartz kindle
#

its a node module

neon leaf
#

its built in

quartz kindle
#

built in

#

..

hushed robin
#

oh

quartz kindle
#

a websocket has two parts, a client and a server

#

i only made the client part

hushed robin
quartz kindle
#

but you can also make the server part the same way

hushed robin
#

this?

quartz kindle
#

yes

hushed robin
#

bruh

#

it’s 1400 lines

neon leaf
#

yes

#

doing stuff like this from scratch does literally mean from scratch

quartz kindle
#

the websocket part is only a small part of the code

#

for example

#

this is where i make the connection ```js
const req = request({
hostname: (this._session.id && this._session.url) || this.url,
path: path,
headers: {
"Connection": "Upgrade",
"Upgrade": "websocket",
"Sec-WebSocket-Key": key,
"Sec-WebSocket-Version": "13",
}
});

hushed robin
#

does it have to be that long

neon leaf
#

no

lyric mountain
neon leaf
#

alot of it is discord-specific code

quartz kindle
#

request is const { request } = require("node:https");

earnest phoenix
# frosty gale ubuntu

You can absolutely change it, you can change the net.ipv4.tcp_fin_timeout property in the /etc/sysctl.conf file (the property value is in seconds)

#

The default value is 2 minutes

quartz kindle
#

then this is how to initiate the connection once its established ```js
req.on("upgrade", (res, socket) => {
const hash = createHash("sha1").update(key + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest("base64");
const accept = res.headers["sec-websocket-accept"];
if(hash !== accept) {
socket.end(() => {
this.emit("debug", "Failed websocket-key validation");
const error = /** @type {Error & { expected?: string, received?: string }} */ (new Error("Invalid Sec-Websocket-Accept"));
error.expected = hash;
error.received = accept;
reject(error);
});
return;
}
socket.on("error", this._onError.bind(this));
socket.on("close", this._onClose.bind(this));
socket.on("readable", this._onReadable.bind(this));

frosty gale
#

yeah but thats a system level setting what if you want to do it per application

frosty gale
#

dont know what happened

quartz kindle
#

notice the socket.on("readable", this._onReadable.bind(this)); thats how i start receiving data from discord

#

it can also be socket.on("data")

earnest phoenix
#

You can't do such a thing per-application in any operating system

hushed robin
#

this is not what I mean

quartz kindle
#

then you need the code to understand the websocket specification

#

how to extract the data from the websocket frames

hushed robin
quartz kindle
#

i do that part here ```js
_onReadable() {
const socket = /** @type {NonNullable<typeof this._socket>} */ (this._socket);
while(socket.readableLength > 1) {
let length = readRange(socket, 1, 1) & 127;
let bytes = 0;
if(length > 125) {
bytes = length === 126 ? 2 : 8;
if(socket.readableLength < 2 + bytes) { return; }
length = readRange(socket, 2, bytes);
}
const frame = socket.read(2 + bytes + length);
if(!frame) { return; }
const fin = frame[0] >> 7;
const opcode = frame[0] & 15;
if(fin !== 1 || opcode === 0) { throw new Error("discord actually does send messages with fin=0. if you see this error let me know"); }
const payload = frame.slice(2 + bytes);
this._processFrame(opcode, payload);
}
}

earnest phoenix
#

Also why the hell is Battleless trying to make a websocket from scratch

hushed robin
#

because

quartz kindle
hushed robin
#

I wanna learn

quartz kindle
#

it also supports ETF and compression

#

it also does heartbeating, reconnection, etc

hushed robin
#

so how long does my websocket need to be

quartz kindle
#

and event emitter stuff

#

if you want only the websocket part

#

let me show you, i actually changed it into a separate version

#

i separated the websocket code into its own file, its ~250 lines

hushed robin
#

wow

#

wtf is taking up the other 1100 lines

quartz kindle
#

i told you

#

discord api logic

#

events, heartbeating, reconnection

hushed robin
#

why does that take up 1100 lines

quartz kindle
#

because discord is complex

hushed robin
#

so will I need to do that

quartz kindle
#

and i also included a built in ETF converter

hushed robin
#

⁉️

quartz kindle
#

which takes a lot of lines

earnest phoenix
hushed robin
#

probably less than that

quartz kindle
#

lmao

#

discord.js is like 5x bigger

neon leaf
#

tiny-discord

quartz kindle
#

just the websocket part

hushed robin
#

sounds excessive

quartz kindle
#

the thing is

#

if you want a minimal implementation

#

you can do it in few lines of code

#

but then you need to start adding stuff to handle edge cases

#

so it ends up being larger than you thought

hushed robin
#

how

#

send me the few lines

quartz kindle
#

like code to handle all possible ways of disconnections

#

code to handle websocket pings

#
    _handleFrame(/** @type {number} */ opcode, /** @type {Buffer} */ message) {
        if(opcode > 2) {
            switch(opcode) {
                case 8: { // close
                    this._closeCode = message.length > 1 ? (message[0] << 8) + message[1] : 0;
                    this._closeMessage = message.length > 2 ? message.subarray(2).toString() : "";
                    this.ondebug(`Received close frame with code: ${this._closeCode} ${this._closeMessage}`);
                    if(!this._closed) {
                        this._write(message.subarray(0, 2), 8); // echo close code
                        this._closed = true;
                    }
                    break;
                }
                case 9: { // ping
                    this.ondebug("Received ping frame, responding with pong");
                    this._write(message, 10);
                    break;
                }
                case 10: { // pong
                    this.ondebug("Received pong frame");
                    if(this._ping) { this._ping.resolve(); }
                    break;
                }
            }
        } else {
            this.onmessage(opcode, message);
        }
    }
hushed robin
#

that’s more than a few lines

earnest phoenix
quartz kindle
hushed robin
#

😵

quartz kindle
#

i mean

#

depends what exactly you want to accomplish

#

if all you want is to see discord events flodding your console logs

#

then you can do it in about 10-20 lines

quartz kindle
#

yes

#

and thats only the discord api logic

#

it does not include websocker logic, nor compression, nor conversion

#

everything else is handled in other files

#

discordjs uses the ws package for the websocket implementation

#

ws alone is sevral thousand lines

#

because they have to support every single feature and quirk of the websocket specification

#

i dont

hushed robin
#

what’s the difference between Ws and http

quartz kindle
#

http opens and closes

#

ws its an http that opens and stays open

hushed robin
#

so yours doesn’t stay open?

quartz kindle
#

it does

#

ws is built on top of http

#

you start with sending an http requiest

#

and then you tell it to not close

hushed robin
#

u said http open and closes

#

and u use http

quartz kindle
#

without ws yes

vivid fulcrum
#

in lays terms, water running from a tap continuously is a websocket, water in a cup is a served http request

quartz kindle
#

ws is like an app built on top of http that specifically tells http not to close

#

http is the base connection for everything

#

ws is a style of using http

#

a normal http request is automatically closed after it finishes

#

a ws requiest specifically asks it not to close

#

it overrides the normal http setting

sage bobcat
#

One message removed from a suspended account.

lyric mountain
#

tcp vs udp

vivid fulcrum
#

lmfaoo

#

good one

quartz kindle
#

lmao

#

one asks you if you would like a cup of water

#

the other throws the water at you

hushed robin
#

are you new here

quartz kindle
#

LMAO

hushed robin
#

what’s funny

#

I’ve never seen them before

quartz kindle
#

cry has been around here longer than you

hushed robin
quartz kindle
#

well idk

#

where have you been cry

vivid fulcrum
#

i pop in here and there mostly when i get on to game a bit, but it's mostly been work lately

#

what's ironic is that my work consists of the one thing i hated the most; java

quartz kindle
#

xD

#

i participated in a java mini course as an assistant teacher

#

safe to say it reinforced my idea that java is bullshit

#

:^)

vivid fulcrum
#

was about to ask how'd that go lmfao, yeah expected

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

quartz kindle
#

lmao

vivid fulcrum
#

i was just trying to be an edgelord i didn't hate anyone fr 😭

wheat mesa
#

I don’t get the hate against Java tbh

sage bobcat
quartz kindle
sage bobcat
#

One message removed from a suspended account.

wheat mesa
#

I understand some of it but like

#

Java is great

vivid fulcrum
#

useful knowledge

#

especially because java is horrid without spring in large scale apps

vivid fulcrum
#

it's all the same

sage bobcat
#

One message removed from a suspended account.

vivid fulcrum
#

your thought process is what matters the most not the language

lyric mountain
#

funny enough, I find it worse with spring

sage bobcat
#

One message removed from a suspended account.

quartz kindle
#

show us your block list

#

:^)

vivid fulcrum
#

granted that's aimed at web so

sage bobcat
#

One message removed from a suspended account.

vivid fulcrum
#

nooooooo

#

as i click the block button

vivid fulcrum
#

i keep trying to send /s but the slash commands are getting in the way god what happened to this app

quartz kindle
lyric mountain
vivid fulcrum
#

I'm really not sure

quartz kindle
#

what i didnt like about the course was that they teach the students spring with a very fixed mindset on mvc principles

#

the code is always split into controllers, models, views, requests, entities, services, etcc

vivid fulcrum
hushed robin
#

no why do u hate Java

vivid fulcrum
sage bobcat
vivid fulcrum
#

one of my main reasons way back was performance

#

but performance is irrelevant in the industry, unless you're making a game or something that requires squeezing every single point of performance out of your hardware

earnest phoenix
#

Gotta love you can access secret information on so many government websites just by searching intext:"ArcGIS REST Services Directory" intitle:"Folder: /" on Google hd_skull

vivid fulcrum
#

you shouldn't concern yourself

vivid fulcrum
#

which is fair, older tech leaves more space for refining

earnest phoenix
#

Government websites be using the oldest technology in existence

hushed robin
earnest phoenix
#

And they never bother using something newer

hushed robin
#

maybe because they don’t need to

vivid fulcrum
hushed robin
#

⁉️

quartz kindle
vivid fulcrum
#

adapt improvise overcome B)

hushed robin
#

so you don’t have a language you’d rather use over all others

vivid fulcrum
#

not really

#

if you want a genuine answer it really depends on what im building

hushed robin
#

hm ok

vivid fulcrum
#

if i want a UI app that i can quickly write the styling and logic for, id go for js because of electron etc etc

earnest phoenix
# hushed robin maybe because they don’t need to

They don't need to, but they should instead of just using something incredibly old that nobody really cares about, and imagine trying to find someone to maintain the said old thing if the current maintainers leave or get fired

Reminds me of this meme

hushed robin
#

I think they should focus on more important things

#

🧌

vivid fulcrum
#

nah that's definitely changing, technology is constantly evolving and there should definitely be more care about keeping things up to date

#

we're slowly entering a new age of computing which leaves the doors open for all kinds of exploits and cracks

lament rock
#

The backbone of the internet is likely mostly run by old tech barely maintained/touched because it all JUST WORKS LIKE MAGIC

#

Same with my bot's old code

#

Some code, I just had to copy paste

hushed robin
#

the government should focus on implementing an official Uber eats / doordash

lament rock
#

I was on some shit 4 years ago

vivid fulcrum
#

psilocybin and a long programming session is the new shit

hushed robin
vivid fulcrum
#

a topic mods probably wouldn't like me talking about :')

hushed robin
#

is it drugs

vivid fulcrum
#

it's a psychedelic commonly found in shrooms, from personal experience microdosing it boosted my cognitive performance by a milestone

#

it's definitely not for everyone but i did notice the code I've been writing after a few months was extremely structurally sound

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

vivid fulcrum
#

hey hey let's not mix natural and synthetic chemicals, but it's a nsfw topic for this server anyway xd

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

hushed robin
#

no im not

#

lol

sage bobcat
#

One message removed from a suspended account.

hushed robin
#

no

#

both of those are wrong 😕

sage bobcat
#

One message removed from a suspended account.

hushed robin
sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

quartz kindle
#

yes but he will get exposed as an immortal time traveler

hushed robin
#

some people on the internet are crazy

sage bobcat
#

One message removed from a suspended account.

quartz kindle
#

the word subpoena implies the existence of a superpoena

frosty gale
#

the irony

sage bobcat
quartz kindle
#

say it

#

or block

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

quartz kindle
#

damn, you got me

sage bobcat
#

One message removed from a suspended account.

hushed robin
#

Tim hasn’t blocked me

quartz kindle
#

i unfriend scammers

#

they friend me out of nowhere, i accept to see what they want, they offer an amazing crypto oportunity, i unfriend

#

:^)

hushed robin
#

why would you not unfriend scammers

vivid fulcrum
#

free tech support

pale vessel
#

sometimes I love to fuck around with them

frosty gale
frosty gale
#

but for some reason it always ends up in me parting ways with my own money

patent onyx
#

I updated my logo for my bot and I was wondering how to change the image on top.gg or how long till it auto updates

sage bobcat
#

One message removed from a suspended account.

gilded plankBOT
#

topgg Fetching Your New Bot Data

To fetch your bot's new name or avatar, please follow these steps:
topggDotRed Click the Refresh Data button in the sidebar on the right.
topggDotRed Click Edit on your bot page and then Save.

💡 Please note: If it still doesn't seem to change, make sure you actually changed the bot's avatar / name on your Discord Developer Portal and not the application's icon / name.

patent onyx
tulip ledge
#

Where do you find your slash command Id

deft wolf
#

Just type your command and right click on the dark box above text area

#

Like that

tulip ledge
#

ah ty

deft wolf
tulip ledge
#

I have a cache with a ttl of 15 seconds, now I also want to clear this using a cronjob every x time. How long should I put between clearing the cache? Every 5 minutes?

#

To clear the ones that exceeded the ttl

lyric mountain
#

if entries are managing to exceed the ttl u need to either find a better lib or find out why it happened

#

ttl is supposed to be absolute, nothing should exceed it

lyric mountain
#

for js there's a lib called expiring-map

tulip ledge
#

is it also for ts?

lyric mountain
#

ts is js

tulip ledge
#

ye I mean

#

does it have ts support

lyric mountain
#

maybe, idk

#

at worst it'll be any typed

tulip ledge
#

alr

#

I'll try that

lyric mountain
#

find a supported lib for a ttl map if that one doesnt work

#

"certified" no longer exists, do u mean verified?

tulip ledge
lyric mountain
#

in topgg or discord?

lyric mountain
#

it needs to reach 76

frosty gale
#

I have this C++ struct here:

struct Entry {
    uint32_t f1 : 16;
    uint32_t f2 : 16;
} __attribute__((packed));

members are defined by a bitfield size so both fields are 16 bits making it 32 bits, a size of a uint32_t
i wanna create them on the stack like Entry e; but the members in the struct have to be 0, this is very important
and I don't think I can use default initialisation here because:

#

i could always use a messy solution like

uint32_t struc = 0;
Entry* e = reinterpret_cast<Entry*>(&struc);

but wondering if theres a better way

earnest phoenix
frosty gale
#

ahh okay i'll try that

#

weird syntax but i dont question

#

thanks!!!!

lament rock
#

anyone got recommendations for fast image manipulation libraries for NodeJS? Thought about using node-canvas. Previously used node-canvas and JIMP, but didn't know if there were better options

lyric mountain
#

like imagemagick

lament rock
#

It'd be for my bot

#

why I requested libraries

lyric mountain
#

cant get much faster than node canvas

earnest phoenix
#

So your best bet for now is Node-Canvas

#

If you want, you can make node-gyp compile Node-Canvas with ThinLTO which can also improve it's performance quite well

lament rock
#

Will look into it. I do have some complex ops like masking so yeah

#

anything for gifs specifically?

#

I tried before and the processing times were extreme

lyric mountain
#

gif is...terrible

lament rock
#

Wish Discord allowed embedding animations of other types

#

video formats as seen on the gif feature doesnt work. apng doesnt work. webm/webp doesnt work

#

if webp even supports animation

#

as in no autoplay I mean by not working

lyric mountain
#

to make it worse, discord technically does support apng but they've made it exclusive for stickers

lament rock
#

Yeah

queen needle
lament rock
#

they used to support apng for avatars and people could get animated avatars without nitro, then they blocked that

#

shit was so dumb

#

I'll have to see how imagescript performs

queen needle
#

It is really fast

lament rock
#

is it just an encoder or?

queen needle
#

I'm a wee bit dumb so im just going to: https://www.npmjs.com/package/imagescript

lament rock
#

mmm does support decoding and encoding gifs, but it's a bitmap based solution

#

might be considerably slower than canvas

#

I'll see if there's any gif support for canvas through external libs/built in first

queen needle
earnest phoenix
# lament rock I'll see if there's any gif support for canvas through external libs/built in fi...

Well you can also use a different library for encoding/decoding GIFs and use https://www.npmjs.com/package/gifencoder to put them together in Canvas

#

Though it can be quite slow

lament rock
#

how slow we talking

earnest phoenix
#

I remember making it take the user's avatar, and output a GIF with lots of frames where the avatar was being pet, a few of them were added to the discord.js server

#

Like petTheCrawl petTheSouji

lyric mountain
#

bitmap is basically a pixel grid

earnest phoenix
#

It generally took 5-6 seconds to generate

lament rock
#

5-6 seconds is acceptible

#

svgs aren't really bitmap

#

can still manipulate it

earnest phoenix
# lament rock 5-6 seconds is acceptible

Though note that it was making my bot come down to its knees because it's quite resource-intensive, make sure to do this in a different process or server unless you have a pretty beefy server

lament rock
#

oh yikes

#

I mean. I have separate processes for stuff and I planned on shoving it onto a worker that didn't handle any important tasks like http or queue handling

#

unless it makes use of multiple cores, I won't have to scale servers just yet

earnest phoenix
#

Although that has nothing to do with the gifencoder library I mentioned, it's because of me doing quite a good amount of canvas operations

#

And as I said, you can compile Canvas with LTO (Full or Thin) to not only improve its performance but also potentially reduce memory usage

lament rock
#

My encoding solutions would be quite simple. Just create the background and copy the base and stitch a frame of the user's avatar to it then push those to the encoder

earnest phoenix
#

Then you should be good to go

lament rock
earnest phoenix
#

I also fixed multiple memory leaks in Canvas itself but a new update hasn't been released that includes those fixes

lament rock
#

Oh. Is there an ETA on that?

#

I may just be tempted to wait for that

earnest phoenix
#

I have absolutely no idea, I fixed them a few months ago I think and yet no new releases

lament rock
#

Could just build manually tbh

earnest phoenix
#

Though I'm not really sure if these memory leaks are on hot or common paths so you can just use it and update when the release is available

lament rock
#

oh fair

earnest phoenix
#

What platform do you host the bot on?

lament rock
#

ubuntu

#

tho I dev exclusively on windows

earnest phoenix
#

You can run the following to compile with LTO (note that you gotta remove the package-lock.json file and the node_modules directory):

$ CFLAGS='-flto' CXXFLAGS='-flto' npm i

Though note that Ubuntu uses the GCC compiler and doesn't have the Clang compiler installed so you won't be able to compile with ThinLTO with GCC which is better than just GCC's LTO

Clang also generally emits better and faster assembly than GCC so I'd recommend switching to it

lament rock
#

what if I use yarn?

#

same thing?

earnest phoenix
#

Yep

lament rock
#

Thanks amandalove

earnest phoenix
#

You're welcome pat2

prisma nebula
#

How can I update replit to the last version

#

?

lyric mountain
#

u don't, it's always in the latest

#

do u mean node?

prisma nebula
#

Idk it always show flags error

#

All my codes are fine

lyric mountain
#

show the error

prisma nebula
#

Sec

#

Here we go

lyric mountain
#

...?

neon leaf
#

I could cry

lyric mountain
#

how are u registering 'em?

prisma nebula
neon leaf
lyric mountain
#

events in events is really really bad

#

even if it's once

prisma nebula
#

Type error : cannot read properties of undefined reading 'FLAGS')

neon leaf
lyric mountain
prisma nebula
#

Sec

lyric mountain
#

there're location info in the stacktrace, to know where it happened

neon leaf
#

the leak is coming from when I do auto reconnect, without it it runs fine

prisma nebula
#

Image sending

lyric mountain
#

then close it inside socket close

prisma nebula
#

Iam not really a very pro coder last time I coded 3 years ago iam just doing now a basic code urgently

lyric mountain
lyric mountain
#

did you write the code yourself?

prisma nebula
#

What should I do

lyric mountain
#

idk, I'm still waiting for the image

prisma nebula
#

I tried chat gpt but it is trash now ian struggling alone

lyric mountain
#

don't use chatgpt for fixing code, it doesn't work

#

chances are you'll just add another error to it

prisma nebula
#

Also iam using prefix bcz slash always shows errorsi worked like 6 hours it is only 4 commands

lyric mountain
#

did you write that code yourself?

neon leaf
#

it seems to work

quartz kindle
neon leaf
#

hm?

quartz kindle
#

sockets can be reused under the hood

lyric mountain
quartz kindle
#

listen to the response event instead

neon leaf
#

thanks

prisma nebula
#

Yes

neon leaf
#

uhhh

#

it doesnt seem to reconnect anymore actually

quartz kindle
#

why are you using socket and not response? if you wanna handle raw http might as well use the tls or net modules

neon leaf
#

I dont want to mess with http/ssl boilerplate

quartz kindle
#

well, i dont see why it shouldnt be reconnecting

neon leaf
#

seems like the events arent firing

quartz kindle
#

shouldnt need to manually destroy them tho

#

ah

#

well

#

the right way is to attach an end event to the response

#

but you dont use response

neon leaf
#

even that isnt firing

#

ah no

#

wait

#

it doesnt fire if the server was never online

#

makes sense

#

but how can I still make it reconnect in that case

quartz kindle
#

if the connection did not succeed, the request should emit an error event no?

neon leaf
#

nope

quartz kindle
#

although close should also be emitted regardless

neon leaf
#

doesnt seem to

#

turns out I also have to listen to the timeout event

quartz kindle
#

huh

#

weird

neon leaf
#

wtf

#

its spamming the timeout event like crazy

#

even though im connected

#

im confused

quartz kindle
#

@_@

#

just use a tls socket

#

you dont need to setup any ssl stuff

#

you're not a server, you're the client

prisma nebula
#

Can anyone help me coding something just so basic pls

#

I gave up

#

My codes

wheat mesa
prisma nebula
#

Can any1 help

neon leaf
#

it turned out to be me not doing .removeAllListeners() (?)
anyways that was just a test to try to even get anything working, now for the hard part I want to make that browser and node compatible, the current solution only works with node

prisma nebula
lyric mountain
#

I suppose that's where ur creating the bot client

#

If so, don't blindly copypaste the example code

prisma nebula
#

const client = new Client({ intents: [Intents.FLAGS.GUILDS] });

lyric mountain
#

Ah, nvm then

#

I don't think it's uppercase FLAGS

prisma nebula
#

What

lyric mountain
#

Type Intents. then press ctrl space

#

Variables are case sensitive

#

FLAGS is not equal to Flags or flags

#

Whatever that lib uses

prisma nebula
#

Lol

#

So what I use

#

Iam confused

neon leaf
#

@quartz kindle do you know what the best way to get this working in browser & node would be? for some reason EventSource is just not working (probably because I am still not sending proper sse)

prisma nebula
#
flags.guilds ?

lyric mountain
#

Let the editor tell you what you should use

prisma nebula
#

It says nothing

#

😫

lyric mountain
#

What library are u using?

#

D.js?

prisma nebula
#

Yes

#

Discord.js

lyric mountain
prisma nebula
#

I really just need to know what I need to write

#

Do I have to read it all

lyric mountain
#

We don't give copypaste-ready codes here

#

We show u the way, and help with questions

prisma nebula
#

Doesn't make sence for 2 words

lyric mountain
#

If you're making a bot you need to get used to reading the documentation, discord.js even gives u guides for popular topics

lyric mountain
#

Don't jump to the code, read the context

deft wolf
#

Just download bot from github at this point kappalul

spark flint
prisma nebula
#

I mean

#

Flags fLags FLAGS

#

All doesn't work

#

ETf

lyric mountain
#

Ctrl space

#

Don't try to guess it

prisma nebula
#

Idh ctrl

#

IAm obligated to code on phone rn

lyric mountain
#

Ah

#

Well, then documentation is thw only way

prisma nebula
#

Bruh 2 words took 6 hrs lpp

lyric mountain
#

Search for Client

prisma nebula
#

I guess it isn't the issue

#

NONE works

#

I've used docs ones

#

Still same error presist

lyric mountain
#

Check which version you're using

#

Latest is v14

prisma nebula
#

Iam using latest

#

I also downloaded it in shell

lyric mountain
#

Djs?

prisma nebula
#

Yes

lyric mountain
#

Why didn't u use npm?

prisma nebula
#

I did use npm

#

Npm install discord.js@latest

#

I sent this or simillar one

#

I dont rmember

lyric mountain
#

Don't think ur supposed to add @latest

#

What version is in package.json?

prisma nebula
#

Ok anyways what should I do with rhay

#

That

#

Let me chrck

#

Idk I didn't install smtng like that

lyric mountain
#

U don't edit packages manually, but everything u install with npm is listed there

prisma nebula
#

My issue is just with 2 word

quartz kindle
#

by logging raw tcp packets

#

for example

lyric mountain
#

Try starting the bot without any intent

prisma nebula
#

Will that work

lyric mountain
#

It's supposed to

#

But the bot will be as functional as a vegetable

quartz kindle
#

intents are required since v13, if it works it means hes using v12 or lower

prisma nebula
#

I'll do that tomorrow it is 1:12AM iam so tired I spent 6hr trying to do it

lyric mountain
#

Always check the docs if you're struggling

#

Trying to guess properties or methods never works well

#

And as long as it might be, usually the issue is solved within minutes

prisma nebula
#

If a pc user got invited to my repl he can fix it?

lyric mountain
#

Well, yes

#

But not me, I'm busy with other stuff

prisma nebula
#

Anyone free here

quartz kindle
#

lmao

lyric mountain
#

Also having someone else do it for you will do no good for u

wheat mesa
#

nobody is going to code for you

#

unless you pay them

prisma nebula
#

Not code just a button to click

wheat mesa
#

plus if you want to learn, then don't have other people write code for you

prisma nebula
#

Because iam not on pc

lyric mountain
#

You'll still don't know the issue, so you'll be always dependant on someone else

prisma nebula
#

I just need sm1 to click ctrl+ space

lyric mountain
#

Quick dip on the docs will solve it easily

prisma nebula
#

To chrck

lyric mountain
#

Ctrl space won't show the properties to u

#

Only to who pressed

prisma nebula
#

Just to select the option

quartz kindle
#

does replit even support auto completition in the web editor?

lyric mountain
#

I think so

neon leaf
#

yes

quartz kindle
#

fancy

prisma nebula
#

I'll try tomorrow iam tired that bot is so important to finish

lyric mountain
#

Did u even code the rest of it already?

prisma nebula
#

Everything is done

#

Just stuck their

lyric mountain
#

Then yeah, u didn't code the bot

quartz kindle
#

copied from somewhere?

prisma nebula
#

No airpurple did them for me

lyric mountain
#

Wherever u copied it from, see if there are no instructions on how to configure

lyric mountain
quartz kindle
#

also make sure the code is compatible with the discord.js version you installed

prisma nebula
#

That's my cousin he said I can help last time I coded a powerfull bot in 3 years before I retire but my team scammed me

#

Stole codes and made different bots

lyric mountain
#

Well...

quartz kindle
#

lel

prisma nebula
lyric mountain
#

They're right tbh

#

I mean, for mobile there's not much u can use

prisma nebula
#

I also didn't use replit it always show useless things

#

Also their is nowhere to copy or clone the current bot source iam doing

#

I dont think anyone did this idea yet

lyric mountain
#

Doubt it, but most bot repos are private anyway

#

If ur afraid someone might steal the code it's best to not invite anyone to the replit

#

Actually, does replit still allow private projects?

prisma nebula
#

No it is not important codes it is just announcements:

Additem ( name info photo)
Checkitem added by botadmin
Promote and demote user pwrms in using the additem command and updatechannel wheir it send new item added onfo and photo etc

prisma nebula
lyric mountain
#

the link I sent has the full example on setting up a bot

#

but given u had it called Intent, I'm afraid ur code is outdated

#

it's for version 13

#

if u installed djs with npm then you're on version 14

#

so it wont work

#

may I say, in that case FLAGS is not your only problem

prisma nebula
#

Bruh

#

I need to update codes ?

#

To 14?

lyric mountain
#

or u can uninstall djs and force version 13

prisma nebula
#

How

lyric mountain
#

but then you'll be on the line, as version 15 is releasing soon

#

so v13 will be the next to be abandoned since v12 goes down when v15 releases

prisma nebula
#

Can't I just work on 1 version those new versions are annoying qf

lyric mountain
#

issue is discord updates a lot

#

so they need to make new versions to include those changes

prisma nebula
#

Oof

lyric mountain
#

(tho d.js devs don't really need to completely rewrite the lib every update)

earnest phoenix
#

anyone know any cheap hostigns

#

for bots

prisma nebula
#

Online ai can't update codes?

lyric mountain
#

so there are two choices

  • revert to version 13 and live with the risk of eventual breaks
  • refactor code to be valid for version 14
lyric mountain
lyric mountain
#

only know those 3

prisma nebula
#

Everything in this life useless

#

Why do I need to recreate

#

Bruh

lyric mountain
#

that's the life of a programmer

#

code that never needs to be maintained doesn't exist

#

it's the philosopher's stone of coding

prisma nebula
#

Shouldn't they do ais for that

lyric mountain
#

ai cant solve everything

prisma nebula
#

It could

lyric mountain
#

nah, they simply can't read your mind to be able to write a code that maintains the exact same functionality

#

don't be lazy, eventual refactors are commonplace

quartz kindle
#

im refactoring my shit rn lol

#

changing a bunch of stuff

prisma nebula
#

I have tons of thing to do I mean can't they translate

lyric mountain
#

me too, still on it for a year already

lyric mountain
#

get ur hands on the dough and start shaping that bread

prisma nebula
#

I was building my dream bot when I got scammed and now I just need a small bot for a hobby

prisma nebula
quartz kindle
# prisma nebula I have tons of thing to do I mean can't they translate

if you want to own a discord bot, then you will have to maintain it as well, its part of the job.
you will make code for one specific version, then when there is an update, you need to check what was updated, and check if those updates affect your bot, and if they do, you will have to adapt your bot to the new versions, or stay in the old version and risk your bot breaking at some point

#

thats what being a developer means

prisma nebula
#

Yes but it hurts me anyways now ill consider my small bot my new baby

lyric mountain
prisma nebula
#

It had everything

#

It is like mee6 and Carl combined

#

Anyways now I have a new baby

#

😁

#

I'll start from tomorrow

quartz kindle
#

good luck!

prisma nebula
#

Thanks

hushed robin
#

☹️

quartz kindle
# lyric mountain me too, still on it for a year already

paradigm cycle:
you start writing a giant procedural shit
rewrite everything into classes because oop is cool
realize you made a huge mess and is a pain to maintain
rewrite everything into small functions and go functional style <- this is where i am now lmao

hushed robin
#

I don’t get the point of classes

lyric mountain
#

just use normal git, or the one included in vscode

hushed robin
#

GitHub is stupid

#

it deleted all my code

peak drum
hushed robin
#

so I’m switching to gitlab

lyric mountain
quartz kindle
#

top.gg server just went offline for like 30 sec

peak drum
hushed robin
lyric mountain
#

be it github, gitlab, bitbucket, svn, whatever, if you don't pay attention to what ur doing the same will happen again

hushed robin
#

bro

#

I didn’t do anything

lyric mountain
#

FFS DISCORD LEMME ARGUE

lyric mountain
quartz kindle
#

lmao again

quartz kindle
# hushed robin it is basically

git is a versioning system that manages files
github is a platform that hosts files for you and uses the git system to sync them
gitlab is also a platform that hosts files for you and uses the git system to sync them

lyric mountain
#

for context tim, e0c resetted his entire 4-day uncommited project

quartz kindle
#

rip

#

tbh i also have a giant backlog of uncomitted stuff

#

but i have a second backup on google drive lel

lyric mountain
#

I commit after every single time I leave the keyboard

quartz kindle
#

i dont

#

lmao

lyric mountain
#

danger boy

quartz kindle
#

also

#

tiny-discord

#

havent worked on it in months

#

sometimes i change a bunch of stuff, then leave it shelved for a while

#

when i go back to it i have to relearn wtf did i change and why

#

and i dont wanna commit because many changes are not finished so the code is pretty much in a broken state

hushed robin
#

GitHub desktop deleted my bots rewr it e that took days to make

quartz kindle
#

well then that happens its likely because you did something wrong

#

and also, i have a backup on google drive

hushed robin
#

I did everything right

#

GitHub Desktop is glitched

quartz kindle
#

yeah right

hushed robin
#

then all my code reverted to old code

wheat mesa
quartz kindle
#

Lol

quartz kindle
#

it never happened to me

#

but in any case its good to have backups

#

i have all my projects in a folder that autosyncs with google drive

hushed robin
#

why

proven lantern
#

@hushed robin status update?

hushed robin
#

blocked 👍

proven lantern
#

oh, i know how to revert code after a git commit

hushed robin
#

how do I fetch a message in discordjs

quartz kindle
#

channel.messages.fetch(id)

hushed robin
#

what if I wanna

#

fetch from any channel

#

do I need to looo through all the channels

quartz kindle
#

messages belong to channels

#

there is no way to find messages if you dont know the channel

#

also there is no way to search through messages through the api

#

discord does not expose the search api that we have in the discord client

hushed robin
#

so in conclusion I need to

quartz kindle
#

by what criteria are you trying to find the message?

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

quartz kindle
#

nice

hushed robin
quartz kindle
#

link soon™️ maybe?

quartz kindle
hushed robin
sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

quartz kindle
#

not possible

hushed robin
#

it is

sage bobcat
#

One message removed from a suspended account.

hushed robin
#

I will just loop through all channels

#

to fetch message

quartz kindle
quartz kindle
#

surely not "all discord channels in all servers ever"

hushed robin
#

yea

sage bobcat
#

One message removed from a suspended account.

wheat mesa
sage bobcat
#

One message removed from a suspended account.

hushed robin
wheat mesa
#

It’ll be funny if someone uses that feature on a server with hundreds of channels

#

Enjoy your ratelimiting

hushed robin
#

it’ll be fine

wheat mesa
#

Famous last words

sage bobcat
#

One message removed from a suspended account.

quartz kindle
#

enjoy trying to guess channel ids as well

wheat mesa
#

I do

hushed robin
wheat mesa
#

Much more than I could do 😭 I hate frontend

hushed robin
#

I will just loop through them all

quartz kindle
#

there is no way to list all channels in discord

sage bobcat
hushed robin
#

there is

quartz kindle
#

from a server yes, not for all discord

hushed robin
#

client.guilds.cache

quartz kindle
#

thays for a server, not for entire discord

#

and in the very least you need to know the guild id

hushed robin
#

well ofc I’m not going to check the entirety of discord

#

If my bots isn’t in the server it can’t edit the message anyways

#

lol

quartz kindle
#

so if you already need tje guild id along with the message id, why not add the channel id

hushed robin
#

I don’t need the guild id

#

client.guilds.cache will give me all of my bots cached channels in all guilds

#

which since I have the guilds intents it will be all of them

quartz kindle
#

so instead of searching throight a couple dozen channels you want to search through thousands of channels

#

got it

earnest phoenix
#

Who the hell at GitHub fucked up the C syntax highlighter hd_skull

wheat mesa
#

Smartest battleless solution

wheat mesa
quartz kindle
#

good luck having your search be stupidly slow and cause rate ljmit errors

hushed robin
#

since this bot is only for my server

wheat mesa
#

50 is a lot when you’re fetching

#

Could literally save yourself a ratelimit nightmare by just saving one channel ID

#

It’s not that hard

#

You’re acting like it’s rocket science

hushed robin
#

but that’s an extra value for the person to add

quartz kindle
#

there is absolutely no reason not to save the channel id

hushed robin
#

I’d prefer a more user friendly experience

earnest phoenix
quartz kindle
#

huh???

wheat mesa
quartz kindle
#

wym friendly user exoerience, how is the user chosing whicj message to save?

earnest phoenix
hushed robin
#

bc they can pick whichever one they want

quartz kindle
#

so whayever message they picked, save its channel id as well

#

the user doesbt need to tell you, you get ir from the message

hushed robin
#

bru

#

u just said I can’t fetch a message without the channel

#

they user will provide the message I’d

quartz kindle
#

you want the user to give you a message id ?

#

thats not very user friendly eitherway lol

hushed robin
#

😐

quartz kindle
#

its more user friendly if you ask for a message link for example

wheat mesa
#

Can you even copy message IDs without developer mode on?

quartz kindle
#

since the user can just right click and copy message link

quartz kindle
#

the nessage id you only get with dev mode enabled

#

a lot of users dont know how to get it

hushed robin
#

maybe I’ll just scrap this totally

wheat mesa
#

Good idea 👍

hushed robin
#

why are you always hating

proven lantern
wheat mesa
hushed robin
sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

hushed robin
dusk field
#

Does anyone want to help me solve an error exam?

#

@sage bobcat help me

rustic nova
#

Probably a bad idea to help you in an exan

#

exam

#

Figure it out yourself, if you can't, keep a note of it and try to learn about it

hushed robin
#

can u use followUp on an interaction you've already replied to?

#

i thought u could

pale vessel
#

you could

hushed robin
#

why am i getting Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.

#
if (!queueData.channel || !queueData.message) return await interaction.followUp({
            content: `The queue message has not been sent!`,
            ephemeral: true
        });
pale vessel
#

the interaction should be a new one I believe

#

it would not work if you reply, and then do a follow up under the same interaction

hushed robin
#

then wtf is the point of it

hushed robin
#

how do i add a user channel permission in discord.js

hushed robin
#

nvm

prisma nebula
#
const { Client, Intents, MessageEmbed } = require('discord.js');

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

client.once('ready', () => {
  console.log(`Logged in as ${client.user.tag}`);
});

client.on('interactionCreate', async (interaction) => {
  if (!interaction.isCommand()) return;

  const { commandName, options } = interaction;

  if (commandName === 'addiots') {
    const name = options.getString('name');
    const info = options.getString('info');
    const image = options.getString('image');

    // Your code to add the iots with the provided information goes here

    await interaction.reply(`Added iots: ${name}`);
  } else if (commandName === 'checkiots') {
    const name = options.getString('name');

    // Your code to retrieve information about the specified iots goes here

    const embed = new MessageEmbed()
      .setTitle(name)
      .setDescription('Some information about the iots');

    await interaction.reply({ embeds: [embed] });
  } else if (commandName === 'updatechannel') {
    const channel = options.getChannel('channel');

    // Your code to update the channel for sending iots information goes here

    await interaction.reply(`Updated channel to: ${channel}`);
  } else if (commandName === 'addpress') {
    // Check if the user is the owner of the bot
    if (interaction.user.id !== '1002843443992743996') {
      return await interaction.reply('You are not authorized to use this command.');
    }

    

    await interaction.reply('Press added successfully.');
  } else if (commandName === 'addadmin') {
    // Check if the user is the owner of the bot
    if (interaction.user.id !== '1002843443992743996') {
      return await interaction.reply('You are not authorized to use this command.');
    }

    const admin = options.getUser('admin');

    // Your code to add an admin goes here

    await interaction.reply(`${admin} has been added as an admin.`);
  }
});

client.login('');
#

Those should be now done

#

Now time to read

lament rock
#

So much work but really happy with the outcome :)

hushed robin
lament rock
#

profiles

hushed robin
#

for what

lament rock
#

my bot??

hushed robin
#

what’s your bot

lament rock
hushed robin
#

nice

hushed robin
prisma nebula
#

V 14

hushed robin
#

that’s v13 code

#

Intents is now GatewayIntentBits

#

and MessageEmbed is now EmbedBuilder

prisma nebula
#

Those all I need to replace?

hushed robin
#

yes

prisma nebula
#

Okay I'll do them and send

hushed robin
#

GatewayIntentBits.Guilds instead of Intents.Flags.Guilds

prisma nebula
#

Owh

#

I just need to change that small part

#

Not all

#

Right?

hushed robin
#

yea

prisma nebula
#

Thabbbkkks

hushed robin
#

then u need to change MessageEmbed to EmbedBuilder

#

and it may work

#

idk though cus that’s v13 code

#

you still may need to update some parts

#

u need to require GatewayIntentBits from discord.js

prisma nebula
#

Like

hushed robin
#

like 😋

prisma nebula
#
const { Client, Intents, EmbedBuilder, GatewayIntentBits } = require('discord.js');

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

client.once('ready', () => {
  console.log(`Logged in as ${client.user.tag}`);
});

client.on('interactionCreate', async (interaction) => {
  if (!interaction.isCommand()) return;

  const { commandName, options } = interaction;

  if (commandName === 'addiots') {
    const name = options.getString('name');
    const info = options.getString('info');
    const image = options.getString('image');

    // Your code to add the iots with the provided information goes here

    await interaction.reply(`Added iots: ${name}`);
  } else if (commandName === 'checkiots') {
    const name = options.getString('name');

    // Your code to retrieve information about the specified iots goes here

    const embed = new EmbedBuilder()
      .setTitle(name)
      .setDescription('Some information about the iots');

    await interaction.reply({ embeds: [embed] });
  } else if (commandName === 'updatechannel') {
    const channel = options.getChannel('channel');

    // Your code to update the channel for sending iots information goes here

    await interaction.reply(`Updated channel to: ${channel}`);
  } else if (commandName === 'addpress') {
    // Check if the user is the owner of the bot
    if (interaction.user.id !== '1002843443992743996') {
      return await interaction.reply('You are not authorized to use this command.');
    }

    await interaction.reply('Press added successfully.');
  } else if (commandName === 'addadmin') {
    // Check if the user is the owner of the bot
    if (interaction.user.id !== '1002843443992743996') {
      return await interaction.reply('You are not authorized to use this command.');
    }

    const admin = options.getUser('admin');

    // Your code to add an admin goes here

    await interaction.reply(`${admin} has been added as an admin.`);
  }
});

client.login('');
hushed robin
#

well

#

did you try it

prisma nebula
#

Yes it logged

#

Now need to check commands

#

Bot online but no commands

hushed robin
#

well

#

the code above doesn’t register any commands

#

so that’s why

peak drum
prisma nebula
#

Oh

#

Okay

prisma nebula
#

I didnt really understand how to register a command

#

It require coding or something else?

deft wolf
#

Just a little bit of rest request

prisma nebula
#

I need to create handler file

#

And make a sheet for every command?

earnest phoenix
#

Pretty explains every step thoroughly

prisma nebula
#

@earnest phoenix so in my index their is the codes for slash commands (string roles user etc....)
So i need to create commands folder and add for example addadmin. Then what to do

#

The codes of it are in index

#

Iam not professional sorry if they are dumb questions

earnest phoenix
#

Take the lines of code belonging to the specific commands and convert them to slash-commands, and separate them to different files like shown in that guide

prisma nebula
#

They are already slash commands so I skip the convert thing ?

earnest phoenix
#

Sure, then put them in different files in that commands directory that you've got, and follow the instructions outlined in the guide

prisma nebula
#

Okay

prisma nebula
#

@earnest phoenix iam testing it only on addadmin rn and still not showing I've moved codes to addadmin.js in commands file and placed this in index :


client.commands.set('addadmin', require('./commands/addadmin')); 


I added deploy command and file

const { REST } = require('@discordjs/rest'); const { Routes } = require('discord-api-types/v9'); const { token, clientId, guildId } = require('./config.json'); const commands = [   require('./commands/addadmin'),   const rest = new REST({ version: '9' }).setToken(token);  (async () => {   try {     console.log('Started refreshing application (/) commands.');      await rest.put(       Routes.applicationGuildCommands(clientId, guildId),       { body: commands },     );      console.log('Successfully reloaded application (/) commands.');   } catch (error) {     console.error(error);   } })();

I also added config.json

#

And the command still not showing

lyric mountain
#

2 things

#

unless you want to eventually lose your bot, put token in replit secrets, instead of a plain json

#

and u don't need to create another client, or should, simply pass the client to the commands

#

I've formatted that code, no idea how you're coding like that

#

there's an error on the commands line

deft wolf
#

Are you gonna tell him? kappalul

lyric mountain
prisma nebula
#

Their is not error in my thing

lyric mountain
#

if the code you sent is the full code, then yeah there's an error

prisma nebula
#

It is not

#





const { SlashCommandBuilder } = require('discord.js');

if (commandName === 'addadmin') {
    // Check if the user is the owner of the bot
    if (interaction.user.id !== '1002843443992743996') {
      return await interaction.reply('You are not authorized to use this command.');
    }

    const admin = options.getUser('admin');

    // Your code to add an admin goes here

    await interaction.reply(`${admin} has been added as an admin.`);
 }
#

Here for addadmin in commands file

prisma nebula
#

And here for deploy