#development

1 messages Ā· Page 2067 of 1

green kestrel
#

so the optimisation are for speed not size

#

you can do maths on it and convert it to double pretty fast

fossil bronze
#

If only I could do something aobut the memory leaks haha

green kestrel
#

and back

earnest phoenix
#

V8 does actually care about size a lot, but that's as much as it can give it care when it's doing everything on the fly

#

It's pretty complex in simple terms

split hazel
#

wont even ask about objects šŸ’€

fossil bronze
#

but apparently this means it's pretty much unsolvable

pine nova
#

@rose warren how do you record your bot's data? like how many users use slash commands vs message commands?

lyric mountain
#

tbh most of the complaints about java gc are programmer's fault

#

like holding references hostage or forgetting to close streams

earnest phoenix
rose warren
#

Which reminds me...

quartz kindle
#

doesnt v8 use SMI for small numbers? those only take 1 byte

rose warren
#

Time for June's adoption figures... šŸ‘€

earnest phoenix
#

What can you really say when the entire thing is almost the size of the Linux kernel

pine nova
#

or new documents per month

wheat mesa
#

You know something is incredibly complex when they designed a language just for use within that project

split hazel
#

by the way is js supposed to start acting weird when the memory usage is very high (like 4gb+)

wheat mesa
#

Although there are a few different projects that do that

boreal iron
#

You simply record (un)successful executing in your event no matter it’s a message or interaction event

earnest phoenix
rose warren
#

End of June: pretty much 50:50 adoption rate amongst 25k active command users this month.

fossil bronze
#

Woah I find that really surprising

#

Are you doing something to urge them to switch?

wheat mesa
#

I think more users are just finding out about slash commands. They’re actually pretty convenient to use compared to message commands

rose warren
#

Nope. Users on slash have exactly the same user experience as users on prefixed commands. I'm just kinda promoting slash as the default prefix but not a lot.

wheat mesa
#

Guarantees you don’t mistype something about the command

fossil bronze
#

i disagree, but that's alright

boreal iron
raw nest
#

Where do you use which and what's the difference between <type> | : type? I'm still confused about this.

split hazel
# earnest phoenix Weird how?

if i remember correctly a bot i used to run sometimes used a shit ton of ram per cluster and that caused the node process to sometimes freeze completely, or at least parts of it such as connections, so the process would log and work but connections would just completely freeze and everything becomes very weird

#

the freezing isnt only temporary, that i would understand considering the gc is trying not to die

wheat mesa
# fossil bronze i disagree, but that's alright

Think about it this way, instead of having 30 different -optionFlagName toggles that you have to use a help command to find, you can use boolean options and explain what they do in the description field

rose warren
#

I prefer slash commands by far. If I were to make a new bot tomorrow I would go 100% slash.

wheat mesa
#

Makes it a lot easier for the average user that doesn’t want to spend 30 minutes shuffling through a help command just to do something in a command

#

Same

green kestrel
#

meaning must store as string

wheat mesa
#

Not to mention it’s so much easier to verify user input on the developer’s end because most of it is already done on discord’s end

green kestrel
fossil bronze
#

Yeah I see an advantage there of course, it's pretty good the first couple of times you use the command

green kestrel
#

I've done nothing to force them to move over, just changed the docs and help to refer to everything with / on the start instead of !

rose warren
#

I wasn't sold on them in the beginning but after rewriting my bot and being forced to test them and use them I actually prefer them now. They're much easier as a user, they save time, they're easy to type and select, and when made properly by the dev, they guide you through the required parameters which means there's less of a chance of a user running the command incorrectly or struggling to read through documentation to figure out how to use command options.

rose warren
earnest phoenix
# split hazel if i remember correctly a bot i used to run sometimes used a shit ton of ram per...

I suppose either the gateway refuses to continue the connection for some reason that may relate to either the process not responding back due to the event loop being frozen, either because of too much memory usage above the set max memory space, or something related to the libraries used to do the connections, whenever you did that; it's probably fixed now or someway, if it's not then it's probably the first case

fossil bronze
#

But once you know how to use the command that benefit is gone and where I am from most users are used to multi-flag commands

rose warren
#

But if you use the -prefix, the bot will show you the -prefix in the response (like in the help menu etc) and will respond using your preferred prefix. I'm really not forcing them at all.

spark flint
#

forcing inputted data to be formatted

#

aka user input MUST be a valid user or user id

fossil bronze
#

Maybe they have changed slash commands since then, but when I tried them, getting the user inputs was really painful

rose warren
#

They've gotten a lot better recently

boreal iron
#

But still are missing a lot more possible input types as well as different field types in modals

fossil bronze
#

like search the array of options... When they could just have sent them as keys in the object...

spark flint
#

nah its not that bad

rose warren
spark flint
#

hit ratelimit 548 times today according to sentry

boreal iron
rose warren
#

My bot has a habit of getting fucked up on weeks I'm too busy to fix it

spark flint
#

lmao

#

my ratelimiting was my bot mass banning a Hype System raid

green kestrel
#

never had such an issue

rose warren
fossil bronze
#

Can slash cmds get attachments yet?

spark flint
#

yes

#

but its not in djs yet

#

its possible tho

wheat mesa
#

Multi line input when :c

spark flint
#

wait no its in djs but undocumented iirc

spark flint
#

wait no mb

#

thats modal inputs

boreal iron
rose warren
#

My clusters are dying for no reason and my voting manager which has worked for MONTHS without issue just stopped working on my VPS at lunchtime. I spun up an instance of it on my laptop, tested it and it worked.

spark flint
#

modals getting nice

wheat mesa
#

Also I’m gonna make a new bot soon, does anyone recommend anything like error frameworks, etc to put on it? Heard sentry is good but never tried it

spark flint
#

made that command for the Anti.fish server, discovered drop downs so thought I'd impliment it

rose warren
lyric mountain
spark flint
#

close enough

earnest phoenix
# wheat mesa Multi line input when :c

They said they're gonna implement that once they're done with the slash-commands UI redesign, especially with the argument inputs as pills now, but the redesign seems to already be done

#

Still no multi-line inputs, classic Discord

spark flint
#

yeah

#

discordā„¢ļø

#

i think ians overworked lmao

spark flint
spark flint
#

by Ian

wheat mesa
#

Gonna make it alone tho sorry babe šŸ˜”

spark flint
#

opened issue 9 days ago

earnest phoenix
lyric mountain
wheat mesa
#

Just await every promise and you won’t need it!

rose warren
#

Fr

boreal iron
raw nest
rose warren
#

What? šŸ‘€ DISCORD IS A COMPANY?

#

They make money? šŸ‘€

#

No way

raw nest
raw nest
boreal iron
#

Sad times we’re living in

rose warren
raw nest
#

I understand that a company needs to make money and pay their bills etc. and nothing to say against that.. But you notice if the company starts to only focus on making more money and actual user updates come second

rose warren
#

Automod, forums, threads, new bot interactions... Even more in data mining.

raw nest
rose warren
#

It's kinda unfair to say Discord are only focusing on nitro

