#development

1 messages · Page 132 of 1

sharp geyser
#

Something like this you also can't just accuse them of breaking any guidelines/tos. If it is a false accusation it could lead to a legal issue.

rustic nova
#

gotta be careful with this one ngl: Since something like mega is entirely based on encrypting files, you cant just make a users files publicly accessible

#

so you gotta weigh between keeping that trusted aka encrypting files or keeping it not trusted and making it another dropbox or mediafire

sharp geyser
#

The plan with this was making it so only the person who uploaded the files has access to them. Not even I or moderators do, unless their account is under review.

#

Or they share them

rustic nova
#

sharing yeah since that would make the files accessible to anyone with a link

sharp geyser
#

Yep

#

Everything will be encrypted.

rustic nova
#

pogu

sharp geyser
#

As to how that is done, no idea yet.

#

I haven't done much in terms of encryption of files and such

rustic nova
#

I've rudamentarily tried out encrypting files manually since I wanted to understand the inner workings behind it

sharp geyser
#

What did you learn?

rustic nova
#

that its hella unsecure to do that yourself and that it is better to have a library handle that KEKW

sharp geyser
#

Lmao

#

Fair enough

#

Have you ever heard of NestJS?

rustic nova
#

nope

sharp geyser
#

Makes sense

#

you're a python boy

rustic nova
#

actually

#

yeah

#

but does somewhat remind me of nextjs

sharp geyser
#

Its a cool nodejs framework wrapped around express and fastify

#

Makes making api's 10x easier and is modeled after Angular

rustic nova
#

could look into experimenting around with that sure

sharp geyser
#

Only thing with NestJS is it is a bit bloaty

#

Thundxr its a project I am passionate about

#

Idgf

rustic nova
#

this background makes me sick ngl

sharp geyser
#

This isn't meant to please anyone, its just something to do to learn more about encrypting files and file sharing in general

quartz kindle
#

dayum that background animation is fire

#

11/10

sharp geyser
#

There's an animation?

quartz kindle
sharp geyser
#

@spark flint

spark flint
#

Lol

sharp geyser
#

seems perfect for the out of context twitter

spark flint
#

Lol

#

I host Nextcloud on oracle

quartz kindle
#

friends sending malware to each other online is the same as friends greeting each other by calling each other bad words

spark flint
#

Lol

sharp geyser
quartz kindle
#

sup bitch
yo sup mofo
heres some malware, check it out
cool, have my virus i just made

spark flint
#

Lol

#

I know of an anti malware server that got banned for distributing malware

quartz kindle
#

Lol

spark flint
#

They got unbanned quick

sharp geyser
#

I know of a person who is getting banned for malware distribution

#

after I send discord an email smirk

quartz kindle
#

you

spark flint
#

Lol

quartz kindle
#

:^)

sharp geyser
spark flint
#

Discord don’t take screenshots smh

peak drum
rustic nova
#

did i hear ban

#

ong

sharp geyser
rustic nova
#

yo did you know we mods have like

#

a cool -b thing

sharp geyser
rustic nova
#

want me to try that? flooshedcat

#

i havent yet im a trial mod uwuowo

#

lemme -b

sharp geyser
#

Aurel is a Jr jr chat moderator

rustic nova
peak drum
sharp geyser
#

And also has been working on the same file for 12h

quartz kindle
sharp geyser
#

Must be a lot of errors

sharp geyser
#

going on 4 soon

rustic nova
quartz kindle
#

:^)

rustic nova
#

actually

sharp geyser
#

its about to be his anniversary

rustic nova
#

how long am i mod already

quartz kindle
#

as long as i remembe you

#

which idk how long that is

sharp geyser
#

Aurel did quit for a good bit

quartz kindle
#

people tend to come and go, but it feels like we've known them forever

sharp geyser
#

He even left the server

#

I am now older than Aurel

rustic nova
#

2 years ish?

sharp geyser
#

Cmon you don't have to blur

rustic nova
#

was the first message I've sent

#

shush

sharp geyser
#

we're all friends here

rustic nova
sharp geyser
rustic nova
#

omg leaked

sharp geyser
#

Fixing to go to the store as soon as it opens

#

its about to be 5am

#

4m more

#

Haven't slept yet

#

Anyway Aurel if you're serious about helping me with my hobby project

#

lmk

#

If top.gg has a secret furry channel

#

I am judging all the moderators

rustic nova
#

nah

sharp geyser
#

#aurel-play-house

rustic nova
sharp geyser
#

#aurel-ban-counter

#

264890171575631873 time to hack into @gilded plank and make it scan all channels

quartz kindle
#

lots of people did that back in the day, myself included

#

when we had all our bots on this server

peak drum
sharp geyser
#

@rustic nova so about preventing movies cause DMCA hassel, I could limit file sizes, though I want to avoid this.

rustic nova
#

limit file sizes for new users

#

then just increase on frequent users

sharp geyser
#

Hm

rustic nova
#

or have people request larger sizes

sharp geyser
#

With valid reasons

rustic nova
#

yes

sharp geyser
#

Issue is

#

They can request and give a valid reason, but in turn could go and break the rules.

#

I might be putting too much thought into this, but I don't wanna make something that will be seen as an invasion of privacy and breaking their trust in the service.

#

I have to find a way to efficently moderate the service so people don't break any guidelines.

quartz kindle
#

just put a disclaimer that you are not responsible for the files people upload

sharp geyser
#

While that is something I will do, I also don't want people having illegal content being hosted

quartz kindle
#

put that in your TOS

#

but there is no way for you to prevent it, unless you break your own encryption

sharp geyser
#

That isn't the issue, the issue is how do I moderate such a thing

quartz kindle
#

you cant

sharp geyser
#

Exactly

quartz kindle
#

thats the whole point of encryption

sharp geyser
#

Yea

#

Which is why Im not sure if I even wanna do it anymore

