#development

1 messages · Page 2033 of 1

quartz kindle
#

there is such a thing as a minimum amount of data possible to represent in a given cpu architecture

#

even in C booleans take 1 whole byte

#

java uses its own jvm which further translates everything into its own data containers

lyric mountain
#

so they use 1 byte to prevent cpu compatibility issues?

quartz kindle
#

its the minimum possible amount of data that the cpu can process

#

A bool takes in real 1 bit, as you need only 2 different values. However, when you do a sizeof(bool), it returns 1, meaning 1 byte. For practical reasons, the 7 bits remaining are stuffed. you can't store a variable of size less than 1 byte.

lyric mountain
#

that makes sense

quartz kindle
#

But you have to keep in mind that we nowadays have 32-bit and 64-bit processors and while a single bit would be enough to hold a boolean, the processor just processes data that is either 32 bits or 64 bits in size. (Although it can compact data to 16 bits or even 8 bits.) But the processor also has a set of flags, which are basically 1-bit registers so it can store booleans as a single bit, depending on how the processor is used.

vivid fulcrum
#

it's basically because of how registers work

#

this ^^

#

it's way easier and faster to flush a byte into the register than flipping through to change a bit

quartz kindle
#

all of this is why bitfields are so damn useful

#

you can pack dozens of booleans in a single 32bit int

#

where if you were to store them independently in memory, each of them would use a minimum of 1 byte, if not more

lyric mountain
quartz kindle
#

yeah but how will you address them

lyric mountain
#

hm, declaration order?

quartz kindle
#

well the compiler still needs to write the number anyway

#

memory usage is a tricky business because everything is addressed by 8 bytes in 64 bit systems

#

even a single reference is 8 bytes

#

so 8 bytes to access the memory position where the bit field is stored, plus 1 byte for the index number in the bitfield

#

and if you go deeper, all memory access is controlled by the allocator, which further decides how to split the data across the physical ram and often does so in fixed size chunks

split hazel
#

you sacrifice memory for performance

fathom sonnet
#

i got a problem...from some reason i cant download anything with npm...i got this and thats all

#

no errors nothing

quartz kindle
#

if its not, then delete your node_modules folder and your package.json and package-lock.json files and install again

fathom sonnet
#

the thing is

#

there is no node module folders

spark flint
cinder patio
#

you need to have a package.json

#

you don't

fathom sonnet
#

yea but as i know they are automaticly created

#

while downloading

cinder patio
#

you need to have a package.json first

quartz kindle
#

are you sure you are in the correct folder?

cinder patio
#

npm init

quartz kindle
#

type dir

cinder patio
#

Same thing has happened to me just create a package.json

quartz kindle
#

did it also say you had 24 packages installed? is npm that bad?

fathom sonnet
#

tnx for help guys

compact pier
#

how I can fix this error

lyric mountain
#

exception-based code flow 👍

#

but well, although your code tickles my security-leak sense, Error doesn't contain password property

compact pier
#

cause there is noway Error gonna have password property

lyric mountain
#

ignore? you don't simply ignore stuff, you fix the issue

#

return null if user doesn't exist

compact pier
#

it is kinda bad :<

lyric mountain
#

if u want to have an exception, print it before returning

compact pier
#

cause I want to return as a Error message

lyric mountain
#

return to who? the user?

compact pier
#

yeah the client

#

like the clinet just have to <h1>{ data.error.message }</h1>

lyric mountain
#
const user = ...;

try {
  if (!user) throw new Error(...);
} finally {
  return user;
}
#

user will be either the user or null

compact pier
#

oh

#

damm this new

copper cradle
#

You don't need to check if the user exists

#

Just return it

compact pier
#

I just want to return the error message

lyric mountain
#

other than that, DO NOT STORE PLAIN TEXT PASSWORDS

#

hash the password then compare with the hash in database

marble juniper
#

Yes

#

If you wanna go the extra mile

#

Do hashing + salt

#

So that a rainbow table wont work lol

lyric mountain
#

if u want to go EVEN further, hash the salt too mmLol

marble juniper
#

The easiest way to do it

#

Use the crypto module

#
const {
  scrypt,
} = require('node:crypto');

// Using the factory defaults.
scrypt('password', 'salt', 64, (err, derivedKey) => {
  if (err) throw err;
  console.log(derivedKey.toString('hex'));  // '3745e48...08d59ae'
});
// Using a custom N parameter. Must be a power of two.
scrypt('password', 'salt', 64, { N: 1024 }, (err, derivedKey) => {
  if (err) throw err;
  console.log(derivedKey.toString('hex'));  // '3745e48...aa39b34'
});
lyric mountain
#

scrypt

marble juniper
#

Yes

#

Provides an asynchronous scrypt implementation. Scrypt is a password-based key derivation function that is designed to be expensive computationally and memory-wise in order to make brute-force attacks unrewarding.

lyric mountain
#

they missed the chance to call it JavaScrypt

marble juniper
#
const {
  pbkdf2,
} = require('node:crypto');

pbkdf2('secret', 'salt', 100000, 64, 'sha512', (err, derivedKey) => {
  if (err) throw err;
  console.log(derivedKey.toString('hex'));  // '3745e48...08d59ae'
});
#

Both have the same purpose

lyric mountain
#

sha512 holy fck

marble juniper
#

Just a different algorithm

#

lol

lyric mountain
#

what are u trying to hash? an individual atom?

marble juniper
#

Security is no joke

lyric mountain
#

chances are there's not enough silicon in the universe to make a computer able to crack that

marble juniper
#

Better that way

lyric mountain
marble juniper
#

Better that way

lyric mountain
#

that's not even about 512 lul

marble juniper
#

At least that means the passwords cant be brute forced

fathom sonnet
#

now this...it just open terminal for like .5s and close it

marble juniper
#

Probably something in ur code that causes it to exit the event loop

fathom sonnet
#

literaly whole code

wheat mesa
#

allIntents is not a valid object parameter most likely

lyric mountain
wheat mesa
#

Try new Client({ intents: allIntents }) or whatever it is

lyric mountain
#

use environment variables or .env

#

don't be lazy when securing your tokens

fathom sonnet
lyric mountain
#

later might be too late

#

how do you think scam bots are created?

fathom sonnet
#

its on my PC soo no wories

fathom sonnet
lyric mountain
#

shhh, don't give a developer dopamine

#

it's dangerous

brave nova
#

its super painful to webscrap a website, just if theres a npm to only scrape the website's head tags

lyric mountain
#

u could use regex

brave nova
#

i did use regex

lyric mountain
#

what did u use and what are u trying to get?

brave nova
#

axios, to get head tag on hmtl

#

to get links

lyric mountain
#

only the head tag or the entire head block?

brave nova
#

entire block

lyric mountain
#

specific tags within it?

brave nova
#

metas

lyric mountain
#

send an example here

#

like, the head block

brave nova
#

i just send get request to youtube for example and axios will return with the html code, and from that code i filter only links and theres will be alot of duplication, so i remove duplicates and thats how i do it for now

wheat mesa
lyric mountain
brave nova
#

aight thanks

lyric mountain
brave nova
#

im currently using this :p
/(http(s)?(:\/\/)?)(?:[A-z0-9](?:[A-z0-9-]{0,61}[A-z0-9])?\.)+[A-z0-9][A-z0-9-]{0,61}[A-z0-9].+(?:[A-z0-9-])/gim

lyric mountain
#

yours will grab links

brave nova
#

yea

#

i targetting links on meta tag

lyric mountain
#

mine will grab meta values, so u might still need to check if it's an url

brave nova
#

i'll improve the regex

#

so it only grab url from metas

#

instead all links

lyric mountain
#

actually, mine still miss second matches within the same line

#

(?<=<meta.+)(?:(?<key>\w+?)="(?<value>.+?)")+(?=.+\/>)

#

