#development

1 messages Β· Page 1597 of 1

cinder patio
#

e.g:

constructor() {
  super();
  this.commands = ...
}
lament rock
#

or you can just

export class botClient extends Client {
  commands: Collection<string, Cmd> = new Collection<string, Cmd>();
}
outer perch
#

oh

#

that's what I forgot

lament rock
#

Can provide initial values in class properties descriptors

outer perch
#

loving ts so far ngl

#

forgot this doesn't execute the commands until I fix all files in ./commands

#

xP

lyric mountain
#

bash is so fckin useful

restive furnace
#

and have a efi partition

lyric mountain
#

just made a script to check all gif in one folder recursively, delete those smaller than 400x200 and rename them to 000, 001, 002... format

outer perch
lament rock
#

That's a pretty dumb rule. The this keyword is weird when trying to access it within some child scopes and can instead reference the child scope. Aliasing can hold a reference

#

I'd most likely disable that rule

copper cradle
#

omg

#

you realize that val will be the current value of the loop right

#

you don't need to index it

#

then why the fuck are you not using it

lament rock
#

entry.changes is Array<AuditLogChanges>
Object.keys(Array<T>) will return ["1", "2", "3", ...]

copper cradle
#
for (let val of Object.keys(entry.changes)) {
    console.log(entry.changes[val]);
}
lament rock
#

Your logic for accessing properties is flawed as the keys are no longer indexes. They are strings.

copper cradle
#

isn't is obvious?

#

just acess the property on each object

#

you can have a nested loop

#

entry.changes is an array right?

lament rock
copper cradle
#
for (let change of entry.changes) {
    change.new // 1146986 & then 'test'
}
#

wdym

cinder patio
#

probably hex

#

in decimal

copper cradle
#

probably

#

I don't really know

old cliff
#

wow I just discovered that we can BroadcastEval from ShardingManager also!

#

This just made my work 10x easier !

outer perch
#

.eslintrc.json isn't triggering on tabs and "

#

idk why

#
{
  "rules": {
    "@typescript-eslint/indent": ["error", "tab"],
    "@typescript-eslint/quotes": ["error","single"],
  }
}
``` but I have these two rules
blissful coral
#

Can I broadcastEval a this.client.emit() Thonk

#

Time to find out

hasty shoal
#

Hi

cinder patio
#

why not

hasty shoal
#

How to Makejson files online for users data ?

#

._.

opaque seal
#

Isn't it possible anymore the get the shard id from the bot client in discord.js v12?

earnest phoenix
#

(guild_id >> 22) % num_shards

opaque seal
#

Uh?

lament rock
#

gotta use BigInts

#
const shard_id = msg.guild ? Number((BigInt(msg.guild.id) >> BigInt(22)) % BigInt(total_shards)) : 0
#

DMs are always handled by shard 0

earnest phoenix
#

js moment

pale vessel
opaque seal
#

I need to see the shard id without any msg or guild

#

just the client

earnest phoenix
#

So, apparently you can't do operations between BigInt and Number?

worldly heron
#

Is there no client.shard?

earnest phoenix
#

I mean yeah, that wouldn't make sense what to return

opaque seal
#

there is just an array of ids

worldly heron
#

Isn’t it an array somewhere with ids

opaque seal
#

which aren't mapped to each client

worldly heron
#

Ahh

lament rock
#

BigInt doesn't have that problem

crimson vapor
#

its annoying how you have to specify a BigInt

old cliff
umbral zealot
#

why the hell would you do array.from()

pale vessel
#

can't you just do 22n

cinder patio
#

Doesn't client.ws.shards give you all shards the client handles

old cliff
#

array from collection

umbral zealot
pale vessel
#

For guild IDs I understand

old cliff
#

is it ?

crimson vapor
#

yes

pale vessel
#

but for small numbers

old cliff
#

i didn't know

umbral zealot
#

collections have a whole lot of array-like features, that's why they're collections and not just Map() objects.

old cliff
#

ok

#

thanks

opaque seal
old cliff
#

yes

opaque seal
#

k thanks

lament rock
cinder patio
#

you can also client.ws.shards.first().id

lament rock
#

Had to use the BigInt constructor

old cliff
#

Array.from would be useful if dealing with mentions

opaque seal
umbral zealot
#

Would it? How would Array.from() be used with mentions?

old cliff
#

wait

opaque seal
#

I don't think that's what I need JAGUAR

umbral zealot
#

Because, again, you have .first(), you can also do forEach, Map, Filter, etc.

opaque seal
#

it just returns a random shard id

old cliff
#
Array.from(message.mentions.users)[1] //for second mention
umbral zealot
crimson vapor
#

what the hell are you doing

old cliff
#

wait that also works ?

umbral zealot
#

of course it does

old cliff
#

bruh let me see collection docs

umbral zealot
#

I know it works because I'm the one that PRed that change Kek

crimson vapor
#

Evie just is a collection, fun fact

pale vessel
#

mentions.first()
mentions.second()
mentions.third() /s

crimson vapor
#

imagine

lament rock
#

mentions.atIndex(0) /s

crimson vapor
#

that would be so stupid

crimson vapor
pale vessel
crimson vapor
#

today I typed my db differently than I structured it

old cliff
pale vessel
#

Mobile back at it with the wrong reply

old cliff
#

i can't find it

crimson vapor
#

NaN go brrrrrrr

umbral zealot
lyric mountain
old cliff
#

that can't be

#

max limit is 2000 chars

#

and 1 mention consumes @old cliff these many chars

crimson vapor
#

what

umbral zealot
#

You understand the concept of humor, don't you Jaguar?

crimson vapor
#

2000 chars for what?

pale vessel
#

How is that relevant

old cliff
umbral zealot
#

You know, like, jokes, memes, funny things, sarcasm?

old cliff
lyric mountain
#

devs can joke too

crimson vapor
umbral zealot
#

Yeah we got a lotta jokes

crimson vapor
#

whatever

#

who even cares

#

as long as its not shitposting

lyric mountain
#

we're developing humor

crimson vapor
#

leave.

lyric mountain
crimson vapor
old cliff
#

@crimson vapor why not 7.5 Billion ?

crimson vapor
#

idk man

#

I don't work here

umbral zealot
#

I promise you, sometimes devs need to escape the reality of their job through humor. It's a function of our brain to find() ways to cope with issues.

old cliff
#

Today I discovered I could broadcast eval from ShardingManager

crimson vapor
#

yes you can

#

great for getting stats

#

such as memory and shit

old cliff
#

yessir

crimson vapor
#

assuming you don't use stinky internal sharding

old cliff
#

I would make an api fromshardingmanagertodashboard

#

uh space key stuck

umbral zealot
#

semantically irrelevant distinction without a difference.

crimson vapor
#

evie do you have a job yet?

umbral zealot
#

Yes.

old cliff
#

nice ice

crimson vapor
#

poggers

umbral zealot
#

Great job working with vuejs to do contract work for businesses that can't or won't do their own inhouse dev for internal tools.

crimson vapor
#

ah

#

pretty good job?

old cliff
#

is vue one of the frontend frameworks ?

crimson vapor
#

yes

#

its like react but not

umbral zealot
#

yeah Vue is like React and Angular. And yes it's a great job, good pay, good benefits, and since it's contractual it means there's variety in the work itself.

old cliff
#

I find react pretty tough to integrate with discord auth login

umbral zealot
#

And Vue > React

crimson vapor
#

oh benefits?

old cliff
#

so I used ejs

crimson vapor
#

thats poggers

umbral zealot
#

yes.

crimson vapor
#

oh

umbral zealot
#

It's not good because in order to do a lot of operations you need to fetch all the values which are all stored in memory

crimson vapor
#

enmap-light coming any time soon? or is enmap pretty fucking memory optimized?

pale vessel
#

JOSH

#

Josh API when

crimson vapor
#

whats JOSH?

pale vessel
crimson vapor
#

ah

lyric mountain
#

where's drake?

crimson vapor
#

so its like quick.db but better?

pale vessel
lyric mountain
#

remember to always draw a dino

stuck pike
#

Any idea how can we take voice as input

#

When in voice channel

stuck pike
umbral zealot
#

We all have our preferences πŸ˜„

stuck pike
#

Yea

stuck pike
umbral zealot
#

That`s a pretty complicated answer, actually. Because it requires you to read the audio stream and also figure out how to pass that through some voice recognition software or API, which in and of itself is a fucking pain in the ass.