#

I don't wanna make something that will just be used as a tool for creeps

quartz kindle
#

thats the cost of freedom of speech and privacy

#

lmao

sharp geyser
#

sadly yes

#

How does mega do it I wonder.

#

Do they just solely rely on reports from users?

#

I know they terminate accounts for violating their tos yet claim to not have any access to the files hosted.

#

So how exactly do they know

#

Reported

#

ss sent to the authorities

#

@quartz kindle honestly who cares about privacy anyway, I will just spy on the files people upload /j

#

but nah, my project could still be feasible.

#

The best I can do is if they get too many reports their account will be under review, meaning despite the files being encrypted, they will be exposed to the moderators to determine if their account needs to be terminated.

#

Also doesn't encryption/decryption require some kind of key?

quartz kindle
#

invisivble icons?

proud mist
#

host

rustic nova
#

you can change that

#

did it too

#

dont like the osx-type of shit taskbar

wheat mesa
#

ghost ping much

fossil bone
slender wagon
#

@rustic nova any clue if telegram supports APNG

#

can't find anything

#

@lyric mountain also you are right why the fuck do we still use gifs

frosty gale
pure patio
#

anyone help me

#

how to make my online bot?

#

but not offline one

frosty gale
#

bot should not be offline

#

it should be online 🙂

slender wagon
#

💀

slender wagon
#

good job telegrammm

jagged gale
#

Hi

#

I need help

rustic nova
#

Sure with what

jagged gale
#

I can't login to my account on top.gg

#

always gives 403 error

#

what should I do?

#

@rustic nova

peak drum
#

Clear cookies etc

rustic nova
#

Where are you getting that 403

slender wagon
#

he be getting ratelimited

#

no actually that's auth

hushed robin
#
rest.post(Routes.channel(config.channel), {
        data: {
            name: config.name.replace('{members}', value)
        }
    }).catch(error => console.error(error));

am i doing something wrong here

wheat mesa
#

thanks for the obscure code fragment with no context associated

hushed robin
#

nvm i think i fixed it i have to use patch

rustic nova
#

I just forgot to spin up my cubicle quantum accelerator for my code to work mb

hushed robin
#
rest.patch(Routes.channel(config.channel), {
    data: {
        name: config.format.replace('{data}', value)
    },
    headers: {
        'Content-Type': 'application/json'
    }
}).catch(error => console.error(error));

apparently the request body has invalid json

rustic nova
#

Context

#

Please

hushed robin
#

it's using discord.js rest thing

#

what other context is required

spark flint
#

personally i wouldn't do it ike that

#

you updating channel name right

hushed robin
#

yea

#

i don't want to connect to the gateway

spark flint
#

oh

hushed robin
#

🧌

frosty gale
#

the troll that is on clearance

hushed robin
#

what

deft wolf
hushed robin
#

lots of people here

#

anyone know issue?

frosty gale
#

you want to change channel name without connecting to gateway?

hushed robin
#

yes

frosty gale
#

im pretty sure tim has a library that lets you do that kind of stuff but im not sure if he keeps it updated anymore

frosty gale
hushed robin
#

i'm using the discord.js REST package i'm not using Tim's overcomplicated and underdocumented one

#

🧌

hushed robin
#

i'm getting an error

frosty gale
#

wow ok

#

did you look at discord documentation?

#

they show you the api request structure

hushed robin
#

yea

#

👿

frosty gale
#

one m

hushed robin
#

nvm fixed it

#

just had to change data to body

#

🧌

#

@frosty gale

frosty gale
#

lol i did see your thing was different from the one on npm so was going to make my own one for you to test

#

thats good then

hushed robin
#

😘

#

what will use less memory

#

a cron job or setInterval

quartz kindle
#

if you mean an actual cron job in a linux system, then the cron job is of course much more efficient since its built into the OS itself

#

but if you mean the cron packages in npm, setInterval is much more efficient than them, because its built into the language itself, whereas the cron packages are basically cron clones made with js

lyric mountain
frosty gale
quartz kindle
#

ok

hushed robin
quartz kindle
hushed robin
pale vessel
#

I just install the repo when I used it

hushed robin
polar zenith
#

Hola

hushed robin
polar zenith
#

Brother can u suggest me some crypto airdrops servers!!

pale vessel
quartz kindle
#

but im busy with other stuff rn lol

proven lantern
#

if you have an Elo rating system and are recording matches with a command like @Team1 beat @Team2 and the players on the team change, would you reset the rating for the team or would the team keep the rating they had with the other player?

#

or both

sharp geyser
#

Okay so idk what kind of elo you are doing, but i've never seen one done like that

sharp geyser
#

From what i've seen when it comes to an Elo System, each player has their own rating and the team members all lose elo if they fail a match or gain elo if they win one

proven lantern
rustic nova
#

I feel like the elo should be summed up rather than setting a teams elo and resetting it when something changes

proven lantern
#

yeah, i think i need to make that change.

sharp geyser
#

Don't reset the elo

proven lantern
#

or store both and let the user decide which to show

sharp geyser
#

You can combine all their elo and divide it by the number of players in the team with an offset so its not too large, but that also sounds like a bad idea now that I am typing it out

#

Is there a cap on elo?

proven lantern
#

at some point you get no rating points for beating a low ranked noob

sharp geyser
#

All I can say is that in systems i've seen they start everyone at 1k elo and it can go down or up from there.

#

Depending on the ranking you are in relation to the other player/team depends on how much elo you get for beating them

proven lantern
#

actually that's Elo's algorithm

sharp geyser
#

One sec

#

That seems off somehow

proven lantern
#

pls fix

#

pls help

sharp geyser
#

Actually nvm

#

I was doing the math wrong

#

the calculation of the elo seems correct

#

Except if they don't win or draw, they lose only .3 elo (this is assuming the opponent has 2k elo while you have 1.9k) idk how you are matching it up but I don't think they are losing enough elo if they lose