also to test an url u can just try to send a request to it

#

if it errors then it isn't an url or isn't reachable (which u wouldn't want to try anyway)

#

most fetch libs are fail-fast, so it'll do a bunch of checks before attempting a connection

fathom sonnet
#

i give up!!

#

registering slash commands is fucking inposible

#

literlay same code...i execute this file and...nothing, no errors, cmd opens and close after sec...

#

using prefix is just easy

fathom sonnet
#

index.js run normal but this dosent

#

Worst part there is no error

#

Maybe i should downgrade node

#

Maybe that could be a problem simce i use 18.0.something version

wheat mesa
#

Are you even running anything in your index.js file? Your other files don’t just magically run because you put code in them

#

Node 18+ should not cause issues

fathom sonnet
#

But this deploy-commands... Dosent run

#

The worst thing is that there is no error

quartz kindle
#

have you tried running it directly?

#

node deploy-commands.js

fathom sonnet
#

Yes

#

I think making this slash commands work will be bigest problem

quartz kindle
#

add a console.log right before rest.put()

#

to see if it logs anything

sharp geyser
#

What is the easiest way to get all the guilds after identify to cache them?

pale vessel
#

listen to GUILD_CREATE events after identifying

#

they also give guilds in the ready event too iirc

quartz kindle
#

yes, the ready event gives you a list of guild ids that you should expect

#

then you receive a bunch of GUILD_CREATES for those ids

sharp geyser
#

Okay so I assume that on guild create I should just add those guilds to the cache?

quartz kindle
#

yes

#

you will not receive any "real" GUILD_CREATE until you receive all those intial ones

sharp geyser
#

I am starting to think about how I should even handle caching, cause right now the way I am doing it wont scale well

lament rock
#

by not caching

sharp geyser
#

bro im serious 😔

lament rock
#

Cache raw structs in a Map<K, V>

sharp geyser
#

Well I already basically made my own djs collection :^)

lament rock
#

Trying to mutate the data returned by Discord is just so much overhead

sharp geyser
#

Mmmm

lament rock
#

or constructing classes I mean

sharp geyser
#

I was thinking of just making a class called
GuildStore that extends BaseStore

lament rock
#

You can do a similar thing to djs where they cache in Collections, but don't bother making so many structures like discord.js. It's just collecting garbage

#

The basic concept of making a good lib is you take all of what discord.js is doing and do none of that

sharp geyser
#

I was thinking just make a class for each thing I cache like Channels, Guilds, Users, etc

#

Actually hol up

lament rock
#

Some stuff I can understand like trying to get dates from SnowFlakes

#

but that can be a Util function

#

really, just store raw data

#

it'll save you a lot of pain of adding members to classes when you could just not update the lib at all unless totally necessary

#

You'll find out very quickly how volatile Discord's api is

sharp geyser
#
import { BaseStore } from '../../../stores';

export class Guild {
    public cache: BaseStore<string, Guild>
    
    constructor() {
        this.cache = new BaseStore<string, Guild>()
    }
    // Have all my guild related methods plus being able to keep the guild cache
}
#

Though now that I think a bout it this probably wont work either

lament rock
#

storing Guilds in a guild?

sharp geyser
#

Mmm, I am trying to think of how to reliably do caching for the important stuff but I am nub

lament rock
#

Look at source code of other libs

sharp geyser
#

djs is out of the question

#

their code is hell

lament rock
#

Kind of

#

not type safe

#

ugly to look at

pale vessel
sharp geyser
#

Nah not anymore

pale vessel
sharp geyser
#

I was thinking about doing that but then decided not to

lament rock
#

what is your goal for the lib? Ease of use? Efficiency and scalability?

#

you can't have both

sharp geyser
#

I wanna make it as user friendly as possible

#

Without holding their hands too much ofc

lament rock
#

That's already discord.js

sharp geyser
#

true

#

Well I can't really go for efficiency and scalability right now

#

I am not good enough to write code to achieve that

lament rock
#

use raw net.Socket for a week and you'll be either good enough by then, or want to kill yourself before

sharp geyser
#

wtf is that?

lament rock
#

net.Socket is a very low level Stream based socket implementation for connecting to web servers

#

I think it still provides some helpful abstractions like dns queries

sharp geyser
#

I mean I don't think I could even write efficient code at all so catshrug

lament rock
#

Welp. If you have a memory target in mind, you can install heapdump and start peeking into js heap snapshots and seeing what takes the most ram

#

as a warning, beginners will find it very hard to do that

quartz kindle
#

discords raw data is actually pretty inefficient

#

but then djs takes it and makes it even worse

#

:^)

lament rock
#

Better than dumping all of the data into some class' members

#

the size of the prototype just adds to the mess

#

discord.js' import size already makes me not meet my memory target

#

combination of the prototypes and module strings

sharp geyser
#

alright so all I am reading is I suck mmLol

lament rock
#

I still think I suck after understanding how to do something at such a low level

#

that wont change

sharp geyser
#

yknow what I am happy with how far I got with this lib

#

time to call it quits and leave it to the big dogs

quartz kindle
#

make an lmdb based cache

lament rock
#

contribute to other libs

#

You can still have fun

sharp geyser
#

fuck no im not smart enough to dick with other libs code

lament rock
#

You dick with other libs' code to get smarter

sharp geyser
#

I lack the confidence to do that tho so it will likely never happen

quartz kindle
#

you dick with other libs to feel good about yourself

#

because other libs suck

#

:^)

lament rock
#

true

sharp geyser
#

I might at some point pick it up again and start working on it but I lack the motivation now

lament rock
#

Honestly, most of the stuff I work with is proprietary because I have very strict demands for performance. For better or for worse, I pushed myself to seek out or make better performing software and how I have it with my bots is good imo. Could be better, but my dep tree it totally clean of libs like axios and others that I consider to just be garbage in the heap if I was the GC.

#

They have their audience, but I'm not in it

sharp geyser
#

I try to be performant as possible but I always end up lacking in that aspect, plus the stuff I generally make either a few people use or no one use it at all so it just doesn't seem like what I am making is very appealing to the public which blows my confident to even continue learning

lament rock
#

You gotta either make something so mind blowingly better that it would be stupid not to use it or just be popular

sharp geyser
#

Yea I suck too much to do either of those mmLady

lament rock
#

I tried to get the libs I maintain listed on the official community resources, but got ignored for like 2 months except for 1 comment by d.py dev correcting one of my statements about not seeing other modular libs in the list and that's it. Then harsher restrictions came and now I'm just fucked

quartz kindle
#

first step is to make something that youre gonna use yourself

#

most of the stuff i made i started because i needed it myself

#

and i use it myself

#

if other people like it or not thats not important

sharp geyser
#

Mmm, my end goal is to make something that people will enjoy using

lament rock
#

The most cursed thing I made was a command documentation based argument parser because slash commands weren't a thing yet and I wanted something that gave me "type safety" without having to jump through so many hoops for each command

#

like

quartz kindle
#

if you try to appeal to others first you just end up making the equivent of yet another multipurpose bot

lament rock
quartz kindle
#

you have to appeal to yourself first

sharp geyser
#

Mmm yea but a lot of the things I would want to make are just way too much for a single person to do without blowing my brains out

lament rock
#

This shit is really cursed

quartz kindle
#

xD

lament rock
#

It worked so well for what it is though

#

like it was a god send to me at the time

sharp geyser
#

I need to come up with something that I enjoy doing, that lib was fun but it made me lose motivation

lament rock
#

Something for your bot if you have one

#

just something to make dev work easier

sharp geyser
#

I decided a while ago to not make any more bots as there is no point anymore

#

the market is too flooded that no matter what even if your bot is better the popular ones will still be used over it

lament rock
#

Well. Either bots don't do a specific thing or so many bots do it terribly

#