stuck pike
#

I have made a command which talks in VC

#

But I don't have way to take imput

#

Direct from vc

lyric mountain
#

if not even google could make 100% working voice commands imagine us

umbral zealot
#

yeah like I said that requires speech-to-text and that's either very slow or really really expensive.

worldly heron
#

Just make commands take a specific pitch + duration

#

Ezzz

stuck pike
#

BTW my bot ain't showing correct users

#

It must say 150k

#

Shows 90k and gradually increase and when restarted come backs to 90k

lyric mountain
#

ppl: sucking microphones
bot: Hello, you used "marry a capybara" command, is that right?

stuck pike
#

LOL

worldly heron
#

Perfect

worldly heron
umbral zealot
stuck pike
umbral zealot
#

ayy triple kill

stuck pike
#

client.users.cache.size()

umbral zealot
#

yeah don't do that

worldly heron
#

Because not all users are cached when your bot starts

misty sigil
#

.size is a function?!

stuck pike
#

Yea

pale vessel
#

isn't it a getter

worldly heron
#

I’ve always just done .array().length

#

No shAming pls

pale vessel
#

don't do that

stuck pike
#

Hm

pale vessel
#

it caches the array iirc

worldly heron
#

It does

pale vessel
#

i always do [...collection.values()]

umbral zealot
pale vessel
#

or if I want to loop for (const value of collection.values())

misty sigil
#

foonspeed

umbral zealot
#

for that tidbit that took me a full fucking 6 months to understand? Yes I''m going to spoonfeed it.

stuck pike
#

Where is Evie btw

umbral zealot
#

reduce() isn't easy to grasp at first

stuck pike
#

No see from days

misty sigil
#

eh

pale vessel
#

But once you get to know how it works, it's really handy

umbral zealot
misty sigil
#

lmao

stuck pike
worldly heron
pale vessel
#

Especially to construct an object from an array for example

#

In one line

stuck pike
#

LOL

stuck pike
#

;+;

umbral zealot
#

because memes are funny

pale vessel
#

Can't she have fun too?

stuck pike
#

Lawl

tidal cave
#

Has anyone built a bot of a phone before?

misty sigil
#

voltrex has

stuck pike
#

Or Dbd.js

tidal cave
#

Im trying to look into easier options im using an app to make a bot

tidal cave
#

Ok

outer perch
#

should I move over to Repl from Heroku?

stuck pike
#

@outer perch depends

#

Repl can expose your data to

#

Thousands of peeps

#

Yea

tidal cave
#

Oh

outer perch
#

o_o

tidal cave
#

Hmmm

stuck pike
#

Heruko oo

#

Op

tidal cave
#

Any other op4

stuck pike
#

I use it to host my bot

tidal cave
#

Options

outer perch
#

bitches

stuck pike
#

With 90 servers and 159k users

outer perch
#

which

outer perch
tidal cave
#

How does repl work?

stuck pike
#

U need to use uptimer bot @tidal cave