raw nest
#

Well about automod you could argue that they replace some successful bots that their base is automod etc.

boreal iron
raw nest
boreal iron
#

you shouldn’t forget there are always different teams dealing with different jobs, while nitro features may have become more and more that team probably has no clue how to deal with api features

#

An artist is creating new content not going to build the backend

#

Also to be fair all that nitro shit is mostly just cosmetic stuff nobody actually needs

#

And has a specific age of people as target

sharp geyser
boreal iron
#

/dev/null

#

The black hole of unix

sharp geyser
#

sudo rm -rf /*

boreal iron
#

lmao

ancient nova
#

any idea how to fix [object Map]? when I try mapping it it just turns to [Object object]

lyric mountain
sharp geyser
#

That command gives you a +200 in social credits

boreal iron
sharp geyser
ancient nova
sharp geyser
#

Well what exactly are you doing first

#

cause I am not going to just guess what is happening

ancient nova
#

but I'm having trouble

sharp geyser
#

isn't joinedUsers already a array?

ancient nova
sharp geyser
#

Wait if I remember correctly this is the handler function for your collector right?

ancient nova
#

this is what joinedUsers it

sharp geyser
#

so joinedUsers is a collection which extends map

#

so ofc it will look like that when trying to use it out right

ancient nova
#

okay that makes sense, how can I fix it?

#

I tried boxing it into a promise and resolving nothing seems to work

sharp geyser
#

you could use .join on joinedUsersMap as it is now an array

ancient nova
#

let me try that

quartz kindle
#

and you can always offload you cache to somehting like lmdb or redis which can store them as native 64bit ints

ancient nova
#

still returns object object

sharp geyser
#

ah wait

#

I am dumb

boreal iron
#

Just log your var and see what its structure actually is

sharp geyser
#

you mapped it so now it is an array of user objects

#

map it so it only returns what you want it to ig

quartz kindle
#

and not awaiting endFunc, which is the thing that should actually be awaited

ancient nova
#

cause checking size doesn't need awaitng as in, for some reason, from what everybody is telling me, to get users I need to do some weird awaiting, mapping or god knows what

boreal iron
quartz kindle
ancient nova
#

well it works so I won't question it

#

that collected.size returns the size of the reactions

#

meaning how many people reacted

#

I'm not structing it

quartz kindle
#

if it needs to be awaited, it doesnt have .size
if it has .size its not a promise so it does not need to be awaited

ancient nova
#

it's what discord.js returns

#

then what am I doing wrong

#

I just want to display all the users who reacted

#

to a message

#

why is everyone making it out so difficult

quartz kindle
#

.map also does not need awaiting

#

you are seeing [Object object] because joinedUsersMap is a Map/Object/Array

#

you cannot convert that to a string directly

#

you need to either JSON.stringify or join into a string

ancient nova
sharp geyser
#

so if he just .map(e => e) doesn't that just turn the contents into an array. So it is still an array of user objects

quartz kindle
#

exactly, that map is not doing anything

#

its a collection of objects, so joining objects will implicitly convert them to [object object]

sharp geyser
#

you can map for specific things though like .map(e => e.username) or smth along those lines

quartz kindle
#

you need to map into something actually useful ^

boreal iron
#

Just log your var and see what its structure actually is

I said this for a reason
If people see the structure of their vars they may understand what they have done wrong

sharp geyser
#

FakE this guy is notorious for not doing that kind of thing

#

its talking onto deaf ears

boreal iron
#

I know KEKW

sharp geyser
#

It is sad when Team Snapchat is the only one to message you šŸ˜”

sharp geyser
#

oh yea

boreal iron
#

(trying to explain)

sharp geyser
#

nah that is just tim as soon as he walks into development

#

fuck am I talking about general

boreal iron
#

ban soon

ancient nova
#

joinedUsers or joinedUsersMap?

sharp geyser
#

well you don't need to log any anymore as we already told you the issue

#

map the info into something useful

#

not into itself

boreal iron
#

I told you to log it before they explained what it is to see yourself what structure this var has

ancient nova
#

bro I don't know what you mean by "map the info into something useful"
can you please just tell me how to get all the users who reacted to the message

sharp geyser
#

you already have all the information you need

#

you just need to turn it into something that can actually be used

boreal iron
#

map the user names as you want them or not?!

sharp geyser
#

I already told you here

boreal iron
#

Ah there we go

quartz kindle
#

you need to specify which part of the user object you want

#

thats what we mean with "remap into something useful"

boreal iron
#

If you don’t and map the entire object (item) the result is the same as the array you’re trying to map in the beginning

ancient nova
#

[null]

#

that's what it returns now

quartz kindle
#

show

ancient nova
quartz kindle
#

cod

boreal iron
#

oof

ancient nova
boreal iron
#

I was close to hit a tree

#

God thanks there are non on the highway

quartz kindle
#

if that is showing null, that means those are not even users

#

what exactly are you collecting?

ancient nova
#

I'm collecting freaking reactions, and trying to get who reacted out of them...

boreal iron
#

Is this the same collector like the last discussion?

ancient nova
#

like literally trying to take all the users who reacted into an array map or anything I just want them stored

ancient nova
#

why can't nobody just tell me straight how to store users who reacted to a single message

boreal iron
#

I mean people can spoon feed but aren’t there like 1 million examples out there how a reaction collector works?

#

I’m sure there are

ancient nova
#

no I've literally been browing google for shitty examples that don't work or explain anything

quartz kindle
#

show your collector code

ancient nova
#

it was formatted better before I just changed it to a code an other guy who tried to help me gave me

#

it didn't work either though.

quartz kindle
#

ok there are a few things that are wrong

#

users and reactions are separate things, im not sure what djs's collected returns on the end event, but i assume its only the reactions and not users

#

so the safe way would be to collect the users in the collect event

#

simiarly to how you are counting the number of users

ancient nova
#

so something like this?

#

I wanted to do that from the start but someone said that's not how you do it

#

jesus christ

quartz kindle
#

yes

#

you still need the end event

ancient nova
#

I'm aware

#

that's stupid

#

whoever told me to do that I hate you

quartz kindle
#

well dont blindly follow people and try to read docs instead

#

and console.log your variables so you dont do it blindly

ancient nova
#

yeah I should've done that

#

if I have picked a word how can I slice it into individual letters to put into an array?

woeful pike
ancient nova
#

ok that will probably require doing some math

#

if I have a word and split it into _ using .repeat

startingEmbed.addField("Letters Guessed", "_".repeat(wordToGuess.length));

how can I replace the specific letter if guessed instead of _?

#

TypeError: Cannot read properties of undefined (reading 'awaitMessages')

    const startGame = async function (joined) {
        const peoplePlaying = joined;
        const wordToGuess = possible_words[Math.floor(Math.random() * possible_words.length)].toUpperCase();
        const lettersToGuess = wordToGuess.split("(?!^)");

        const startingEmbed = new MessageEmbed();
        startingEmbed.setTitle("Hang Man");
        startingEmbed.setColor(commandColor);
        startingEmbed.addField("Current Players", peoplePlaying.join(", "));
        startingEmbed.addField("Letters Guessed", "_".repeat(wordToGuess.length));

        const startingMessage = message.channel.send({embeds: [startingEmbed]});

        const filter = (reaction, member) => peoplePlaying.includes(member.user.username);
        const collection = await startingMessage.channel.awaitMessages({ filter, time: 180000 });

        const replaceAt = function(text, index, replacement) {
            return text.substring(0, index) + replacement + text.substring(index + replacement.length);
        }

        collection.on('collect', (msg) => {
            if (lettersToGuess.includes(msg.content)) {
                const msgIndex = wordToGuess.indexOf(msg.content);
                let newGuessedText = replaceAt(wordToGuess, wordToGuess, msg.content);

                const startingEmbed = new MessageEmbed();
                startingEmbed.setTitle("Hang Man");
                startingEmbed.setColor(commandColor);
                startingEmbed.addField("Current Players", peoplePlaying.join(", "));
                startingEmbed.addField("Letters Guessed", newGuessedText);
                
                startingMessage.edit({embeds: [startingEmbed]});
            }
        });
    }
#

any ideas?

quartz kindle
#

.send() has to be awaited

ancient nova
#

this line: ```js
const filter = (reaction, member) => peoplePlaying.includes(member.user.username);

wheat mesa
#

Because that’s not the filter

#

The filter for awaitMessages is only one parameter, a Message object

ancient nova
wheat mesa
#

Yes

#

You should be able to

ancient nova
#

am I doing anything wrong?

#

looks quite cool already not going to lie tho

#

hopefully I can get it working

sharp geyser
#

Ima just go back to learning python

quartz kindle
#

you cannot use .on("collect") on it

#

awaitMessages is a simplified collector that returns when the collector ends, its the same as returning the value of the end event in a collector

ancient nova
sharp geyser
#

Doesn't the normal message collector do that?

ancient nova
#

define "normal"?

sharp geyser
#

just don't give it a max

ancient nova
#

I thought this was the only one

sharp geyser
#

ofc not

ancient nova
#

what's the other one?

sharp geyser
#

the more you talk in this channel the more I realize you never read documentation

#

When I used djs I only ever used createMessageCollector

#

so idk if awaitMessages can already do what this one does so you might not even need to use this one

#

but it is an option if you wanna handle the data yourself

ancient nova
#

yeah this seems to be what I wanted

#

lets see if it works

#

hmm still doesn't appear to collect any messages

sharp geyser
#

@dry imp who would ever format a string like this

#

isn't print(f"") a thing?

ancient nova
#

any idea why this collector doesn't work?

#

can paste letters nothing ever updates

sharp geyser
#

define 'Doesn't work'

#

What is it doing?

dry imp
ancient nova
#

nothing, the embed just sends and doesn't update when you type the correct letter

sharp geyser
#

question

#

can't you just include your lettersToGuess logic in the filter

#

actually nvm

#

I am dumb

ancient nova
#

lol

#

soo

#

I still have 0 idea why it doesn't appear to work

sharp geyser
#

Neither do I

#

haven't touched djs in ages so can't really help when it comes to collectors

ancient nova
#

lol

#

just when I think I found the answer my VPS getting ddosed

#

šŸ’€

#

I am officially deceased

lyric mountain
#

lock the ports ez pz

#

but really, you shouldn't have unlocked ports without any authentication or safety layer

ancient nova
#

somehow the replacement doens't work

#

it just gives the correct char first and then the word u were supposed to guess

woeful pike
#

man yall really send messages to your bot through discord to test your business logic like this?

#

must be an excruciating development cycle

pale vessel
#

Imagine wasting all the identify sessions just to test your hangman game

vivid fulcrum
#

tbf unit testing a discord bot is annoying and hard

#

you should still separate your business logic from the discord mess though, at least make the testing a tiny bit easier

sharp geyser
woeful pike
#

why involve discord at all?

sharp geyser
#

Wym

#

What else can you use

woeful pike
#

you don't need discord to play and test the business logic of hangman

sharp geyser
#

I mean true

wheat mesa
#

Set up tests for the logic of your hangman game instead

#

It can be easier in some cases

woeful pike
#

instead of messing around on discord constantly restarting and reconnecting your bot. Go write a test and keep changing stuff until it passes. By the end you'll have a working test suite instead of a channel with 800 spammed messages

wheat mesa
#

Personally I don’t do this but for the next bot I make I’ll probably end up doing that, would save a ton of time

#

Once you have the logic of your game, then you can move to the logic of the bot šŸ˜‰

woeful pike
#

doing functional programming really drills this concept into ur brain since your life becomes so much harder when you don't do it this way

quartz kindle
#

or do it like i do and mentally unit test things for days on end

#

:^)

wheat mesa
#

Tim you are literally the js interpreter though

woeful pike
#

idk what ppl have against unit tests tho. It's literally faster to test than sending messages on discord

quartz kindle
#

they are hard

#

thats all

woeful pike
#

setting up jest is a pain in the ass that's true

wheat mesa
#

Because it’s annoying to set up your logic separately sometimes and some people just want to see how it looks in discord

woeful pike
#

I mean the discord part of things is the smallest portion

#

most of what you're dealing with is business logic

ancient nova
wheat mesa
#

I like to see what it looks like in discord, if you do a command 30 times testing it then you can make design choices on how to make it more usable/enjoyable

woeful pike
#

sure but then you send like 4 messages instead of 480

woeful pike
ancient nova
#

it will take twice as long to code and test

#

even if the game logic works flawlessly integrating it to work with discord afterwards also takes time

woeful pike
#

not as much as making the game itself

ancient nova
#

I still have the error but I decided to continue with the game tomorrow

#

can't be bothered to finish

woeful pike
#

give it a shot sometime, you might be surprised at how much nicer it is to work with raw data instead of coupling to discord

ancient nova
sharp geyser
ancient nova
#

yes, it may be a little easier to make that, but it will take a longer time

#

so what will you pick?

woeful pike
#

i mean idk it sounds like you wasted a lot of time dealing with discord related stuff already chaewonlaugh

#

you're not writing more code, just decoupling stuff

fallen holly
#

how do i check for user permission from a interaction

sharp geyser
#

there should be a .member prop on the interaction you get back

#

with that you can access their permissions and do what you will with em

sharp geyser
wheat mesa
#

🤨

sharp geyser
#

What waffle

boreal iron
#

just don’t ask

sharp geyser
#

Hey I am following the pycord tutorial on how to do it

#

fuck off

wheat mesa
sharp geyser
#

isn;t 55 very low

wheat mesa
#

Pretty low yeah

#

Been 32 before though so

sharp geyser
#

how you not die

wheat mesa
#

Got lucky

boreal iron
#

Common guy has literally no clue about this if that’s high or low

sharp geyser
#

That is why I asked FakE

boreal iron
#

Lemme answer with

sharp geyser
#

smh

boreal iron
wheat mesa
#

Normal human’s blood sugar usually ranges from 80-140

#

My average blood sugar for the past 3 months was not good, 262

sharp geyser
#

oof

wheat mesa
#

But I’m working on it

#

Less stress in the summer

boreal iron
sharp geyser
#

well there was 2 people talking boomer

wheat mesa
#

This is my blood sugar in the last 24 hours, red line is below 80 and yellow line is above 180

boreal iron
#

Looks weird

wheat mesa
#

Sorta

#

Glad I have this thing tho, definitely saved my life a few times

sharp geyser
#

where the fuck is the red and yellow line

#

am i just color blind

wheat mesa
#

The red section and the yellow section

#

Dingus

sharp geyser
#

It literally all looks black and white to me

boreal iron
#

Zoom in my gosh

wheat mesa
#

My dude you are colorblind

craggy pine
#

I see black dots and a big blue rectangle going across the screen

sharp geyser
#

Bruh it literally looks all white

#

even if I zoom in

boreal iron
#

I see red yellow and gray

sharp geyser
#

Bruh tf is up with discord

#

It doesn't show the colors (veryy very dim btw) until I go to take an ss

craggy pine
#

When I dim the picture I see the red now

boreal iron
#

Probably your bad screen not discord

sharp geyser
#

No it literally is discord

#

I have to dim the pic

#

and even then it is hard to see

boreal iron
#

Don’t blame discord for your bad eyes

sharp geyser
#

Are you talking about me having bad eyes?

#

fucking auto correct I should stop talking about blind people

boreal iron
#

i know how you feel sir

sharp geyser
#

@wheat mesa I went through an entire 2h crash course on python I think I got the basics

boreal iron
#

Better forget it all, quickly

sharp geyser
#

no tf

#

I actually need python rn

boreal iron
#

nobody needs python

sharp geyser
#

actually in this use case I do

#

so

#

fuck off

boreal iron
#

We just accept it as we’re tolerant

#

Alr back to work

#

Buy some glasses dingus

sharp geyser
#

no u

lyric mountain
#

Wait until they make a minor release that breaks everything

lyric mountain
#

Python

#

Breaks every update

dry imp
#

misty using python? 😱

sharp geyser
#

Yes

dry imp
#

time to rate your indentation šŸ¤“

pallid zinc
#

i have a function which use instagram oauth and it works well but as soon as i use it inside of a express .get() event it starts to give errors

#

does anyone have idea about it?

#
app.get("/", async (req, res) => {
  var code = req.query.code.toString();

  console.log("CODE", code)
  getAccessToken(code)
  res.send("<body></body>")
})

const getAccessToken = async (code) => {
    axios({
        method: 'POST',
        url: 'https://api.instagram.com/oauth/access_token',
        data: qs.stringify({
            client_id: '',
            client_secret: "",
            grant_type: 'authorization_code',
            redirect_uri: "URL",
            code: code.toString()
        })
    })
    .then(function (response) {

    console.log(response)
     axios.get("https://graph.instagram.com/me/media?fields=id,caption,media_url&access_token="+response.data.access_token)
     .then(async (response) => {
         console.log(response.data)
     })
     .catch((e) => { console.log(e) })
    })
    .catch((e) => { console.log(e) })

};
#

instagram oauth is getting annoying if anyone have experience using it will be appreciated

dry imp
sharp geyser
pallid zinc
#

🄺 thanks

sharp geyser
#

No

#

Np*

pallid zinc
#

Its just im trying this for 3 days and it's keep on getting irritating

bright hornet
#

https://sourceb.in/eITrejT74a, just wanna try about connecting 2 js files using discordjs, but how do I call the async execute for client, message, args, prefix on my levels.js?

ancient nova
#

I want to repleace a word with a letter but keep everything the same. how

#

word = hey
replace e with i
word = hiy

#

how can I do that?

#

but not by text since wordToGuess is just a bunch of _ _ _ _

#

but by position of the char

#

so

#

word = hey
replace 2nd char with i
word = hiy

#

HOW

#

TO

#

DO

#

THAT

#

?

woeful pike
#

keep your string as an array and join it when you need to display it

ancient nova
#

any idea why this doesn't work?

#

only works for one letter then breaks

#

tries used doesn't even count itself for some reason

#

:/

sharp geyser
#

You have to increment whatever tires used is

#

Tries*

bright hornet
#

Yo misty, do you think checking all array for one item is possible?

ancient nova
#

if wordToGuess contains the letter, increment choice and if more than 6 choices kill the game

#

is that not right/

sharp geyser
#

Idk I'm too tired to think through your code

#

So to recap your what breaks?

ancient nova
#

it ony works for 1 letter then stops accepting any others

#

plus it doesn't seem to count the wrongChoices even though it's clearly there

#

ever seen a 19kb hangman game KEKW

#

the code is a mess

sharp geyser
#

Even though you increment wrongChoices you do know you have to edit the embed right

ancient nova
#

I am

bright hornet
#

do you intend to replace the _ value to array value?

ancient nova
sharp geyser
#

Tbh your code is rather confusing to read on mobile

#

The pics are super blurry

bright hornet
ancient nova
#
        collection.on('collect', (msg) => {
            const guessedLetter = msg.content.toUpperCase();
            
            // Checking if the leter includes the any of the correct letters 
            if (lettersToGuess.includes(guessedLetter)) {
 
                if (!lettersGuessed.includes(guessedLetter)) {
                    lettersGuessed.push(guessedLetter);
                }
                // Do a game over screen if player tries too many times.
                if (wordToGuess.indexOf(guessedLetter) === -1) {
                    wrongChoices++;
                    if (wrongChoices === 6) {
                        hasWonGame = false;
                        collection.stop();
                    }
                }
                // Check if player won instead of losing.
                if (wordToGuess.split("").map(l => lettersGuessed.includes(l) ? l : "_").includes("_")) {
                    hasWonGame = true;
                    collection.stop();
                }
                
                // Generate a new text after the guess.
                const newGuessedText = wordToGuess.split("").map(l => lettersGuessed.includes(l) ? l : "_").join(" ");
                
                const startingEmbed = new MessageEmbed();
                startingEmbed.setTitle("Hang Man");
                startingEmbed.setDescription("You can guess by sending an individual letter in chat. If guessed properly the message will update. All of you have 3 minutes to win the game, otherwise it will fail automatically! Good Luck!");
                startingEmbed.setColor(commandColor);
                startingEmbed.addField("Current Players", peoplePlaying.join(", "));
                startingEmbed.addField("Letters Guessed", "```" + newGuessedText + "```");
                startingEmbed.addField("Tries Used", wrongChoices + "/6");
                
                startingMessage.edit({embeds: [startingEmbed]});
            }
        });
bright hornet
#

the function ends?

ancient nova
#

have the entire collection

#

yes

bright hornet
#

do looping

ancient nova
#

what do you mean?

#

the collector shouldn't be ending for no reason anyway should it. tho

bright hornet
#

ill give a sample

sharp geyser
#

Huh

#

Why would you loop

#

His logic is probably just wrong but I can't exactly tell cause I'm on mobile. Everything looks bad on mobile

bright hornet
#

just seen your code

bright hornet
#

you have alot of if statements

ancient nova
#

misty do you want the IDE I made for mobile

sharp geyser
#

No

#

I've been there done that

ancient nova
sharp geyser
#

Never coding on mobile

bright hornet
ancient nova
#

my IDE is actually good tho

sharp geyser
#

Idc

ancient nova
#

proper syntax highlighting

#

code indexing

#

code indenting as well

sharp geyser
#

I'm good thanks

ancient nova
#

okay okay

#

anyway

#

how to fix :c

sharp geyser
#

Well you can log things and see what's happening

ancient nova
bright hornet
#

how many is your max?

#

I hope its not 1

ancient nova
#

I don't have a max set

#

so?

feral aspen
#

How can I make properties lead to classes? Example:

const a = new Student();
a // Student Class.
a.meow // Meow class
vivid fulcrum
#

šŸ¤”

#

a is your student instance, not a class they're taking

feral aspen
#

Logging a logs the Student class.

#

You know, it's like in discord.js. message returns Message and message.channel returns TextChannel, supposedly.

vivid fulcrum
#

oh, sorry, i misunderstood

feral aspen
#
module.exports = {
    Student: class {
        constructor (name, age, ID) {
            this.name = name ?? names[Math.floor(Math.random() * names.length)];
            this.age = age ?? Math.floor(Math.random() * 13) + 5;
        };
    },
};
vivid fulcrum
#

it's just a property on the object like any other

feral aspen
#

Here's my current class, supposedly.

feral aspen
vivid fulcrum
#

sure

#

it's a property like any other

#

so for example

feral aspen
#

this.example = class {}?

vivid fulcrum
#

this.school = new School(); would create a school property that leads to the school object

#

also

#

is there a particular reason why you're creating classes like that

feral aspen
#

I've trying to achieve same thing like discord.js, but for my own example.

#

Example, example...

#
a.name; // Bob
a.age; // 16
a.password; // Returns a class.
a.password.change('NEW_PASSWORD'); // Modifies the password
#

Hopefully, you understood what I'm trying to achieve.

vivid fulcrum
#

where School would be another class that has its own properties and methods

feral aspen
#

Oh, wait.

vivid fulcrum
#

read through this

#

you're getting confused about basic object-oriented programming concepts

feral aspen
#

For sure, many thanks!

vivid fulcrum
#

there's also this if you wanna take a look

feral aspen
#

I'll look into it.

idle coral
#

Reason:

Error: Request failed with status
code 400 at createError(/home/runner/Gage/node_modules/erela.js-spotify/node_modules/axios/lib/core/createError.js:16:15) at settle (/home/runner/Gage/node_modules/erela.js-spotify/nodemodulesaxios/lib/core/settle.js:17:12) at IncomingMessage.handleStreamnd(/home/runner/Gage/node_moduleserela.js-spotify/node_modules/axios/adapters/http.js:244:11) at IncomingMessage.emit(node:events: 402:35) at endReadableNT (node:internal/streams/readable:1343:12) at processTicksAndRejections(node: internal/process/task queues: 83:21
#

I keep getting this unhandled rejection when trying to run my bot..

earnest phoenix
# idle coral Reason: ``` Error: Request failed with status code 400 at createError(/home/runn...

The status code 400 means bad request, the error seems to be coming from the erela.js-spotify package you're using, you're either using it incorrectly by either passing in the wrong credentials, or the wrong arguments to it's functions/methods, or the package is pretty much outdated as it was last updated 2 years ago
https://www.npmjs.com/package/erela.js-spotify

lyric mountain
feral aspen
lyric mountain
#

...student.school // School instance

#

damn now school sounds like a weird word

feral aspen
lyric mountain
#

why are you even using that syntax for OOP?

#

use a normal class definition

feral aspen
#

I'm unsure what I'm supposed to be doing, in the first place.

feral aspen
#

Trying to create a replica but like a student-school system based.

lyric mountain
#

because they use ā˜€ļø classes ā˜€ļø

feral aspen
#
module.exports = {
    Student: class {
        constructor (name, age, ID) {
            this.name = name ?? names[Math.floor(Math.random() * names.length)];
            this.age = age ?? Math.floor(Math.random() * 13) + 5;
            this.school = // Returns School class.
        };
    },
};
lyric mountain
#
class Student {
  constructor(schoolName) {
    this.school = new School(schoolName);
    this.school.students.push(this);
  }
}

class School {
  students = [];

  constructor(name) {
    this.name = name;
  }
}

let std = new Student("Harvard");
console.log(std.school.students); // [[object Student]]
feral aspen
#

Ohh, alright, alright. šŸ‘

lyric mountain
#

also don't save age, save birth year

feral aspen
lyric mountain
#

even for imaginary cases, saving age is asking for having to update your entries each year

#

just save birth year and do today - birth

feral aspen
#

Indeed, for now, I'm just trying to learn as much as I can about classes and figure out how prototypes, inheritance, etc. works.

lyric mountain
#

even better then, make a getAge to convert birth year to age

feral aspen
#

In terms of <Class>.prototype, does it work with class <Class Name> or only for function classes like let a = () => { this.name = 'm' };

lyric mountain
#

prototype is something that should never be touched

#

but if you really need to, it works with anything that extends Object

#

so anything in js

feral aspen
#

What if I want to make my own methods?

lyric mountain
#

then u add the methods to the class

feral aspen
#

This is my current code, for example:

const { names } = require('../functions/names.js');

class Student {
    constructor (name, age, ID) {
        this.name = name ?? names[Math.floor(Math.random() * names.length)];
        this.age = age ?? Math.floor(Math.random() * 13) + 5;
        this.loggedIn = false;
    };
};

Student.prototype.login = () => {
    this.loggedIn = true;
    console.log(`Successfully logged in to your account. Welcome, ${this.name}.`);
}

module.exports = { Student };
#

this.name would return undefined.

lyric mountain
#
class Student {
  constructor(name) {
    this.name = name;
  }

  function login() {
    this.loggedIn = true;
    console.log(`Successfully logged in to your account. Welcome, ${this.name}.`);
  }
}
feral aspen
#

Without the function.

lyric mountain
#

WITH function

feral aspen
#

HUH, it errors?

lyric mountain
#

re-check ur scope

earnest phoenix
#

You can't use the function keyword to denote methods in a class

lyric mountain
#

really?

feral aspen
#

I don't think, yeah.

lyric mountain
#

well, remove it then

#

actually, wait lemme check something

feral aspen
#

However, when I am in the console and I log a in const a = new Student(), it shows the methods too which I don't want but instead put in the prototype of Student.

feral aspen
lyric mountain
#

tf I swear function was used for declaring functions

feral aspen
#

Or in object properties.

#

const a = { f: function() {} }

earnest phoenix
feral aspen
#

I mean, it did say I can just use prototypes to achieve such so.

lyric mountain
#

no u cant

feral aspen
lyric mountain
#

prototype should not be used unless it's absolutely necessary

#

it's, imo, a flaw of js

feral aspen
#

I mean, the prototype I'm using is for a class (that I created), only.

lyric mountain
#

still

feral aspen
#

But then I'll be repeating methods?

#

Over and over, again.

lyric mountain
#

no, declare its properties and functions inside it's definition

#

then simply use it

feral aspen
#

So I just put the function inside the class as a method, that's it?

earnest phoenix
# feral aspen What does that mean?

For example

class Foo {
  constructor(bar) { this.baz = bar; }
}

Object.defineProperty(Foo.prototype, {
  value: function biz() {
    return this.baz + 1;
  },
  enumrable: false
});
#

That's the way to define innumerable properties/methods, just as you wanted as you said you didn't want the methods to show up

#

You can use the Object.defineProperties() method to define multiple

lyric mountain
#

not really worth the extra work tbh

feral aspen
earnest phoenix
#

Why would you not want the methods to show up though?

feral aspen
earnest phoenix
#

Yes

feral aspen
#

Supposedly, show how the login() code works?

#

Even in real life scenarios?

lyric mountain
#

you aren't supposed to print the object itself in a real life scenario

#

nor have sensitive logic inside objects

feral aspen
#

Alright, fair.

crystal wigeon
#

How do I show server count next to my bot?

#

On topgg

lyric mountain
#

call the api

#

see #topgg-api, plenty of people ask about that there

feral aspen
#

Also, did I do this correct in terms of passwords?

const { names } = require('../functions/names.js');

class Student {
    constructor (name, age, ID) {
        this.name = name ?? names[Math.floor(Math.random() * names.length)];
        this.age = age ?? Math.floor(Math.random() * 13) + 5;
        this.password = new Password(this.name.slice(0, 3) + '@' + this.ID);
    };
};

class Password {
    constructor(password) {
        this.password = password;
    };

    show() {
        return this.password;
    }
}

module.exports = { Student };
#

I messed up in the understanding of your earlier example.

lyric mountain
#

you don't really need show(), just access it directly

feral aspen
#
        this.password = new Password(this.name.slice(0, 3) + '@' + this.ID);
                      ^

TypeError: Cannot set property password of #<Student> which has only a getter
crystal wigeon
lyric mountain
lyric mountain
feral aspen
#

Oh, well, it worked since I removed the get password which I defined earlier.

lyric mountain
#

well u do need to make a setter if ur gonna change the value

feral aspen
#
Student {
  name: 'Lois',
  age: 14,
  password: Password { password: 'Loi@0037' },
}
#

It returned this.

lyric mountain
#

yes, it's an object

feral aspen
#

Don't you think it's supposed to return something like [class Password].

lyric mountain
#

no, password is an object instance too

feral aspen
#

Oh, so I should make something like this.password = Password?

lyric mountain
still burrow
#

ok

sharp geyser
#

Very descriptive thanks

feral aspen
sharp geyser
#

Never seen someone create a password with a class

feral aspen
#

I know, just trying to figure out how I can work with classes.

earnest phoenix
#

Other than that you can also make it a getter

sharp geyser
#

Or delete it from the object when displaying it

lyric mountain
#

if someone has console access to the code I think there are bigger issues tbh

feral aspen
#

Alright, I believe I figured it out.

feral aspen
lyric mountain
#

tbh, I'd suggest you to try fiddling with java a bit

sharp geyser
#

Dw my system is already vulnerable

#

Best words I've heard all day

feral aspen
#

Ik.

lyric mountain
#

java is really good to teach how to OOP since it screams at you if u dont

#

ig that's why schools use it after C

feral aspen
earnest phoenix
feral aspen
#

I reached classes and I'm learning it in Javascript first to learn it in Java, then, or later.

lyric mountain
#

js wasn't made with OOP in mind, I said java cuz regardless of where you look, all tutorials and studying materials will have it done through classes and objects

#

with js you'll probably find people doing it functionally

sharp geyser
#

Functional js is fucking pain imo

feral aspen
lyric mountain
feral aspen
#

How does discord.js handle such so? Eyes

lyric mountain
#

you can use oop in js, it's just not as robust

earnest phoenix
#

You can't call JS pain when you use Java troll

lyric mountain
earnest phoenix
feral aspen
earnest phoenix
feral aspen
#

I mean, I've repeated this multiple times and it's getting quite repetitive, but it's having properties returning classes to be used.

#

<Message>.channel returns said channel class which I can then use its methods, properties, etc.

earnest phoenix
#

It's properties aren't returning classes to be used, those are class instances

lyric mountain
#

you cannot access methods of a class (unless they're static, and idk if js has that)

sharp geyser
#

Js has static ofc

lyric mountain
#

you need to first make an instance and THEN access its methods

earnest phoenix
#

When you do this.password = Password for example, you're assigning it the class itself, not an instance of it

earnest phoenix
#

When you do this.password = new Password(...), you're instantiating a new instance of the class

feral aspen
#

How will I be able to connect such whereas if I type a.password, it would take me to the Password class or let's say the instance.

lyric mountain
#

it already does

feral aspen
#

Alright, so that leads me to the place I am now.

lyric mountain
#

try doing a.password.password in ur current code

feral aspen
#

Yes, it returns a string password.

lyric mountain
#

the last password isn't inside Student, it's inside the Password instance

feral aspen
#

Yes.

lyric mountain
#

then u did a.password u accessed the instance u created

feral aspen
#

However, how will I be able to use values such as this.loggedIn in the Password class, do I use the extends syntax?

earnest phoenix
#

If you want to access the password (the string) with just a.password for example instead of a.password.password, what you're looking for is extending the classes

lyric mountain
#

a.password.loggedIn

#

think of . as / in a folder

#

and properties as files/folders

feral aspen
lyric mountain
#

extension isn't for that

feral aspen
#

a.password.loggedIn returns undefined?

lyric mountain
#

because u didn't add that to the class

#

u only added password prop

feral aspen
#

Yes.

lyric mountain
#

u cant access a property that doesn't exist at all

#

it's like doing card.fly

#

ok, what's fly?

feral aspen
#

I mean, I'm wanting to use the loggedIn from the Student class, however?

lyric mountain
#

then don't access password at all

earnest phoenix
#

That's what I told you

lyric mountain
#

no

lyric mountain
feral aspen
#

What if I want to use the value in the Password class?

lyric mountain
#

you pass in the constructor

feral aspen
#

There's two, now, though?

lyric mountain
#

no, a single

feral aspen
#

this.loggedIn in Password and Student.

lyric mountain
#

look, that's not how you think in oop

#

why would Password use loggedIn?

#

you need to think as real life objects

earnest phoenix
#

I think you two are confusing each other with the concept of what exactly that needs to be achieved

lyric mountain
#

why would Apple access properties of Pie?

feral aspen
#

I want to be able to do something like:

a.password.change("NEW_PASSWORD")
/*
It has to check whether loggedIn is true for the user before changing the password.
*/
lyric mountain
#