Like, I wanted to make a text based multiplayer rpg since that didn't exist at the time

#

I quickly gave up on that tho

sharp geyser
#

I can't do that

#

i'd end up getting in over my head and try and do the impossible which then leads to me giving up since icouldn't do it

#

Plus the discord api in terms of making bots is getting boring for me, I don't want the discord api to define my entire career as a dev I wanna branch out into something more enjoyable that will bring enjoyment to other people as well as myself

lament rock
#

My music bot has been in service for 4 years and is only at 6900 guilds (nice)
and I've received a lot of positive feedback that it's just so much better than other bots, but what can I do if I don't advertise it so cut throat like other bots that farm votes to reach front page

sharp geyser
#

I mean shit for a music bot that is pretty nice

lament rock
#

I suppose, yeah, but I see other bots that have existed for much less time and are in hundreds of thousands of guilds

#

Not like I'm jealous. Must be a nightmare to scale discord.js music bots

sharp geyser
#

I bet those ones aren't nearly as good as yours tho

#

They are typically either made poorly or copy pasted

lament rock
#

Well. That's for others to decide, not me. And it seems like people want whatever competitors offer

#

the meta is vote locking

#

wanna give people volume control? Vote lock

#

Is what I would say if I did do that, but I don't

sharp geyser
#

That is what I dislike tho

#

Vote locking is just pain

#

I get it, wanna get your bot on front page but some people take it too far and votelock nearly everything

lament rock
#

Whatever gets you to front page I guess

sharp geyser
#

I still have a project idea that i have been reluctant to actually start on, mostly due to lack of people supporting the idea

lament rock
#

The first week my bot got accepted onto a list I won't name because it isn't this one, It got 2,000 invite uses. That's only because it appeared on a "new bots" category on front page

#

what is it

sharp geyser
#