outer perch
#

ye

umbral zealot
#

not if you configure it right

outer perch
#

never died randomly

outer perch
#

file named Procfile inside root, with worker: node index.js inside

#

no

mellow kelp
#

Well yes

#

But no

outer perch
#

you have 550h, around 26 days for hosting

#

if you provide your Debit/Credit card

#

u get +200h

#

which is 750h, around 35 days

mellow kelp
#

That works fine unless you got more apps running

outer perch
#

yes, exceeds 31, cuz if u host 2 bots on the same account, both count on the same hours

#

or apps in general

cinder patio
#

Still, not much customization and you can run only simple bots

fluid basin
#

there is a cap on resources that you are allowed to use

#

not to mention you will be unable to install or use any third-party software beside your bot itself

#

e.g. databases (mysql/mongo/etc), cache servers (redis)

fluid basin
#

wdym hyperlink

outer perch
#

host the db somewhere else, then link it

fluid basin
#

well sure, but there isn't "free" dbs out there

copper cradle
#

then host your bot along the database

limber flume
#

yes there is

outer perch
#

sad

livid lichen
umbral zealot
copper cradle
fluid basin
#

500MB

outer perch
#

I use Firebase

limber flume
#

MongoDB is free and it’s epic

#

πŸ˜ŒπŸ‘

livid lichen
copper cradle
#

yeah but you get limited

cinder patio
#

but you get 500mb

umbral zealot
#

ok but everything is limited

copper cradle
#

on firebase at least

limber flume
#

you can just get 500$ for free from having GitHub pro

outer perch
#

let it be limited

restive furnace
umbral zealot
#

literally everything in life is limited except misery.

outer perch
#

my bot isn't huge yet

limber flume
#

inside of mongodb

#

GitHub pro is great

fluid basin
#

and its $200, not $500

copper cradle
#

hmm

fluid basin
#

the starting plan on mongodb atlas is $57/mo, which means it'll barely last

pale vessel
#

Selfhost 4head

outer perch
#

why is .eslintrc.json not triggering on typescript?

