#development

1 messages ยท Page 2030 of 1

dry imp
#

do it on on_message function under msg declaration

quartz kindle
#

see? everything i said holds true

#

you were doing the wrong thing all this time

#

and refusing to show us

fossil bone
#

.-.

#

bruh

#

bruuuuuuuuuuh

sharp geyser
#

How da heck do I make a ready event request thingy

quartz kindle
sharp geyser
#

I am but not getting anything back

quartz kindle
#

you will receive more stuff as soon as you send the identify

sharp geyser
#

I sent the indentify but I get nothing back after

quartz kindle
#

then you're doing something wrong

#

show cod

fossil bone
sharp geyser
#
ws.on('message', (message) => {
    const data = JSON.parse(message.toString())
    console.log(data)
    
    switch (data.op){
        case GatewayOpcodes.Hello:
            const heartbeat_interval = data.d.heartbeat_interval;
            ws.send(JSON.stringify({
                op: GatewayOpcodes.Heartbeat,
                d: heartbeat_interval
            }))
            break;
        case GatewayOpcodes.HeartbeatAck:
            console.log(data)
            break;
        case GatewayOpcodes.Identify:
            ws.send(JSON.stringify({
                op: GatewayOpcodes.Identify,
                d: {
                    token: 'discord yelled at me not to send it',
                    intents: 513,
                    properties: {
                        "$os": "win32",
                        "$browser": "strife",
                        "$device": "strife"
                    }
                }
            }))
            break;
    }
})
quartz kindle
#

you have to send them

sharp geyser
#

Ah wait you right

#

So should I send it when I get an acknowledged heartbeat?

quartz kindle
#

this is what they send you

#

those are the things you make a case for

#

everything else its you that has to send

sharp geyser
#

I see, so I assume i would send the indentify when they acknowledge my heartbeat right?

quartz kindle
#

you can send an identify right after you receive the hello

sharp geyser
#

gotcha

#

too big

#

:^)

#

but ye it worked thanks tim :)

quartz kindle
#

also your heartbeating is wrong

sharp geyser
#

oh?

fossil bone
#

anyway got any other solutions?

quartz kindle
#

in the d key you have to send the sequence number, not the interval

fossil bone
#

i did what u asked me to do

quartz kindle
#

everything you receive after hello, will have a sequence number here

#

the first heartbeat you can send d: null, but every heartbeat after that, you have to send the sequence number of the last packet you received

fossil bone
#

ok sorry to interrupt

#

i'll just show myself out ๐Ÿ™‚

quartz kindle
#

and the heartbeat_interval you use to create a setInterval to send a heartbeat every x time

sharp geyser
#

ah

#
            setInterval(() => {
                ws.send(JSON.stringify({
                    op: GatewayOpcodes.Heartbeat,
                    d: data.s
                }))
            }, data.d.heartbeat_interval)

so it would essentially be this?

quartz kindle
fossil bone
#

i deserve this

#

it fkn prints nothing

#

nada

quartz kindle
fossil bone
#

pls understand it needs a pulsee to work

#

without a pulse it won't print anything

quartz kindle
#

for example js if(data.s > sequence) { sequence = data.s; } then ```js
d: sequence

fossil bone
#

๐Ÿ™‚

quartz kindle
#

and store sequence somewhere

sharp geyser
#

Could I use a map or something similar then?

#

or would it not matter just putting it in a variable

quartz kindle
#

doesnt really matter where you store it

fossil bone
#

ok i'm thinking of using javascript

quartz kindle
#

if later on you make it into a class, you will store it in the class somewhere

fossil bone
#

can one use csv with javascript?

quartz kindle
#

like this.sequence

quartz kindle
fossil bone
#

ok

sharp geyser
#

Yea I plan on using classes I am just trying to get a basic understanding of the gateway right now :^)

dry imp
fossil bone
#

recommend it for me?

sharp geyser
#

My issue later on though will be how I wanna structure the package when I actually start going for it

fossil bone
#

like best programming language for discord bots?

solemn latch
#

most devs here are js devs, so we will recommend js.

sharp geyser
quartz kindle
#

at this point i would recommend using botghost or discord bot maker

#

lmao

solemn latch
#

its probably best to not ask this community alone, but multiple communities, or do your own research

wheat mesa
dry imp
wheat mesa
#

anything but python is the best language

fossil bone
#

ok but it's like a sea i mean i'd need a lot to do anything with it

dry imp
#

what lang do u know?

quartz kindle
#

let me guess, nada?

fossil bone
#

i made a dumb bot with js before but i had to torture some one for it and he almost dioed

#

so i decided to try python

quartz kindle
#

lord almighty

fossil bone
#

now i need another sould for my bot

#

soul

dry imp
#

so... you decided to learn bot dev before learning the language?

fossil bone
#

lol

solemn latch
#

my general reccomendation is do 2-5 small other projects and maybe 1-2 big projects with a language before bot development

fossil bone
quartz kindle
#

start with a calculator that has every answer hardcoded

solemn latch
#

o

lament rock
#

A bot was how I learned to code. Was a pain in the ass, but I turned out okay. Didn't really bother with basic language issues either so I'm kinda proud

solemn latch
fossil bone
#

i know C C++ and python but my memory is like RAM

dry imp
#

wwhat

quartz kindle
#

x doubt

fossil bone
#

'-'

#

i made websites

solemn latch
#

websites are mostly markup though

#

not an actual programming language.

fossil bone
#

then i deleted them because i hosted them in an indian website

earnest phoenix
fossil bone
#

i'm good at programming i just have to store my memory every where and explain to me what i stored because after i sleep i lose some memory of what i've done

sharp geyser
wheat mesa
#

programming isn't about memory

fossil bone
#

-_-

wheat mesa
#

programming is about knowing how to use your tools to solve complex problems

sharp geyser
#

which I don't ^

dry imp
#

using google is not a shame

#

you dont need to remember everyhing

wheat mesa
#

90% problem solving, 5% IDE suggestions, 105% stackoverflow, 5% memorizing syntax

#

(we're not good at math)

fossil bone
#

i rather ask the humans

solemn latch
#

google is very pog

fossil bone
#

i don't always use google

sharp geyser
#

@quartz kindle I have question

fossil bone
#

but i do tho

wheat mesa
#

google should be your first resource when you have a question

sharp geyser
#

If I am sending an indentify every heartbeat ack will that fuck shit up?

wheat mesa
#

when your question becomes too obscure or complex to ask google, that's when you ask other people

austere surge
#

so probably

sharp geyser
spark flint
sharp geyser
#

Actually nvm ye you right

austere surge
fossil bone
#

anyway thnx for your trying to help i'll find me another apprach to it

wheat mesa
#

by the way, I'm working on a framework in Java for making CLI commands quickly and reliably, how does this look? ```java
@TextCommand(
name = "test"
)
public class TestCommand extends BaseCommand implements DisposableArguments {
static class TestCommandArgs {
public String name;
public int age;
}

private TestCommandArgs parsedArgs = new TestCommandArgs();

public TestCommand() {
    super("test");
}

@Override
public void run(String[] args) throws CommandException {
    parseArgs(args);
    System.out.println(
            "You used the "
                    + getName()
                    + " command. Your name is "
                    + parsedArgs.name
                    + ". Your age is "
                    + parsedArgs.age
                    + ".");
}

@Override
public String getDescription() {
    return "A test command.";
}

private void parseArgs(String[] args) throws CommandException {
    args = CommandUtils.removeEmptyArgs(args);

    if(args.length < 2) {
        throw new CommandException("Too few arguments provided.");
    }

    parsedArgs.name = args[0];
    if(CommandUtils.tryParseInt(args[1])) {
        parsedArgs.age = Integer.parseInt(args[1]);
    } else {
        throw new CommandException("Second argument must be a valid integer value.");
    }

}

@Override
public void disposeArguments() {
    this.parsedArgs = new TestCommandArgs();
}

}