do instead a.changePassword("NEW_PASSWORD")

feral aspen
#

Wat, but that's the whole purpose of the Password class, though, to put the change() method inside it.

lyric mountain
feral aspen
#

My point is, how do I access loggedIn from Student while I am at Password.

lyric mountain
#

you dont

feral aspen
#

Not even using extends Student and super()?

lyric mountain
#

or if you REALLY must, pass the Student instance to Password

#

new Password(this, "pass")

earnest phoenix
#

You need to either extend the class to access those properties, or pass them in the constructor

feral aspen
#

Where do I pass in super() or what's the continuation of it?

lyric mountain
#

oh my

earnest phoenix
#

But if you extend it, you'll also be instantiating a new instance of the Student class instead of using a different one you already instantiated

lyric mountain
#

sir, even if you extend, YOU WONT have the properties of the other instance

feral aspen
#

Oh.

lyric mountain
#

before extending you need to ask yourself:

"Is A an instance of B?"

#

like, a dog is an animal, thus Dog extends Animal

#

but a fork isn't a plate, so Fork extends Plate is totally senseless

feral aspen
#

Alright.

earnest phoenix
#

You can basically have another parameter called loggedIn for example, and pass that in, or pass it to the method called change() for example

lyric mountain
#

if you really, REALLY need to access the parent's properties from a child do

