#development
1 messages · Page 132 of 1
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
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
sharing yeah since that would make the files accessible to anyone with a link
pogu
As to how that is done, no idea yet.
I haven't done much in terms of encryption of files and such
I've rudamentarily tried out encrypting files manually since I wanted to understand the inner workings behind it
What did you learn?
that its hella unsecure to do that yourself and that it is better to have a library handle that 
Its a cool nodejs framework wrapped around express and fastify
Makes making api's 10x easier and is modeled after Angular
could look into experimenting around with that sure
Only thing with NestJS is it is a bit bloaty
Thundxr its a project I am passionate about
Idgf
This isn't meant to please anyone, its just something to do to learn more about encrypting files and file sharing in general
There's an animation?
here, my first file: https://wormhole.app/KEloY#TkuiggS9Qsiezf9grNBXoQ
Lol
seems perfect for the out of context twitter
friends sending malware to each other online is the same as friends greeting each other by calling each other bad words
Lol
Hello tim, open this notsosuspicious file for me 😉
sup bitch
yo sup mofo
heres some malware, check it out
cool, have my virus i just made
Lol
They got unbanned quick
I know of a person who is getting banned for malware distribution
after I send discord an email 
you
Lol
:^)

Discord don’t take screenshots smh

message links work too
#development message
1119956878961684500
Aurel is a Jr jr chat moderator
indeed

trial mod for how many years?
Must be a lot of errors
0
:^)
actually
its about to be his anniversary
how long am i mod already
Aurel did quit for a good bit
people tend to come and go, but it feels like we've known them forever
2 years ish?
Cmon you don't have to blur
we're all friends here


omg leaked
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
#aurel-ban-counter
264890171575631873 time to hack into @gilded plank and make it scan all channels
lots of people did that back in the day, myself included
when we had all our bots on this server

whaaat I would never
@rustic nova so about preventing movies cause DMCA hassel, I could limit file sizes, though I want to avoid this.
Hm
or have people request larger sizes
With valid reasons
yes
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.
just put a disclaimer that you are not responsible for the files people upload
While that is something I will do, I also don't want people having illegal content being hosted
put that in your TOS
but there is no way for you to prevent it, unless you break your own encryption
That isn't the issue, the issue is how do I moderate such a thing
you cant
Exactly
thats the whole point of encryption
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
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?
invisivble icons?
host
ghost ping much
Happens to the best of us
@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
probably because literally anything that has a screen supports them and theyre low in size ig
💀
i heard apng is lower on size
good job telegrammm
They don't
Sure with what
I can't login to my account on top.gg
always gives 403 error
what should I do?
@rustic nova
Clear cookies etc
Where are you getting that 403
rest.post(Routes.channel(config.channel), {
data: {
name: config.name.replace('{members}', value)
}
}).catch(error => console.error(error));
am i doing something wrong here
thanks for the obscure code fragment with no context associated
nvm i think i fixed it i have to use patch
I just forgot to spin up my cubicle quantum accelerator for my code to work mb
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
what context?
it's using discord.js rest thing
what other context is required
oh
🧌
when no discord nitro makes you use the discount troll
the troll that is on clearance
what