sharp geyser
#

absolute ass

wheat mesa
#

you look like absolute ass misty

sharp geyser
#

ok woah

fossil bone
#

btw if you noticed the -,*,/,+ are the ones needed in a calculator so a smart person would recognize that i was trying to made a bot that is able to do calculations, the code for that is already done i needed to make sure the bot would recognize the operators in a message to understand that the user is trying to make a calculation and thus helpin them(the user) out

#

but i'll go the hard way for that as usual

quartz kindle
#

dude just use loops then

fossil bone
#

the hard way always works

quartz kindle
#

for each character in the string, check if it equals one of those operators

#

you dont need to overcomplicate it if you're having trouble getting it to work

#

just do it as simply as you can

#

the way you know how

fossil bone
#

now i have to do it that way

wheat mesa
#

loops... make it so you have less lines...

fossil bone
#

the old boring way

sharp geyser
#

tim I think I am doing something majorly wrong

wheat mesa
#

you could write a full on recursive descent parser and have more lines of code instead if you'd prefer :^)

sharp geyser
#

giving them too much credit waffle

quartz kindle
#

also less lines does not necessarily mean more performance

fossil bone
earnest phoenix
#

Smaller != Better

solemn latch
#

honestly, I often code with more lines intentionally

wheat mesa
#

there's probably hundreds of mathematical operators out there

#

write more lines now, write less later

#

much easier

sharp geyser
#
let seq = null;

ws.on('message', (message) => {
    const data = JSON.parse(message.toString())
    console.log(data)

    switch (data.op){
        case GatewayOpcodes.Hello:
            setInterval(() => {
                ws.send(JSON.stringify({
                    op: GatewayOpcodes.Heartbeat,
                    d: data.s
                }))
            }, data.d.heartbeat_interval)
            break;
        case GatewayOpcodes.HeartbeatAck:
            console.log(data)
            if(data.s < seq) {
                seq = data.s
            }
            if(seq === null) {
                ws.send(JSON.stringify({
                    op: GatewayOpcodes.Identify,
                    d: {
                        token: 'dasd',
                        intents: 513,
                        properties: {
                            "$os": "win32",
                            "$browser": "strife",
                            "$device": "strife"
                        }
                    }
                }))
            }
            break;
    }
})

So I think this is failing to do what I meant it to do. It seems like every heartbeat ack it is sending the indentify (unless discord just ignores any after the initial identify)

fossil bone
wheat mesa
#

case and point

wheat mesa
quartz kindle
wheat mesa
#

unlucky

sharp geyser
#

ye waffle

#

you are very wrong

#

get good

wheat mesa
#

totally didn't mean to reply to misty

fossil bone
#

anyway i'll come back to ask how to fetch so good quality pics from REddit subs lol so be prepared for future me :p

#

some*

sharp geyser
#

or just dont

#

:)

wheat mesa
#

fetch some bitches misty

sharp geyser
#

ok one pump chump

sharp geyser
#

Wait what

fossil bone
#

js is a headache x-x

sharp geyser
#

so are you saying during the Hello I should make the indentify ?

quartz kindle
#

and sequences have to be recorded on every packet

sharp geyser
#

Ah

quartz kindle
#

not acks

#

you dont really need acks for anything basically

#

they're just there to confirm your heartbeat was received

#

also

sharp geyser
#

right also

quartz kindle
#

and data.s > seq

#

not < seq

sharp geyser
#

is there a reason it responds twice with the heartbeat ack?

quartz kindle
#

because you console.log it twice

sharp geyser
#

Right :^)

#

I forgor about that one

sharp geyser
#

Does it just increment or is it a random one every time?

quartz kindle
#

it increments on every single packet after hello

sharp geyser
#

Mmmm

#

Then it seems to be stuck on 2

quartz kindle
#

because you stop receiving? or did you receive multiple packets with the same sequence (which is not possible)?

sharp geyser
#

Well I am still receiving the heartbeat ack every 41 seconds roughly

#

so that means it should increment right?

quartz kindle
#

pretty sure acks dont count

sharp geyser
#

Mmm I thought they would

quartz kindle
#

they are a reponse to something you sent

#

the sequence is for stuff discord sends

sharp geyser
#

gotcha

quartz kindle
#

did you receive a READY after sending the identify?

sharp geyser
#

Yea

quartz kindle
#

then from there on you should start receiving data

sharp geyser
#

Mmmm there must be some data I am not known about since the seq should be 1 if that was the case right?

quartz kindle
#

what are you seeing in your data?

#

like guilds, messages, etc

sharp geyser
#

I am just seeing the initial heartbeat interval thing and getting back the ready event with a s of 1

quartz kindle
#

and nothing else after that?

sharp geyser
#

actually yea fucking webstorm displayed it weird

#

I am noticing a guild create

quartz kindle
#

so yeah each of those should have an increasing sequence

sharp geyser
#

Gotcha

#

This is starting to get fun now that I am starting to understand it more

quartz kindle
#

:)

sharp geyser
#

So how do logins work?

#

like do you know what djs does with the login method they have?

#

I assume it is something separate from the indentify or am I wrong?

quartz kindle
#

nah, its just the identify and setting up the sequences/heartbeats/etc

#

the login method creates a new WebsocketShard instance, if it doesnt exist yet

#

then the WebsocketShard instance connects to /gateway/bot

#

then connects to websocket

sharp geyser
#

Mmmm

quartz kindle
#

and identifies

sharp geyser
#

Sounds like a lot

quartz kindle
#

and sets up the sequences and heartbeats to keep alive

#

as well as all the shit to reconnect/resume/etc

#

the READY event has an array of guild ids

#

those guilds are added to the guild cache as unavailable guilds

#

then it receives a bunch of GUILD_CREATE events

#

that will fill up the data for the guilds in the cache

#

after all guilds are accounted for, it emits the client ready event

sharp geyser
#

omfg

#

that is a headache

#

:^)

quartz kindle
#

if you use internal sharding

#

basically do the same, but with multiple websocket instances

dry imp
#

so much words and letter

quartz kindle
#

if you're lazy feel free to steal my websocket code lel

sharp geyser
#
 async connect() {
    const invalidToken = new Error(WSCodes[4004]);
    const {
      url: gatewayURL,
      shards: recommendedShards,
      session_start_limit: sessionStartLimit,
    } = await this.client.api.gateway.bot.get().catch(error => {
      throw error.httpStatus === 401 ? invalidToken : error;
    });

    const { total, remaining } = sessionStartLimit;

    this.debug(`Fetched Gateway Information
    URL: ${gatewayURL}
    Recommended Shards: ${recommendedShards}`);

    this.debug(`Session Limit Information
    Total: ${total}
    Remaining: ${remaining}`);

    this.gateway = `${gatewayURL}/`;

    let { shards } = this.client.options;

    if (shards === 'auto') {
      this.debug(`Using the recommended shard count provided by Discord: ${recommendedShards}`);
      this.totalShards = this.client.options.shardCount = recommendedShards;
      shards = this.client.options.shards = Array.from({ length: recommendedShards }, (_, i) => i);
    }

    this.totalShards = shards.length;
    this.debug(`Spawning shards: ${shards.join(', ')}`);
    this.shardQueue = new Set(shards.map(id => new WebSocketShard(this, id)));

    return this.createShards();
  }