#
{
  "devDependencies": {
    "@types/eventsource": "^1.1.5",
    "@types/node-schedule": "^1.3.1",
    "@typescript-eslint/eslint-plugin": "^4.15.1",
    "@typescript-eslint/parser": "^4.15.1",
    "babel-eslint": "^10.1.0",
    "ts-node": "^9.1.1",
    "typescript": "^4.1.5"
 }
}
```this are my devDependencies
umbral zealot
#

where's eslint? Kek

#

don't you also need it as a dependency?

outer perch
crimson vapor
#

don't you also need tslint or something

umbral zealot
#

no that's a babel translator

#

you need the actual eslint module

outer perch
#

fack

outer perch
#

thought that was only needed for Dev

restive furnace
#

yes

limber flume
restive furnace
#

npm i -D eslint

outer perch
#

just now

umbral zealot
#

yeah I Did mean dev dep

outer perch
#

ah, k

#

done

cinder patio
#

Don't you also need the vscode eslint extension

#

or is it integrated

outer perch
#

"@typescript-eslint/eslint-plugin": "^4.15.1"

cinder patio
#

I meant extension

#

vscode extension

outer perch
#

I had

#

lemme check again

#

it's enabled globally

marble juniper
#

anyone know a html parser for nodejs

#

I just kinda need to be able to access some stuff from the html

#

and its a string with the html from a page

cinder patio
#

cheerio

#

jsdom

outer perch
#
[Info  - 15:45:11] ESLint server is starting
[Info  - 15:45:12] ESLint server running in node v12.18.3
[Info  - 15:45:12] ESLint server is running.
[Info  - 15:45:14] ESLint library loaded from: C:\Users\ragsf\Desktop\gumball-and-penny\node_modules\eslint\lib\api.js
cinder patio
#

weird

outer perch
#

still not triggering anything

#

like quotes

#
"@typescript-eslint/quotes": ["error", "single"],
cinder patio
#

Can you show your fulll eslint file

outer perch
cinder patio
#

put it in a bin

copper cradle
#

there

outer perch
#

ik

restive furnace
#

too late though :(

#

for me

cinder patio
#
        "import/extensions": [
            "error",
            "ignorePackages",
            {
                "js": "never",
                "jsx": "never",
                "ts": "never",
                "tsx": "never"
            }
        ]

Could this be the reason

#

remove that

#

other than that everything looks fine

outer perch
#

hmmm

cinder patio
#

Actually I think the snippet I gave just tells eslint ignore node_packages

#

I dunno

#

but why is it in the rules section?

outer perch
cinder patio
outer perch
#

used to work in .js

#

when I swapped to .ts

#

I changed the rules names

#

to match ts

#

cuz without them it may not do anything with ts

#

actually they didn't as they were

lucid prawn
#
client.on('guildCreate', async message => {
  const welcomeChannel = message.guild.Channels.cache.find(channel => channel.name === 'general')
      const vc = new Discord.MessageEmbed()
        .setDescription("This bot will help you and it be updated alot and we are trying to give 75 server so can u help us!!")
        .setColor('RANDOM')
        .setTitle(`Thank You for inviting me`)
        .setImage("https://media1.tenor.com/images/d185187feba0e4daa627f344d07cfad7/tenor.gif?itemid=14465470")
        welcomeChannel.send(vc)
      })
cinder patio
#

lowercase c in Channels

lucid prawn
#

it not working
i will remove the embed later

lucid prawn
lucid prawn
cinder patio
#

guildCreate doesn't provide a message as the first argument

#

it gives you a guild

lucid prawn
cinder patio
#

no, you don't need the message at all

#

there's no message

#

the function gets called when your bot joins a guild

solemn latch
#

Only the guild parameter is given

lucid prawn
#

and it fixed my problem

lyric mountain
#

even smaller code can be unreadable on discord

restive furnace
#

true

outer niche
#

Cannot seem to get the font to work on this anyone know why?
<p><span style="font-family: Monotype Baskerville">Welcome to the official website for Echo</span></p>

lyric mountain
#

is the font loaded?

#

also, baskerville is paid stuff

icy skiff
#

im having an issue with dpy and the wait_for method, it works fine for few seconds and then for apparently no reason at all it stops working, this is the code:

#

at first i thought it was timing out when it shouldnt, but its not printing the "timedout"

#

also no errors on the terminal

pale vessel
#

@ norizon

blissful coral
#

Dpy makes me scared ngl

icy skiff
#

the "checking" also does not print

icy skiff
#

ive found some ppl on stack overflow with the same issue but none of them had solutions lol

pale vessel
#

if it doesn't print "checking" then the event isn't getting triggered

#

maybe intents?

icy skiff
#

but the thing is

#

it works

old cliff
#

Python needs intents

icy skiff
#

then it does not

#

like for real

old cliff
#

Even for reaction

icy skiff
#

it works fine for a few pages and then it stops accepting the reaction adds

#

its definitely stuck on the wait_for method but idk why

old cliff
#

btw why while True ?

icy skiff
#

cause the user can keep passing pages as long as they want

old cliff
#

It will always be true

earnest phoenix
icy skiff
#

ye thats why theres the try except return

#

if the wait_for times out the function stops

old cliff
#

Ok

earnest phoenix
#

Use raw_reaction_add instead, reaction_add only gets dispatched for reactions on cached messages

blissful coral
icy skiff
blissful coral
#

No?

icy skiff
#

what do u use lol

lyric mountain
#

batch script

blissful coral
#

What is djs?

#

Like define it

#

@icy skiff

icy skiff
#

discord.js?

blissful coral
#

Yes

#

What is it

#

Is it a coding language?

pale vessel
earnest phoenix
blissful coral
#

Shush flaze

lyric mountain
icy skiff
#

theres another discord api module for js?

shell crest
#

does anyone know how to show how many servers your bot is in in python?

blissful coral
#

Yes

#

There are a few lmao

pale vessel
#

Eris, Discord.js, Detritus

blissful coral
#

^

#

Discord-rose

lyric mountain
blissful coral
#

^

pale vessel
#

JPBBitch berry is nice nohomo

blissful coral
#

CensorBotIsBad

#

Best library by far^

#

@slim heart

restive furnace
#

JCord

#

barebones lib what's also deprecated :D

icy skiff
lyric mountain
#

also don't forget fetch

restive furnace
blissful coral
#

JCord is long gone

blissful coral
icy skiff
#

i code on js once in a lifetime so i didnt even know there were multiple modules for discord api

restive furnace
#

but you use that?

blissful coral
#

Yeah it’s berries lib

restive furnace
#

alright

earnest phoenix
#

np

fervent goblet
#

I have never ran into this issue

lyric mountain
#

enable 2fa on ur acc

#

you're trying to do a sensitive action

fervent goblet
#

oh i c

shell crest
#

Does anybody know how to set a playing status similar to yui's?

#

I know how to do it but i want it to show multiple and say how many servers its in

eternal osprey
#

hey guys

#
const obj1 = require("./trainers.json");
                        const obj2 = require("./trainers.json");
                         index1 = obj1[targetMember.id].mons.indexOf(given1)
                         index2 = obj2[targetMember.id].spawnIds.indexOf(given1.spawnId)
                         trainers[targetMember.id].mons[index1] = given1
                         trainers[targetMember.id].spawnIds[index2] = given1.spawnId
                         index3 = obj1[firstmember].mons.indexOf(given)
                         index4 = obj2[firstmember].spawnIds.indexOf(given.spawnId)
                         trainers[firstmember].mons[index3] = given
                         trainers[firstmember].spawnIds[index4] = given.spawnId
                         fs.writeFileSync("./trainers.json", JSON.stringify(trainers), "utf8");```why is this not overwriting the trainers.json?
umbral zealot
#

it is

#

but require() caches data

eternal osprey
#

owh so i most likely should use fs.readFileSync?

umbral zealot
#

I mean you should NOT Be using json as a database in the first place, mind you, that's ridiculously dumb

eternal osprey
umbral zealot
#

you've explained many times you really want to keep shooting yourself in the foot?

#

and you choose to do the things that will lose you data?

#

ok then

#

good to know you're fully aware of how stupid that is

eternal osprey
umbral zealot
#

Ok so why not use a real database here then

#

you're doing something that's HARDER than using a database.

#

it's easier to just use sqlite or, failing the desire to write sql queries, use quick.db or enmap

#

both of which are synchronous and extremely trivial to use

eternal osprey
#

Yeah my main database is mongodb

umbral zealot
#

So just use mongo, seriously.

#

honestly why do people keep insisting that json is easier than it is.

fluid basin
#

well it technically is

#

but you should just use mongo

#

makes promoting things to production easier

lyric mountain
#

it's just a snap of the wrist and all json is...gone

umbral zealot
#

"Oops! You read this at the wrong moment in time, sorry not sorry GOODBYE ALL YOUR DATA! BYE FELICIA!"

lyric mountain
#

Mr. Torgue created json.db

#

THAT'S A F****N BAD DATA, THE F****N DB WILL EXPLODE

shell crest
#

Does anybody know how to set a playing status similar to yui's?
I know how to do it but i want it to show multiple and say how many servers its in

umbral zealot
#

what does yui's playing status looks like? we don't know yui.

shell crest
#

the yui bot

umbral zealot
#

yeah I get you're talkinga bout a bot