sharp geyser
#

I don't really know if this was your intention

proven lantern
sharp geyser
#

Then my math is definitely off

#

so ignore me

#

:p

proven lantern
#

if i delete a discord role is there some way to undo that so i get back the same discord role with the same id?

sharp geyser
#

Don't think so

rustic nova
#

Nope there's not

queen needle
#

Unless you have a time machine

sharp geyser
#

shouldn't be too hard to code one up

proven lantern
#

that's dangerous

#

if a team is linked to a discord role and they accidently delete that role then i got to do tricky stuff

#

i need another mapping probably

sharp geyser
#

Don't allow teams to be linked to roles.

#

Simplest solution

#

If you still want it to be linked to roles you will have to listen to the event that is run when roles are changed and if the role for a team is deleted you have to quickly remake it and assign it again using the new id

proven lantern
#

what if i use the role name instead of the role id. then they could remake the discord role to remake the team. are roles allowed to have the same name?

#

the discord server mods could be in charge of making sure the names are unique

sharp geyser
#

Ofc roles can have the same name

#

The only thing that keeps a role unique is their ID

#

Just use IDs

#

and if their team role is deleted have it remake it, the only thing you have to do is make sure the bot has the permission to do so

proven lantern
#

i dont get any socket events in my bot

#

i probaby shouldn't use roles

sharp geyser
#

Why not?

proven lantern
#

they are a limited resource

#

idk

sharp geyser
#

I see

proven lantern
#

250 per server

sharp geyser
#

Well you can just use a database to store the team member's ids

#

if they change a team member then swap ids for the new one

proven lantern
#

but the team needs to be separate from the members

sharp geyser
#

It will be?

proven lantern
#

yeah, the team rating stays even when players change

sharp geyser
#

No I mean it will be separate

#

Just have a table for teams storing the member's ids as well as the rating for the team

proven lantern
#

oh i see

sharp geyser
#

simple as that

proven lantern
#

so they would register a team using plain text probably

#

no role mention

#

that'll be tricky to parse

sharp geyser
#

How so?

#

Are you using slash commands?

proven lantern
#

yeah, the input is an array of user input for 1st_place and 2nd_place

sharp geyser
#

I don't understand the issue

proven lantern
#

let's say there are 3 team.

q q
q q q
q

then i record this match /record_match 1st_place: q q q 2nd place: q q q
does it match q q + q team or q q q

#

if someone make the team name the then that will match a lot of prefixes for other teams

lyric mountain
#

u can use a simple numeric column for storing scores

proven lantern
#

i'm thinking about using roles again

lyric mountain
#

honestly it'd be easier and more performant if u used ids for each team and simply recorded the winner instead

#

once u have the winner, u already have the 2nd place

proven lantern
lyric mountain
#

then use /record_match tie

#

or /record_match winner: tie

#

to keep a pattern

proven lantern
#

i need to list the players or teams that tied

#

tim came up with the pattern im using now

lyric mountain
proven lantern
lyric mountain
#

use ids for each team then

#

instead of names

proven lantern
#

i have 1st_place...10th_place options for the slash command. each one can take a list of players by @mentioning them. You can also indicate teams by grouping with parens (@player1 @player2)

lyric mountain
#

what's the context for all that btw?

proven lantern
#

right now the team is based off of the player ids

#

so if a player in the team changes, the Elo for the team resets

lyric mountain
#

I mean the full context

#

like, what kind of game is it?

proven lantern
#

Any zero sum game

lyric mountain
#

...not exactly what I asked but ok

#

so, can't u use a csv input instead of 1st...10th?

#

and assign a unique (and short) id for each player/team

proven lantern
lyric mountain
#

you'll be working extra to make it work with the parens option

proven lantern
#

i already made a fancy regex to get it to work

lyric mountain
#

regex for names?

proven lantern
#

    // remove all whitespace
    const placementInputNoWhitespace = placementInput.replace(/\s/g, '');

    // tokenize the placement input
    const teamOrPlayerStrings = placementInputNoWhitespace.match(/(\([^()]*\)|[^\b>]*)/g).filter(a => a);
lyric mountain
#

people will make it fail

#

unless u use the users' pomelo

#

which is guaranteed to have a predictable pattern and to be unique

proven lantern
#

pomelo?

lyric mountain
#

the username

#

it's unique, no whitespaces and no special chars

#

100% either letters, numbers or underscore

proven lantern
#

oh, the new username thing

#

this is the description for 1st_place
List player(s)/team(s) that placed first. Group teammates with (parenthesis)

#

i should say something about @mentioning

pale vessel
proven lantern
#

what if the team Elo rating is derived from each player on the team and not actually stored anywhere. so changing a teammate changes the team rating, but doesn't reset it

lyric mountain
#

That's the proper way yeah

#

Else u get elo manipulation

proven lantern
#

Like people making teams just to farm rating points out of it

lyric mountain
#

Or to purposely be matched with lower ranking players

earnest phoenix
#

Anyone that use google workspace and cloudflare?

lyric mountain
#

Cloudflare dns?

earnest phoenix
#

cause I'm trying to activate gmail using cloudflare a dns and this shit is not workin lmao

#

yes

lyric mountain
#

Wdym activate gmail?

earnest phoenix
#

Since I'm using google workspace/domains, I have to "activate gmail" by setting MX records, since I don't use the default google dns settings.

lyric mountain
#

@unkempt ocean

earnest phoenix
#

yeah I've been mashing the retry activation button forever now and I am getting nowhere

#

Been ~1 hour I've been trying to figure this out

#

The normal domain works just fine.. I did have it proxied but then switched to DNS only to see if that with help and it didn't change anything... so I'm kinda stuck lmao

I'm trying to get social media accounts lol

unkempt ocean
lyric mountain
#

Email stuff is always annoying to make work