so this is what djs does when using the login method

quartz kindle
#

yup

sharp geyser
#

Mmm I don't really wanna model after djs tho

#

I guess I should start actually developing this library though

quartz kindle
#

sure

#

you still need to add the resuming stuff

sharp geyser
#

Yea I will figure that out as I go

fossil bone
#

IT WORKS

#

IT FUCKING WORKS

#

T^T

quartz kindle
#

congrats

fossil bone
sharp geyser
#

Well fuck I am stumped on what I should do first when actually making the WebsocketManager

#

๐Ÿ˜”

#

love it when I know what to do but now how i should do it

quartz kindle
#

if you wanna go straight into internal sharding, first step is connect to /gateay/bot

fossil bone
#

i can't believe i could do it all this time if i didn't just be stupid to try stupid new things

quartz kindle
#

then create multiple websockets

sharp geyser
#

wtf

fossil bone
#

lol

sharp geyser
#

my shit got deleted

fossil bone
#

seen that

sharp geyser
#

BRUH

#

@lost berry why my stuff being deleted

#

;c

fossil bone
#

it's not deleted for all tho

#

some still can see it

#

like mods looooool

sharp geyser
#

I bet it is probably some scam protection thing

#

yep

fossil bone
#

yea prolly cuz you sent like 100 code in one night

#

one of them must've been like .-. this dude

sharp geyser
#

nah it is likely cause some bot is noticing a discord link and thinks it is a scam link

lost berry
#

uhhh

#

lemme see

#

well our scam bot would've kicked you

#

im not really sure what happened ngl

fossil bone
#

RIP X'D

sharp geyser
#

It deletes the link when I send it

quartz kindle
#

wait you have a scam bot that auto kicks?

sharp geyser
#

it is just the gateway link

quartz kindle
#

what if i post a scam link as a joke

fossil bone
#

X'D

sharp geyser
#

well tim this is what I was trying to do at first but realized doing the websocket like this might not work in the long run and will just get annoying

import { EventEmitter } from 'node:events'
import WebSocket = require("ws");
export class WebsocketManager extends EventEmitter {
    private sequence = null;
    public ws = new WebSocket('gatewaylink/gateway/bot?v=9&encoding=json')

    constructor() {
        super();
    }

    async connect() {
        
    }
}
lost berry
#

yea we use zerotwo to protect against all of those scam messages

quartz kindle
#

since you will need to destroy it and recreate it when resuming for example

sharp geyser
#

Mmmm

#

See I tried looking at your tiny-discord code and it all looked very confusing

#

:^)

quartz kindle
#

xD

lament rock
#

I actually wouldn't recommend trying to make your own gateway implementation and instead just rely on some low level module like cloudstorm or tiny-discord or detritus ws module

#

Not because I want you to use one of them specifically, but because it's really difficult

quartz kindle
#

but thats kinda why its fun

lament rock
#

Kinda yeah

quartz kindle
#

but well, also annoying af

sharp geyser
#

I wanna do it all myself for the learning experience

#

I wouldn't be making my own discord lib if I didn't wanna learn how the internals work

quartz kindle
#

its fun at the beginning, but then it gets annoying when you're just hunting and patching flaws and edge cases and connection issues

sharp geyser
#

so what is this tim

        const req = request({
            hostname: this.url,
            path: path,
            headers: {
                "Connection": "Upgrade",
                "Upgrade": "websocket",
                "Sec-WebSocket-Key": key,
                "Sec-WebSocket-Version": "13",
            }
        });
#

you seem to make a request to smth

quartz kindle
#

i made my own ws

sharp geyser
#

I see

quartz kindle
#

thats basically part of whe websocket spec

lament rock
#

Websockets are just http requests, but the connection isn't destroyed

quartz kindle
#

to verify that the websocket is conforming to the rules

sharp geyser
#

I see

quartz kindle
#

that code is basically useless

#

because the only target host is discord, and they would never not conform to those rules

sharp geyser
#

Mmmm makes sense

quartz kindle
#

i mean

#

this part

lament rock
#

Discord might go under and someone steal their domain

quartz kindle
#

this will basically never fire

#

but since it only happens once per connection its not really a meaningful performance hit

#

so i let it be

quartz kindle
#

and go straight to _processMessage()

fossil bone
#

ok so how's everyone doing? :^)

#

should i say or should i not

#

๐Ÿ™‚

#

ich habe a new error

quartz kindle
#

thats not the full thing, but from the looks of it you got cloudflare banned

#

wait about 1 hour and try again

fossil bone
#

O.O

#

it's

#

i can't live another hour

quartz kindle
#

go sleep

fossil bone
#

no

#

this is not related to my job but i want to do it

#

for fun

#

my sanity like the speedy NFT says lol

#

what have i done?

#

i feel like y'all escaping me lol

#

understandable

#

have a good night

#

i just added my calculator to the code and got cloudflare banned -_-

solemn latch
#

Is it possible you got a restart loop?

fossil bone
#

the only loop i added is the if / elif loop

#

and that too has an exit

#

maybe if i make it in a different class method and call it's result by the return in a different function

#

maybe that's what could be making it loop when a calculation is triggered

#

can't believe i'm the only one using python in this godforesaken website -_-

quartz kindle
#

no matter what you do, it will not stop erroring until the ban is lifted

fossil bone
#

yeah i'm also waiting for that

#

10 mins till the hour ends

sharp geyser
quartz kindle
#

basically what ws does for you

sharp geyser
#

I see

quartz kindle
#

the websocket protocol has its own opcodes and stuff

sharp geyser
#

so essentially I would just model after _processMessage?

quartz kindle
#

yup

fossil bone
#

ok i'm bored now fr braincrush.exe has been executed

#

i still got the same error like wtf now

#

aren't there calculator bots in discord? or is using a calculator forbidden in here

#

because i'm so moving on to the next step if so

#

i still got other plans to do

dry imp
wheat mesa
#

there's lots of calculator bots

#

but most of them use a 3rd party api like wolframalpha to do their calculations

austere surge
#

i once made a calculator out of buttons when they were introduced

#

though it broke

dry imp
#

hosting in replit is like playing russian roulette, never know when it will fuck u up

fossil bone
#

wait

#

one sec

#

it didn't show the error

dry imp
#

thays good then

sharp geyser
fossil bone
#

yea the return fuction i wrote isn't being called but at least that's one step forward

dry imp
#

do kill 1 every time there is a rate limit

fossil bone
#

it's not showing the calculations

dry imp
#

let the other suffer for your api abuse troll

fossil bone
quartz kindle
# sharp geyser Why do you make a timeout then a interval when sending the heartbeat?

thats what they ask you to do, although they are not strict about it, nothing will happen if you dont

After receiving Opcode 10 Hello, the client may begin sending Opcode 1 Heartbeat payloads after heartbeat_interval * jitter milliseconds (where jitter is a random value between 0 and 1), and every heartbeat_interval milliseconds thereafter. You may send heartbeats before this interval elapses, but you should avoid doing so unless necessary. There is already tolerance in the heartbeat_interval that will cover network latency, so you do not need to account for it in your own implementation - waiting the precise interval will suffice.

fossil bone
#

always must kill1 for code to work lol

dry imp
#

killing your container

fossil bone
#

XD

quartz kindle
#