shell crest
#

it says how many servers its in

eternal osprey
umbral zealot
#

there's a hundred thousand bots

shell crest
#

sorry

#

I just want code that shows different playing status and to show how many servers its in

fluid basin
#

so yea

umbral zealot
#

"I'm going to keep making excuses for doing something bad and then complain that I've been doing the wrong thing for so long and it's too hard to change now" is a shit defence against doing the wrong thing.

fluid basin
# shell crest the yui bot

there isnt a "yui" bot that I can see in this server, you'll either need to show us an example with a screenshot or somehow

umbral zealot
eternal osprey
fluid basin
#

also do let us know what you have tried and what didnt work

#

we're here to help and not to feed

eternal osprey
fluid basin
#

not you, I meant Astral

eternal osprey
#

my bad

shell crest
#

I couldn't find anything on how to do it

lyric mountain
#

d.js?

umbral zealot
#

I'm guessing it's a size or count property on client.servers ?

umbral zealot
lyric mountain
shell crest
#

yep

umbral zealot
#

I don't know python at all but it should be pretty straightforward to get the size or the client.guilds structure

lyric mountain
pale vessel
#

you just do len()

shell crest
lyric mountain
shell crest
#

I just want one of the statuses to be showing how many servers its in

lyric mountain
#

ah, that

shell crest
#

yeah

#

sorry i didn't make that clear

lyric mountain
#

just get the length of guilds collection then

shell crest
#

thats the problem- I don't know what the code is for that

umbral zealot
#

len(client.guilds)

eternal osprey
icy skiff
#

len(client.guilds)

shell crest
#

so I put that in the status?

icy skiff
#

Ye

fervent goblet
#

is there a way to get the bot owner in discord.js?

eternal osprey
#

get your point tho, don't get me wronjg.

umbral zealot
fluid basin
umbral zealot
#

you can't have that much JSON if you don't know require()ing a json file caches it

fervent goblet
umbral zealot
icy skiff
eternal osprey
fervent goblet
fervent goblet
#

oh i call it first then i can get the owner

umbral zealot
pale vessel
#

You want to get the owner of your own bot?

fervent goblet
#

yes

pale vessel
#

Oh

#

Yeah, use that and get the owner property

umbral zealot
#

I'll give you a hint: you're the owner Kek

shell crest
#

lmao

icy skiff
#

Cant u just hardcode It?

fervent goblet
#

no shit thats not the point

icy skiff
#

If the owner is yourself

#

Just hardcode it

umbral zealot
#

So TL;DR:
"I've been doing JSON for months and I know how to do JSON, I don't care if JSON is bad, just tell me how to fix this JSON thing"
Answer: "Do the JSON thing the exact same way you've been doing it for months, or stop doing JSON altogether, it's bad.

eternal osprey
midnight blaze
#

learn mysql

pale vessel
#

I'd say PostgreSQL

restive furnace
pale vessel
#

post the tag

restive furnace
#

(from DAPI): MySQL is a bad database. Don't use it unless you have LITERALLY no other option.
Why?

  • MySQL has no transactional DDL. This means that if you fuck up creating a table in the middle of a migration, you CANNOT ROLLBACK easily.
  • MySQL has a lot of security issues. New zero-days are found REGULARLY.
  • MySQL is owned by Oracle. Yeah.
  • MySQL is slow. It beats Postgres etc at some things, but once you move beyond basic queries it begins to DRAG.
  • MySQL disconnects you randomly. Unless you setup your connection specially, it will break regularly.
  • MySQL allows all kinds of insane data to be inserted. '0000-00-00' is valid in MySQL.
  • MySQL is not ANSI compliant. You have to turn it on; even then it isn't fully compliant.
  • MySQL has no feature advantage over other databases; PostgreSQL has many more useful features (such as RETURNS).

There is NO reason to use MySQL over PostgreSQL, or even sqlite3. See also:
https://blog.ionelmc.ro/2014/12/28/terrible-choices-mysql/
https://grimoire.ca/mysql/choose-something-else

pale vessel
#

thank you

fluid basin
#

mariadb: exists

solemn latch
#

MySQL disconnects you randomly. Unless you setup your connection specially, it will break regularly.
This was one i had a ton of issues with

#

every 8 hours on the dot, and it doesnt seem to be disableable? why AngryDoggo

misty sigil
#

mysql ew

fluid basin
#

use json.db KEKW KEKW

mellow kelp
#

jason.db πŸ‘

misty sigil
#

im convinced even that would be better ngl

umbral zealot
#

To be fair, there are good functional databases using a json back-end, but they're implemented using proper atomic read/writes which prevent corruption - but that stuff is harder to implement "simply" and require more code and boilerplate than most people care to write.

lyric mountain
restive furnace
#

true

fluid basin
snow urchin
pale vessel
#

await sync lmao
in forEach too Thonk

fluid basin
#

you registered the ready event more than once?

snow urchin
fluid basin
#

hmm you sure

#

there 4 events but only 3 files

snow urchin
fluid basin
#

where are you logging that connected part

snow urchin
#

the first events folder in the screenshot

fluid basin
#

hrm

#

also just saying

#

your client event collection or map or whatever gets overriden if you have more than one of the same event

#

use an array instead or something

#

could potentially cause issues later on

lyric mountain
#

anyone here know how to open ports on windows?

outer perch
#

your PC ports?

#

and also, which one?

fluid basin
#
  1. router port forward
  2. windows firewall
outer perch
#

search for Firewall on windows search

#

open it, then Advanced Settings

#

then you have access to everything the firewall has

#

click on New Rule in Entry Rules

#

choose Port > select the protocol you want > type on local ports what pot you want

#

probably 8080 is the one you want

lyric mountain
#