I can dm you the idea (not like it is a very good one but yknow I don't want some rando sniping it)

lament rock
#

ok

earnest phoenix
lament rock
#

But I used it for most of its development cycle

#

only recently have I started using modular libs

brave nova
#

lul, wants to use FX, you must vote to use dis command, me just make my own bot den kek

carmine summit
#

userId or userID?

pale vessel
#

context?

#

userID seems more natural to me

carmine summit
dry imp
#

USERID is better

craggy pine
#

uSeRiD

sharp geyser
#

Mmmm what should I use to make my api thinkies

#

should I just stick with the basic express or hmm

pale vessel
#

what happened to coding in go mmLol

sharp geyser
#

I am probably just going to use ts and then microservice things or smth

#

I am not too confident with go as I am ts

sharp geyser
pale vessel
#

nop

#

i made a simple tool with it, it wasn't bad to work with

fathom sonnet
#

ok, so i tried to console.log before rest.put() and it loogs --- Test --- and then close...

sharp geyser
#

Do you get an error?

fathom sonnet
#

No

#

Cmd open, print test and close

pallid zinc
#

@fathom sonnet console log the commands

fathom sonnet
pallid zinc
fathom sonnet
#

yep

#

still same

pallid zinc
#

Like it does not show the slash commands na

fathom sonnet
#

yea there is no slash commands at all

pallid zinc
#

Clientid is right?

#

Try removing the guildid to make it a global thing

#

Maybe you dont have perm in guid to add slash

#

But it should give error

fathom sonnet
fathom sonnet
#

yea...removing guildID dosent nothing

tidal nymph
#

rip bot was good for 2 days until it just got rate-limited

#

💀

dry imp
#

mood

fathom sonnet
#

ok, i donwgraded node to 16.15 and now i getting errors again...tnx God

#

ok here is error

#

now...

#

...i was using my clientid instead of aplication id

#

ok ok... now i have this:

#
DiscordAPIError[50035]: Invalid Form Body
guild_id[NUMBER_TYPE_COERCE]: Value "undefined" is not snowflake.
    at SequentialHandler.runRequest (C:\Users\emanu\Desktop\boolean BOT (recode)\node_modules\@discordjs\rest\dist\index.js:708:15)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async SequentialHandler.queueRequest (C:\Users\emanu\Desktop\boolean BOT (recode)\node_modules\@discordjs\rest\dist\index.js:511:14) {     
  rawError: {
    code: 50035,
    errors: { guild_id: [Object] },
    message: 'Invalid Form Body'
  },
  code: 50035,
  status: 400,
  method: 'put',
  url: 'https://discord.com/api/v9/applications/967483641393455104/guilds/undefined/commands',
  requestBody: {
    files: undefined,
    json: [
      [SlashCommandBuilder],
      [SlashCommandBuilder],
      [SlashCommandBuilder]
    ]
  }
}
#

ok...

#

what next emoji_8

pallid zinc
fathom sonnet
#

Yep i tougjt that could be solve issue

pallid zinc
#

Did it?

rustic nova
#

wait I forgot about the discordpy shit: Is there no python-based discord library that actively has the interactions stuff?

#

because the ones I'm finding are either abandoned or not maintained

rustic nova
#

welp, guess I know why

kinda not comfortable using the library from that dev mentioned there, so welp back to java

fathom sonnet
rustic nova
#

but yeah, basically kills off my plans for doing this one private bot in python iara_ded_lost

#

will discord.py be somewhat continued by someone else in the future or is it entirely dead

spark flint
#

dpy is now being continued again

#

original dev

fervent moss
#

Ded

spark flint
#

^

rustic nova
#

honestly not getting the vibes of that when I'm not seeing anything referring to interactions or components on the docs

pallid zinc
rustic nova
#

nevermind it is in there

#

and nevermind again, literally latest version is 1.7.3 which doesnt have it

#

istg

fathom sonnet
#

error occure after "test" si logged to console

pallid zinc
#

Do console.log(clientId)

lyric mountain
#

guilds/undefined/commands

#

Ur trying to publish slash cmds to a non existing guild

fathom sonnet
#

throw err

lament rock
#

You should be posting to global commands route, not guilds route

lyric mountain
#

Also u didn't had to hide the client id, it's public and written on the bottom

fathom sonnet
#

ah ye ik

fluid garden
fathom sonnet
#

habbits

fluid garden
#

Anyone know what this error?

lyric mountain
#

No

#

I can barely read it

fathom sonnet
#

your roles

#

are undefined

fluid garden
#

What?

fathom sonnet
#

'cannont read properties of roles'

lament rock
#

I can get your bot's token from just the client ID!!! See, the first part of the token is OTY3NDgzNjQxMzkzNDU1MTA0

lyric mountain
#

Hackerman

lament rock
fluid garden
#

The kt just have a addrole global command

#

That only thing of roles

lyric mountain
#

Paste it here

fluid garden
#
    at Object.module.exports.run (/home/runner/All-in-one-bot-with-SlashCommands/src/events/messageCreate.js:43:24)
#

Have mqny error

lyric mountain
#

That doesn't help much

fathom sonnet
#

fixed error...

#

1 fucking word

fluid garden
fathom sonnet
#

and its not working...

pallid zinc
# fathom sonnet throw err

I just wanted to check if you had a valid client id and you can put that guildId thing i just asked you to remove it cause your code was not even giving any errors before

lyric mountain
fathom sonnet
#

i downgraded to 16.15

pallid zinc
#

Yup

fluid garden
fathom sonnet
#

i was using 18.0

fluid garden
#

It do t allow

lyric mountain
#

Reading stacktrace on mobile is hard enough, reading a stacktrace on mobile as a print of YOUR mobile is even worse

pallid zinc
lyric mountain
#

Are u sure u can't copy?

fluid garden
#

Ya

#

From logs

#

Cant

#

I can send image

lyric mountain
#

Show messageCreate line 43

fluid garden
#

I added some notes

lyric mountain
#

Oh my

fluid garden
#
if (message.member.roles.cache.highest.position >message.guild.member.roles.cache.highest.position) return;

    if (check) {
      if (array.some((word) => message.content.toLowerCase().includes(word))) {
        message.delete();
#

The if is at line 43

lyric mountain
#

But well, message.member.roles is undefined

#

That or message.guild.member.roles

#

I bet on the second

#

Not all messages are sent in guilds

fluid garden
#

Wdym

lyric mountain
#

Private messages

#

Have no guild

lament rock
#

message.guild.member isn't a GuildMember is it

fluid garden
#

I cant close the bot dm

lyric mountain
#

Ah that too

fluid garden
#

Can i?

#

How

lament rock
#

idk

fluid garden
#

If i closed bot dms it will work?

lyric mountain
#

That's not the issue, it's what papi pointed

fluid garden
#

What should i do

#

Iam confused

lament rock
#

if you want to check highest bot role, check message.guild.me.roles.highest.position

lyric mountain
#

message.guild.member is not valid code

fluid garden
#

I replace with?

lament rock
#

Collection<string, Role>.highest isn't a property as well

pallid zinc
# fluid garden

Ig dont use replit if you dont have there premium tho, peeps can search that url in ss and can see your token tho

fluid garden
#

No

#

It is in secret env

#

@lament rock so what should i do

lament rock
fluid garden
#

Ok but can you check odes before

lament rock
#

I don't think you understand my advice or totally forgot the context in which I posted that in. You might want to read it again and then your own code

fluid garden
#

This error

#

Wasnt showing before

#

It suddenly appeared

#

And every ckmmand was working

lament rock
#

Everything else was probably broken or that command never ran or got to that point

fluid garden
#

It was working proparly

#

Maybe some body dm bot and it get issue

lament rock
#

You should also be checking that

fluid garden
#

How

#

Cant

lament rock
#

what do you mean you can't

fluid garden
#

I cant check

#

Whoo dm

#

Bot

#

And in logs

#

Cant show

#

That someone did

lament rock
#

message.author is who created the message

#

message.guild is either a Guild or null depending on if the message was sent in a guild or not

fluid garden
#

Can i send my codes?

lament rock
#

For what purpose

spark flint
#

Using Discord.js, how can I acknowledge a button click without replying to it?

fluid garden
#

Idl what to do :(

#

Iam not nnderstanding

lament rock
#

message.guild.member.roles.cache.highest.position
to
message.guild.me.roles.highest.position

fluid garden
#

I do that?

#

?

lament rock
#

Ok. That should be it

fluid garden
#

That will make the bkt do the action kn the lower role user

#

?

lament rock
#

yeah

fluid garden
#

I thi k will not work z it have sometng different see my code

lament rock
#

Well. Try it and see

fluid garden
#

Ok

lament rock
#

also, for guild only commands you should be checking if (!message.guild) return or something like that

fluid garden
#

Nothing working

lament rock
#

ok. What's the error

fluid garden
#

Idk what happened

fickle arch
#

I don't know how you manage to code on phone with replit lol

fluid garden
#

My pc right

#

Now

#

Isnt woth me

solemn latch
#

looks like you are using .roles on null

fickle arch
#

hmm, I could install other package but not enmap and better-sqlite3

fluid garden
#

?

pallid zinc
lyric mountain
#

Replit no longer uses .env, it uses a separate config menu

sour swan
#

Question (JavaScript): I have multiple objects that all relatively look the same, but some have a chain of objects in them, see examples
Normal object:

{
"type":{
    "kind":"SCALAR",
    "name":"String",
    "ofType":null
},

Abnormal object:

{
    "type":{
        "kind":"LIST",
        "name":null,
        "ofType":{
            "kind":"NON_NULL",
            "name":null,
            "ofType":{
                "kind":"SCALAR",
                "name":"Int",
                "ofType":null
            }
        }
    }
}

I need to get the name of the object, but in the abnormal objects its at a lower level. How can I go about grabbing the name of objects without having to check how many levels down it is?

#

Sorry if the question is a little weirdly typed out, deffo ask me for clarifications if needed

lament rock
spark flint
#

Is it possible to fetch an interaction by its ID? I'm using discord-modals (not asking for help with this, just giving context) and on the modalSubmit event it returns the interaction ID but not the message object.

lyric mountain
spark flint
#

True

#

I'm trying to make it so when a button is clicked, it shows the modal, then when submitted it will edit the embed in the original message with the button

lyric mountain
#

you could store the message id when someone press the button, and use it to edit the message later on

#
when (button is clicked) {
  store messageId
  show modal
  
  when (modal is finished) {
    message = get(messageId)
    edit message
  }
}
#

just example code in whatever lang that'd be

spark flint
#

i'm now thinking of storing a unique id for the button, then looking up in the db for the message etc

#

actually

#

i can store a custom ID for the modal, i could set the message id as that and not even have a db involved

lyric mountain
#

sure

spark flint
#

yep that worked yay

lyric mountain
#

atta boy

sharp geyser
#

hello developers

wheat mesa
#

hello developers

slender wagon
#
let w1 = 3
let w2 = 1
let w3 = 2

how do i sort these variables from the smallest to the largest but still keep track of it

#

for example i could make it an array but it would just sort the numbers thus i wouldn't be able to keep track of which var it is

rustic nova
#

you could probably do that with a key/value thing

#

and just sort the values

earnest phoenix
#

AKA objects

lyric mountain
#

idk if js has it, but you could try to implement something akin to java's LinkedHashMap

#

which is a map but can be sorted

slender wagon
#
let workers = [
        {
            "workerName": "Grainger",
            "shift": 3
        },
        {
            "workerName": "GRRRRRRRRRRRRRRRRRR",
            "shift": 1
        },
        {
            "worker": "Idk",
            "shift": 2
        }
    ]
    workers.sort((a, b) => parseFloat(a.shift) - parseFloat(b.shift));
#

worked

#

: )

earnest phoenix
slender wagon
#

cuz stackoverflow

#

oh this guy was using it on a string

#

fixed

lyric mountain
#

I believe sort works even for numeric strings as long as it's below 10

#

then it starts acting sussy baka

slender wagon
#

what would i have to use then

earnest phoenix
#

There's no limit (except for the array element limit which is way too many that you wouldn't even reach it unless done purposefully)

lyric mountain
slender wagon
#

hm?

earnest phoenix
#

Just use a.shift, no parsing or casting required

lyric mountain
#
  • forces a string to be cast to number
slender wagon
#

yeah i did remove the parsing

lyric mountain
earnest phoenix
#

Yeah you can cast numeric strings to numbers using the unary plus operator, although I'd recommend using parseInt() (or parseFloat() depending on the case) since they're more verbose and readable rather than syntactic sugar which can be unreadable to others who are unaware of what unary operators do

quartz kindle
#

i prefer using Number(str) depending on the situation

slender wagon
#
        {
            "workerName": "Grainger",
            "shift": 3,
            "daysOff": [6,9]
        },

i am working on a automatic shift manager

quartz kindle
#

but its kinda funny that nobody uses String(n)

slender wagon
#

is the array on the daysOff ok?

earnest phoenix
#

Yeah

slender wagon
#

what i am trying to do is get all the requirements a certain worker want for example he has to go somewhere without ruining other workers days

earnest phoenix
#

Btw you don't need the quotation around the object keys unless you're in a JSON file

earnest phoenix
quartz kindle
#

usually my tests say otherwise, but could be depending on the situation

#

because parseInt does a lot more than simply translating the type

earnest phoenix
#

Yeah, depending on the case either way

quartz kindle
earnest phoenix
#

My previous tests showed that parseInt() is faster, although that's probably changed now

quartz kindle
slender wagon
#

parseInt do be running th egame

#

wait

#

i thought Number was 99

quartz kindle
#

lmao

#

implicit coercion much faster than explicit conversion

sharp saddle
#

replica

#

wow

#

smh

sharp geyser
#
C:\Users\dyeaa\Documents\github\misty\strife\src\index.ts:23
        console.log(await message.send('972334766399582218', 'Hello World'));
                           ^
TypeError: message.send is not a function
import { BaseClient } from '../../BaseClient';
import { RESTPostAPIChannelMessageJSONBody } from 'discord-api-types/v9';

export class Message {
    public client: BaseClient;
    public id: string;
    public content: string;
    constructor() {}

    async send(channelId: string, content: RESTPostAPIChannelMessageJSONBody | string) {
        return await this.client.rest.createMessage(channelId, content);
    }
}
    public async createMessage(
        channelId: string,
        content: RESTPostAPIChannelMessageJSONBody | string,
    ): Promise<RESTPostAPIChannelMessageResult> {
        const { body } = await request(Api.CREATE_MESSAGE.replace(':channelId', channelId), {
            body: JSON.stringify(content),
            headers: {
                'Content-Type': 'application/json',
                Authorization: `Bot ${this.client.token}`,
            },
            method: 'POST',
        });

        return body.json();
    }
earnest phoenix
#

Have you checked if message is an instance of your Message class?

#

Although I assume that would already be checked since you're using TypeScript

sharp geyser
earnest phoenix
#

Have you initialized a new instance of the class or just calling it right on the class like a static method?

#
import Message from '...';

// Instance
const message = new Message(...);

await message.send(...); // Ok

await Message.send(...); // TypeError Message.send is not a function
// As `send()` is a prototype method in your case and not a static method
sharp geyser
#

So I think I found the place where I want to manage what the data is typed as right

#

this.manager.client.emit(GatewayEvents[data.t], data.d); so I have this right here that will emit any event if it is found in the GatewayEvents object, but the data doesn't necessarily correspond with the event being emitted it is just 'any'

quartz kindle
#

you are emitting the raw discord data

sharp geyser
#

Yea, I am thinking here is where I wanna set what the data could be based on the event being emitted

quartz kindle
#

you want to type the raw data or convert it into one of your classes?

sharp geyser
#

I am thinking I should convert it so I can have the send method

sharp geyser
quartz kindle
#

like add types to the raw discord data

#

so you can have intellisense on message.content for example

#

basically what discord-api-types does

sharp geyser
#

Ah, whatever makes it easier. I just wanna make sure my methods will also be attached to the data or whatever so I can like send and such

quartz kindle
#

you need to convert it to your class then

#

like new Message(data.d)

#

and then attach all the data from data.d into your class

sharp geyser
#

Mmmm I see

#

Okay so that works, now I just need to figure out how to do that based on the event being triggered

#

I guess I can do a case for every event possible but that seems tedious no?

#

So I did it in a really stupid way but it works :^)

quartz kindle
#

you will need to do it for every single event type yes

flat karma
#

Hey y'all! Working on my first Discord bot in Python and I'm having issues with something. I'm part of a server where it's become a meme to ban and unban me at random, and it's a good inside joke for the moderators and I. I'm looking to expand the functionality and make it a bit of a game. So I'd like a bot that when it hears ?Fuzzy it randomly sees if I'm getting banned. The issue is that it seems like I'm required to pass a username to the ban command, when I'd really just like to always make it me without having to pass a name as an argument. I've tried messing around with it for a few hours now but I'm coming up with nothing. Here's my latest attempt:

`bot = commands.Bot(command_prefix='?', case_insensitive=True )

@bot.event
async def on_ready():
print(f'{bot.user.name} has connected to Discord!')

@bot.command(name='Fuzzy')
@commands.has_any_role('Senior Admin', 'Admin', 'Moderator')
async def fuzzy_ban(ctx, member:discord.User=name):
#await ctx.send("Yo it's working")
await ctx.send("Banning Spark, probably")
await member.ban()
await member.unban()`

The name variable is currently set to a buddy of mine's Discord name for testing purposes in a server with just us.

Current error I get on running and trying the command is:
await member.ban() AttributeError: 'NoneType' object has no attribute 'ban'

Any ideas?

#

I'm just trying to get the ban working, then I'll work on the randomness of it - which should be relatively easy

#

I'm sure I'm missing some easy solution to this

sharp geyser
#

Would there be a reason why my lib is sending the message twice? I have it set so if the message received in the message create event author is a bot it won't respond with the Hello World message but for some reason after I made a change to the websocket shard class it now responds twice

lament rock
#

the event is probably being emitted twice

sharp geyser
#

Okay so ignore this literally just found the issue :^)

sharp geyser
lament rock
#

break

sharp geyser
#

lol

split hazel
#

@quartz kindle i need a break from low level 💀

#

I should do what this guy is doing and make a discord lib

split hazel
#

one with a specific aim

#

i see people mostly focus on performance/efficiency but i usually see it comes at a massive cost

#

(e.g. simplicity)

quartz kindle
#

make the slowest possible discord library

#

and make it use the maximum ram possible

split hazel
#

i cant it goes against my morals

quartz kindle
#

xD

split hazel
#

ive ran into another one of those "undebuggable" bugs in my os

quartz kindle
#

become a maintainer at tiny-discord

split hazel
#

interesting

#

i do really like your storing objects in a buffer concept so

#

have you measured metrics to see how it performs?

quartz kindle
#

im still finishing my binary serializer, i keep reworking parts of it over and over again

#

generally, serialization/deserialization is faster than json

#

but storing them in a buffer is a whole other story

#

my buffer storage project is currently shelved

#

i imagine it will be much slower than native objects/maps

split hazel
split hazel
quartz kindle
#

the serialized object or the buffer storage?

split hazel
#

uh

quartz kindle
#

like, the serializer is just for converting an object to a buffer

#

storing multiple buffers in a map-like buffer structure is a separate project

flat karma
split hazel
#

im talking on whether you store the objects in the buffer as a "string" or a "struct" (aka all in a linear buffer)

quartz kindle
split hazel
split hazel
flat karma
split hazel
#

what if the number is above 255? does it use more bytes?

flat karma
#

Not familiar with members intent

#

I'll try it with await

quartz kindle
#

the number of bytes in a given number is also included in the type byte

#

numbers from -32 to 64 can be represented in the type byte itself

#

the rest of the numbers require more bytes

#

basically its exactly the same as MessagePack does

#

but MessagePack only gives you stuff like uint8, uint16, uint32

#

mine always uses the exact number of bytes a number needs, never more

#

if a number is 24bit long, then it will use 3 bytes, not 4 as if it were int32

split hazel
#

i can imagine that gets really complicated quickly

quartz kindle
#

yeah i keep rewriting it over and over again

split hazel
#

have you considered making a node gyp type plugin

quartz kindle
#

lmao

split hazel
#

lower level languages deal with lower level objects much better and easily

#

at the cost of the object conversion between js and assembly of course

quartz kindle
#

its not worth it

split hazel
#

honestly i'd just make ints 4 bytes for everything and call it a day

quartz kindle
#

lmao

#

well the idea is being as space-efficient as possible

split hazel
#

i'll help out with the discord lib for sure but for your parsing lib i think i have to pass because i may lose my remaining sanity

quartz kindle
#

lmao

split hazel
#

I see the ACPI specification flashing before me during sleep

lyric mountain
#

hey tim, quick question

quartz kindle
#

most of the hard work is already done, i mean dont even get me started on string compression and char mapping

#
    _write5(data, start) {
        let temp = 0;
        let bits = 0;
        let end = start;
        for(let i = 0; i < data.length; i++) {
            let c = data.charCodeAt(i);
            let small = false;
            if(c > 96 && c < 123) {
                c -= 97;
                small = true;
            } else if(c === 32) {
                c = 26;
                small = true;
            } else if(c === 45) {
                c = 27;
                small = true;
            } else if(c === 95) {
                c = 28;
                small = true;
            }
            if(small) {
                temp <<= 5;
                temp += c;
                bits += 5;
            } else if(c < 256) {
                temp <<= 5;
                temp += 30;
                temp <<= 8;
                temp += c;
                bits += 13;
            } else {
                temp <<= 5;
                temp += 31;
                temp <<= 16;
                temp += c;
                bits += 21;
            }
            while(bits >= 8) {
                bits -= 8;
                this._buffer[end++] = temp >> bits;
                temp &= (1 << bits) - 1;
            }
        }
        if(bits) {
            this._buffer[end++] = temp << (8 - bits);
        }
        return end - start;
    }
#

lmao

lyric mountain
#

let's say I have an array of 5 ints that won't go above 100 (guaranteed)
is it more efficient to pack them into spaces of 1 byte for each inside an integer or use actual arrays?

pure stream
#

my bot never told me my token
and i cant reset it because it asks a code
i never set up 2FA for my bot

quartz kindle
lyric mountain
#

like, very much?

quartz kindle
#

an integer will cost you 8 bytes if stored as a double, plus whatever overhead the lang has

#

an array will cost basically 5x that minimum, plus the array overhead which is much larger than the number overhead

sharp geyser
lyric mountain
#

ic

quartz kindle
#

the only issue is that if you're using js, you cant do bitwise on 5 byte numbers natively

sharp geyser
#

It is public yea

lyric mountain
#

nah, java

quartz kindle
#

although there are workarounds for that

#

should be fine then

#

also im pretty sure doing 2 bitwise operations is gonna be 100x faster than an array lookup

split hazel
split hazel
sharp geyser
copper cradle
#

wait

split hazel
#

memory reads take around 50-70 assuming no cache

lyric mountain
#

I'm asking bcuz my tcg has dodge/block chance for all cards, which can be influenced by other cards in the game

copper cradle
#

can operations take half a cycle?

pure stream
#

my bot never told me my token
and i cant reset it because it asks a code
i never set up 2FA for my bot

split hazel
#

yeah you can do multiple things in one cycle

pure stream
#

im dyin

lyric mountain
#

the array is of fixed size of 6 entries

lyric mountain
#

1 for effects + 5 for each slot index

flat karma
#

Thanks for pointing me in the right direction!

lyric mountain
#

and currently I use arrays, but ik they aren't the most efficient I could get

quartz kindle
#

yeah you can fit that into a 6 byte number

split hazel
#

6 byte numbers sound so illegal

quartz kindle
#

its just an uint64 but only 6 bytes are used

#

lel

split hazel
#

ah

pure stream
#

it did not give me it

quartz kindle
#

if you need more than 8 bytes you can always use bigint, does java have bigints?

pure stream
#

and i cant get it

pure stream
#

why did they change it

copper cradle
pure stream
#

this sucks

lyric mountain
#

after long there's BigInteger, which is as big as your ram allows

quartz kindle
#

yeah, biginteger can do bitwise operations as well

#

you can store data there

#

but its probably much slower

pure stream
#

bruh

quartz kindle
pure stream
#

what tf do i do

pure stream
#

im under bot

lyric mountain
pure stream
#

it says reset token

lyric mountain
#

yes

craggy pine
#

Click it

lyric mountain
#

you cant copy the token anymore

quartz kindle
#

yes, click reset token, and you get a new one

pure stream
#

i dont have 2fa for my bot

#

but it says i do

copper cradle
#

what do you mean that doesn't even work

pure stream
#

i dont have the da,m code

#

how tf do i get the code

lyric mountain
#

is your account 2fa enabled?

pure stream
lyric mountain
#

that's the code

pure stream
lyric mountain
#

your bot = your 2fa

quartz kindle
#

you forgot your 2fa?

pure stream
copper cradle
#

the code you use to login

pure stream
lyric mountain
#

you arent

copper cradle
#

that same code

pure stream
copper cradle
#

where do you get it

lyric mountain
#

that's why u use an app to generate it

#

2fa codes expire each minute or so

pure stream
#

i have that

lyric mountain
#

except the ones u got as backup codes

quartz kindle
#

when you login into discord, how do you login? doesnt it ask you for 2fa to login as well?

pure stream
#

holup

copper cradle
pure stream
#

it worked

#

ty guys

lyric mountain
#

well...nvm

pure stream
#

it works and its just easier

#

ty!

#

how do i add my bot to my server>

#

nvm

sharp geyser
#

btw speedy if you ever do contribute ty in advance <3

split hazel
split hazel
#

i saw a lot of things you may want to improve early tho

#

like making a central handler for http requests

sharp geyser
#

Mmmm, yea that makes a lot of sense. I just have been mainly focused on actually getting this to work and honestly I am shocked I have not run into issues yet regarding errors from the discord gateway and shit

sharp geyser
split hazel
#

for example it will handle rate limits for you

#

and it will pre-fill all mandatory data like tokens

sharp geyser
#

Ah yea, that makes sense I thought you meant an entire separate class or smth

split hazel
#

so instead of doing request({method: "POST", ...}) you can make something like

discordAPI.post("/members", { ... });
eternal osprey
#

hey, would the guildmemberupdate event be triggered if a user stops his/hers nitro server boost?

split hazel
#

good question honestly dont know

#

there is a separate event for that right

sharp geyser
#

I am wondering if I should just have the post, get, delete, patch, etc methods in the RestManager class and then utilize those in the Structure classes to do what I need

#

but idk

split hazel
#

sure if you think it'd make your code cleaner

eternal osprey
# split hazel there is a separate event for that right
client.on('guildMemberUpdate', (oldMember, newMember) => {
  if (oldMember.premiumSince !== newMember.premiumSince) {
    
  }
});``` well yeah I found this, pretty sure both member properties will change so it will work for both i guess.
#

I just don't have nitro so i can't test it. Anyone that knows an alternative to test this out?

split hazel
#

uh

#

buy nitro

eternal osprey
#

Smart

#

I don’t have friends so I rather buy nitro tbh

spark flint
#

how can I get the hex code from that?

quartz kindle
#

color.toString(16)

#

although that method will require certain corrections

#

color.toString(16).padStart(6, "0") would be more accurate

sharp geyser
#

What would be the most logical way to cache the channels the client currently has access to without spamming the api/gateway on ready (I am assuming on ready would be the best time to cache them anyways if there is a better way please do tell) Unless caching on GUILD_CREATE would be better?

split hazel
#

on ready discord sends you all of the channels and guilds I believe

#

you then choose whether you want to cache them or not

sharp geyser
#

Mmmm I see

#

I knew ready sends you the guilds as unavailable I didn't know they sent the channels as well

split hazel
#

if you don't cache everything you need to have some kind of fetch function

quartz kindle
sharp geyser
#

So should I cache the guilds and channels on guild create?

quartz kindle
#

if you need them, yes

split hazel
#

that's really up to you but as a kind of required minimum you should cache the guilds

quartz kindle
#

its something that should be customizable

sharp geyser
#

It will be customizable

split hazel
#

always good to have a local copy of the guilds

sharp geyser
#

but by default it will cache the guilds & channels

quartz kindle
#

sure

sharp geyser
#

what is the difference between icon and icon_hash in the discord docs?

#

both say they return a hash

quartz kindle
wheat mesa
#

Nevermind

#

Does not guarantee a role change

sharp geyser
quartz kindle
#

@split hazelimagine making a json format that supports bigints of up to 2gb length

wheat mesa
#

isnt that what floating point types are for tho

#

to some extent of precision

#

since they support exponents

#

(or have I misunderstood something about how floating points work)

quartz kindle
#

thats what bigints are for, when you need more precision

wheat mesa
#

ah

quartz kindle
#

doubles only give you 53 bits of precision

#

bigint has arbitrary/infinite precision

#

a ~2mb bigint has 7 million digits in it

#

imagine a 2gb bigint

#

exdee

proven lantern
#

has anyone used sveltekit? how would i refactor the {#each loop into a function?

quartz kindle
#

you could put it into a separate component and import the component

#

or you could make a js function that outputs html string and call the function in there

#

but idk i havent used svelte yet

proven lantern
#

mmkay, i'll try putting in a different component. i dont think sveltekit lets functions return components

quartz kindle
#

you can do {@html yourvarhere}

#

and it lets you insert raw html

#

so you can do any html string building in pure js instead of svelte loops

sharp geyser
#
                    case GatewayDispatchEvents.GuildCreate: {
                        if(this.manager.client.options.cacheEnabled && this.manager.client.options.cache.guild) {
                            this.manager.client.guilds.set(data.d.id, new Guild(this.manager.client, data.d))
                            for(const channel of data.d.channels){
                                this.manager.client.channels.set(channel.id, channel)
                            }
                        }
                        this.manager.client.emit(GatewayEvents[data.t]);
                    }

Alright so I am going to go out on a limb and say this is not the most efficient way to do it right? Though with my knowledge this is the only way I see to do it

quartz kindle
#

do you want your Guild class to be available only if cached?

sharp geyser
#

Well yea, cause I want guilds, channels, roles to always be cached unless they say they don't want it to

quartz kindle
#

yeah but i mean

#

if cache is enabled, client.on("guildCreate") gives you a Guild object

#

if cache is disabled, then client.on("guildCreate") gives you a raw discord guild?

#

without any of your Guild class methods?

sharp geyser
#

Mmm, yea I don't think that is right

#

Even when not cached it should still have the guild class methods

quartz kindle
#
case GatewayDispatchEvents.GuildCreate: {
    const guild = new Guild(this.manager.client, data.d);
    if(this.manager.client.options.cacheEnabled) {
        if(this.manager.client.options.cache.guild) {
            this.manager.client.guilds.set(guild.id, guild);
        }
        if(this.manager.client.options.cache.channels) {
            for(const channel of guild.channels.values()){ // assuming the Guild class also processes channels
                this.manager.client.channels.set(channel.id, channel)
            }
        }
    }
    this.manager.client.emit(GatewayEvents[data.t], guild);
}
sharp geyser
#

yea I was planning on processing channels with the guild class but wasn't entirely sure on how i should do that

quartz kindle
#
import Channel from "./Channel.js"

class Guild {
  constructor(client, data) {
    if(client.options.cache.channels) {
      this.channels = new Map();
      for(const rawChannel of data.channels) {
        const channel = new Channel(client, rawChannel);
        this.channels.set(channel.id, channel);
      }    
    }
  }
}
sharp geyser
#

Alright thanks :)

#

That was very helpful I didn't think it would be that easy to do that

fickle arch
celest gate
#

the bot is not replying my help command

sharp geyser
#

whatever createMessageComponentCollector is being used on is undefined

celest gate
#
DiscordAPIError: Invalid Form Body
components[1].components[0].options[1].emoji.id: Invalid emoji
    at RequestHandler.execute (/home/container/node_modules/discord.js/src/rest/RequestHandler.js:350:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (/home/container/node_modules/discord.js/src/rest/RequestHandler.js:51:14)
    at async TextChannel.send (/home/container/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:175:15)
    at async Object.execute (/home/container/commands/info/help.js:207:23) {
  method: 'post',
  path: '/channels/960462723836170271/messages',
  code: 50035,
  httpStatus: 400,
  requestData: {
    json: {
      content: undefined,
      tts: false,
      nonce: undefined,
      embeds: [Array],
      components: [Array],
      username: undefined,
      avatar_url: undefined,
      allowed_mentions: [Object],
      flags: 0,
      message_reference: [Object],
      attachments: undefined,
      sticker_ids: undefined
    },
    files: []
  }
}
TypeError: Cannot read properties of undefined (reading 'createMessageComponentCollector')
    at Object.execute (/home/container/commands/info/help.js:215:35)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
sharp geyser
#

Show code

celest gate
#

which folder

sharp geyser
#

Tho it seems like you are sending something incorrectly thus it becomes undefined to where createMessageComponentCollector is not going to work

boreal iron
#

the message content can never be undefined, but null if you send an embed

dry imp
#

invalid emoji

boreal iron
#

(... or component)

boreal iron
celest gate
sharp geyser
#

helpmsg is undefined

#

what is helpmsg

boreal iron
#

once tested djs v14 and it's pissing me off instantly

#

wtf it doesn't even wanna receive any event

sharp geyser
#

strife > djs /s

boreal iron
#

at least guild messages and direct messages are set as intents (4608) but I'm not able to receive any of it

#

just the ready event, nothing else anymore

sharp geyser
#

djs fucking stuff up?

boreal iron
#

idk regarding the debug log, the gateway connection is ok

sharp geyser
#

Well I am not having any troubles receiving those events so it def isn't a gateway issue, so it is likely djs just fucking their code up

boreal iron
#
DEBUG  [WS => Manager] Spawning shards: 0
DEBUG  [WS => Shard 0] [CONNECT]
    Gateway    : wss://gateway.discord.gg/
    Version    : 10
    Encoding   : json
    Compression: none
DEBUG  [WS => Shard 0] Setting a HELLO timeout for 20s.
DEBUG  [WS => Shard 0] [CONNECTED] Took 221ms
DEBUG  [WS => Shard 0] Clearing the HELLO timeout.
DEBUG  [WS => Shard 0] Setting a heartbeat interval for 41250ms.
DEBUG  [WS => Shard 0] [IDENTIFY] Shard 0/1 with intents: 4608
DEBUG  [WS => Shard 0] [READY] Session 40401f6fe1a7f38c0a7db7b03edc1391.
DEBUG  [WS => Shard 0] [ReadyHeartbeat] Sending a heartbeat.
DEBUG  [WS => Shard 0] Shard will not receive any more guild packets.
Unavailable guild count: 1
NOTICE  Logged in as Test app#7080
sharp geyser
#

Weird

boreal iron
#

while Logged in as ... being logged within the ready event

#

no message create event, nothing

sharp geyser
#

and you have the guild messages intent right?

boreal iron
#

idk what's wrong with it

#

yeah

#

[IDENTIFY] Shard 0/1 with intents: 4608

sharp geyser
#

I don't the intents calculation for that :p

boreal iron
#

which is GUILD_MESSAGES and DIRECT_MESSAGES

#
{
  Guilds: 1,
  GuildMembers: 2,
  GuildBans: 4,
  GuildEmojisAndStickers: 8,
  GuildIntegrations: 16,
  GuildWebhooks: 32,
  GuildInvites: 64,
  GuildVoiceStates: 128,
  GuildPresences: 256,
  GuildMessages: 512,
  GuildMessageReactions: 1024,
  GuildMessageTyping: 2048,
  DirectMessages: 4096,
  DirectMessageReactions: 8192,
  DirectMessageTyping: 16384,
  MessageContent: 32768,
  GuildScheduledEvents: 65536
}
sharp geyser
#

yea

boreal iron
#

whatever MessageContent is in that list

#

it doesn't exist in the offical docs

sharp geyser
#

Mmm, maybe they are changing some stuff around and haven't fully implemented it?

boreal iron
#

doesn't matter, i should still receive the message_create event

#

even without content

#

but I'm not gonna get anything except ready wtf

#

even reinviting and deleting the app didn't work

sharp geyser
#

mmm

boreal iron
#

which means it has to be djs, or not?!

#

I'm not sure how I could init the client wrongly

sharp geyser
#

Well it doesn't seem to be a gateway issue as far as I can tell I just tested it with my lib, so it is very likely a djs problem or smth they haven't documented that is required to be done before it works (which I would 100% believe as it has happened before)

slender thistle
#

Didn't they change the message event to something else in some version

boreal iron
#

you mean message to messageCreate?

sharp geyser
#

yea that was v13

boreal iron
#

yeah downgrading to v13 and it works

#

pfff...

#

what a bullshit

pale vessel
#

you need guilds intent

sharp geyser
#

you don't need it for messages I don't think

#

At least I didn't need it

pale vessel
#

i'm pretty sure it's required to receive guild messages now for discord.js, since it heavily relies on caching

boreal iron
eternal solar
#
client.on('message', message => 
{
        read = message.content;
        output = `${prefix}${read}`;
        message.channel.send(output);
})```
this starts an infinite loop, how to stop it after 1st execution?
boreal iron
#

Also direct messages don’t need guild intents

pale vessel
#

i didn't say direct messages

sharp geyser
#

other than ready

pale vessel
#

well that's odd

boreal iron
#

It is indeed

celest gate
#
DiscordAPIError: Invalid Form Body
components[1].components[0].options[1].emoji.id: Invalid emoji
    at RequestHandler.execute (/home/container/node_modules/discord.js/src/rest/RequestHandler.js:350:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (/home/container/node_modules/discord.js/src/rest/RequestHandler.js:51:14)
    at async TextChannel.send (/home/container/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:175:15)
    at async Object.execute (/home/container/commands/info/help.js:207:23) {
  method: 'post',
  path: '/channels/960462723836170271/messages',
  code: 50035,
  httpStatus: 400,
  requestData: {
    json: {
      content: undefined,
      tts: false,
      nonce: undefined,
      embeds: [Array],
      components: [Array],
      username: undefined,
      avatar_url: undefined,
      allowed_mentions: [Object],
      flags: 0,
      message_reference: [Object],
      attachments: undefined,
      sticker_ids: undefined
    },
    files: []
  }
}
TypeError: Cannot read properties of undefined (reading 'createMessageComponentCollector')
    at Object.execute (/home/container/commands/info/help.js:215:35)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
sharp geyser
celest gate
#

help command is not working

sharp geyser
austere surge
sharp geyser
#

what is helpmsg

celest gate
sharp geyser
#

ok cool not what I asked

eternal solar
sharp geyser
#

ofc

#

message has an author prop which holds the sender's user object

eternal solar
#

hmm, i think it should work like this, right?

        var sender = message.author;
        read = message.content;
        output = `${prefix}${read}`;
        message.channel.send(output);
        message.channel.send(sender);
#

if i want to print author id

sharp geyser
#

try it and see

boreal iron
#

author is an object

eternal solar
#

thx, found a way to get author id and hence a way to stop repeating executions

sharp geyser
# boreal iron author is an object

Okay so it does seem to be a gateway issue, I just relaunched my test bot with the v10 gateway and it was only receiving the ready event.

#

I then swapped back to v9 and it works fine

sharp geyser
#
C:\Users\dyeaa\Documents\github\misty\strife\src\client\rest\structures\Guild.ts:16
                        for (const rawChannel of data.channels.values()) {
                                          ^
TypeError: Cannot read properties of undefined (reading 'values')

Alright so for some reason this is starting to act up now. I don't see why data.channels is undefined when in the scope of the if statement

import { BaseClient } from '../../BaseClient';
import { GuildData } from '../../../util';
import { BaseStore } from '../../../stores';
import { Channel } from './Channel';

export class Guild {
    public client: BaseClient;
    public channels = new BaseStore<string, Channel>();
    public id: string;
    constructor(client: BaseClient, data: GuildData) {
        this.id = data.id;
        this.client = client;

        if (client.options.cache.channels) {
            console.log(data.channels);
            for (const rawChannel of data.channels.values()) {
                const channel = new Channel(client, rawChannel);
                this.channels.set(channel.id, channel);
            }
        }
    }
}

But outside of it, there is no issue

fickle arch
#

SHARD_LIST what's the replacement for this in djs 13

#

scrapping some old code for future use

sharp geyser
#

v10 is still experimental iirc to be fair

boreal iron
#

Probably but I wonder if I’m the only one noticing

#

And discord didn’t fix it yet

#

I mean people are supposed to develop stuff to move to v10

sharp geyser
#

Mmm, maybe or again it could be something we don't know about yet and there is a weird requirement

boreal iron
#

Yeah I thought about that, too first but then a working gateway connection only receiving the ready event wouldn’t make sense, too

sharp geyser
#

true

sharp geyser
#

I am trying to find the easiest way to set the guild for the channel and everything i've tried so far doesn't seem to be working/logical when looking at it from the standpoint of the channel must belong to the guild it represents.

#

I was thinking of just setting the guild based on passing a guild to the channel's constructor when creating a new channel class instance but that wouldn't work for when I am setting the channel cache in the different channel events

grizzled patrol
#
components[1].components[0].options[1].emoji.id: Invalid emoji
    at RequestHandler.execute (/home/container/node_modules/discord.js/src/rest/RequestHandler.js:350:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (/home/container/node_modules/discord.js/src/rest/RequestHandler.js:51:14)
    at async TextChannel.send (/home/container/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:175:15)
    at async Object.execute (/home/container/commands/info/help.js:207:23) {
  method: 'post',
  path: '/channels/960462723836170271/messages',
  code: 50035,
  httpStatus: 400,
  requestData: {
    json: {
      content: undefined,
      tts: false,
      nonce: undefined,
      embeds: [Array],
      components: [Array],
      username: undefined,
      avatar_url: undefined,
      allowed_mentions: [Object],
      flags: 0,
      message_reference: [Object],
      attachments: undefined,
      sticker_ids: undefined
    },
    files: []
  }
}
TypeError: Cannot read properties of undefined (reading 'createMessageComponentCollector')
    at Object.execute (/home/container/commands/info/help.js:215:35)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) 
sharp geyser
#

Show code alongside it please

carmine summit
#

do you all make a constructor with default values then define them later? or make a constructer with actual parameters then just do something like this.x = x;?

sharp geyser
#

Depends on the use case

#

Most of the time I find myself just using params tho and giving them values as I need em

pine nova
sharp geyser
#

Looks like what you'd do in C# always line breaking the brackets

pine nova
#

fr

carmine summit
#

should I use function foo({x, y}) {} or function foo(obj) {}? I believe they act the same

sharp geyser
#

Why do that in the first place?

#

Unless you are going to use the object for something then there is no need for foo({x,y})

#

Unless I am unaware of the benefits of doing so

carmine summit
hybrid cargo
carmine summit
hybrid cargo
#

I mean... that depends on you?

carmine summit
#

which is more commonly used?

somber ridge
#

depends on you

#

i use both

earnest phoenix
#

Hello i am 2 years old

#

can i have some milk?

#

Daddy Enigma

split hazel
#

milk privileges denied

hybrid cargo
split hazel
#

@quartz kindle you might know about this - I wonder if you can make a mail server in node?

#

like a proper server that receives emails

quartz kindle
#

but i know nothing about email, its an old ass weird ass protocol that nobody understands

split hazel
#

i dont either

#

it is a weird protocol

#

just like ACPI and USB

#

too bad the whole world uses it and transitioning to something new could be difficult

quartz kindle
#

there are plenty of smtp libs for node

split hazel
#

yeah but thats for sending

#

what about receiving

#

unless it does both

#

idk email is so confusing

quartz kindle
#

it does both but doesnt have any storage, just emits an event

#

you need to combine it with an imap server

#

and some kind of storage

split hazel
#

what is imap for

#

i see so it just emits and receives

#

can you just skip an imap server and use your own database

#

it wont be accessible from external clients anyways only from a dashboard

quartz kindle
#

possibly yes

#

imap is for accepting third party clients like thunderbird to sync with your server

split hazel
#

thunderbird started syncing my entire years worth of email as soon as i linked my gmail 💀

#

had to delete it

quartz kindle
#

yeah thats what it does

#

having your entire email history available offline is its main goal