they do that to randomize the timings for people to send their heartbeats and spread the load a bit more

fossil bone
dry imp
#

if you can automate that, there wont be any rate limit forever troll

sharp geyser
#

ah ok

#

I notice you set a lot of internal stuff

#

I should probably do the same

quartz kindle
#

not all of it is strictly necessary

sharp geyser
#

Ima just do the stuff I think is necessary

#

like the connectedAt, readyAt heartbeatInterval lastAck and such

quartz kindle
#

yeah, some stuff i might remove later, like the last sent and last received

sharp geyser
#

How do you think I should handle events?

#

like messageCreate guildCreate etc

quartz kindle
#

handle how? like creating structures like djs does?

fossil bone
#

fuck yeah

sharp geyser
#

Yea, I wanna make it as easy as possible for people to be able to use events

fossil bone
#

now i can go sleep T^T

sharp geyser
#

I was actually thinking of in this library bulding a build in event handler and command handler ya know

quartz kindle
#

you will need to look into djs since i dont use them

sharp geyser
#

Well really all I need to do is find a way to effectively make a event handler

quartz kindle
#

start by thinking what you would like to have if you were to use that event

fossil bone
#

ok turns out for some reason it's a little stupid can't count past ten but i'll look it over tomorrow

fossil bone
quartz kindle
#

like if you were to make a bot with your lib

#

what would you want the lib to do for you

fossil bone
#

to get dressed

quartz kindle
#

how would you want it to handle the events for you

fossil bone
#

not be visible to all devs lol

sharp geyser
#

Well I am trying to make a lib that is easy for beginners so I would like it to handle majority of the processing for me and just return the data for that event

quartz kindle
#

then do that

fossil bone
#

ok good night y'all :p

quartz kindle
#

log the event from discord and see what you can do with it

#

good night

sharp geyser
#

alrighty

#

I might take a rest here soon too I got school tmrw

quartz kindle
#

๐Ÿ‘

fossil bone
#

Almost forgotten lol

#

I'm gonna come back tomorrow to ask how to fetch images and posts from Reddit

#

So be prepared hehe

#

Y'all gonna be like oh fuck. This python dude again

dry imp
#

search for asyncpraw

#

or redditeasy

fossil bone
sharp geyser
#

or just write it down

#

:^)

fossil bone
#

Copied to the keyboard ๐Ÿ‘

#

Still can't believe it took me 30mins to write the code but a full night to run it

#

A whole night on discord to get it running T^T

dry imp
#

skill issue

fossil bone
#

Could've been worst if i just copy pasted it to the bot without testing the bot's capability of detecting all the operators '+,-,/,*'

fossil bone
fossil bone
lyric mountain
#

It's weird that u keep writing as a single string

wheat mesa
#

Just make it an array

#

15 thousand times easier

wary minnow
#

Help

sharp geyser
#

You provide no question, error or code

fossil bone
split hazel
#

bro was legit here before I went to sleep

#

which was 8 hours ago

lament rock
#

step 1: be an insomniac
step 2: nawbruh

fossil bone
#

Lol

tidal nymph
#

I started disabling some d.js caching and its actually less memory usage

slender thistle
#

We all have our struggles, it's okay

thick pebble
tidal nymph
#

depends on what your bot does I guess

valid sierra
#