we're trying to allow connection from world <----> his webserver

outer perch
#

it's 80 so xD

lyric mountain
#

yeah, but windows is being windows

smoky herald
#

Hola, I'm struggling with sending information across the shards once again... How would I set fameLeaderboard variable on all shards to the array values? This code throws reference error and fameLeaderboard on other shards than 0 is empty

let array = [
      "1. someone\n2. someone\n3. someone\n4. someone",
      "5. someone\n6. someone\n7. someone\n8. someone"
]
client.shard.broadcastEval(`fameLeaderboard = ${array}`)
cinder patio
#

The array should probably be attached to every client instance

outer perch
#

well, new big problemo

#

what's faster, localhost or Heroku?

smoky herald
#

attached as adding it directly to the client object?
like

client[array] = [
      "1. someone\n2. someone\n3. someone\n4. someone",
      "5. someone\n6. someone\n7. someone\n8. someone"
]
cinder patio
#

yeah

#

except... you should probably JSON stringify the array

#

and also you attach it to the client inside the eval script

#

and then access it by doing client.fameLeaderboard

#

for example

smoky herald
#

alright, I'll give it a try, thank you πŸ˜„

fathom frost
#

is this channel like stack overflow?

earnest phoenix
#

na not really, we dont spoonfeed

outer perch
cinder patio
outer perch
cinder patio
#

Typescript just compiles your code to javascript

outer perch
#

he needs to do that only once, at startup

lament rock
#

Not really compiling tbh since js is interpreted

cinder patio
#

yeah but the ts code gets compiled to js

#

Also, javascript also gets compiled to bytecode behind the scenes, before getting interpreted

opal plank
lament rock
#

TS to JS is usually called transpiled

opal plank
#

actually

outer perch
#

so, is TS slower than just JS?

opal plank
#

to compile? yes, to run? not usually, no

lament rock
#

TS is JS effectively

#

just "statically typed"

opal plank
#

ts will most of the times make your code more optimized than not

outer perch
#

I successfully rewrite all .js to .ts

opal plank
#

good job

#

now switch to detritus instead of shitty d.js

outer perch
#

even the functions are .ts

opal plank
#

come join us in the dark side

outer perch
opal plank
#

indeed

#

just gotta use a Ts lib now

#

since d.js is js

#

cough cough detritus cough cough

outer perch
#

but Node libs are js too

#

I think

opal plank
#

everything is js, wont matter

#

its just that for ts users, detritus is a whole lot better

#

not counting the library functionality

#

which beats d.js by a mile

outer perch
#

now, explain Detritus, which are the differences

#

and why is it better?

opal plank
#

check this for example

#

these are the options per COMMAND

#

theres options for the handler too

#

no more that fs.readDir bullshit with setting the module.exports

#

no more checking if a user has permissions

#

no more checking for custom prefixes

#

give it a directory and it will pull all commands/folders from inside

#

and organize them

#

thats ONLY for command handling

#

detritus offers a shit ton more stuff thats far better than d.js

#

this is what your client looks like, this, with all the commands loaded

#

just this

rocky dagger
#

i have this code and instead if listing the files after each other in the logs i want them under each other client.once('ready', () => { console.log(commandFiles + ' loaded'); console.log('Bot launched successfully'); }); i am dumb ik

opal plank
#

tell it the directory your commands are in, and it'll auto load them

cinder patio
#

that's not hard to do though

opal plank
#

indeed it inst, but its cleaner, has more options, is a lot smarter and has a solid framework to be worked upon

cinder patio
#

I prefer making my own command handlers. That ^^ feels bloated

opal plank
#

just think of how much code you skimming from your index for not checking:
prefixes
cooldowns
permissions
your permissions
loggers
error handling

#

trust me, i done both, and im 100% sticking to this one, even after have made my own

cinder patio
#

I think I'll stick to discord.js-light for making bots

opal plank
#

i much rather this one, you can change its caching behaviour just as equally, and ive shown tests before of how it compares to d.js

#

then stabilized at around 810mb

lament rock
#

I'd rather modular interfaces

#

100MB avg

opal plank
#

i wouldnt throw dirt at detritus until you try it tbh, even on a test bot

#

the difference is huge

restive furnace
#

but it can't beat djs-light :))

opal plank
quartz kindle
#

it can

cinder patio
opal plank
#

indeed

restive furnace
#

well if you disable every cache, no i think (in djs-l)

opal plank
#

same bot, same cache

#

same token

#

4gb to 800mb

quartz kindle
#

detritus supports disabling caches

#

whatever djsl can do, detritus can as well

outer perch
restive furnace
#

oh no

quartz kindle
#

thats why i mention it in my readme

opal plank
#

detritus is too powerful

#

it feels like using postgres to store 10 strings tbh

outer perch
#

is it? so it's too much for me πŸ˜”

opal plank
#

its overkill to a point

outer perch
#

I can't handle so much power

opal plank
#

the amount of handy stuff it has is insane

quartz kindle
#

djsl is for people who like the djs api

opal plank
#

^^

quartz kindle
#

if you dont mind moving to a whole different api style, i do suggest detritus

opal plank
#

detritus is perfect for TS users, the types are super well organized

outer perch
#

wait

#

my args are string[]

#

xD

opal plank
#

the ONLY thing i had to whine about it, is that it didnt have reaction collectors, so i had to make my own, which was like, 20 lines of code

#

at least not as far as i could tell

quartz kindle
#

and no proper docs

#

lmao

rocky dagger
#

i have this code and instead if listing the files after each other in the logs i want them under each other client.once('ready', () => { console.log(commandFiles + ' loaded'); console.log('Bot launched successfully'); });i am dumb ik

opal plank
#

well that too

#

but they do have some test bots

outer perch
opal plank
#