class Parent {
  constructor(aProp) {
    this.aProp = aProp;
    this.child = new Child(this)
  }
}

class Child {
  constructor(parent) {
    this.parent = parent;
  }
}
#

now u can do parent.child.parent.child.parent... ad infinitum

#

this is called ciclycal reference

#

for obvious reason, you can't use JSON.stringify on it anymore

#

or any other sort of serialization

feral aspen
#

You defined parent first, right?

spark flint
#

Accidentally caused a code issue I can’t find

#

šŸ’€

lyric mountain
#
let p = new Parent("abc");

console.log(p.child.parent); // will error, but it would print whatever "p" is
earnest phoenix
spark flint
#

Ty

lyric mountain
#

child has a reference o parent, so it can access its properties normally

feral aspen
feral aspen
#

Ciclycal reference.

lyric mountain
#

yes, remember that

#

if you have a cyclical reference you won't be able to serialize it at all

#

since it'll make a reference cascade

feral aspen
#

Yup, I believe that's what I was trying to achieve.

lyric mountain
#
parent: {
  aProp: "abc",
  child: {
    parent: {
      aProp: "abc",
      child: {
        parent: {
          aProp: "abc",
          child: {
            ...
          }
        }
      }
    }
  }
}
#

and it'll go on, forever

#