hi, i am facing a problem with the permissions for my bot
it can't add a role

  • Bot's role higher than the role Check
  • Bot's role higher than the member's role Check
  • Bot has admin or manage role permissions Check
    Yet i still face this issue
  File "/home/container/.local/lib/python3.10/site-packages/discord/client.py", line 375, in _run_event
    await coro(*args, **kwargs)
  File "/home/container/griselda_blanco.py", line 153, in on_message
    await _function.voteFunction(int(userID))
  File "/home/container/griselda_blanco_cogs/functions.py", line 70, in voteFunction
    await member.add_roles(role)
  File "/home/container/.local/lib/python3.10/site-packages/discord/member.py", line 1012, in add_roles
    await req(guild_id, user_id, role.id, reason=reason)
  File "/home/container/.local/lib/python3.10/site-packages/discord/http.py", line 495, in request
    raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access```
quartz kindle
#

missing access is not a permission issue

#

it means your bot is trying to access something that it has no access for, or was deleted

#

for example trying to access a guild your bot is not in, or trying to access a channel that your bot cant see

rustic nova
#

seems to not be able to access something on a member, are you trying to direct-message a user when voting?

#

since you're calling add_roles too, is the member on the guild to begin with? is the bot also there?

dry imp
#

okay guys i have a question

#

is js easy?

earnest phoenix
#

i want to have all data in one collection form data & user details

lyric mountain
#

it goes from person to person

quartz kindle
#

easier than py in my opinion

#

but i never used py so im biased

#

:^)

fossil bone
# dry imp is js easy?

js isn't about easy it's a sea, u can never really say i got good at js because there's always something u didn't know yet, but it's not a bad language because you can achieve lots with it there's always more than a way to do anything with js unlike other languages that u only have one way only to do something, however it always requires a big number of lines to do the simplest thing.

#

or so i heard ๐Ÿ˜—

lyric mountain
#

that defines pretty much any language

#

more than a way to do anything with js unlike other languages that u only have one way
except for this, there are NO languages where there's only 1 way to do something

quartz kindle
#

the very requirement for something to be a programming language is the ability to do anything, including producing and running a copy of itself, so by default all languages can do anything in an infinite number of ways

lyric mountain
#

regex is turing complete

wary minnow
#

@spark flint sorry for the ping but which api key i can use in a music bot for lyrics

#

Earlier it was ksoft api

lyric mountain
split hazel
#

tf is a semaphore

lyric mountain
#

a traffic light but for code

split hazel
#

i need to implement it and its the first time i've seen it

#

is it so threads do things in a specific sequential order

wary minnow
#

@lyric mountain but how to get the key please tell me that also

lyric mountain
lyric mountain
earnest phoenix
#

const DiscordStrategy = require("passport-discord").Strategy;
const passport = require("passport");
const DiscordUser = require("../modules/DiscordUser");

passport.serializeUser((user, done) => {
console.log("Serializing user...");
done(null, user.id)
});

passport.deserializeUser(async (id, done) => {
console.log("Deserializing user...");
const user = await DiscordUser.findById(id);
if(user)
done(null, user);
});

passport.use(new DiscordStrategy({
clientID: process.env.CLIENT_ID,
clientSecret: process.env.CLIENT_SECRET,
callbackURL: process.env.CLIENT_REDIRECT,
scope: ["email", "identify"]
}, async (accessToken, refresToken, profile, done) => {
console.log(profile);
console.log(profile.email);
try {
const user = await DiscordUser.findOne({ discordId: profile.id })
if(user) {
{
console.log("User exists in our user DB...")
done(null, user);
}
}
else {
console.log("User does not exist in our user DB...")
const newUser = await DiscordUser.create({
discordId: profile.id,
username: profile.username,
email: profile.email,
tag: profile.discriminator
});
const savedUser = await newUser.save();
done(null, savedUser);
}
}
catch(err) {
console.log(err);
done(err, null);
}
}));

lyric mountain
#

In computer science, a semaphore is a variable or abstract data type used to control access to a common resource by multiple threads and avoid critical section problems in a concurrent system such as a multitasking operating system.

earnest phoenix
#

whats the problem please?

wary minnow
lyric mountain
split hazel
lyric mountain
#

mutex is 1<>1 usually

lament rock
earnest phoenix
lyric mountain
#

like, only 1 process can hold a mutex at any given time

#

while a semaphore is 1<>N

split hazel
#

wut

lyric mountain
#

like, there are 2 kinds of semaphores

#

counting and binaries

#

binaries are effectively mutexes

wary minnow
#

@lyric mountain is this the api key

earnest phoenix
lyric mountain
lyric mountain
earnest phoenix
#

and how i can fix it if you can tell me ๐Ÿ˜Š

lyric mountain
lament rock
#

By actually putting the env var in the env variables file or table on your host if it has that. Also make sure your env file is being loaded if it is a file

earnest phoenix
#

i dont have const env = require("../env")

#

?

wary minnow
split hazel
#

honestly i might just implement it without completely knowing the purpose

earnest phoenix
split hazel
#

it seems easy enough

lyric mountain
lyric mountain
lament rock
# earnest phoenix ..?

what do you not understand. If it's undefined then that key either isn't in the env file or the env file isn't being loaded at all

earnest phoenix
#

ah

lament rock
#

look at the env module to see how it works because you don't require it

#
earnest phoenix
earnest phoenix
lament rock
earnest phoenix
#

My guy, you're not supposed to directly import the .env file, you're supposed to load the environment variables using what Papi showed

#

Which'll load them to the process.env object

#

i have now this const env = require("../env)

#

but i have another problem

lyric mountain
#

for example

split hazel
earnest phoenix
#

@lament rock and @earnest phoenix thanks for helping

dry imp
#

lowkey wanna learn js

#

but i wanna learn lua

lyric mountain
#

from what I understood, a process can't hold a semaphore if there's no capacity

#

so basically a mutex with multiple uses

lament rock
#

JS can be fun, but really weird on edge cases and it's quite different in syntax

lyric mountain
split hazel
#

do you understand the purpose

#

im trying to i cant lmao

#

i'll just implement it and get on with my life

lyric mountain
#

to limit flow ig?

#

I mean, that also reflects real life semaphores

#

you have a crossroad, you need to limit flow to prevent disasters

earnest phoenix
lyric mountain
#

did you clone that project from somewhere?

lament rock
#

don't use body-parser for express. Express has one built in, so use that

split hazel
#

from a quick look i think its a multithread mutex kinda

lyric mountain
#

if u limit to 1 holder per thread, yeah

wary minnow
earnest phoenix
#

dedicated ubuntu

lyric mountain
#

you bought a dedi?

tidal nymph
#

if I build a crud app and I can do either Nestjs MVC or Nestjs + Vue, which way is faster?

lyric mountain
#

whatever u find easier

#

the bottleneck won't be what you use, but how you use

dry imp
#

anyone here good at lua?

sacred smelt
#

@lament rock how can i make that if i close server.js it will send before it webhook with: Server offline ๐Ÿ”ด

#

or someone

#

please

lament rock
#

listen for process kill signals like signal interrupt or signal kill

sacred smelt
#

please โค๏ธ

lament rock
#

no

#

โ™ฅ๏ธ

#

because its not recommended, because there are a ton of signals you have to possible account for and properly handle an exit

sacred smelt
sacred smelt
# lament rock no

can i use

process.on('exit',
const embed = new MessageEmbed()
.setTitle('Api Status:')
.setDescription('Offline ๐Ÿ”ด !')
.setColor('#5865f2');
console.log("[HEYDISCORD LOG] Webhook Api_Status was sened");
webhook.send
);

#

or

#

@lament rock

earnest phoenix
#

Use a codeblock at least, not an inline codeblock

sacred smelt
earnest phoenix
#

@lament rock or @earnest phoenix how can i make mongo db collection with discord user email name etc and data from form i still have errors

#

please help me

#

const DataSchema = {
Text: String,
// userId: String,
// Name: String,
// username: String,
// usertag: String
Email: String,
}

const Data = mongoose.model("Data", dataSchema)
const DiscordStrategy = require("passport-discord").Strategy;

app.post("/", function (req, res) {
let newData = new Data({
Text: req.body.data,
Email: WHAT HERE?
});
newData.save();
res.redirect('/')
console.log("New data:" + newFeedback);

lament rock
#

idk. I don't use mongo. Look at code which does similar stuff to you and take inspiration

rich iron
#

I don't understand why it doesn't work?

rustic nova
#

thats a direct file url, not a web url to an image

rose warren
#

Looks like Discord is getting their way darkAYA

#

At this rate my users will have probably almost completely adopted slash commands by this summer ๐Ÿ‘€

celest gate
#

hmm

rich iron
rustic nova
#

then you did not properly embed it, it has to be a direct image url

#

right click the image and copy image url

rich iron
#

nvm i figured it out

rose warren
#

I started tracking if commands being run are prefixed or slash back when I released slash commands to my bot

tired panther
#

Let me quickly aggregate my data

rose warren
#

Note the only advertising promoting the use of slash commands I've done is in the bot status where it says /help and on the Top.gg page. Otherwise, if my older users who are used to prefixes are still using their prefixed commands they would barely notice.

#

So I'm guessing a lot of the slash command users are new users but that's just a guess

#

Statistically, it should be a 50:50 split by the end of the month

solemn latch
#

thats just chart.js?

rose warren
#

It's not that sophisticated I'm just pasting the sql data into a google sheet KEKW but I use chart.js for my stats dash yep it's poggers

solemn latch
#

I want do make a trend line in chartjs, just havent even tried.
seems I need to calculate the trend on my own.

bright thorn
#

HELLO anyone using hybridesharding

whole stream
#

some reason my bot wont start up? Im new to coding can i have some help?

rose warren
whole stream
#

might be config.json

rose warren
bright thorn
#

๐Ÿ˜

#

and i just asking him that how we can map shard uptime for all shard

whole stream
#

node. is discord bot start-up?

earnest phoenix
earnest phoenix
bright thorn
#

but now i have to check uptime of all shards

#

how can i

earnest phoenix
whole stream
#

incorrect?

earnest phoenix
#

If you have index.js as your main file then yes that's correct, although I assume you're using discord.js but you don't have it installed

whole stream
#

sorry to ask.

earnest phoenix
#

in the start script you seem to be using tsc, did you write your bot in TypeScript?

whole stream
#

nope what i was told to type

#

its just a very basic js bot like a ping pong sorta thing

earnest phoenix
#

Then I would recommend removing the start script as it's incorrect in this case

#

And you can install discord.js by running npm i discord.js

whole stream
#

thank you very much, now it says node. is incorrect

#

so anything else i can run

whole stream
earnest phoenix
#

node ., a space between the node and .

whole stream
#

seems to work i think i might need to get a newer index.js whats the most basic script just to get the bot online?

winter pasture
earnest phoenix
#

*** I NEED HELP***
file: https://www.mediafire.com/file/e7ciy9z88p28hwy/login.rar/file
there is all files of login
and i need to import there to schema of feedbacks userID etc

and after i had app.js with this:

`const discordStrategy = require("./strategies/discordstrategy");

const feedbacksSchema = {
Text: String,
// userId: String,
// Name: String,
// username: String,
// usertag: String
Email: String,
}

const Feedback = mongoose.model("Feedback", feedbacksSchema)
const DiscordStrategy = require("passport-discord").Strategy;