earnest phoenix
#

factual statement

#

i always have bad luck with email

unkempt ocean
#

I'm not sure I understand your problem but cloudflare already provides domail email feature

#

is that what you're looking for?

lyric mountain
#

The worst is that even if all go well, the other end might block the email or send it to trash

earnest phoenix
#

But be able to use cloudflare as a dns, which so far is not working out the greatest when it comes to email and stuff lamo

unkempt ocean
earnest phoenix
#

I'll try reaching out to Google

unkempt ocean
# earnest phoenix I have

There's an answer on cloudflare community that says if you have Cloudflare Email Routing enabled then it blocks the google's MX records

earnest phoenix
#

Already looked into it and it’s not enabled

earnest phoenix
#

Finally got it to do something different

#

Looks like Google detected that I have the records and now it's running some further verification...
Just need time... 1 hour+

rustic nova
pale vessel
#

little did they know

next storm
#

I'm using express.js to create a dashboard, I've my css file in public folder named style.css, also I've made the public folder as static directory using app.use(express.static(__dirname + '/public'));, but still when I'm trying to load the css file in my ejs file using <link rel="stylesheet" type="text/css" href="/public/style.css">, it's not loading and when I saw the console of my website, it's showing Refused to apply style from 'http://localhost:3000/public/style.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

pale vessel
#

it's because it's loading a 404 page, which is HTML

#

static should be at the root, so try /style.css

next storm
pale vessel
#

href

#

also, if you want the files to be under /public, use app.use("/public", express.static(__dirname + '/public'));

next storm
#