you want to change channel name without connecting to gateway?
yes
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
but if you really want to you should be able to do it with this
i'm using the discord.js REST package i'm not using Tim's overcomplicated and underdocumented one
🧌
yeah but look above
i'm getting an error
wow ok
did you look at discord documentation?
they show you the api request structure
one m
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
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
Gifs are anything but small
ok
ok
ok
tim
!battle
where is npm package for tiny discord
I just install the repo when I used it
what]
Hola
hi
Brother can u suggest me some crypto airdrops servers!!
npm i https://github.com/timotejroiko/tiny-discord
ok
wym
its not on npm yet because i still want to do some changes before i release
but im busy with other stuff rn lol
oh ok
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
Okay so idk what kind of elo you are doing, but i've never seen one done like that
Question for ya, why is it a team matter and not a player matter?
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
i have 5 different rating types currently. overall_player, combined_player, distinct_player, combined_team, distinct_team. but currently team is keyed off of the players that make up the team. so if one player on the team changes there is a new key and that resets the team's Elo rating.
I feel like the elo should be summed up rather than setting a teams elo and resetting it when something changes
yeah, i think i need to make that change.
Don't reset the elo
or store both and let the user decide which to show
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?
if you have a fixed sized player base then yeah
at some point you get no rating points for beating a low ranked noob
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
this is my elo algorithm
actually that's Elo's algorithm
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
Am I following what you are doing correctly?
I don't really know if this was your intention
it shows how much the playerElo changes.
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?
Don't think so
Nope there's not
Unless you have a time machine
shouldn't be too hard to code one up
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
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
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
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
I see
250 per server
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
but the team needs to be separate from the members
It will be?
yeah, the team rating stays even when players change
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
oh i see
simple as that
so they would register a team using plain text probably
no role mention
that'll be tricky to parse
yeah, the input is an array of user input for 1st_place and 2nd_place
I don't understand the issue
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
why are u doing it that way btw?
u can use a simple numeric column for storing scores
i'm not going to do teams that way
i'm thinking about using roles again
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
there can be ties
i need to list the players or teams that tied
tim came up with the pattern im using now
can there be more than 2 teams per match?
yeah
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)
what's the context for all that btw?
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
Any zero sum game
...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
I currently have one result field, but tim suggested I split it up into different inputs
you'll be working extra to make it work with the parens option
i already made a fancy regex to get it to work
regex for names?
// remove all whitespace
const placementInputNoWhitespace = placementInput.replace(/\s/g, '');
// tokenize the placement input
const teamOrPlayerStrings = placementInputNoWhitespace.match(/(\([^()]*\)|[^\b>]*)/g).filter(a => a);
people will make it fail
unless u use the users' pomelo
which is guaranteed to have a predictable pattern and to be unique
pomelo?
the username
it's unique, no whitespaces and no special chars
100% either letters, numbers or underscore
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
periods too
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
Like people making teams just to farm rating points out of it
Or to purposely be matched with lower ranking players
Anyone that use google workspace and cloudflare?
Cloudflare dns?
cause I'm trying to activate gmail using cloudflare a dns and this shit is not workin lmao
yes
Wdym activate gmail?
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.
@unkempt ocean
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
ty 
Unfortunately idk if I can help with that
Email stuff is always annoying to make work
I'm not sure I understand your problem but cloudflare already provides domail email feature
is that what you're looking for?
The worst is that even if all go well, the other end might block the email or send it to trash
not really, I am looking to activate gmail through google workspace
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
What if you just update your cloudflare MX records point to Google's servers
There's an answer on cloudflare community that says if you have Cloudflare Email Routing enabled then it blocks the google's MX records
Already looked into it and it’s not enabled
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+
Is that Google domains?
little did they know
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.
it's because it's loading a 404 page, which is HTML
static should be at the root, so try /style.css
at where?
href
also, if you want the files to be under /public, use app.use("/public", express.static(__dirname + '/public'));
worked, thanks (:
but it is massive
you'll need to rebase
to remove it from previous commits
else it'll stay in the history
h.o.w
...by rebasing
h.o.w 2 re.base..?
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
kay i did
u named it .gitignore right?
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
hey i learnt classes as u said
now i m thinking to divide by codes into seperate files and then do
u don't
do u think its a good idea
ayo why
but to import,i need export
you're the button game guy right?
yes
not for classes
unless js requires it
don't think it does
nvm it does
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
can u please say common method
es6 wont work coz i alr did module.exports for command
u can export inside it
not working na
module.exports = {
name: "toss",
aliases: [],
description: "toss a coin ",
run: async (client, message, args) => {```
hm
module.exports = {
aclass,
otherclass,
{ thecommand }
}
but idk how you'd name the command to be able to import
i dont think that works
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
know someone who might be able to help?
u can put the class in a separate file
that way u dont need to modify the command's exports
put the class in its own file, then export as u do with commands
module.exports = { theclass }
then how do i export command as same time sir
u dont
same issues come over
theclass.js
thecommand.js
ok now i need use the class
import in thecommand
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
yep
let obj = new TheClass();
obj.thevariable
that's a variable
talking about a variable in the method
ah, u mean inside a method
i can access that like that?
then no, the variable dies with the method
put the variable as a class property if u need it outside
how to do that
that's the browser's console btw
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
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
but i have put it in class
what if i want in diff file as i said
what is result 0 meaning??
import { Coin } from './coin'
nothing, I'm simply assigning an initial value
u could do ```js
toss() {
this.result = Math.floor(Math.random() * 2) + 1;
}
but u run into the possibility of result being undefined
also,should i do like,make a sperate file for all classes and eventually export them
what? why
because unless u run toss(), the property will never be created
if ur gonna use it in other files, yes
else u can put in the same file and not export it
well what do u prefer
Make one class for one fucntion or one class for all
I prefer one file for each class
the problem is with buttons
you were saying?
i said make one file for all classes and export them
whats that
nono, I said "one file for each class"
my commands folders
💀
every one of them is a class
ok how about a folder for all classes
the structure is up to you
whatever is easier to organize and find the files you want
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
../folder/theclass
const { Game} = require("../Classes/tossclass")```
not working
says cannot find module
Is Classes in parent folder?
Then u need to specify the path
how
...
Yes, the whole address
Relative to the current file
no actual way to access that variable??
Which "that variable"?
Oh here u are
this
^
U don't need to call it result, and u can declare more than one
in js you need to declare the variable inside the constructor, not outside
tbh you dont need to declare it at all
Works outside too
No, only things inside the method can access the variables inside it
That's called scope
oh it does, never see that before lmao
U can assign that variable from inside the method tho
Just a bit flavorless without private lul
if (obj.x === 1 || obj.y === 1)
Simply put x and y as class variables
ok guys
And assign them from inside the method
i am working with classes right now how do i make something pass by a code before running
Example
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
Simply call whatever code u want to run before the rest of the code
why don't u simply declare a function for it then?
wym
I think ur overthinking too much
You don't need to access anything from the function
u are right
but then I will need to copy and paste that function everywhere
ok listen up.!!
i do what u said
Now i want buttons in that message,i also want reply with them
Make it global
what
basically i'll explain what i'm trying to do
Export that function and use it wherever u want
we both have issues at same time and kuu trynna explain us both
also these paths are such mess dude
well ok
total mess1
Store the buttons somewhere in the class
Then use it for replies
It's easier once u visualize it
what store
../ is "one folder up"
nvm i solved path issue
A variable
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
class Coin {
buttons = [...them]
}
Then access with coin.buttons
Assuming u named ur instance coin
what that ".."
btw you dont need to use a collector, you can use awaitMessageComponent()
which is simpler and easier
Tim continues from here
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]})```

u just got betrayed ig
u may continue on how do i access?
if u arent feeling frustrated..
Any variables declared as class variables can be accessed just like functions
class AClass {
anything here
can be acessed
}
so what is class variable here
isn't tit called constructor??!?
No
class AClass {
constructor() {
this is a constructor
}
}
It's a function that's ran when u use new AClass()
same as method?
class AClass {
buttons() {
I mean, it is, but only during new
like this smth?
You can call the constructor directly
U can, but shouldn't unless during new
That's because js is a mess and has no visibility modifiers at all
It does
That'll create a function called buttons
#methodname creates private methods
That's very recent
yo but with ur method,i cant put buttons in a message
multiple even
like diff buttons in diff message
For a language that's as old as the internet, one year is recent
java applets came before js
Please show me a complete example of your intent
but yeah
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
You can, simply call it
let coin = new Coin()
Then
coin.buttons
It'll return whatever you put in buttons = ...
so i put all this in a method called buttons
You can, just make sure to pass the required values as parameters
for eg?
addButtons(param, params, param) {
...
}
and what will be those parametres
For example, you need to use interaction, so you pass it to the function
So it'll be a param
Date.now() + this.cache.ttl
why is this returning NaN
Log it
this.cache.ttl is 60000
u mean addbuttons(interaction(){
stuff}
Sigh no
addButtons(interaction) {
}
thats what i wrote??!?
oh sorry i added two brackets instead of one to close it
any other parametres than interactions?
💀
only parameters you need to make the function work
U added extra parens
well if its like this
then i make one function named buttons
and other named result
should owrk?
may we know why are u doing this?
u sure u defined client?
bro look at the first screenshot
?
....
when class instantiation returns null 💀
wtf r u saying
hey
do u know why my isssue is presisting
what?
the this keywork can be mutated with .bind or reference something different in a pre es6 style function
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
I suppose Client is a d.js thing and not your own class
or is it?
why
bro
it's mine
then show it
🤦
because arrow functions dont let you use this unless you bind to it
thing is, you're doing this.cache = new Map();
how to do i make it async in that case
this.cache.ttl cannot possibly exist (because it's a map)
nvm
what
unless u add a ttl entry to it
u declared cache as new Map();
it's not what u passed on the constructor as a param
ofc it does now
becuase you have not defined the search function for your class "client"
yes i have
then it does not return a promise
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
😗
w people
btw how do i do that cool thing
where if you hover over the function
it'll tell u shit abt it
jsdoc
ok
why?
typescript is a blessed language
JavaScript is amazing
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
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
u basically described groovy
huh?
a java superset
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
it has typing but is almost as lenient as js
and not as awkward as ts
i'm just use to it
but i dont think you can use this in them?
i'm just getting started using classes today
ill have to test this
well
maybe its an exception for classes
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
probably because it's enclosed in a class declaration
alert('Hacked');
hi what do this do
don't put semicolons on brackets
you can if it's an expression
in that case only the second bracket
He doesn’t listen, I already tried telling him like 20 times 😭
is sub categories one word
as it's a class closing bracket
man never use semicolons on javascript
it looks weird when i don't
sorry
lets goo
i have to
To you maybe, but to literally everyone else on the planet it’s the opposite
You’ve just formed a bad habit of doing that
any code formatter would call you insane
bro needs a linter
most editors will also mark those semis as typos
Honestly just install prettier and auto format on save
It’ll save you a hell of a lot of time
no
it's proper
if it wasn't proper it would error
there's a difference between errors and best practices
?
also I doubt your editor is silent about it
you don't need a function for result
it is
it says nothing
noe rrorsd
show a print of that line
this is how i set a default value right
then?
I think you're looking at classes the wrong way
classes are just entities with properties and methods
you definitely muted your editor linter
no i didn't
oh, funny, vscode doesn't warn about useless semis
ig i m overthinking
ye I checked, vscode barely has highlightings
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
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
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?
me when intellij
you could even install it as an extension, no extra package needed
is my code readable 
i am uploadding more code now
anyway, to keep the flame low, useless semicolons are not necessarily unreadable, but you're developing a really bad habit of ignoring best practices
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
I love writing some badly spaced and formatted code and saving and boom, formatted nicely
why are you being aggressive towards him
it's hard to explain, but everytime u type statement, put a ; at the end of the line
but not for scopes
huh
ok
thisIsAFunctionScope() {
thisIsAStatement();
}
so like i don't do this
function() {
console.log('hi');
};
i remove it from last line?
yes, put semis only on statements
ok
oh no
my code is too long
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
how is this code?
https://github.com/battleless/kick-api/blob/main/client.js
i removed semicolems from where u said
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
happy birthday waffle
my guy it's a private repo
Certified 404 because it’s private
remove the semicolon after the catch block
You still forgot to fix them on like half of your code
look again
screenshot whhere
L35
honestly that code looks optimal enough
remove that one on the last line too?
nah
that one is a statement
.then(...);
so it's a valid semi
oh ok
yeah that looks good
this is part of why I like jetbrains tools, they warn u while u type
battleless w
tho prettify is good enough
webstorm
yeah you learned how to listen to people
or idea, but idea is the full kit
🧌
If you want a light feel then you can use vim 🧌
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
an IDE for an interpreted language is so not worth it
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
u can limit gradle cache
Also if you’re concerned about storage in your PC then just upgrade it
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? 💀
don't create a new Game() inside itself
yea yea sorry my bad
rest everything fine?
uff,whats the best way..
without classes whatsoever, ur just rolling 1 or 2
Yeah for cointoss stuff you can honestly just get away with Math.random() and an if statement unless you’re making it complex
well its not a toss game
Toss is a initial command to be run before playing the game
wish me luck,thank you for explaining good as always