app.post("/", function (req, res) {
let newFeedback = new Feedback({
Text: req.body.feedback_idea,
Email: WHAT HERE
});
newFeedback.save();
res.redirect('/')
console.log("[HEYDISCORD LOG] New idea: " + newFeedback);
})`

MediaFire
wheat mesa
#

@split hazel caught in 4k

split hazel
#

yea

#

was just making sure

#

very good server btw people there aren't stuck up like other cpp servers

lyric mountain
#

js isn't typed btw, so doing Text: String ur actually assigning the class itself

#

also use ```
for codes
see?
way better to read

#

and u can't get an user's email without using the scope

lyric mountain
#

you had what?

lethal pine
#
Require stack:
- C:\Users\savir\AppData\Local\npm-cache\_npx\c67e74de0542c87c\node_modules\readable-stream\transform.js
- C:\Users\savir\AppData\Local\npm-cache\_npx\c67e74de0542c87c\node_modules\through2\through2.js
- C:\Users\savir\AppData\Local\npm-cache\_npx\c67e74de0542c87c\node_modules\hyperquest\index.js
- C:\Users\savir\AppData\Local\npm-cache\_npx\c67e74de0542c87c\node_modules\create-react-app\createReactApp.js
- C:\Users\savir\AppData\Local\npm-cache\_npx\c67e74de0542c87c\node_modules\create-react-app\index.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (C:\Users\savir\AppData\Local\npm-cache\_npx\c67e74de0542c87c\node_modules\readable-stream\transform.js:1:18)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\savir\\AppData\\Local\\npm-cache\\_npx\\c67e74de0542c87c\\node_modules\\readable-stream\\transform.js',
    'C:\\Users\\savir\\AppData\\Local\\npm-cache\\_npx\\c67e74de0542c87c\\node_modules\\through2\\through2.js',
    'C:\\Users\\savir\\AppData\\Local\\npm-cache\\_npx\\c67e74de0542c87c\\node_modules\\hyperquest\\index.js',
    'C:\\Users\\savir\\AppData\\Local\\npm-cache\\_npx\\c67e74de0542c87c\\node_modules\\create-react-app\\createReactApp.js'
  ]
}``` how to fix this error i cant install react app
lyric mountain
#

install _stream_transform.js

#

whatever that is

fluid garden
#

Im repl.it i can link 2 project for one bot?

lyric mountain
#

a better question would be "why?"

#

you can, but why?

fluid garden
#

Cz first one have many files

#

The bot will not get issues?

lyric mountain
#

projects are meant to have many files

fluid garden
#

The index is like full

lyric mountain
#

then put things out of index

#

also it isn't full, unless u managed to write more than 2 billion lines

fluid garden
#

Tf

#

Wow

lyric mountain
#

and it isn't a limit, it's just how far you can go before most file readers refuse to open it

#

the amount of files/lines doesn't really matter, WHAT is in those files do

#

you can have a 100k lines bot be faster than a 50 lines one

spark flint
#

How come when I pass an array with ejs, it no longer acts like an array?

lyric mountain
#

wdym?

spark flint
#

ejs

#

the actual output is like 744657468222865438,[AUTOMOD] Sent PHISHING links,Blacklister#3409 (866364881917837312),3/5/22,784278333075750922,[AUTOMOD] Profile picture matched anti-scam filter,Blacklister#3409 (866364881917837312),3/5/22,840706801921163264,[AUTOMOD] Sent IP_LOGGER links,Blacklister#3409 (866364881917837312),3/5/22,724670236955246713,DM ads,big.bun#6969 (471409054594498561)

#

i added [] either side

lyric mountain
#

shouldn't u be using objects for each block?

fluid garden
#
Owo
lyric mountain
#

since they have a common structure

spark flint
#

The code does make it like tat

lyric mountain
#

no, I mean, here

spark flint
#

oh

#

thats how the js library i'm using for tables wants it

lyric mountain
#
{
  id: "12312512512",
  description: "[AUTOMOD] something",
  infractor: "black#1234 (id)",
  date: "3/5/22"
}
#

like this

spark flint
#

i would do it like that

#

but the lib doesn't want it like that

lyric mountain
#

eh

fluid garden
#

I have also a question

#

If some commands linked to a mongodb in a project i can make commands not related to that db

#

Right?

spark flint
#

yeah

lyric mountain
#

just remember to put each thing in the proper file

#

flooding index isn't the answer, albeit js allows it

#

index is like when u open a book and have a guide of where to open for a specific content

fluid garden
#

Iam working but the end is that bcz iam not 16+ and my bot in 60servers iam scared of a deletion

lyric mountain
#

this is an index

fluid garden
#

Oh

#

You gaved me the hint

#

I got it

lyric mountain
#

index.js should just guide the code to know where it can find the beginning (and stuff like creating bot client, setting endpoints, db connections, etc)

fluid garden
#

Ohh

opaque acorn
#

Ubuntu can be booted without graphic card?

quartz kindle
#

depends

#

if you have an integrated gpu, then your motherboard will have a video out plug even if you dont have a dedicated gpu

#

so yes it will work

#

but if your cpu does not have integrated graphics, or your motherboard does not have a video out, then you need a dedicated gpu to even have a video out plug to plug in your screen

#

if you're talking about network boot or vps, then yes it will work without gpu regardless

opaque acorn
#

Ok

#

Which format have the autoexecute?

quartz kindle
#

what is that?

opaque acorn
#

The extension

#

Of an autoexecutable file

sick agate
#

oh

quartz kindle
#

idk what that is

sick agate
#

on windows it depends on file format
on unix it depends onn? chmod type

fluid garden
#

Discord have a support server

#

?

past idol
#

You want an invite?

fluid garden
#

Yes pls

fluid garden
#

Ty

past idol
#

No problem.

lyric mountain
#

and what icon to put in it

#

they're entirely optional, such that linux doesn't even care abt them

#

I could rename chrome.exe to chrome.txt and still run it

sick agate
#

yup

#

windows cares about file extensions a bit

sick agate
lyric mountain
#

windows is sussy baka

sharp geyser
#

I still failed at making the basic part of library tho

#
Received hello. Heartbeat interval = 41250ms. First heartbeat in 18617ms
Identifying

This is the response I get from debug

quartz kindle
#

add a socket.on("close"

#

and log the close code

sharp geyser
#
Received hello. Heartbeat interval = 41250ms. First heartbeat in 33658ms
Identifying
Sending heartbeat
Sending heartbeat
Sending heartbeat
Sending heartbeat
Sending heartbeat
Sending heartbeat
Sending heartbeat

Well now I know why nothing is happening

#

It is spamming the gateway after the heartbeat interval is up

quartz kindle
#

you didnt add the timer to setinterval

#

but you should still get the ready before that

sharp geyser
#

Yea that is weird

quartz kindle
#

add the close event

#

maybe the connection was closed

sharp geyser
#

I did check it

#

Nothing logged

#

Just the gateway spam

sharp geyser
quartz kindle
#

you literally have a setInterval

#

with no interval

sharp geyser
#

it should?

#

oh shit you right

#

I forgot that part :^)

quartz kindle
sharp geyser
#

listen man I was tireddd

#

Is it supposed to start identifying before sending the heartbeat or does it not matter when you identify?

lament rock
#

Heartbeat even when not identified

quartz kindle
#

its doesnt matter

lament rock
#

Discord recommends you to keep heartbeating until the gateway can assign you a session

#

and of course continue after that

sharp geyser
#

Well I still don't see why I am not receiving the ready event back

quartz kindle
#

log the identify data youre sending

sharp geyser
#

Mmm, for some reason intents is undefined huh

#

Ok so it was another one of me being so damn tired I wrote shit code and forgot to define intents having a value of options.intents

#

:^)

#

I now receive the ready event

quartz kindle
#

๐Ÿ‘

#

no idea why discord didnt close it for invalid intents

sharp geyser
#

Yea that doesn't make sense

#

What should I implement now Thinking

lament rock
#

max_concurrency

sharp geyser
#

what is that

quartz kindle
#

resume

sharp geyser
#

Isn't resuming just checking if there is a session available and then if so that means there was a previous session?

lament rock
#

max_concurrency is an int from GET /gateway/bot where it defines how many identifies you can do within 5 seconds instead of just 1

quartz kindle
#

yes, you also need to listen to the resume opcode and restart the connection

sharp geyser
#

the resume opcode is 6 right?

lament rock
#

receive resume is op 9

quartz kindle
#

op 7

#

9 is invalid session

lament rock
#

oh mb

#

Its been a hot sec since I did gateway work

quartz kindle
lament rock
#

resume also doesn't count towards identify call limitations, so if there is a session you can resume, you should do so

quartz kindle
#

yup

#

also, sometimes even invalid session can be resumed, because discord is weird

hollow depot
#

does anyone have a solution for this? those weird symbols are supposed to be accented letters (the correct lyric would be "Dipenderรฒ da te, perchรฉ non so piรน stare sola"), this is requested to Genius api and converted to utf8, but accents show up with this weird รฏยฟยฝ

#

(nodejs btw)

quartz kindle
#

how is it converted to utf8?

sharp geyser
#
    _initReconnect() {
        if(!this._internal.reconnectPromise) {
            let resolver;
            const promise = new Promise(resolve => { resolver = resolve; }).then(() => { this._internal.reconnectPromise = null; });
            promise.resolve = resolver;
            promise.offline = false;
            this._internal.reconnectPromise = promise;
        }
    }

Btw tim, I notice you do this in initReconnect in your code but this doesn't actually resume the connection dose it?

hollow depot
lament rock
#

bad way to do that

#

Buffer.toString("utf8");

#

where Buffer is usually the response body

hollow depot
#

ill try, thnx :)

quartz kindle
#

utf8 is the default anway

quartz kindle
#

i might change that tho

#

since it can cause issues in unstable networks

sharp geyser
#

Mmm but if you are wanting to reconnect why not just call _resume?

quartz kindle
#

the websocket has to be fully closed and reconnected

sharp geyser
#

Mmmm

sharp geyser
quartz kindle
#

where do you get data from?

#

does this api youre using have an npm package ir are you doing the request yourself?

quartz kindle
sharp geyser
#

Wait what

#

But if I am calling connect won't I already identify again?

quartz kindle
#

after you receive hello, you resume if you have a session, and identify if you dont

hollow depot
sharp geyser
#

Actually wait yea

#

I just thought bout that

#

What close code do you use I don't remember seeing it in the docs

quartz kindle
#

you dont need to send a close code

sharp geyser
#

Oh? I thought you did

lament rock
sharp geyser
#
            case GatewayOpcodes.Hello: {
                const interval = d.heartbeat_interval
                const timeout = Math.floor(interval * Math.random())
                this.emit('debug', `Received hello. Heartbeat interval = ${interval}ms. First heartbeat in ${timeout}ms`)
                internal.heartbeatInterval = setTimeout(() => {
                    internal.lastHeartbeat = Date.now();
                    this.emit('debug', 'Sending heartbeat')
                    this._socket.send(JSON.stringify({ op: GatewayOpcodes.Heartbeat, d: this.sequence }))
                    internal.heartbeatInterval = setInterval(() => {
                        internal.lastHeartbeat = Date.now()
                        this.emit('debug', 'Sending heartbeat')
                        this._socket.send(JSON.stringify({ op: GatewayOpcodes.Heartbeat, d: this.sequence }))
                    }, interval)
                }, timeout)

                if(this.session && this.sequence) {
                    this._resume()
                } else {
                    this._identify()
                }
                break;
            }
            case GatewayOpcodes.Resume: {
                this.emit('debug', 'Discord asked to reconnect')
                this._socket.close()
                this.connect()
                break;
            }

So theoretically this should work right?

quartz kindle
#

thr close code you send is echoed by them, so i send a custom code , so when i receive the close confirmation i know if i was the one who closed it, or if they were the ones who closed it

quartz kindle
#

but if youre using an npm package, it should be giving you the decoded data already, not a buffer?

quartz kindle
sharp geyser
#

right

#

ty for that

#

Also another thing to work on is helping with rate limiting

#

At least I think that is something I should do right?

#

That way people don't get banned as easily

quartz kindle
#

websocket rate limit is very straight forward, its 120 requests per 60 seconds

#

but these requests are only for presence updates, voice state updates and requesting guild members

sharp geyser
#

I see

#

Do you mind if I copy your send method in tiny discord?

quartz kindle
#

feel free

sharp geyser
#

Tyty

#

Also ty for all the help with my endeavor I'm a complete noob with this so sorry if I bother you with all the questions

quartz kindle
#

just add a coment/license about it when you release it

sharp geyser
#

Yeee

sharp geyser
#

Seems like the rate limiter works

#

:^)

#

ty again tim for all this help :p

quartz kindle
#

np

sharp geyser
#

I think everything gateway wise is done (other than voice state update thingy)

#

Also I notice you do a lot of stuff on close that is smart

quartz kindle
#

i have to think of every possible scenario

#

all sorts of shit can happen

sharp geyser
#

Yea, that makes a lot of sense

#

I am kinda just going with the flow rn so I am not thinking of every possible thing that could go wrong, plus I am not entirely sure of what could go wrong as I am new to the whole socket thing so I have no idea what possible outcomes can occur

green kestrel
#

i got dpp to name its threads ๐Ÿ˜„

#

gonna use that in my bot's admin panel to report on specific cpu usage per shard

outer niche
quartz kindle
#

you know where the error happens, you know which line is causing the error

#

log it and test it independently to see whats wrong

#

print answers, print answers[0], print answers[0][2:-1]

#

and eventually you will find whats wrong

wheat mesa
#

wtf is answers[0][2:-1]

#

is that like answers[0][2] if it exists, but answers[0][finalIndexOfAnswers] if it doesn't?

quartz kindle
#

im assuming its some weird syntax for .slice(2, -1)

wheat mesa
#

oh yeah I forgot python has slice syntax

bright thorn
#

If shard dont have any sessionId that mean its dead?

quartz kindle
#

yes

hollow needle
#

huh

#

iโ€™m gayyyyyy

lyric mountain
#

No way, real shit? This changed everything

sharp geyser
quartz kindle
#

that hes gay

sharp geyser
#

lol

#

Man tim I am stumped on how I wanna handle the events. I even looked at djs way of doing events and it is a rabbit hole

#

:^)

#

I know they emit the events in actions but idk how the actions are called or how they work

quartz kindle
#

djs converts every single event into a djs structure before emitting

#

actions are called from handlers

sharp geyser
#

Mmmm, how do they even do that?

#

Where does the conversion begin?

quartz kindle
#

check the handlers folder

#

in the websocket folder

sharp geyser
#

client.actions.WebhooksUpdate.handle(packet.d)

#

hmmm

quartz kindle
#

some of them call the action directly, others do a lot of preprocessing before the action

#

its a mess

sharp geyser
#

Yea it is very hard for a nub like me to follow this

quartz kindle
#

the structure conversion is done in actions

#

with the ._add() methods

sharp geyser
#

some of the events are just done directly in the handler file

quartz kindle
#

yes

#

its very messy

#

but there is a reason behind it

sharp geyser
#
  register(Action) {
    this[Action.name.replace(/Action$/, '')] = new Action(this.client);
  }

wtf is this bs

#

Are they just getting the name and setting the action for it or?

#

Alright so from what I can tell, the websocket manager catches the events, uses the handlers for that event, and then the action processes the data and does what it needs with it and then emits it?

quartz kindle
#

yes

#

and the reason handlers and actions are separate is because

#

for exanple

#

when your bot sends a message with the rest api

#

discord responds to the http request with the created message

#

but also sends a message create event for the same message

sharp geyser
#

I am now realizing how fun yet how fucking annoying this project is :^)

quartz kindle
#

the response from the http request also goes through the actions

#

so actions are used by both websocket and rest

#

handlers are only websocket

sharp geyser
#

I get that

#

But I really don't wanna make my system in such a messy way even though it will likely end up like that

quartz kindle
#

yeah

#

i chose to not use structures at all

#

just use the raw evebts directly

sharp geyser
#

I was also thinking of just doing that and having something similar to discord akairo

#

listener and listenerhandler ya know

#

The listener would essentially do what actions in djs do

#

and the handler would be for registering those events with the code base

#

I think before I focus on events though ima work on the websocket some more

quartz kindle
#

๐Ÿ‘

sharp geyser
#

Welp I give up for now

#

ty for the help today tim PatPeepo

lament rock
#

@sharp geyser for when you see later, I really highly recommend you don't try to make the next Discord.js as you'll burn yourself out faster than anything

sullen crater
#

omg akairo ๐Ÿฅบ

worn pasture
#

Replying a year later

#

So

#

All you have to do

#

Is search for kali nethunter

celest gate
lament rock
#

using import() instead of require() or change the module to be a common js module instead of esm

celest gate
#

ok

sharp saddle
#

how the hell does nest work? I thought there were docs

earnest phoenix
sharp saddle
#

aah thanks volt

hidden gorge
#

const { REST } = require("@discordjs/rest");
const { Routes } = require("discord-api-types/v9");
const { readdirSync } = require("fs");
const path = require("path");
const { CLIENT_ID, GUILD_ID, TOKEN } = require("./config.json");

const commands = [];
readdirSync("./slashcommands/").map(async dir => {
    readdirSync(`./slashcommands/${dir}`).map(async (cmd) => {
        commands.push(require(path.join(__dirname, `./slashcommands/${dir}/${cmd}`)));
    })
})

const rest = new REST({ version: "9" }).setToken(TOKEN);

(async () => {
    try {
        console.log("[INFOMATION] Start refresting application (/) commands.");
        await rest.put(
            // if you want to use global slashcommand use here => "Routes.applicationCommands(CLIENT_ID)"
            //Routes.applicationGuildCommands(CLIENT_ID, GUILD_ID),
            Routes.applicationCommands(CLIENT_ID),
            { body: commands },
        );
        console.log("[INFOMATION] Successfully refreshed application (/) commands.");
    } catch (error) {
        console.log(error);
    }
})();```
quartz kindle
#