so u need to hide parent from child first if u want to serialize it

feral aspen
#

Is it possible to modify values of a property in a constructor of one class from another class? OR STILL NO.

vivid fulcrum
#

why not

feral aspen
#

An example of so, please?

vivid fulcrum
#
class Parent {
    constructor() {
        this.name = "Parent";
        this.child = new Child(this);
    }
}

class Child {
    constructor(parent) {
        parent.name = "Parent from child";
    }
}
feral aspen
#

Hmm.

#

Thanks. šŸ‘

somber ridge
#

Did anyone face an issue while using express where req.headers.cookie would log the raw cookie sent from the browser for example name.sid=sess-id-here but req.signedCookies logs undefined?

#

Or even req.cookies logging undefined but you surely know the cookie is being sent from the browser

sharp geyser
#

Well are you signing your cookies?

lament rock
#

JS calls it circular which is more easy to understand than whatever that is

#

Had to google to see the definition makes sense

lyric mountain
#

I think both are synonymns

lament rock
#

circular is implied synonym, sure but Idk about direct synonyms

#

Context is important

#

learn new words every day I guess

lyric mountain
#

perchance

somber ridge
# sharp geyser Well are you signing your cookies?

For context, when a user logs in using discord (I handle the auth flow myself) , I manually just modify the session object attached to the request and by doing that it automatically sets a cookie on the client on a successful login whose value corresponds to a session ID on the server