the internals are super well organized though

quartz kindle
#

a bit too organized

opal plank
#

and this is the bot from the dev

#

he made it open source so people could see how to do stuff

outer perch
#

woah

cinder patio
#

Is that the notsobot?

opal plank
#

ye

#

i think he evaled the shards a couple days ago

restive furnace
#

erwin say how clusterclient helps in clustering uhh?

opal plank
#

its huge

#

its literally an object with all shards inside

outer perch
opal plank
#

each shard being its own shardClient

#

thats all

restive furnace
#

isn't Client same?

#

normal

outer perch
opal plank
#

no, your main client in detritus is commandClient

lament rock
#

You could always write abstraction layers to mirror DJS' API, but that would introduce some overhead

opal plank
#

commandClient.client(as clusterClient or ShardClient)

slim heart
opal plank
#
// with cluster
commandClient.client.shards.get(0) //rest

//with shard
commandClient.client //rest
#

you can always map it too

restive furnace
#

so commandClient can't have shards but clusterClient can?

opal plank
#

nono

slim heart
opal plank
#

okay, lets reiterate in a d.js manner

#

imagine client as commandClient

#

as in d.js

#
client.shards.map(shard => shard.guild.cache.get('1234')) //cluster client

client.guilds.cache.get('1234') // shard client
#