is that the code for registerSlashGlobal.js?

hidden gorge
#

yes

quartz kindle
#

the error says the problem is on line 1

#

i dont need anything wrong on the first line of that code

lyric mountain
#

timhadastroke

sharp saddle
#

also, if you are using node v8

#

Discord.js v13 doesn't work

quartz kindle
sharp saddle
#

Replit uses v8

quartz kindle
#

no?

sharp saddle
#

ah

#

wait

#

npm v8

#

im dumb

quartz kindle
#

lel

sharp saddle
#

replit uses node v12

#

replica

#

loves auto corrector

quartz kindle
#

exdee

sharp geyser
bright thorn
#

How can we check if any shard got issue or off

opaque acorn
bright thorn
#

๐Ÿฅด am new in shard

opaque acorn
#

In replit we must use npx

lyric mountain
#

the shardmanager should contain all managed shards

#

loop though it to find your faulty shard

bright thorn
#

so any scale for status?

lyric mountain
#

use the enums, not the codes

#

I mean, if your lib has them

quartz kindle
bright thorn
#

hybride

snow urchin
#

How would I go about using blobs in NodeJS, need to use new Blob

quartz kindle
#

discord-hybrid-sharding?

bright thorn
#

yes

quartz kindle
#

client.ws.shards has a list of shards on each cluster

