#development

1 messages · Page 1554 of 1

young flame
#

i code shit thats what i do i have like 40 private repos

#

mmulu your point

quartz kindle
#

must have all brackets and all colons

opal plank
#

my point is that you dont have much, if any right, to complain about what i do when you write shit like that

#

plain and simple

earnest phoenix
#

Why braces doe, just return;

#

Pain

young flame
#

i wrote it because i can

proven lantern
#

why would i do a file read?

young flame
#

plain and simple

quartz kindle
mellow kelp
#

"plain and simple"

opal plank
#

so you writing shit code on purpose to feed it to the community? specially knowing a lot of noob devs might see your repo?

#

good job moon

#

👍

young flame
#

noob devs

proven lantern
quartz kindle
#

you're already reading 20+ files

young flame
#

it isnt even displayed when its searched

quartz kindle
#

one more read wont do shit

#

specially not at loading time

opal plank
#

its pinned on your fucking profile my dude

#

wdym its not displayed?

proven lantern
#

some hosting doesn't give you file access too

quartz kindle
#

wut

young flame
#

didnt know my opinion was so dire your harrasing me about it

proven lantern
#

i could do it on my localhost

opal plank
#

you should call it quits already moon

young flame
proven lantern
#

serverless hosting

quartz kindle
#

does the host support node.js?

young flame
#

call what quits

misty sigil
#

timscript

#

poggers

young flame
#

your in your feelings cause i joked about ts-node

quartz kindle
#

if it runs node.js then it supports fs

#

most "serverless" hosts just run an ephemeral disk

earnest phoenix
#

Bro, Tim, TimScript, TimGaming

#

When

quartz kindle
#

but its still a disk

mellow kelp
#

Tim.js

quartz kindle
#

Lol

mellow kelp
#

the next-generation framework

proven lantern
young flame
#

lol

proven lantern
mellow kelp
#

depends on where you're using fs

steep orchid
#

hello, a friend of mine in #support told me to come here.
I am trying to use markdown for top.gg desc (server)
but I'm having trouble with it

quartz kindle
#

wait so you're not requiring server side? you're requiring on client side?

mellow kelp
#

of course you can't use fs on the frontend part, but you can at least use it on the server-side

young flame
#

@mellow kelp ima make a functioning league api that has max deps

mellow kelp
#

using one of the prop functions

earnest phoenix
#

I like how there is a way faster Implemention of Array.prototype.sort() called TimSort, Tim do be sorting out things really fast doe

opal plank
proven lantern
#

i am running on localhost. vanilla js

steep orchid
young flame
#

was i supposed to keep that to myself to

mellow kelp
#

tim be like

#

"why do i fix everything i touch?"

young flame
steep orchid
#

can someone help me please pleaseee

quartz kindle
#

honestly some things just fix themselves just my be approaching them

#

happened may times before

mellow kelp
mellow kelp
#