I’m not sure if by doing it, are the cookies being signed by the secret I gave while initialising the express-session middleware

#

Regardless, shouldn’t req.cookies be something but undefined?

green dome
#

Hello, I'm having trouble fetching your DBL-Java-Library dependency via maven, are you aware of issues?
The error I get:
Could not find artifact com.github.DiscordBotList:DBL-Java-Library:jar:2.1.1 in jitpack.io (https://jitpack.io)

lyric mountain
green dome
#

I get a similar result for that:
Could not find artifact com.github.top-gg:java-sdk:jar:2.1.1 in jitpack.io (https://jitpack.io)

#

And the readme could get some love as well.

#

Any workaround available in the meantime?

sharp geyser
#

It's req.session.cookies

lyric mountain
sharp geyser
#

The cookies are attached to the session

lyric mountain
#

it's the one I use currently

#

although I might be moving entirely off the lib, top.gg api is too simple to warrant a wrapper

green dome
#

Thanks! That one seems to work indeed. This could have been documented though.

lyric mountain
#

you're not really supposed to update packages unless the current one is deprecated or stops working

#

2.0.1 works fine, so I stuck to it

green dome
#

Yeah, problem was that the other one no longer worked, which failed all the CI builds.

lyric mountain
#

that's due to repo rename

#

but yeah, the readme still shows the old url

green dome
#

I'll file a PR to update the readme.

sick agate
#

dotpost moment

tepid glade
#

vds

sick agate
#

?

tepid glade
#

sorry mensorry wrong channel

surreal breach
#

/

earnest phoenix
#

Hi! I found some bots that have the same #mod-logs ban case logs mute logs ecc, is it a source code free to use or is it made by someone and copied?

slender wagon
#

can u set gifs as thumbnails on embeds?

earnest phoenix
slender wagon
#

ok ty

feral aspen
ancient nova
#

I'm getting so many DiscordAPIError: Missing Permissions errors in my console

#

basically one every couple seconds/ minutes I have no idea where they come from

#

I want to get rid of them so bad

#

does anyone have an idea of what I can do?

feral aspen
#

Handle them, otherwise, silently mute them.

ancient nova
#

huh?

feral aspen
#

.catch(() => {});

ancient nova
#

how can I handle them if I have no idea where they even come from

feral aspen
#

But that is never the best way.

feral aspen
ancient nova
#

I executed every command and it never showed the error

#

it shows it randomly

#

and never shows the stack trace

#

so I don't know where it comes from

feral aspen
ancient nova
#
[2022-07-05 16:14:31]: ERROR Unhandled rejection: DiscordAPIError: Missing Permissions 
DiscordAPIError: Missing Permissions
    at RequestHandler.execute (/home/container/node_modules/discord.js/src/rest/RequestHandler.js:350:13)
    at runMicrotasks (<anonymous>)
    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:176:15) {
  method: 'post',
  path: '/channels/491324642166964227/messages',
  code: 50013,
  httpStatus: 403,
  requestData: {
    json: {
      content: undefined,
      tts: false,
      nonce: undefined,
      embeds: [Array],
      components: undefined,
      username: undefined,
      avatar_url: undefined,
      allowed_mentions: undefined,
      flags: undefined,
      message_reference: undefined,
      attachments: undefined,
      sticker_ids: undefined
    },
    files: []
  }
}
#

that's the entire error

ancient nova
feral aspen
#

I mean, you can put on every file that if it doesn't have permissions to send messages, attach embeds, or etc. then to return.

ancient nova
#

shall I do that in the messageCreate event?

wheat mesa
feral aspen
wheat mesa
#
class Student {
  constructor(param1 = null, param2 = null) {
    this.param1 = param1;
    this.param2 = param2;
  }
  
  print() {
    console.log(this.param1);
    console.log(this.param2);
  }
}

let student = new Student();
student.print();

let student2 = new Student(15, "Jack");
student2.print();
``` you can do something like this
ancient nova
#

will this work?

wheat mesa
#

This is something you should probably do for ts if you're trying that ```ts
class Student {

private param1?: number;
private param2?: string;

constructor(param1?: number, param2?: string) {
this.param1 = param1;
this.param2 = param2;
}

print() {
console.log(this.param1);
console.log(this.param2);
}
}

let student = new Student();
student.print();

let student2 = new Student(15, "Jack");
student2.print();

#

sorry for formatting, it fucked up for some reason

feral aspen
feral aspen
wheat mesa
#

No

#

This runs just fine

#

That code snippet generates

feral aspen
wheat mesa
#

And if you want to give it default values, you can do something like ```ts
class Student {

private param1: number;
private param2: string;

constructor(param1 = 12, param2 = "Test") {
this.param1 = param1;
this.param2 = param2;
}

print() {
console.log(this.param1);
console.log(this.param2);
}
}

let student = new Student();
student.print();

let student2 = new Student(15, "Jack");
student2.print();

wheat mesa
ancient nova
#

is it wise to check it like that?

#

shouldn't I check if the user actually executes a command?

ancient nova
#

eh

feral aspen
vivid fulcrum
feral aspen
wheat mesa
#

Btw, use number, boolean, and string, not the capitalized versions

wheat mesa
ancient nova
#

I think that might've actually sovled the issue somehow

feral aspen
ancient nova
#

I haven't seen anything pop up yet

wheat mesa
#

I'm really confused what you're asking. You are using ts, I'm giving you the ts version of things

feral aspen
wheat mesa
#

The very first thing I gave you was js because I didn't think you were using ts at first, but you mentioned that you're learning it so I've been giving ts examples since

wheat mesa
feral aspen
#

To make the arguments optional... I...?

wheat mesa
#

There's a few ways to do this, hold on

ancient nova
wheat mesa
#

First way: ```ts
// This will assign "Some string" to name, 12 to age, and 6 to ID if they are not passed in the constructor
constructor(name = "Some string", age = 12, ID = 6) {
// ...
}

feral aspen
#

Yes, those are called default values.

#

However, to make the arguments optional?

ancient nova
cinder patio
#

What do you mean optional?? Arguments in javascript are always optional technically

wheat mesa
#

Next way: ```ts
// This will be default make name, age, and ID undefined if they are not passed into the constructor
constructor(name?: string, age?: number, ID?: number) {
// ...
}

feral aspen
#

šŸ‘

cinder patio
#

javascript is never going to stop you from not passing an argument

wheat mesa
ancient nova
cinder patio
#

it's your own logic

wheat mesa
#

js doesn't stop you from doing basically anything

lyric mountain
#

let's be real, js doesn't stop u from doing anything at all

#

damn waffle

queen basin
#

js stops me from changing characters in a string 😠

wheat mesa
#

ts stops you from doing some things, but it's usually helpful in validating the types passed to your function

ancient nova
#

it's not

const func = function(this) {
console.log(this)
}
func() // undefined
func("hi") //hi
#

that's what I mean

#

and if you have some extensive logic it can error either way

wheat mesa
#

Then don't use js, or put that logic in with type checks

#

That's basically what ts is for

ancient nova
#

I'm just saying it's possible

viscid gale
wheat mesa
#

Never said I hated js

lyric mountain
viscid gale
#

šŸ˜” I like a language that trusts the dev to know what they're doing

wheat mesa
#

Just saying you need to be aware of types before you're allowed to be typeless šŸ˜‰

ancient nova
lyric mountain
#

ah ok

queen basin
viscid gale
wheat mesa
#

typescript isn't a training bicycle, it's a helpful tool in the development cycle

ancient nova
#

my boi dissing ts out here

lyric mountain
wheat mesa
#

I don't like truly dynamic types that much

#

It's often times very annoying to validate preconditions for functions with

#

type safety is poggythumbsuppoggythumbsuppoggythumbsuppoggythumbsuppoggythumbsuppoggythumbsuppoggythumbsuppoggythumbsuppoggythumbsuppoggythumbsuppoggythumbsup

viscid gale
queen basin
#

c users when they realize everything is converted implicitly

wheat mesa
#

c users when they need to make tons of dogshit macros just to bypass writing tons of boilerplate

queen basin
#

my mistake was writing my os in c++ šŸ’€

#

but then you get classes and namespaces so

#

worth it?

wheat mesa
#
#define GROW_CAPACITY(capacity) \
    ((capacity) < 8 ? 8 : (capacity) * 2)

#define GROW_ARRAY(type, pointer, oldCount, newCount) \
    (type*)reallocate(pointer, sizeof(type) * (oldCount), \
        sizeof(type) * (newCount))

#define FREE_ARRAY(type, pointer, oldCount) \
    reallocate(pointer, sizeof(type) * (oldCount), 0)
``` classic c moment
#

truly

cinder patio
queen basin
#

what alt?

cinder patio
#

Um... you're Speedy

queen basin
#

?

wheat mesa
#

Don't think so

#

account created 4 years ago

#

lol

viscid gale
#

jokes aside I have a question regarding permissions(no my bot isn't in over 75 servers so don't read faq for me on that)..
I can only see a dm when I send to the user first.. is there a way to stop this? these are my intents(yes I use windows notepad ok)

queen basin
#

wot

cinder patio
#

Same writing style and everything

viscid gale
wheat mesa
#

my current account is older than most top.gg users

queen basin
#

there are 7.7 billion people in the world

wheat mesa
#

6 years 2 months

queen basin
#

coincidences happen

lyric mountain
viscid gale
#

im using discord.js v13.8.1

lyric mountain
#

that isn't related to any intent afaik

viscid gale
#

is it a discord.js issue or is the api itself is being more strict?

lyric mountain
#

the api is the same it was, the changes don't affect dm at all

#

might be a code issue

feral aspen
lyric mountain
#

epic embed fail

lyric mountain
#

also don't put semis after functions

feral aspen
queen basin
feral aspen
lyric mountain
#

it'll be removed during compilation anyway

queen basin
#

yea but they make me happy

feral aspen
#

Same.

feral aspen
#

view is not a property but a method.

feral aspen
#

No.

#

_password is the actual hashed password.

#

password is the reference class.

#

I did a.password and it logged the class of Password.