client in this instance is either a cluster client(if you're sharding)

#

or a shardClient (single shard)

slim heart
#

idek why use detritus if you need to cluster

opal plank
#

go whine to the author berry

slim heart
#

i still dont get it tbh

opal plank
#

i told you

restive furnace
opal plank
#

its working amazingly for me

slim heart
#

it looks fine, but if you need to cluster it takes a huge performance hit just for the sake of being easy

outer perch
#

Let me guess, if I do a library to return 10, will I get Library Developer role in here? 🀣

opal plank
#

nope

slim heart
#

no library dev is for the official top.gg packages

opal plank
#

only devs that maintain the libraries related to topg.gg

outer perch
#

heheh

earnest phoenix
#

i found a good mongodb* wrapper thats not quickmongo

opal plank
#

though still, detitrus for me is the ultimate library

slim heart
#

how large of a bot have you made in it?

restive furnace
opal plank
#

click me berry

slim heart
#

i tried running my bot with detritus and got a memory leak

opal plank
#

im at 750MB rn, with around 450k users cached and 2k guilds, roughly

#

Β―_(ツ)_/Β―

slim heart
#

that's terrible

opal plank
#

its not

slim heart
#

it is

opal plank
#

remember i have my own custom cache

slim heart
#

that should make it even less lmao

opal plank
#

you are under the assumption i only use the library cache

slim heart
#

i have 1.5GB on a 40k bot

opal plank
#

which isnt true

slim heart
#

and regardless the way it handles events cannot scale period

opal plank
#

remember i have custom objects for each user

slim heart
#

even djs handles it better

opal plank
#

not only that i save image buffers in memory too

#

for canvas

#

some of those images are 8mb in size

#

and i have around 300k other objects for genshin_users

slim heart
#

ig that makes sense

crimson vapor
#

hi nerds

slim heart
#

but still events are just poop

opal plank
#

so thats 450k from the library + 300k frmo my own personal cache

slim heart
#

are you just doing internal sharding esc stuff?

opal plank
#

me? no

slim heart
#

like 2 shards on the same process

opal plank
#

each shard uses its own worker

#

i think i mistakenly set the shards to 2 cuz i forgot to remove it

#

but it was at 5

#

that makes canvas a whole lot better

smoky herald
opal plank
#

since its not all blocking on the same thread

outer perch
opal plank
#

canvas is used quite a lot

slim heart
#

idk it's just so strange to me

#

also you should just use a separate api for the canvas but that's opinion ig

crimson vapor
#

wait

crimson vapor
#

erwin

opal plank
#

Β―_(ツ)_/Β―

slim heart
#

@crimson vapor maybe u can learn a thing or two

crimson vapor
#

wtf how does canvas work on 2 threads

#

explain please

slim heart
#

cuz he cant get canvas to run on 2 threads

#

yeah

outer perch
opal plank
slim heart
#

beeg brain

median moss
#

hey

opal plank
#

a friend is probably going to be doing a rust api

median moss
#

anyone from JS that can help me with alias?

cinder patio
opal plank
crimson vapor
#

wait Erwin do you use canvas on the shard process?

restive furnace
#

why though only 1 shard per worker? isn't that a bit waste?

median moss
#
module.exports = {
    name: 'pokemon',
    aliases: ['pk', 'p']
}```
this isn't working for some reason
crimson vapor
slim heart
outer perch
#

may I speak in PT for him a little?

opal plank
slim heart
#

but performance isnt the goal in detritus anyways KEKW

opal plank
#

so its not blocking

cinder patio
#
const arr = [1, 2, 3];

Then, inside the broadcastEval:

this.fameLeaderboard = ${JSON.stringify(arr)};
median moss
#

in dms

smoky herald
opal plank
#

well, berry, feel free to ask the author of the lib if you think its unoptimzed, cake is always willing to listen to feedback https://discord.gg/5Jgz8Xfk

cinder patio
#

The thing is that you define fameLeaderboard in shard X, and the code executes on all shards.

slim heart
#

the only way to fix it would be to bork the ease of the library

#

which ig is the whole point

cinder patio
#

So it's going to be undefined for all shards except for shard X

slim heart
#

its made for simple users (no offense) and it's prolly fine that it doesn't scale

crimson vapor
#

bro im ngl

opal plank
#

like i said, tell em not me, for me its working amazing

crimson vapor
#

berry just called it shit

slim heart
#

weary

quartz kindle
#

still scales much better than djs

opal plank
#

^^

slim heart
#

barely

#

it sends all of the events back to the main process tim

opal plank
#

and its not for simple users at all

slim heart
#

there's no way that scales at all

opal plank
#

it sounds like you barely looked at it tbh

slim heart
#

i literally tried using it to confirm my suspicion

quartz kindle
#

depends

#

its one of the possible design patterns

#

it depends on your workload to see how much it scales

slim heart
#

sort of defeats the purpose of clustering if everything just gets sent back to the master

cinder patio
#

I agree that sending all events to one process isn't a good idea

quartz kindle
#

there are people for whom the shards themselves use a lot more cpu than the actual bot commands

#

for those cases, the funnel pattern works fine

slim heart
#

that cannot scale

quartz kindle
#

it can if done properly

slim heart
#

regardless of what you're doing funneling every event back to a single process is like anti-scaling lmao

quartz kindle
#

the same way you use nginx for ssl termination, you use worker processes for websocket + zlib termination, plus you can add custom filters to them

#

and funnel only the useful packets back to main

slim heart
#

i literally memory leaked just trying to run my bot with default caching

#

that's not a good sign

quartz kindle
#

lmao

opal plank
#

did you ask the author if you were doing something wrong?

slim heart
#

i followed the example to a tee

opal plank
#

which example?

slim heart
#

on the main page

opal plank
#

not so bot uses it

quartz kindle
#

@slim heart which design pattern are you doing on rose?

#

master -> workers right?

slim heart
#

each clusters take care of their own event

#

yeah

cinder patio
#

That doesn't look like THE notsobot, notsobot has so many more commands

opal plank
quartz kindle
#

and worker handles multiple shards?

slim heart
#

correct

quartz kindle
#

cool

#

thats another good design pattern

cinder patio
slim heart
#

ill look into this source code, but atleast whatever is default for this and according to the example it just doesn't work well

opal plank
#

oh my bad, wrong bot then

#

it uses the same logo too tho

cinder patio
#

One of the contributors is the same

#

maybe it's a rewrite

opal plank
#

possibly

pale vessel
smoky herald
opal plank
pale vessel
#

Exactly

opal plank
#

notSoSuper is on the detritus server too

#

i assume it IS the notsobot

pale vessel
#

That's a fair assumption xd

quartz kindle
#

maybe they have two version of it

#

one in py, the other in detritus

#

ask them which one they run in prod

slim heart
#

they've gotta be using a different design pattern then what's the default if they're running a 500k bot with it

pale vessel
#

I doubt the old python code can still run

slim heart
#

idek how to change it with detritus but there ought to be if they haven't

quartz kindle
#

well, if you can customize shard ids and shard total, you can use any client with your own design pattern

slim heart
#

true

quartz kindle
#

i used pm2 cluster mode with djs lul

cinder patio
#

I gave an example

slim heart
#

well then again idek cuz with detritus unless there's a way to change it (looking rn) it forces all the events to go to master

smoky herald
slim heart
#

so even changing it wouldn't make any real affect on the issue i see

smoky herald
#

still returns undefined on other shards

quartz kindle
#

even so, you have to actually benchmark the funnel pattern because it may be more performant than you'd think

cinder patio
#

can you show how you're defining the variable

#

and how you're using broadcastEval

slim heart
#

i was trying to and memory leaked

#

i cant even do it

quartz kindle
#

i mean by yourself

#

with a custom client

#

xd

slim heart
#

weary so much effort

quartz kindle
#

im gona do it

slim heart
#

funnels in djslight?

quartz kindle
#

nah

#

im gonna run some custom experiments

#

idk when

#

but i hav a few ideas

restive furnace
#

now

#

:))

slim heart
#

i'd love to see your results

#

but then again i cant see there being an issue unless its a bigger bot tm

#

time to steal mee6's token

quartz kindle
#

xD

cinder patio
#

I think the funneling approach is definitely going to get super slow when the bot gets big

slim heart
#

yeah

quartz kindle
#

launch your bot 10 times and send all events to your lib

#

to simulate a bot 10 times your size

#

lmao

slim heart
# quartz kindle launch your bot 10 times and send all events to your lib
-       this.shard.worker.emit('*', msg)
+       this.shard.worker.emit('*', msg)
+       this.shard.worker.emit('*', msg)
+       this.shard.worker.emit('*', msg)
+       this.shard.worker.emit('*', msg)
+       this.shard.worker.emit('*', msg)
+       this.shard.worker.emit('*', msg)
+       this.shard.worker.emit('*', msg)
+       this.shard.worker.emit('*', msg)
+       this.shard.worker.emit('*', msg)
+       this.shard.worker.emit('*', msg)```
quartz kindle
#

xD

slim heart
#

ez

smoky herald
# smoky herald

this is from shard 0, if I call client.fameLeaderboard on shard 1 it returns undefined

opal plank
slim heart
#

the way they're describing it is how the traditional clustering should be done

#

but in practice im receiving every event on a master process rather than on each individual cluster

lament rock
#

why 8 per cluster

#

is the inbound events just too much beyond 8?

quartz kindle
#

nah

slim heart
#

depends on what your bot does

quartz kindle
#

idk why they chose 8 either

slim heart
#

they prolly just say it cuz in their own practice 8 is on the dot

lament rock
#

I'd hate to be paying for 50+ VMs

slim heart
#

i do 5 for mine

opal plank
#

not a flaw in the lib

slim heart
#

i followed the example

quartz kindle
#

if you want the best possible efficiency, its not very useful to spawn more processes than your cpu cores

#

if you have 32 cores, do 32 processes and distribute shards among them

#

thats what i'd do

slim heart
#

im looking into notsosource so i can see what's happening / changes

#

see what i did there