bright thorn
#

yes

quartz kindle
#

each shard has .status

bright thorn
#

can you dm me this docs

quartz kindle
#

the docs for the shards are from discord.js

quartz kindle
snow urchin
#

I am trying to respond to a button interaction on the raw event so it works even after a restart, I am trying to send an image alongside the data, which requires form data and payload json
I am struggling to get this working ๐Ÿ˜ญ

#

This is what I got currently, seems to be a bit further now, may not even need blob
current issue now is cannot send an empty message api response ๐Ÿ˜ฆ
https://i.callumdev.xyz/dEviPESo18.png

quartz kindle
#

your append is wrong, and you're missing the boundary headers

#
formData.append("files[0]", data, filename);
#
headers: {
  ...formData.getHeaders(),
  content-type: "multipart-formdata"
}
#

also what type is captcha.dataURL? not sure if formdata supports base64 dataurls

#

its better if its buffer or stream

snow urchin
#

Yeah, I can try a stream for it one sec, the above code has gotten it to send a file now but the image is just blank and it doesnt have the embed either

#

Cool, it sends the image now just fine with the stream, only issue is it sends ONLY the image, and it sends it as a file

quartz kindle
#

try instead of filename

#

{filename: 'captcha.png', contentType: 'image/png'}

#

you're using the form-data npm package right?

snow urchin
#

I am yeah

snow urchin
quartz kindle
snow urchin
#

Once again it just sends as a message attachment and does not include the embed either ๐Ÿ˜ฆ

quartz kindle
#

try changing the order

#

the file first, and payload_json second

snow urchin
#

still no difference

quartz kindle
#

not sure then, can you show your current code again?

snow urchin
#

This is it currently

const captcha = new Captcha(100),
          newData = new FormData();

        newData.append("files[0]", captcha.PNGStream, { filename: 'captcha.png', contentType: 'image/png' });
        newData.append("payload_json", JSON.stringify({
          "type": 4,
          "embeds": [
            {
              "title": "Verification Code",
              "type": "rich",
              "description": "Please click the verify button and enter the code you see below.",
              "timestamp": Date.now(),
              "color": 16777215,
              "image": {
                "url": "attachment://captcha.png"
              },
              "ephemeral": true
            }
          ]
        }))

        axios(`https://discord.com/api/v8/interactions/${interaction.id}/${interaction.token}/callback`, {
          method: "POST",
          data: newData,
          headers: {
            ...newData.getHeaders(),
            "Content-Type": "multipart-formdata"
          }
        });
quartz kindle
#

since its an interaction callback, it should have a data object

#
{
  type: 4,
  data: {
    embeds: [...],
    attachments: [...]
  }
}
snow urchin
#

Thank's Tim, that works now, just curious, do I have the "ephemeral" in the wrong place?

quartz kindle
#

yeah it should not be inside the embed

earnest phoenix
#

How do i make a bot with auto-mod?
Like i want to create my OWN Private bot
To moderate the server

quartz kindle
#

you need to set it in flags

earnest phoenix
quartz kindle
#
data: {
  embeds: [...],
  flags: ephemeral flag here
}
earnest phoenix
#

or how to even input a code into a bot