![Alt text](https://image.jpg)

earnest phoenix
#

Bro, just put it in rice @quartz kindle

#

Fixes them 100%

young flame
mellow kelp
#

tim should have written the star wars sequels

quartz kindle
#

but does it fix my financial problems?

quartz kindle
earnest phoenix
#

Sad

young flame
#

@quartz kindle is making your own cmd handler bad

earnest phoenix
#

What

quartz kindle
young flame
#

hope said i should and i did but someone said its bad

mellow kelp
#

emphasis on properly

young flame
#

its 5,672 lines

#

and stretches over 3 files

#

and its in ts

quartz kindle
#

then its likely not "properly"

#

lmao

earnest phoenix
#

He meant "properly" by writing one if you know what you're doing probably

quartz kindle
#

i mean

misty sigil
#

@modern sable

quartz kindle
#

the code that erwin was showing around

quartz kindle
#

with if command === "ping"

#

was that yours?

#

your command handler?

young flame
#

no lol

mellow kelp
#

yanderedev would be proud of you

young flame
#

i was just coding shit cuz i was bored

mellow kelp
#

and that's no good thing KEKW

quartz kindle
#

lmao

young flame
#

@mellow kelp remember the 50 dep bot

mellow kelp
#

yes

young flame
#

that i was coding cuz i was bored ad

earnest phoenix
#

At least that was better than Yandere simulator's code

quartz kindle
#

well, show handler and i'll tell you if its a good handler

young flame
#

thats the bot erwin showed

#

lol

#

package .json was like 76 lines

earnest phoenix
#

Wtf

quartz kindle
#

just pick any turkish bot on glitch

#

all of them have 50 deps

#

lmao

young flame
#

well the first part

quartz kindle
#

thats not the command handler tho, is it?

young flame
#

testhandler/Utilities

young flame
earnest phoenix
#

Bro, they should just have a native check on the npm module

if (this.project.bot && this.turkishBottum) await this.addAllDependencies();```
young flame
#

i gota scrool down

#

500 lines

mellow kelp
#

const shuffle = arr => arr.sort(() => Math.random() - 0.5)

#

pog

quartz kindle
#

you probably wanna split your bot into more files lul

young flame
#

kk

quartz kindle
#

but i mean, my first bot was also a monolithic file

young flame
misty sigil
#

Oh my god.

young flame
#

and theres 3 of them

mellow kelp
#

all of our first bots were gigantic one-files KEKW

misty sigil
#

not even my website is that big

#

and my website is 500 lines

marble juniper
#

please don't make a one filer

misty sigil
#

and i would write 500 more

marble juniper
#

thanks

#

use a command handler

young flame
misty sigil
#

just to be the man who writes 1000 lines of code just to have it break

young flame
#

hi link

marble juniper
#

its faster and easier to use a command handler than a single file

mellow kelp
#

ofc

marble juniper
#

kik

#

*lol

earnest phoenix
#

Don't lie, all of our first bots were one file bottums

young flame
#

its 3 thousand lines tho

#

mainly cause half of it is functions

earnest phoenix
#

1k lines for exec?

young flame
quartz kindle
#

do you actually need that many functions lul

young flame
#

thats line 2398

young flame
#

i could make a bot that just send help but itd be 200 lines

mellow kelp
#

i guess that's actually acceptable

young flame
quartz kindle
#

you're the opposite of me then

young flame
#

you really thought i cant code

#

lmfao

quartz kindle
#

i oversimplify everything

young flame
#

o

#

us making a project would be hell

marble juniper
#

oversimplify sounds better than overcomplicated

#

lol

young flame
#

one half would be 5 lines and the other half would be 6000

#

they would be like wtf

marble juniper
#

lmfao

#

I am

#

just both

#

lol

young flame
#

link

marble juniper
#

Im a mix between you two

#

I would say

young flame
#

u are

#

best child

marble juniper
young flame
#

@quartz kindle o i have a question

quartz kindle
#

hmm?

marble juniper
young flame
# quartz kindle hmm?
 //buat read json
  let curxp = xp[user.id].xp;
  let curlvl = xp[user.id].level;
  let nxtLvlXp = curlvl * 500;
  let difference = curxp/nxtLvlXp *297;
  let difference2 = nxtLvlXp - curxp;
  
  try {
  async function createCanvas() {
  return new Canvas(300,50)
.setColor('lightgrey')
.addRect(0,0,300,200)
.setColor('#f44262')
.addRect(0,0,difference, 200)
.setTextFont('bold 15px Courier New') 
.setColor('#000000') 
.addText(`${curxp} / ${nxtLvlXp}`, 120,30)
.toBufferAsync() 
  } 
    let m = await message.channel.send('*Please Wait...*');
  const gumen = `
__**\`${user.username}\`'**s level information__
Current Level: **${curlvl}** - Total XP : **${curxp}**
Progress: ${getProgbar(curxp, nxtLvlXp, 10)}
Needed XP to reach level **${curlvl +1}** : **${difference2}**
`;
message.channel.send(gumen, {file: new Requis.MessageAttachment(await createCanvas(), 'xp progress till level up.png')}).then(() => {m.delete()})
``` i was testing this out
#

but whenever i run it

#

before i got an error and i fixed it

#

now it doesnt send the image

#

just the gumen part

#

unless i did it wrong

#

its 5 pm and i havent had a nap

quartz kindle
#

thats not the canvas lib is it? is it canva or canvas-constructor?

#

whats Requis? your Discord variable?

#

should be files:[new Requis....]

young flame
#

requis is my discord variable

#

you said files?

#

ill try it out

#

1715 in requis.js is the message.channel.send line above

stark abyss
#

I am still unsure what to do next. I have my code in visual studio now. I am using heroku to have it online, but I don't think localhost database is gonna work with it. Heroku does have "heroku-postgres" which I did look into, and it was 1gb storage free (I have no clue if this is enough or not) more then that I have to pay. I don't have money to spend on this, especially since I am just learning. I don't know if I should switch a vps or switch to new database, if you know something please let me know else you can ignore.

quartz kindle
#

notice the []

young flame
#

o

young flame
#

like

#
 [new Requis.MessageAttachment(await createCanvas(), 'xp progress till level up.png']
earnest phoenix
#

Guys, I’ve tried everything nothing, shows the bots on too but dosent reply with command

quartz kindle
earnest phoenix
#

Huh, lol

quartz kindle
#

missed a parens, but yes

young flame
#

o oki

#

parens at the end correct

#

@quartz kindle

quartz kindle
#

before the ] obviously

earnest phoenix
young flame
#

o kk

#

wait wut

#
 [new Requis.MessageAttachment(await createCanvas(), 'xp progress till level up.png', ]
#

that

#

again im not slow just t i r e d

quartz kindle
#

parens

#

parenthesis

#

not comma

#

yous attachment is open

young flame
#

o

quartz kindle
earnest phoenix
quartz kindle
#

what is the name of the actual function that runs the commands?

#

run()?

#

execute()?

earnest phoenix
#

run()

quartz kindle
#

yes

#

so, where is command.run()?

earnest phoenix
#

The file?

quartz kindle
#

in your main file

#

the code that you just showed

earnest phoenix
#

Lemme check

quartz kindle
#

i dont see command.run() anywhere

earnest phoenix
#

Oh uh..

#

@quartz kindle which line should I add command.run() in?

young flame
#

uh

#

@quartz kindle it worked but

#

the image is like

quartz kindle
#

looks like a font loading problem

young flame
#

o

quartz kindle
#

does it work if you use the default font?

#

ie remove courier new

young flame
#

uh lemme see

earnest phoenix
#

Tim, which line should I add command.run() @quartz kindle

quartz kindle
#

where do you think?

young flame
#

nope

#

image is the same

earnest phoenix
#

Line 13? @quartz kindle

quartz kindle
#

how did you come to that conclusion lol

earnest phoenix
#

Tim, you're basically witnessing a "please spoon-feed me" moment

#

đź—ż

earnest phoenix
young flame
#

still the same

#

o

#

messages sent

earnest phoenix
young flame
#

at dif times

#

spoon-feeding is like

quartz kindle
young flame
#
module.exports = {
 
}
``` why wont it work
#

and you just

quartz kindle
#

the top of the file has the list of all commands, but has 0 information on the message the user sent

young flame
#
module.exports = {
 function async name(client, message, args)
 [full code thing]
#

o

#

uh

summer torrent
quartz kindle
#

there is nothing about commands there

young flame
earnest phoenix
#

I’m confused, do you mean in index.js or in my commands? @quartz kindle

young flame
#

bald

#

at the top

earnest phoenix
#

ski

earnest phoenix
#

Lol

young flame
#

your bald at the top right

earnest phoenix
young flame
earnest phoenix
quartz kindle
#

you want to add command.run() right?

earnest phoenix
#

Why would I even need that?

quartz kindle
#

then logically, it has to be somewhere there command exists

earnest phoenix
#

Well, it worked before without that..

quartz kindle
#

command doesnt exist at the bottom of the file, nor at the top

earnest phoenix
#

Then where should it be?

young flame
#

bruh

quartz kindle
young flame
#

b r u h

#

can i say it tim

earnest phoenix
quartz kindle
earnest phoenix
#

I was kinda rushing while coding, ima check my old index file and see what’s there

quartz kindle
#

the run() part is what actually makes the code inside the command run

#

otherwise that code will just sit there and do nothing

earnest phoenix
#

True, well thanks for making me realize that

#

@quartz kindle command.run(message, args, client);

#

Right?

quartz kindle
#

if thats what the run function needs, yes

earnest phoenix
#

Yes, it does. Thanks fellow guy lol..

young flame
quartz kindle
#

well i cant help you then

mystic shell
#

im using discord.js for my bot, im trying to get my bot to read the full list of members in my server but it only works with the first two

quartz kindle
#

i dont use canvas constructor

quartz kindle
mystic shell
#

where in the developer portal would that be, in oauth2 or in bot

#

wait found it

buoyant aspen
#

any clue why this might be returning unknown user?

const dsc = await client.users.fetch(report.user);
````report.user` is defined, it's a discord user id string
#

does it need to be an int?

quartz kindle
#

no it needs to be a string

#

console.log it to make sure its correct, if its still doesnt work, then the id is invalid or the user doesnt exist

summer torrent
#

the user isn't in cache i think

buoyant aspen
#

Thonk console.log was correct

summer torrent
#

is fetch fetches it from api

quartz kindle
#

yes

buoyant aspen
summer torrent
quartz kindle
#

fetch already does it

summer torrent
#

there is options

dense jungle
#

can 2 different bots be hosted on one server?

summer torrent
#

yes why not

quartz kindle
#

the code is not the issue, fetch is correct

#

if it returns unknown user then the id really is unknown

#

are you sure the id exists?

buoyant aspen
#

yeah

dense jungle
summer torrent
#

show error

dense jungle
#

could be my command handler

buoyant aspen
#

if that's the issue

quartz kindle
#

thats not the issue

#

the fetch() method automatically caches it

#

whats the id of the user in question?

buoyant aspen
#

been using RJain (286737962769580032)

dense jungle
summer torrent
#

show code

#

oh

quartz kindle
pure lion
quartz kindle
pure lion
#

huh

#

on node v15.x I get that error when trying to install @djs/opus

quartz kindle
#

undefined variable module_name

pure lion
#

apparently so

quartz kindle
#

and with node 14 it works?

pure lion
#

havent tried yet

quartz kindle
#

give it a try

pure lion
#

am do

buoyant aspen
#

thanks

quartz kindle
#

try restarting your bot

#

it could be a discord bug

buoyant aspen
#

kk

pure lion
#

cb() never called

quartz kindle
#

thats usually a path issue

#

but doesnt look like its your case

pure lion
#

pain

#

calling npm rebuild

summer torrent
#

clear your npm cache

dense jungle
#

Still cant find why it executes

#

I am using a different token for the bot

mystic shell
#

im still kinda confused on js promises, could somebody please explain them to me

#

if something returns a promise then what do i do to actually get the data from that promise so i can use it

quartz kindle
quartz kindle
jolly ether
#

Does anyone here play genshin impact? I'm looking for someone to give me feedback on a bot I'm making

quartz kindle
#

one way is to force the code to wait for the promise, and continue once the promise has fulfiled. this is achieved using the async/await syntax
the other is to set a function to be executed once a promise fulfills, and have the rest of your code continue running while it waits. this is achieved by using the .then() method

dense jungle
quartz kindle
#

wut

#

they dont?

dense jungle
#

okeh oh shit

jolly ether
#

Lmao

quartz kindle
#

i mean, they do if you run both bots in the same file lol

dense jungle
#

which is not what I am doing

quartz kindle
#

then they dont

#

xd

zenith terrace
quartz kindle
#

15

zenith terrace
#

Idk if I have it updated to that

quartz kindle
#

latest is 15.7.0

zenith terrace
#

I would need to check mine

dense jungle
#

the help command still has to be coded but the first bot has a clearly different prefix

#

which is -

quartz kindle
#

show the code for your command handler

zenith terrace
#

Does the v15 node do anything with d.js, cause I remember needing node updated when d.js v12 first came out

quartz kindle
#

you might be processing the prefix wrongly

quartz kindle
#

otherwise no

zenith terrace
#

And v13 hasn't released yet?

quartz kindle
#

nop

zenith terrace
#

Ok

#

Do ya know if anythings changed in v13 like v12 did

quartz kindle
#

some stuff, but nothing like the cache thing lol

#

fetchAllMembers was removed

#

guild.permissionsFor was removed

#

other than that idk

zenith terrace
#

Dont think I used them anyway

quartz kindle
#

gateway and rest api versions will be updated to v8

summer torrent
quartz kindle
#

intents will move to client options instead of client.ws

#

djs-next is not v13

summer torrent
#

huh

zenith terrace
#

Tim knows everythingKEKW

quartz kindle
#

lmao

zenith terrace
#

Tim is a robot with a database filled with everything of d.js zoomeyes

quartz kindle
#

well i cant really be out of the loop if i am to maintain djsl

zenith terrace
quartz kindle
#

but if djs ever implements disablable caches

#

im gonna trash it

#

xD

zenith terrace
#

disablable

quartz kindle
#

yes

#

thats a new word i made up

zenith terrace
#

.cache.disablable

opal plank
#
const client = new Discord.Client({
  disablable:true,
  partials: ['DISBABABABLABLE']
})```
delicate zephyr
#

just rename true and false

#

DISABLABABLED and ENABLABABLED

#

Actually technically you could do that

#

just define them as 1 / 0

#

or true and false

#

either or

dense jungle
#

@quartz kindle It worked! Something wrong with the command handler

opal plank
#

now just use them in your code

delicate zephyr
#

yep

quartz kindle
#

lmao

opal plank
#
if(message.bot === enababled) return disablable
delicate zephyr
#

LMFAO

zenith terrace
#

Sounds pog

opal plank
#

someone absolutely need to rewrite d.js with jsfuck and add retarded shit like that

#

lucas repo got nothing

earnest phoenix
#

disableable<enableable>

opal plank
zenith terrace
#

d.js retarted shit > luca github

delicate zephyr
#

@opal plank do you like the Luca ascii art

delicate zephyr
#

you do not even understand how long it took to make it look right

#

I did it manually

opal plank
#

i should disable my linter and turn my code in ascii

delicate zephyr
#

a lot of generators didnt do it justice

#

so lots of manual tweaking

opal plank
#

that repo is hilarious

#

i cant get tired of it

zenith terrace
#

First time I looked at it I was like wtf

delicate zephyr
#

First time I looked at it I was like "I can do something here"

quartz kindle
#

luca best bot

zenith terrace
#

42 forks as well, idk if some are legit trynna steal code or not KEKW

opal plank
#

judging by the masses here, probably the former

delicate zephyr
#

tempted to make an easter egg for the Luca bot page on dblstats

#

that posts the ascii to the users browser console

opal plank
#

that'd be dope ngl

#

i endorse it

delicate zephyr
#

hold on

#

lemme get the console log from the repo

#

good

#

it still works

opal plank
#

actually

#

let me check my bots metrics on ur thing

#

thats some nice metrics

delicate zephyr
#

yea I added the rolling daily stats

#

since someone asked for it

#

plus added a temporary remedy for the gaps that constantly happen on the board

opal plank
#

most of it matches my data, just more detailed

delicate zephyr
#

well as long as top.gg doesnt go down and you're consistantly posting enough every hour

#

it'll always be accurate

opal plank
delicate zephyr
#

yea grafana is cool

opal plank
#

grafana bae af

#

thats the only thing that i'd miss from dblstatisics, a way to query by time

#

last week

#

between yesterday and 4 days ago

#

thats one of the big upsides of grafana, being able to query within a range

delicate zephyr
#

Yea

#

its planned but tbh its a pain in the ass with the amount of data we have

#

Like I would say we could display all the data on the graph

#

but the graphs would uh

#

lag

opal plank
#

lmao i feel ya

#

grafana has a hard time pulling all those sources too

#

its quite intensive on the browser

#

some are fetch, some are pg queries, some are prom, some are elk

#

and all updating every 5 seconds

#

its really resource hungry

delicate zephyr
#

yup

opal plank
#

adapting this for overall usage is a big hassle

delicate zephyr
#

Hold on

#

lemme show you whats happened over the last 2 months

#

since we deprecated the old site

quartz kindle
#

you sure get a ton of votes for such a small bot

#

you have vote locked stuff?

delicate zephyr
opal plank
#

hmmm not quite

#

but i do have incentives to vote

delicate zephyr
#

dblstats went brrrr

opal plank
#

the ONLY thing i give feedback upon is the locale and browser time

delicate zephyr
#

hmm?

opal plank
delicate zephyr
#

Oh right

opal plank
#

timestamps are unix aparently

#

they arent using locale times

delicate zephyr
#

They aren't being calculated on the browser

#

I tried that

quartz kindle
#

look at my votes lmao

delicate zephyr
#

it crashed the page

opal plank
#

thats the only improvement/suggestion i'd give

quartz kindle
#

votes go brrr

opal plank
#

smol votes

delicate zephyr
#

@opal plank iirc its UTC

#

i cant remember exactly tho

opal plank
delicate zephyr
#

yea

#

it is

quartz kindle
delicate zephyr
#

The array of data

#

is like

quartz kindle
#

just literally new Date(timestamp)

delicate zephyr
#

300k large for every bot

opal plank
#

the browser should query it

earnest phoenix
delicate zephyr
#

Yea I compile the hourly data down

opal plank
#

just send the unix timestamp and convert it on the browser

quartz kindle
#

^

#

new Date(timestamp) on the client side

delicate zephyr
#

that would mess up the dates

#

since i use the 23rd hour of UTC to calculate the times

#

which would make it inaccurate

opal plank
#

@earnest phoenix im getting more votes than you with a 1k bot? pog

quartz kindle
#

its not innacurate

delicate zephyr
quartz kindle
#

timestamps are timestamps

delicate zephyr
#

meaning

earnest phoenix
#

Only 2 commands have voting requirements

quartz kindle
#

so your backend is offset by 1 hour?

opal plank
#

mine doesnt have any requirements for voting lol

delicate zephyr
#

I calculates 23rd -23rd

#

and yes

earnest phoenix
delicate zephyr
#

because rn Midnight is the biggest time when it errors

earnest phoenix
#

Your bot is awesome lol

delicate zephyr
#

until I rewrite the fetcher

opal plank
#

yeah, it just gives a bit of currency, but you can get it with other means

quartz kindle
#

well, its still the same, there's no diff

delicate zephyr
#

thats gonna be the reason I use the 23rd hour

quartz kindle
#

its still a timestamp

delicate zephyr
#

its not, because of how I sort the dates

opal plank
#

then its not requirements

#

unless you are locking all currency behind it

earnest phoenix
#

ohh

quartz kindle
#

its just a matter of where is the timestamp converted to readable date

#

currently you're converting it on server side right?

delicate zephyr
#

The timestamp is useless after the hourly data is compiled into daily data

quartz kindle
#

how so?

delicate zephyr
#

since I sort them by dates on the server side

quartz kindle
#

isnt there a timestamp for when the data was compiled?

delicate zephyr
#

Not really

#

Since each bot is updates at different times when the fetcher actually pulls them

#

meaning the timestamps are offset by a few secs

quartz kindle
#

but you have the timestamp of when the data was obtained right?

delicate zephyr
#

Yes, but Tim

#

I think you're misunderstanding me

#

how do I explain this

#

Explaining shit do be hard

#

hold on

quartz kindle
#

lmao

#

i mean

#

what im imagining is that you have a table somewhere correlating timestamps and the data

delicate zephyr
#

Nope

quartz kindle
#

like at this time stamp this was the number of votes, and this was the number of guilds

delicate zephyr
#

Nope

quartz kindle
#

then what do you have lol

delicate zephyr
#

A mongo collection

#

with around

#

140 million documents

quartz kindle
#

so you dont use timestamps in the data?

delicate zephyr
#

Hold on

opal plank
#

then how do you sort them in the page?

#

surely you have timestamps relating to where each compiled data was produced

delicate zephyr
#

I hate trying to explain shit

opal plank
#

these timestamps

#

theres gaps in them, surely you have timestamps to know which you have and which you dont

delicate zephyr
#

nope

opal plank
#

im confused now

delicate zephyr
#

Its based on which days aren't there

#

Which is why its done on the backend

opal plank
#

hmmm

quartz kindle
#

lets see if i understand

#

you get data hourly

#

and when the day is over, you compile that into a "day" package, and delete the hourly data

#

then you put the "day" package into the db

delicate zephyr
#

I haven't done the math to get the most recent hour because its a pain in the ass to do, so I sort through the data to get the 23rd and if its not there it doesnt get entered

quartz kindle
#

something like that?

delicate zephyr
#

like all the other difference calculations are done on render

#

but the compilation of daily data is done on the backend due to the fact I handle the missing data

#

since I use a for loop to display 24 rows

#

if the date isnt there is shows a blank row

#

if it does is shows as shown

delicate zephyr
#

I don't store daily data in the database

quartz kindle
#

then what do you store?

delicate zephyr
#

hourly

#

Thats all we store

quartz kindle
#

and does each hour have a timestamp?

#

or it is rounded to the hour?

delicate zephyr
#

Its the timestamp of when it was fetched

quartz kindle
#

alright so you do have timestamps

delicate zephyr
#

Yes

#

but passing them to the page

#

would break the daily data tables

quartz kindle
#

how?

delicate zephyr
#

iirc last time I tried it, it made the data off by X hours of the timezone

#

since the daily data is compiled based on the servers timezone

quartz kindle
#

why not in utc?

#

or in timestamps?

delicate zephyr
#

it is in UTC

#

but

quartz kindle
#

then thats all you need?

delicate zephyr
#

if a user is for example

#

12 hours behind UTC

#

the first row gets fucked

#

since its a day ahead

#

like it would just not show the date

#

or it would show a time that wasn't even accurate to the present

#

which is why I just showed UTC

#

I fucking hate dealing with timezones

quartz kindle
#

but like

#

you dont need to do anything to the tables

#

this is strictly display

#

not sorting or arranging

delicate zephyr
#

I would have to change how the backend works

#

since the backend sorts the data based on the day

#

not the timestamp

crimson vapor
#

should config.json go inside or outside of the src/ folder?

quartz kindle
#

you can simply take a day, and generate a timestamp for that day

#

and send it together with the request

#

and let the browser show its local date based on the timestamp

delicate zephyr
#

which would fuck the tables and show future dates

#

like I was before

quartz kindle
#

the tables would remain exactly the same

#

just the date would change

earnest phoenix
crimson vapor
#

ok

delicate zephyr
#

It would still require me to fuck around with the backend

earnest phoenix
#

or i use .env file

delicate zephyr
#

and tbh I really dont wanna deal with timezones again

crimson vapor
#

fuck timezones

quartz kindle
#

lmao

#

wanna see my timezone code?

delicate zephyr
#

Theres a reason I gave up trying to fix the auctions timer

quartz kindle
#

its ugly af

delicate zephyr
#

Timezones can suck my dick

#

I'll just slap a "(i) Times are displayed in UTC" notice

#

so people dont get confused

#

theres a reason the auctions timer isnt fixed

#

it got broke when shit got moved and now I really cant be arsed dealing with the timezone crap

#

I should work on my bot again

crimson vapor
#

fun

quartz kindle
#

well thats the whole point about doing everything with timestamps, sending then to client side, and let the browser decide the timezone

#

so you never have to deal with them yourself

#

forcing everything to utc also works

delicate zephyr
#

and yea, honestly I prefer just using UTC, it's a Coordinated Time for a reason

quartz kindle
#

are these times not universal?

delicate zephyr
#

they are

#

but I have to detect last monday from current monday and all that milarkey

#

because the times got fucked

quartz kindle
#

set open times and close times to timestamps and let the browser tell them the date

delicate zephyr
#

Cant

#

they change every week

quartz kindle
#

is it the same time every week?

delicate zephyr
#

I do pass the timestamp to the browser for that one ^^

quartz kindle
#

so every week the opening time is different than the week before?

delicate zephyr
#

no

#

Right

#

hold on

#

Im bad at explaining my own code

#

its annoying

quartz kindle
#

because if its the same time every week, like every money at 7am utc

#

you can modulus the timestamp

delicate zephyr
#

Its more the fact that it Starts on tuesday End on monday

earnest phoenix
#

n unit ago mmLol

delicate zephyr
#

trying to detect when they're open and closed and all the other bullshit to made me give up with the timer

#

lmfao

#

I made it way too advanced to the point where its a mess

quartz kindle
#

want me to do that for you?

#

lmao

delicate zephyr
#

nah

#

its dead now anyway

#

since we cant get auctions data easily anymore

#

I mean we can, but the way we used to calculate the days and everything relating to auctions weeks and stuff is broke

#

since it got shifted by 24 hours

#

I'll prolly put the page under maintenance like the other lot

#

Tim

#

blame marco for the ternary

lyric mountain
#

Ternaries are nice

delicate zephyr
#

@quartz kindle its the getting the next week when its monday that breaks

quartz kindle
#

if i had to do it, i would do it like this:
set base starting timestamp, ie previous monday 7am utc
set elapsed time to base - (base % 1 week)
set start time to now - elapsed
set end time to start time + duration

delicate zephyr
#

we're calculating 3 different times here

#

which is why we're having the issue

#

and then we're using those to detect whether or not the other should be open close / counting down etc

#

its a pain in the ass and convoluted as all hell

quartz kindle
#

everything can be done by modding the current timestamp by predefined amounts using a base timestamp as offset

#

something like an epoch calculation

delicate zephyr
#

thats not the issue we are having

#

thats the easy part

#

its more the

#

its fine from Tuesday to sunday

#

but

#

the moment

#

literally

#

the second it hits monday

#

everything goes to shit

#

because it then goes "Oh we need the NEXT week"

#

which is why that ternary is there

quartz kindle
#

thats where modding the current timestamp comes into play

delicate zephyr
#

even tho it broke too

quartz kindle
#

it will always be the current week

delicate zephyr
#

thats the problem

#

we dont always need the current week

quartz kindle
#

wut

delicate zephyr
#

We need the Last week on the monday

#

since it needs to use the times from last week

#

until tuesday

#

like I said

#

convoluted as hell

quartz kindle
#

just needs more modding

delicate zephyr
#

yea

quartz kindle
#

but i mean

delicate zephyr
#

it's not somethign worth fixing rn anyway

quartz kindle
#

its not that hard, you use the current timestamp, and you mod it to fixed times, like day start, specific hour of the day, specific week before or after

#

like a time cursor

lyric mountain
#

Can't u just create a new date object and add days?

delicate zephyr
#

thats what we're doing, but

#

the moment

#

the next week starts

#

it shifts to the next week

#

Which isnt what we want

#

its just more effort and convoluted crap to do on top of something that would work fine if it was just using the standard week

#

I thought of a better solution though

quartz kindle
#

lmao

lyric mountain
#

Js is indeed weird

delicate zephyr
#

wait

#

nvm

#

shit solution

#

i cba to think about timestamps and crap

#

makes my head hurt more than maths

lyric mountain
#

You could try to analyze java's time package

#

Like, it works really well when dealing with dates

#

If you're stuck with logic or maths you could peek inside it

quartz kindle
#

i would just abuse modulus and be done with it

lyric mountain
#

Modulus operandi

quartz kindle
#

:^)

opal plank
#

I'd like to interject for a hot second just to remind you to protest against people killing ducks to make duck tape

quartz kindle
#

yes

mellow kelp
#

finally, an objective to strive for

delicate zephyr
lyric mountain
#

People love to flex that they use flex tape

opal plank
#

speaking of gorillas, that reminded me i need to shield my message.edit()'s to make sure dumb users dont go deleting the message before the setTimeout() runs

delicate zephyr
#

LMFAO

regal edge
#
            bot.setMaxListeners(0);
            fs.readdir('./events/', (err, files) => {
                if (err) return console.error;
                files.forEach(file => {
                    if (!file.endsWith('.js')) return;
                    const evt = require(`./events/${file}`);
                    let evtName = file.split('.')[0];
                    console.log(`Loaded event: ${evtName}`);
                    bot.on(evtName, evt.bind(null, bot));```

So I wrote this event handler right and now it's loading events multiple times.
mellow kelp
#

why are you setting the max event listeners to 0?

sudden geyser
#

You're probably calling your loader recursively.

#

For example, if you ran the loader in your run event and somehow re-emitted the run event.

sudden geyser
#

That warning is only for a lot of duplicate event listeners

#

You shouldn't silence it.

lyric mountain
#

listeners must always at all moments be created together with the bot client

#

to ensure you never re-create them

mellow kelp
#

you're adding too many listeners

sudden geyser
#

Too many of one listener™️

lyric mountain
#

humans are very inneficient

regal edge
sudden geyser
#

return to monke

regal edge
#

...

#

...

lyric mountain
#

because we have two listeners for the same kind of event

regal edge
#

._.

sudden geyser
# regal edge Where would that listener be?

You see how it says: Loaded event: guildCreate/guildDelete. Because those events keep being added, you have 11 of the same listener (one of the two). Hence, that warning.

#

Anyway, you probably have some recursive loading going on, because just from that snippet of code, we can't tell much

regal edge
#

ahh ok thx guys

#

ty and I am monke

#

lol

sudden geyser
#

Takeaway is:

  • Remove the bot.setMaxListeners(0) line. The warning is to help you.
  • Try debugging and seeing where/when the loader is being called. Using your IDE/code editor's debugging tools will help since you can jump around.
regal edge
#

Alrighty

lyric mountain
#

do you guys have any idea on how I can avoid 4 for loops?

#

like, it must iterate over the lobby to find possible 4-player matches

#

like, it's not being slow nor giving me any issues, but that's just plain ugly

brisk gate
#

so you need to sample 4 distinct items from [0, size - 1] range, right?

#

you can try to generate 4 random numbers, check them, if they don't pass, add to cache so you don't select that pair again

#

also, is your tryMatching functions returns different results for tryMatching(0,1,2,3) and tryMatching(3,2,1,0) @lyric mountain

#

what i mean, does the order of a, b, c and d matter?

lyric mountain
#

tryMatching gets the players in positions a, b, c and d in this case

#

all values are distinct

#

that random idea, I like it

brisk gate
#

so the order matters

lyric mountain
#

not at all

brisk gate
#

in that case you have many duplicate cases in the loop

lyric mountain
#

it also takes mmr in consideration

#

so low-mmr players will get partnered with higher-mmr ones

brisk gate
#

and you have to sample distinct tuples of size 4

lyric mountain
#

I think the random idea will work

brisk gate
#

just to make sure to uniformely sample all positions

lyric mountain
#

I have a getRandomN function that I made, it takes an array, an amount of values to return and how many copies of each element is allowed

#

so it'll always return me 4 distinct values

#

thx

brisk gate
#

cool

lyric mountain
#

but boi, does that function be handy sometimes

brisk gate
#

Just to note you, that you are not sampling unifromely if you just pick a random number each time

#

lookup reserviour sampling

dire obsidian
#

i mean, what is the best server for a node.js app?

lyric mountain
dire obsidian
#

sorry for the stupid question but i can't go incognito in this server

quartz kindle
lyric mountain
mellow kelp
lyric mountain
quartz kindle
#

perhaps

lyric mountain
#

now it'll use the original array's hashcode as seed

#

all calls to rng will use the same generator

#

so now it'll be uniform

lyric mountain
#

don't ask me

crimson vapor
#

5 nested loops

#

3 per

#

240 operations?

lyric mountain
#

yeah, I know

#

this is one of my codes where I'll eventually look at it and say "wtf"

#

although it was a prototype earlier today

delicate zephyr
crimson vapor
brisk gate
lyric mountain
#

ah, that's no issue actually

#

the rng method is another method inside my Helper class

#

it already handles such stuff

#

actually, java has a ton of customization for vanilla Random class

#

not as much as c++ tho

#

c++ random is fckin overkill

brisk gate
#

ok, then. I'm not familiar with java libraries. I just know if you naivly sample integer and then resample it if it's duplicate that will break "uniformity"

lyric mountain
#

maybe I might implement that shuffle, doesn't seem a bad thing to have just for the sake of it

#

if I understood right, all I need to do is shuffle each time the element surpasses maxIntances, right?

brisk gate
#

No, just need to go over first maxInstances elements shuffle them with random index

sudden geyser
lyric mountain
#

maxInstances is an integer actually

#

in the code above, if the element to be added cannot be added it'll shuffle the list and retry

lyric mountain
#

the full generic definition would be <T extends Object>

#

but it can be reduced to <T>

brisk gate
#
    static void shuffle(int[] array, int maxInstances) {
        int n = array.length;
        Random random = new Random();
 
        for (int i = 0; i < maxInstances; i++) {
            int randomValue = i + random.nextInt(n - i);
            int randomElement = array[randomValue];
            array[randomValue] = array[i];
            array[i] = randomElement;
        }
    }
#

here is a random fisher yets but capped to maxInstances

#

I assume maxInstances is <= array.length

lyric mountain
#

Yep (well, not actually)

#

But that wouldn't work

#

Like

#

MaxInstances is the maximum amount of repeated values

brisk gate
#

ah, I misunderstand your function then

lyric mountain
#

Like, in my previous usage I'd get one instance of each player

#

No more than one instance per player must exist in the matchmaking

#

So MaxInstances is 1

brisk gate
#

oh, in that case this function will work

#

you generate 4 random numbers, where first one is from 0 to N, second one is from 1 to N - 1, etc

lyric mountain
#

Ig I could remove the element from the aux list to prevent further clashes

sudden geyser
# lyric mountain we can also do this

Yeah I know what generics are, but the extra space feels weird. I'm so used to functions being declared like func fun<T>(fn: (T) -> T) {...} where the generics are after the name

lyric mountain
#

Oh

brisk gate
lyric mountain
#

Ngl, I spent about 3 hours adjusting delphi's formatting style

#

Vanilla formatter is plain awful

brisk gate
#

last time I heard delphi was 2005 in Russia

lyric mountain
#

Wish I never had to use it

#

Unfortunately delphi is hugely popular here in brazil

#

Seriously, any lang would do better than object pascal

sudden geyser
#

I spent like 2-3 hours on a giant ESLint configuration file

#

but now I don't bother using formatters

brisk gate
sudden geyser
#

they're annoying, but if I run a public project, I probably will enforce it

#

so you don't have people writing luca code

brisk gate
#

I'm kidding. Esling is not formatter

#

it's a nazi linter

sudden geyser
#

mine definitely was

#

I remember running it for the first time

#

600+ warnings & errors

brisk gate
#

from year to year i was removing rules from it

#

and just switched to prettier

sudden geyser
#

and used one provided by WebStorm and got around 1k+ warnings & errors

brisk gate
#

also, i started using go, which has formatter built-in with super opiniated formatting which is cool

lyric mountain
#

Tbh, I once fighted against my college assignment's partners

brisk gate
#

no one debates over spaces vs tabs

lyric mountain
#

Reason? Formatting

#

They simply just not used tabs

brisk gate
#

that often happens in start of your career

lyric mountain
#

Nor spaces

mellow kelp
#

how about we debate tabs and spaces KEKW

lyric mountain
#

Like, it was ONE HECKIN BLOCK OF TEXT

#

No indentation at all

mellow kelp
#

oh dear god

sudden geyser
#

You should see C/C++ developers fighting on what line to put the braces on

lyric mountain
#

It's already a C#/Java fight

mellow kelp
#

unfortunately, my vscode formatter puts brackets on the next line

#

c# too

lyric mountain
#

C# puts below, java in front

mellow kelp
#

yea

#

i don't remember the reason though

brisk gate
#

during frehsman year I saw so much awful code, there was one guy didn't know about existence of Enter and he was writing C++ in one line

lyric mountain
#

I see no reason at all

#

Putting is front is cleaner

sudden geyser
#

reason is "eh we like it this way"

brisk gate
#

yes, that's pretty much how Golang works

#

"you like spaces? we don't! we use tabs over here!"

lyric mountain
#

In this Christian server we don't believe in spaces

mellow kelp
#

i prefer tabs since anyone can adjust them however they want

#

but i can see why people also use spaces

brisk gate
#

but no one really cares, you just pass through the formatter before commit and than right, anyone can adjust the spacing in their editors

mellow kelp
#

i remember cloning a really big repo and accidentally ran prettier

#

shit took like a minute and ended up converting every space to tab

lyric mountain
#

Lul

#

Like, tabs have at most 2 uses

#

Why leave it with only 1?

#

Space is already a popular dude

mellow kelp
#

bad thing is they look really messed up on github

sudden geyser
#

eslint node_modules

lyric mountain
#

Yeah, github doesn't know how to handle them

#

Also they're frickin long there

mellow kelp
#

apparenty you can add ?ts=2 to the url

#

and that turns tabs to 2-spaced tabs

lyric mountain
#

In github?

mellow kelp
#

yea

lyric mountain
#

Cool

mellow kelp
#

but no one got time for that anyways

lyric mountain
#

Imagine if they added a setting to in the profile to adjust that

#

Guess I'll open a suggestion there

mellow kelp
#

they should actually coolflushed

#

something like a tab spaces option

brisk gate
#

probably someone made an extenssion for that

lyric mountain
#

There's an extension for everything

#

Even for blocking content and leaving ads

brisk gate
#

Does anyone use Discord slash commands? They have proper UI for them only in Web version.

mellow kelp
#

only in web version?

brisk gate
#

On mobile, it's barely working

mellow kelp
#

damn, discord

lyric mountain
#

Slash commands are...how can I call it? Niche?

brisk gate
#

like in Slack

mellow kelp
#

and they expect devs to fall in love with slash commands

lyric mountain
#

Like, EVERYONE already have a prefix system for their bot

brisk gate
#

i just started making a bot and used slash commands exclusevily

#

also I hate when some bots register /help command and it becomes their

lyric mountain
#

Slash commands are somewhat redundant

mellow kelp
#

i have a bad feeling about this

lyric mountain
#

And have that issue mike pointed out

brisk gate
#

I like them better than regular commands

#

They have better UX for user

lyric mountain
#

Does discord really expect servers to have only one bot?

brisk gate
#

They see all commands, with help. They have autosuggestion

mellow kelp
#

idk what they're thinking anymore

lyric mountain
brisk gate
#

You can send replies in the channel which they can only see

brisk gate
lyric mountain
#

Yep

brisk gate
#

do you have gh issue link?

lyric mountain
#

It was announced the same time as slash commands