worked, thanks (:

jagged fable
#

guys

#

how to delete .node_modules in a github repo?

hushed robin
#

🧌

#

by deleting it

jagged fable
#

but it is massive

hushed robin
#

can't u just do this?

#

you should try gitignore it's useful

lyric mountain
#

to remove it from previous commits

#

else it'll stay in the history

jagged fable
#

h.o.w

lyric mountain
#

...by rebasing

jagged fable
#

h.o.w 2 re.base..?

lyric mountain
#

I also advise adding a gitignore file to your repo

#

else it'll be comitted again next time unless u specifically remove it from git add

jagged fable
lyric mountain
#

u named it .gitignore right?

north cairn
#

hey

#

can someone say how to export classes

#

its not really working for me

#

also keep in mind i am making dc bot so pls say common js method

north cairn
lyric mountain
north cairn
#

do u think its a good idea

lyric mountain
#

I think so yeah

#

it's cleaner than putting everything in a single file

north cairn
lyric mountain
#

because classes dont need to

#

u simply import and then let obj = new TheClass()

north cairn
#

but to import,i need export

lyric mountain
#

you're the button game guy right?

north cairn
lyric mountain
#

unless js requires it

#

don't think it does

#

nvm it does

north cairn
#

ok so i made a file for toss command
and used game class
now i m making seperate file named asktodo to make user choose bat bowl

north cairn
#

es6 wont work coz i alr did module.exports for command

lyric mountain
north cairn
lyric mountain
north cairn
#
module.exports = {
  name: "toss",
  aliases: [],
  description: "toss  a coin  ",
  
run: async (client, message, args) => {```
lyric mountain
#

hm

#
module.exports = {
  aclass,
  otherclass,
  { thecommand }
}
#

but idk how you'd name the command to be able to import

north cairn
#

i dont think that works

lyric mountain
#

can't help much with that as I don't use node that much

#

and when I do it's usually for react

#

my domain is java

north cairn
#

know someone who might be able to help?

hushed robin
#

maybe tim

#

he's skillful

north cairn
#

i justneed know how doi export the class

#

rest i'll manage

lyric mountain
#

u can put the class in a separate file

#

that way u dont need to modify the command's exports

north cairn
#

again i need export then

#

how do i use then when its in sperate file

lyric mountain
#

put the class in its own file, then export as u do with commands

#

module.exports = { theclass }

north cairn
#

then how do i export command as same time sir

lyric mountain
#

u dont

north cairn
#

same issues come over

lyric mountain
#
theclass.js
thecommand.js
north cairn
#

ok now i need use the class

lyric mountain
#

import in thecommand

north cairn
#

oh ic

#

ic

#

ok one moredoubt

#

suppose i have a variable named d in one of the methods of class

#

now when i import that class

#

into a new file

#

will i be able to access that variable

lyric mountain
#

yep

let obj = new TheClass();
obj.thevariable
north cairn
#

bro

#

not talking about method

lyric mountain
#

that's a variable

north cairn
#

talking about a variable in the method

lyric mountain
#

ah, u mean inside a method

north cairn
#

i can access that like that?

lyric mountain
#

then no, the variable dies with the method

#

put the variable as a class property if u need it outside

north cairn
#

how to do that

lyric mountain
#

just put it outside of any function

north cairn
#

that wont work ig

#

lemme show code that u might undertsand

lyric mountain
#

that's the browser's console btw

north cairn
#
collector.on("collect", (interaction) => {
 
  
if (interaction.customId == "Heads") {
  let x = Math.floor(Math.random() * 2) + 1; 
  if(x==1) {
    const itstails = new MessageEmbed()
    .setTitle("**YOU LOST THE TOSS**")
    .setDescription("Its Tails,You Lost The Toss! Computer Will Bowl Fist!")
    .setImage("https://media.istockphoto.com/id/877266822/vector/gold-coin-with-letter-t-vector-icon.jpg?s=170667a&w=0&k=20&c=Z9Ga7p6uC3aMmNv__RWc4RAnMs46spiNE4Wk_-F7AxY=")
    return interaction.reply({embeds: [itstails]})
  } else{
    const itsheads = new MessageEmbed()
    .setTitle("**YOU WON THE TOSS**")
    .setDescription("Its Heads,You Won The Toss! What Will You Like To Do First?")
    .setImage("https://previews.123rf.com/images/webstocker/webstocker1711/webstocker171100045/89827841-gold-coin-with-letter-h-design.jpg")
   

    return interaction.reply({embeds: [itsheads]})
    }
  }
  if (interaction.customId == "Tails") {
  let y =  Math.floor(Math.random() * 2) + 1;
  if(y==2) {
    const itstails2 = new MessageEmbed()
    .setTitle("**YOU WON THE TOSS**")
    .setDescription("Its Tails,You Won The Toss! What Will You Like To Do First?")
    .setImage("https://media.istockphoto.com/id/877266822/vector/gold-coin-with-letter-t-vector-icon.jpg?s=170667a&w=0&k=20&c=Z9Ga7p6uC3aMmNv__RWc4RAnMs46spiNE4Wk_-F7AxY=")
    
    return interaction.reply({embeds: [itstails2],})
  }  else{
    const itsheads2 =  new MessageEmbed()
   .setTitle("**YOU LOST THE TOSS**")
    .setDescription("Its Heads,You Lost The Toss!  Computer Will Bowl Fist!")
    .setImage("https://previews.123rf.com/images/webstocker/webstocker1711/webstocker171100045/89827841-gold-coin-with-letter-h-design.jpg")
    return interaction.reply({embeds: [itsheads2]})
                }
#

see here

#

this is the code inside toss method

#

now what i want is

#

i import the class

#

then do if(x==1 || y ==1) {
message.reply("u lost the toss)

#

my bad wrote won instead of lost,corrected it

lyric mountain
#
class Coin {
  result = 0;
  
  toss() {
    result = Math.floor(Math.random() * 2) + 1;
  }
}

...
let coin = new Coin();
coin.toss();

// do whatever u want with coin.result
#

u dont need a class for that btw, as it's a simple value

north cairn
#

but i have put it in class

north cairn
north cairn
lyric mountain
lyric mountain
#

u could do ```js
toss() {
this.result = Math.floor(Math.random() * 2) + 1;
}

#

but u run into the possibility of result being undefined

north cairn
lyric mountain
#

because unless u run toss(), the property will never be created

lyric mountain
#

else u can put in the same file and not export it

north cairn
#

well what do u prefer
Make one class for one fucntion or one class for all

lyric mountain
#

I prefer one file for each class

north cairn
#

bro there are gonna be

#

like 20 then

north cairn
lyric mountain
north cairn
north cairn
lyric mountain
lyric mountain
north cairn
lyric mountain
#

every one of them is a class

north cairn
#

hose deck ones?

#

those*

lyric mountain
#

ignore the names

#

all blue circles are a class

north cairn
#

ok how about a folder for all classes

lyric mountain
#

the structure is up to you

#

whatever is easier to organize and find the files you want

north cairn
#

also can u say like how to name file location

#

like "./

lyric mountain
#

./ means same folder

#

../ means parent folder

north cairn
#

what if diff folder

#

like i just said a folder for classses

#

three dots??!?

#

also i didnt got it how do i access that variable

lyric mountain
north cairn
#
const { Game} = require("../Classes/tossclass")```
#

not working

#

says cannot find module

lyric mountain
#

Is Classes in parent folder?

north cairn
#

no total diff

#

Classes is a diff folder

lyric mountain
#

Then u need to specify the path

north cairn
#

how

lyric mountain
#

...

north cairn
#

path means kind of whole adress

#

right??

lyric mountain
#

Yes, the whole address

#

Relative to the current file

north cairn
lyric mountain
#

Which "that variable"?

quartz kindle
#

having fun over there?

#

:^)

lyric mountain
#

Oh here u are

lyric mountain
#

Simply define those as class variables

#

Gave u 2 examples already

lyric mountain
#

U don't need to call it result, and u can declare more than one

quartz kindle
#

in js you need to declare the variable inside the constructor, not outside

#

tbh you dont need to declare it at all

lyric mountain
#

Works outside too

north cairn
#

ok and that result would be able to access that variable which is inside method

#

?

lyric mountain
#

No, only things inside the method can access the variables inside it

#

That's called scope

quartz kindle
lyric mountain
#

U can assign that variable from inside the method tho

north cairn
#

bro

#

i toldu buttons issue

lyric mountain
lyric mountain
#

Simply put x and y as class variables

hushed robin
#

ok guys

lyric mountain
#

And assign them from inside the method

hushed robin
#

i am working with classes right now how do i make something pass by a code before running

lyric mountain
#

Example

hushed robin
#

like

#

i am have functions inside of my class called getChannel and searchChannels, I wanna run both of them pass a specific code before it actually runs the code inside the function

lyric mountain
#

Simply call whatever code u want to run before the rest of the code

hushed robin
#

but

#

then i will have to copy and paste a lot

#

why no 1

lyric mountain
#

why don't u simply declare a function for it then?

lyric mountain
#
doStuff() {
    ...
}
#

Functions can call other functions

north cairn
#

my mind i sgetting rippped off

#

first this path

#

now this variables

lyric mountain
#

I think ur overthinking too much

#

You don't need to access anything from the function

north cairn
#

u are right

lyric mountain
#

Simply assign a class variable and use it instead

#

As I did in my coin example

hushed robin
north cairn
#

ok listen up.!!

#

i do what u said
Now i want buttons in that message,i also want reply with them

lyric mountain
hushed robin
#

what

north cairn
#

ig thats what he means

hushed robin
#

basically i'll explain what i'm trying to do

lyric mountain
#

Export that function and use it wherever u want

north cairn
#

also these paths are such mess dude

hushed robin
#

well ok

north cairn
#

total mess1

lyric mountain
#

Then use it for replies

lyric mountain
north cairn
lyric mountain
#

../ is "one folder up"

north cairn
lyric mountain
north cairn
#

u know i gotta add a collector

#

to reply with buttons

#

so to lessen the mess i wanna do in diff file

#

but u say i cant access it

lyric mountain
#
class Coin {
    buttons = [...them] 
} 
#

Then access with coin.buttons

#

Assuming u named ur instance coin

north cairn
lyric mountain
#

Example

#

Put inside [] your buttons

north cairn
#

ok then?

#

how do i access it

quartz kindle
#

btw you dont need to use a collector, you can use awaitMessageComponent()

#

which is simpler and easier

lyric mountain
#

Tim continues from here

quartz kindle
#

nope i dont :^)

#

i g2g buy food

#

c ya

north cairn
# quartz kindle btw you dont need to use a collector, you can use awaitMessageComponent()
 const filter = (interaction) =>
              interaction.user.id === message.author.id;
            const collector = message.channel.createMessageComponentCollector({
              filter,
              max: 1
            });
    

collector.on("collect", (interaction) => {
 
  
if (interaction.customId == "Heads") {
  let x = Math.floor(Math.random() * 2) + 1; 
  if(x==1) {
    const itstails = new MessageEmbed()
    .setTitle("**YOU LOST THE TOSS**")
    .setDescription("Its Tails,You Lost The Toss! Computer Will Bowl Fist!")
    .setImage("https://media.istockphoto.com/id/877266822/vector/gold-coin-with-letter-t-vector-icon.jpg?s=170667a&w=0&k=20&c=Z9Ga7p6uC3aMmNv__RWc4RAnMs46spiNE4Wk_-F7AxY=")
    return interaction.reply({embeds: [itstails]})```
lyric mountain
north cairn
#

u may continue on how do i access?

#

if u arent feeling frustrated..

lyric mountain
#
class AClass {
    anything here
    can be acessed
} 
north cairn
lyric mountain
#

Result

#

See how it's declared inside the class

north cairn
lyric mountain
#

No

#
class AClass {
    constructor() {
        this is a constructor
    } 
} 
#

It's a function that's ran when u use new AClass()

north cairn
#

same as method?

lyric mountain
#

Yes

#

The only difference is that it's not called directly

north cairn
#

class AClass {
buttons() {

lyric mountain
#

I mean, it is, but only during new

north cairn
#

like this smth?

lament rock
#

You can call the constructor directly

lyric mountain
#

U can, but shouldn't unless during new

#

That's because js is a mess and has no visibility modifiers at all

lament rock
#

It does

lyric mountain
lament rock
#

#methodname creates private methods

lyric mountain
#

That's very recent

lament rock
#

Not really

#

over a year

north cairn
lament rock
#

multiple even

north cairn
#

like diff buttons in diff message

lyric mountain
#

For a language that's as old as the internet, one year is recent

lament rock
#

java applets came before js

lyric mountain
lament rock
#

but yeah

north cairn
#

wait a second

#
  const sentMessage =  message.channel.send({embeds: [tossembed], components: [row, ]
});
        const filter = (interaction) =>
              interaction.user.id === message.author.id;
            const collector = message.channel.createMessageComponentCollector({
              filter,
              max: 1
            });
    

collector.on("collect", (interaction) => {
 
  
if (interaction.customId == "Heads") {
  let x = Math.floor(Math.random() * 2) + 1; 
  if(x==1) {
    const itstails = new MessageEmbed()
    .setTitle("**YOU LOST THE TOSS**")
    .setDescription("Its Tails,You Lost The Toss! Computer Will Bowl Fist!")
    .setImage("https://media.istockphoto.com/id/877266822/vector/gold-coin-with-letter-t-vector-icon.jpg?s=170667a&w=0&k=20&c=Z9Ga7p6uC3aMmNv__RWc4RAnMs46spiNE4Wk_-F7AxY=")
    return interaction.reply({embeds: [itstails]})
  } else{
    const itsheads = new MessageEmbed()
    .setTitle("**YOU WON THE TOSS**")
    .setDescription("Its Heads,You Won The Toss! What Will You Like To Do First?")
    .setImage("https://previews.123rf.com/images/webstocker/webstocker1711/webstocker171100045/89827841-gold-coin-with-letter-h-design.jpg")
   

    return interaction.reply({embeds: [itsheads]})
    }
  }
  

    }
   
 
})
}```
#

look here

#

first i sent a message with buttons

#

then i added a collector to reply with the buttons

#

so if i make buttons like a class variable

#

and call it

#

i cant put it wherever i want

lyric mountain
#

You can, simply call it

#

let coin = new Coin()
Then
coin.buttons

#

It'll return whatever you put in buttons = ...

north cairn
lyric mountain
#

You can, just make sure to pass the required values as parameters

north cairn
#

for eg?

lyric mountain
#
addButtons(param, params, param) {
    ... 
} 
north cairn
lyric mountain
#

For example, you need to use interaction, so you pass it to the function

#

So it'll be a param

hushed robin
#

Date.now() + this.cache.ttl

why is this returning NaN

lyric mountain
#

Log it

hushed robin
#

this.cache.ttl is 60000

north cairn
lyric mountain
#

Sigh no

north cairn
#

then?

#

dude programming !..

lyric mountain
#
addButtons(interaction) {

}
north cairn
#

oh sorry i added two brackets instead of one to close it

#

any other parametres than interactions?

slender wagon
#

💀

lament rock
#

only parameters you need to make the function work

lyric mountain
north cairn
#

well if its like this
then i make one function named buttons
and other named result

#

should owrk?

hushed robin
#

why is this returning undefined

#

🧌

north cairn
hushed robin
#

cache the results?

#

🧌

north cairn
#

u sure u defined client?

hushed robin
#

bro look at the first screenshot

north cairn
#

wait

#

change const client + new Discord.Client

hushed robin
#

bro what

#

this is not discord.js

north cairn
north cairn
frosty gale
#

when class instantiation returns null 💀

hushed robin
#

wtf r u saying

hushed robin
#

do u know why my isssue is presisting

north cairn
lament rock
#

the this keywork can be mutated with .bind or reference something different in a pre es6 style function

frosty gale
#

where are you calling this from

#

what function

#

but yeah you might have to use bind

hushed robin
#

🧌

frosty gale
#

what a weird class

#

how does this even work

#

but ignoring that arrow functions dont have this context

#

youd have to use the old function() {} way

#

might work

hushed robin
#

stop bullying me

#

i'm new to this

lyric mountain
#

or is it?

hushed robin
hushed robin
#

it's mine

lyric mountain
#

then show it

hushed robin
#

🤦

frosty gale
#

because arrow functions dont let you use this unless you bind to it

hushed robin
frosty gale
#

its easier to do function() {} instead

#

by this i mean this

#

confusing

hushed robin
#

I see ok

#

let me test

lyric mountain
hushed robin
#

how to do i make it async in that case

lyric mountain
#

this.cache.ttl cannot possibly exist (because it's a map)

hushed robin
#

nvm

lyric mountain
#

unless u add a ttl entry to it

frosty gale
#

thats true too

#

i feel youre very confused bro 💀

lyric mountain
#

it's not what u passed on the constructor as a param

hushed robin
#

🧌

#

ok

#

it kinda works

lyric mountain
#

ofc it does now

hushed robin
#

why does it error

#

instead of returning the data

harsh nova
#

becuase you have not defined the search function for your class "client"

hushed robin
#

yes i have

harsh nova
#

then it does not return a promise

hushed robin
#

why do i need to return a promise

#

ok thanks

#

it works now

harsh nova
#

because you are trying to use .then() which runs when a promise resolves. If you are not returning a promise the .then() method does not exist

hushed robin
#

😗

#

w people

#

btw how do i do that cool thing

#

where if you hover over the function

#

it'll tell u shit abt it

harsh nova
#

jsdoc

hushed robin
#

ok

frosty gale
#

use a language that isnt javascript

#

(typescript is forbidden)

hushed robin
harsh nova
#

typescript is a blessed language

hushed robin
#

JavaScript is amazing

harsh nova
# hushed robin it'll tell u shit abt it

if you use vsc try typing /** then hitting tab right over where the function is defined. This will autofill some jsdoc for you and all you need to do is input the types and descriptions

hushed robin
#

yea it's cool

#

oh wow

#

thats useful

harsh nova
#

yeah sure is poggythumbsup

#

I should really document my code

frosty gale
#

i just accept the void type into my soul

#

its easier than documenting every function

#

and i am NOT touching typescript until its more seamless and less annoying and maybe one that doesnt require you to use the any type for a basic js feature

#

but other than that i like the language

lyric mountain
frosty gale
#

huh?

lyric mountain
#

a java superset

hushed robin
#
const puppeteer = require('puppeteer');

class Client {
    constructor({ options }) {
        if (options.cache.enabled || options.cache.ttl) {
            this.cache = new Map();
        };

        this.options = options;
    };
    /**
     * Fetches data with a headless browser (puppeteer)
     * @param {string} url
     */
    async fetch(url) {
        const browser = await puppeteer.launch({ headless: 'new' });
        const page = await browser.newPage();
        await page.goto(url);
        
        const data = await page.content();
        
        browser.close();
    
        try {
            const parsedData = JSON.parse(data.replace(/<\/?[^>]+>/gi, ''));

            this.cache.set(url, {
                data: parsedData,
                expires: Date.now() + this.options.cache.ttl
            });

            return parsedData;
        } catch {
            return null;
        };
    };
    /**
     * Checks the cache for data before fetching it
     * @param {string} url
     */
    validiateCache = (url) => {
        if (!this.options.cache) return this.fetch(url);

        const data = this.cache.get(url);

        if (!data) return this.fetch(url);

        if (data.expires <= Date.now()) {
            this.cache.delete(url);
            return this.fetch(url);
        };

        return Promise.resolve(data.data);
    };
    /**
     * Get data on a Kick channel
     * @param {string} channel
     */
    getChannel = (channel) => {
        return this.validiateCache(`https://kick.com/api/v1/channels/${channel}`);
    };
    /**
     * Search channels and categories on Kick
     * @param {string} searched_word
     */
    search = (searched_word) => {
        return this.validiateCache(`https://kick.com/api/search?searched_word=${searched_word}`);
    };
};

module.exports = Client;

i can now search the Kick API with this and cache the results

lyric mountain
#

it has typing but is almost as lenient as js

frosty gale
#

ah

#

battleless rlly loves his arrow functions in classes

lyric mountain
#

and not as awkward as ts

hushed robin
frosty gale
#

but i dont think you can use this in them?

hushed robin
#

i'm just getting started using classes today

frosty gale
#

ill have to test this

hushed robin
frosty gale
#

maybe its an exception for classes

hushed robin
#

it works

#

getChannel and search both work with this and they use arrow functions

lyric mountain
frosty gale
#

nevermind it is an exception for classes

#

usually you cant use this in arrow functions unless you bind a context but here it does that automatically ig

lament rock
#

probably because it's enclosed in a class declaration

hushed robin
#

hm?

slender wagon
#

alert('Hacked');
hi what do this do

lyric mountain
pale vessel
#

you can if it's an expression

lament rock
#

onWindowFocus(() => alert("hacked"))

#

!11!!

lyric mountain
wheat mesa
hushed robin
#

is sub categories one word

lyric mountain
#

as it's a class closing bracket

slender wagon
#

man never use semicolons on javascript

hushed robin
#

sorry

slender wagon
hushed robin
#

i have to

wheat mesa
#

You’ve just formed a bad habit of doing that

lament rock
#

any code formatter would call you insane

pale vessel
#

bro needs a linter

lyric mountain
#

most editors will also mark those semis as typos

wheat mesa
#

Honestly just install prettier and auto format on save

#

It’ll save you a hell of a lot of time

hushed robin
#

it's proper

#

if it wasn't proper it would error

lyric mountain
#

there's a difference between errors and best practices

north cairn
lyric mountain
#

also I doubt your editor is silent about it

lyric mountain
hushed robin
#

it says nothing

#

noe rrorsd

lyric mountain
#

show a print of that line

hushed robin
#

this is how i set a default value right

north cairn
lyric mountain
#

classes are just entities with properties and methods

lyric mountain
hushed robin
lyric mountain
#

oh, funny, vscode doesn't warn about useless semis

north cairn
lyric mountain
#

now I know why the former maintainer of the project I assumed liked vscode

#

and why his code is fucking hell to work with now

lament rock
#

classes are fancy functions. You can assign arbitrary properties to the prototype of functions and functions can have the new key word applied to them

lyric mountain
#

just a sec, I'll paste your code in intellij to show the full highlights

#

ignore the squiggles, they're there because I don't have the rest of the project

#

see how ; is highlighted?

hushed robin
#

no

#

i'm not installing bloatware

lyric mountain
#

me when intellij

hushed robin
#

does it really matter if it does nothing?

#

my code is readable

pale vessel
#

you could even install it as an extension, no extra package needed

#

is my code readable DoordTroll

hushed robin
#

i am uploadding more code now

lyric mountain
#

anyway, to keep the flame low, useless semicolons are not necessarily unreadable, but you're developing a really bad habit of ignoring best practices

pale vessel
#

I mean you don't need prettier at all if you could actually code properly

#

but yeah the auto formatting is really nifty in save

hushed robin
#

ok

#

what do I remove?

pale vessel
#

I love writing some badly spaced and formatted code and saving and boom, formatted nicely

hushed robin
#

no

#

i'm not installing bloatware

#

i will do it manually

#

?

pale vessel
#

why are you being aggressive towards him

lyric mountain
#

but not for scopes

lyric mountain
#
thisIsAFunctionScope() {
  thisIsAStatement();
}
hushed robin
#

so like i don't do this

function() {
console.log('hi');
};

#

i remove it from last line?

lyric mountain
#

yes, put semis only on statements

hushed robin
#

oh no

#

my code is too long

wheat mesa
#

Wdym your code is too long

#

I’ve formatted 2000 line files before

#

Surely you don’t have more than that in a js project

#

💀 my dude “bloat” would be if it made your code run slower with no reasonable trade off

#

This is quite literally just so when people are helping you they don’t lose their mind trying to read your code

hushed robin
wheat mesa
#

Discord is a little ram hungry but I can’t say that using electron/react native was necessarily a bad idea, it’s cross platform and easy to work with which is important for discord given that they were a startup with no income at some point

hushed robin
#

happy birthday waffle

pale vessel
#

my guy it's a private repo

wheat mesa
hushed robin
#

oops

wheat mesa
#

Upload it to a gust

#

Gist*

hushed robin
#

there

#

click now

pale vessel
#

remove the semicolon after the catch block

wheat mesa
#

You still forgot to fix them on like half of your code

hushed robin
#

wym

pale vessel
#

look again

hushed robin
#

screenshot whhere

pale vessel
#

L35

hushed robin
#

oh ok

#

i will fix now

pale vessel
#

honestly that code looks optimal enough

hushed robin
#

remove that one on the last line too?

pale vessel
#

nah

hushed robin
#

hm?

#

sussy link

#

just send code

lyric mountain
#

.then(...);

#

so it's a valid semi

hushed robin
#

oh ok

pale vessel
#

you can send the text file lol

#

discord does that for you even

#

ah

hushed robin
#

ok i fixed it all now

#

i think

pale vessel
#

yeah that looks good

lyric mountain
#

this is part of why I like jetbrains tools, they warn u while u type

pale vessel
#

battleless w

lyric mountain
#

tho prettify is good enough

hushed robin
#

this is a good day

#

i've learned a lot

lyric mountain
#

webstorm

pale vessel
#

yeah you learned how to listen to people

lyric mountain
#

or idea, but idea is the full kit

hushed robin
wheat mesa
#

I wouldn’t bother using jb for js

#

Too bulky for my liking

hushed robin
#

it feels

#

slow

#

and yanky

pale vessel
#

my friend had issues with TS typings on webstorm too

#

while on VSC they worked fine

wheat mesa
#

If you want a light feel then you can use vim 🧌

lyric mountain
#

I mean, webstorm is a full IDE, so it does have longer start time than vscode without plugins

#

but it is nowhere slow once it finishes boot

pale vessel
#

an IDE for an interpreted language is so not worth it

wheat mesa
#

This tbh

#

The IDE can’t do a ton of work on warnings for you just because there’s not a lot to warn about in the first place without type information

#

Then you’re kinda defeating the purpose of swapping to linux

lyric mountain
#

u can limit gradle cache

wheat mesa
#

Also if you’re concerned about storage in your PC then just upgrade it

north cairn
#

class Game{
x = 0
y = 0

buttons (interaction) {
do all the stuff,send message with buttons,do collector adn reply with it}
const coin = new Game()
coin.buttons()

after this i just import the class and do
if (coin.x === 1 || coin.y === 1) {
"you won toss" }
@lyric mountain is it right? 💀

wheat mesa
#

Get a 1tb drive for 30 bucks

#

They’re hella cheap

lyric mountain
north cairn
#

rest everything fine?

lyric mountain
#

but yeah, it's right I think

#

not the best way to approach a coin toss game tho

north cairn
lyric mountain
#

without classes whatsoever, ur just rolling 1 or 2

wheat mesa
#

Yeah for cointoss stuff you can honestly just get away with Math.random() and an if statement unless you’re making it complex

north cairn
lyric mountain
#

ah ok

#

then proceed

north cairn
#

wish me luck,thank you for explaining good as always