#development

1 messages · Page 1054 of 1

opal plank
#

ok i found the index

#

i'd extend it there then?

quartz kindle
#
Chat.prototype.say = function() {
  // copy paste the entire original say() method here, and replace it as you wish
}
#

are you forking this code? is it fine if you modify the original files?

opal plank
#

good question, without distribution it should be fine for most code, lemme check license

quartz kindle
#

or you prefer adding it without modifying the originals

opal plank
#

since im not distributing it should be fine, but lemme just double check their license

#

MIT, it should be fine to modify it

#

tbh it doesnt matter too much which method is better, as long as the final result is the same

quartz kindle
#

well there are basically 3 ways

#
  1. edit the original file
  2. create an extended class
  3. modify the prototype
opal plank
#

prob best to go with extended class im assuming to prevent future problems

still badge
lyric mountain
#

because that ain't how u use custom emotes with bots

#

you gotta use the non-parsed emote mention like <:emotename:id>

still badge
#

thats how i did it with the rest of my stuff?

#

ol

#

ok

lyric mountain
#

for example, programmingsocks becomes ![programmingsocks](https://cdn.discordapp.com/emojis/585884319814516762.webp?size=128 "programmingsocks")

sudden geyser
#

yes

still badge
#

for example, programmingsocks becomes ![programmingsocks](https://cdn.discordapp.com/emojis/585884319814516762.webp?size=128 "programmingsocks")
@lyric mountain ty

lyric mountain
#

if you need to get the non-parsed mention, just put \ behind the emote

#

it'll give u the complete mention

sudden geyser
#

it can also be used to reference the parent class (such as calling parent methods when overriding)

opal plank
#

ty @quartz kindle

#
  • rep
thin sonnet
#

Does anybody know how to make a welcome message for a bot running discord.js?

lyric mountain
#

write the desired code inside an guildMemberAdd event block

#

there are a lot of examples out there

misty sigil
#

which OS should I put on my VPS

lyric mountain
#

ubuntu

misty sigil
#

which version

quartz kindle
#

20

misty sigil
#

.04

quartz kindle
#

which ever there is

lyric mountain
#

and try not to lock yourself out of it by messing with ufw

restive furnace
#

i would choose debian or red hat (i have experience on linxu distros thats why)

earnest phoenix
#

i have used all of linux os

#

ubuntu is the best imo

#

@misty sigil if you want to know what ubuntu is best just dm me

#

ill expain

#

İ need to install phyton?

summer torrent
#

"You need to install the latest version of Python"
read the error pls

earnest phoenix
#

latest version

#

pip update python

#

İnstalling

#

pip update python would work too

#

but i geuss this is better

quartz kindle
#

just install windows-build-tools

earnest phoenix
#

add to path

#

add the pypthon execuaable t opath

#

How

#

copy the ppath of the ppython executable

quartz kindle
#

npm i windows-build-tools

earnest phoenix
#

Wait

#

Node_modules?

stark abyss
#

fs.readdir('./commands/', (err, files) => {
  if(err) return console.error(err);
  console.log(files.join(' '));
  console.log(files)

  for(const file of files){
    const commandFiles = fs.readdirSync(`./commands/classic/`).filter(file => file.endsWith('.js'));
    
    const command = require(`./commands/${file}`) 
    console.log(command)
  }
});```
#

why isn't this working?

quartz kindle
#

you didnt install it

stark abyss
#

me?

pale vessel
#

is there any error

earnest phoenix
#

İ am jnstalled pyhton

pale vessel
#

please explain

earnest phoenix
stark abyss
#

yes

earnest phoenix
#

İnstallee latest version

stark abyss
#

internal/modules/cjs/loader.js:960
throw err;
^
Error: Cannot find module './commands/classic'
Require stack:

  • /home/runner/test-bot/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:957:15)
    at Function.Module._load (internal/modules/cjs/loader.js:840:27)
    at Module.require (internal/modules/cjs/loader.js:1019:19)
    at /home/runner/test-bot/index.js:17:21
    at FSReqCallback.oncomplete (fs.js:155:23) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [ '/home/runner/test-bot/index.js' ]
    }
quartz kindle
#

@earnest phoenix npm install windows-build-tools

stark abyss
#

classic is a folder in commands

earnest phoenix
#

@earnest phoenix npm install windows-build-tools
@quartz kindle i cant install this too

quartz kindle
#

show installation log

earnest phoenix
#

Wait

#

İt says install pyhton

quartz kindle
#

from windows-build-tools

earnest phoenix
#

Yes

#

Wait i need powershell?

quartz kindle
#

npm install -g windows-build-tools

#

forgot the -g

earnest phoenix
#

Very sloww

quartz kindle
#

yes

#

it should take a few minutes

earnest phoenix
#

Do i need to select bot folder from powershell?

#

@quartz kindle

quartz kindle
#

no

#

its a global install

stark abyss
#

fs.readdir('./commands/', (err, files) => {
  if(err) return console.error(err);
  console.log(files.join(' '));
  console.log(files)

  for(const file of files){
    const commandFiles = fs.readdirSync(`./commands/classic/`).filter(file => file.endsWith('.js'));
    
    const command = require(`./commands/${file}`) 
    console.log(command)
  }
});```
earnest phoenix
stark abyss
#

don't understand why I am getting Error: Cannot find module './commands/classic'

quartz kindle
#

@earnest phoenix wait until it says "all done"

earnest phoenix
#

Ok

quartz kindle
#

@stark abyss you're still stuck on that?

earnest phoenix
#

Oh this is hurt myneyes

still badge
#

wats the code for actual users?

stark abyss
#

yes sir

still badge
#

cause ${message.guild.memberCount} includes bots?

earnest phoenix
#

İ think yes

#

Maybe

quartz kindle
#

@still badge guild.memberCount is the only reliable way to get the total number of users

#

all other methods depend on the cache

still badge
#

@quartz kindle but how i get it to give only users

quartz kindle
#

which is either contains only online users, and not offlines, or you need to enable the fetchAllMembers option, which uses a lot of memory

earnest phoenix
quartz kindle
#

@earnest phoenix not stuck, keep waiting

earnest phoenix
#

Ok

thin sonnet
#

So. My bot is online but not dnd. Anybody know a fix?

earnest phoenix
#

İmagine my bot gets declined for offline

thin sonnet
#

It's online and shows a activity

#

but not the correct status

earnest phoenix
#

Still waiting

quartz kindle
#

@stark abyss so... fs.readdir gives you a list of items in a folder. these items can be either files or folders, it doesnt differentiate between them. however, it only reads one level of folders, not the contents of all folders. so you have to loop over the list of folders you get from readdir, and for each of these folders, you have to make another readdir to get the contents of each folder, and then again get all files from that folder, and only then require the command using the main folder, the subfolder and the file

earnest phoenix
#

Stilllll waiting bruh its very slow

#

Omg

stark abyss
#

oh

earnest phoenix
#

Stilll waiting

#

Bruh

thin sonnet
#

Anybody know a fix?

#

or

quartz kindle
#

setting status is buggy, randomly works or doesnt and nobody knows why

earnest phoenix
#

@quartz kindle

#

How long is this?

quartz kindle
#

a few minutes usually

thin sonnet
#

ok.

quartz kindle
#

depends on your pc and internet

#

keep waiting

#

it will be done eventually

earnest phoenix
#

Wait wtf

#

İ hear a error message sound but

#

İ cant see anything

thin sonnet
#

Oh there we go

#

thanks

earnest phoenix
#

@quartz kindle

#

İ think this is stuck

barren basin
#

Please i need help, my bot always go offline for no reason...

spark wadi
#

@barren basin in what way

earnest phoenix
barren basin
#

@spark wadi The bot is online for some hours and it goes offline while it is still running on VSC

spark wadi
#

do you start it on VSC or cmd

earnest phoenix
#

@quartz kindle

barren basin
#

It could be an infinite loop but i don't think so | i start it with VSC

spark wadi
#

hmmm... weird. do you close the application at any point in the day?

barren basin
#

hmm no

quartz kindle
#

@earnest phoenix ?

barren basin
#

this issue came with the last VSC update

spark wadi
#

so it doesn't even show an error message in terminal?

barren basin
#

no

earnest phoenix
#

@quartz kindle now it says c++ desktop devolement

spark wadi
#

what's your startup message "node . or node [name of main file]"

earnest phoenix
#

And its 7 gb

#

._.

valid frigate
#

i literally ran a bare minimum bot

quartz kindle
#

@earnest phoenix where did you get that from?

#

did you cancel the windows build tools?

earnest phoenix
#

İ said N and it exited

valid frigate
#

oh yeah

spark wadi
#

what's your startup message "node . or node [name of main file]"
@barren basin

earnest phoenix
solemn latch
#

discordjs caches everything @valid frigate

valid frigate
#

so that drop is not gc?

#

it's discord.js?

#

LMAO

quartz kindle
#

@earnest phoenix you didnt let it finish

#

run it again

#

@valid frigate thats the gc

valid frigate
#

typically node applications would have a "sawtooth" pattern but this one just hikes up the mountain

#

weird

quartz kindle
#

are you using intents?

valid frigate
#

yeah but literally

#

only two here

quartz kindle
#

which ones

valid frigate
#

i dont need like

#

any caching at all

#

thats the thing

solemn latch
#

discordjs-lite

earnest phoenix
solemn latch
#

;p

quartz kindle
#

its not that bad of a sawtooth, only 20mb oscilation

barren basin
#

@spark wadi "C:\Program Files\nodejs\node.exe <file path>"

valid frigate
#

huh well this might be a bit interesting

#

one sec

quartz kindle
#

@earnest phoenix where did you get that from?

earnest phoenix
#

Whenni start build tools installitation

quartz kindle
#

npm i -g windows-build-tools opened that?

obtuse jolt
#

why

quartz kindle
#

last time i checked today is monday

valid frigate
#

im just concerned that it's djs because i've used the node inspector to monitor everything

spark wadi
#

@barren basin what language are you coding it in i'll try and find a solution on stack

obtuse jolt
#

no thats the response from web hook api

#

@quartz kindle

valid frigate
#

not monitor per se, take snapshots

quartz kindle
#

@obtuse jolt then its correct

barren basin
#

i am using javascript...

obtuse jolt
#

WHY

quartz kindle
#

why what

obtuse jolt
#

why does it say if its the weekend

spark wadi
#

ok sec A.Z

quartz kindle
#

because top.gg has a weekend system where votes are worth double during weekends

obtuse jolt
#

really?

#

thats pretty cool

quartz kindle
#

@valid frigate the sawtooth pattern is normal in discord bots because of websockets

tulip ledge
#

@quartz kindle

quartz kindle
#

lmao

valid frigate
#

ah

#

tim would you happen to know why it just constantly goes up in the graph above

lone yoke
#

it took me 18 minutes to verify my phone number

valid frigate
#

would that be my fault or discord.js?

lone yoke
#

idk

quartz kindle
#

is it unmodified discord.js?

valid frigate
#

yeah nothing is touched

quartz kindle
#

then yes its discord.js's caching

lone yoke
#

anyway what can i do here

valid frigate
#

fuck

#

ive been really like

#

i moved to djs from eris because eris was giving weird errors that had no issues on the github

#

but i guess the tradeoff is aggressive caching

barren basin
#

But it could be because of a loop, however i have no idea where the mistake should be @spark wadi

quartz kindle
#

well, both have untoggleable caches

valid frigate
#

unfortunately

quartz kindle
#

djs's is a bit worse tho

valid frigate
#

true

quartz kindle
#

you need either a different lib or a modified lib

#

both options exist

spark wadi
#

It is a loop @barren basin

#

that is the only way

valid frigate
#

im not sure where to look tim lmao

pure lion
#

djs light

quartz kindle
#

if you wanna go for a different lib, check out detritus
if you wanna go for a modified lib, check out discord.js-light

spark wadi
#

i couldn't find anything on stack for js but yeah you will just have to solve the loop

quartz kindle
#

there is also klasa-core but its pretty alpha last time i checked

lone yoke
#

k

valid frigate
#

thing is

#

i have looked at discord.js-light but

pure lion
#

Tim on patreon:
Haha Arthur Dent go brrrrr

valid frigate
#

no types :^)

barren basin
#

All of my "while" loop are not very hazardous ... @spark wadi

valid frigate
#

and i know that sounds like pretty weird to be upset over but yeah its just a small thing

quartz kindle
#

go for detritus then, its full ts

valid frigate
#

ill use it though thanks

#

nah id rather have less caching over a different ib

quartz kindle
#

ye

#

btw if you feel like contributing with types feel free lol

#

i dont ts so i didnt do it

valid frigate
#

ya

pure lion
#

h

earnest phoenix
barren basin
#

... and they all end when i test them

earnest phoenix
#

10 minutes

quartz kindle
#

patience

#

you're already waiting 3 weeks for your bot to get approved, you can handle 10-20min for this thing

earnest phoenix
#

Tim do have a point tho

#

İ am punching my laptop when it freezing 😂

#

But yeah, it can take some time

quartz kindle
#

poor laptop

earnest phoenix
#

No

#

Thermal limit

#

My fps drops 80-100 to 25 fps

quartz kindle
#

LOL

#

dude.. open it up and clean the fans

#

or take it to a service to do it

earnest phoenix
#

Ye ik i can see dust from there

valid frigate
#

tha fuck

earnest phoenix
#

dude.. open it up and clean the fans
@quartz kindle this laptop is not mine

#

;-;

quartz kindle
#

rip

earnest phoenix
#

my dads laptop

sudden geyser
#

could secretly open it up, try and clean it, put it back together and act like nothing happened (if it breaks just say a bird took it)

earnest phoenix
#

Bird

#

Lol

nimble kiln
#

just blow into the fans 👀

earnest phoenix
#

Do this laptop under warranty :D?

nimble kiln
#

Make sure you dont spit into it while blowing air

earnest phoenix
#

Because this laptop is 2 nd hand

#

Lol wtf

#

1 year limitee warranty

nimble kiln
#

Did you look up the serial number?

earnest phoenix
#

And this is a premium product :D

#

@nimble kiln what

nimble kiln
#

Did you use the serial number to check warranty?

earnest phoenix
#

No

#

Alright im gonna have to keep this chat on topic, we're getting a bit off topic here.

#

Ok

nimble kiln
#

u right sorry

hidden lynx
#

When I lol on my laptop it usually goes to 97° or higher

#

xD

#

Oh sorry Zoro, didn't see that message at first

earnest phoenix
#

guys how anti raid system works?

livid rivet
#

you need to save the message timestamp in a timestam, so you can compare the time difference between now and the last sent message

#

@earnest phoenix and then you can specify at which difference something should happen

earnest phoenix
#

lol?

#

that's anti raid?

livid rivet
#

basically

#

you need to save it for each user individually

#

and guild-wise

#

if you don't want to check every message, save a counter for each user, and if a message is being sent too frequently, you increase the counter by one

#

if the counter reaches a certain value you can then take actions

#

that's how I did it

earnest phoenix
#

i don't think that anti raid

sudden geyser
#

An anti-raid system depends on how it's implemented. Some anti-raid systems block a lot of users joining at the same time, while others may just watch for many messages being sent at the same time (from a single user or several). Some even do both, but it's like dune said: You need to record when the message was sent and keep recording. When it reaches a certain threshold passed, you can take action.

You can think of it linear line. If your unpredictable line being the messages received passes the linear line, you do something. It's kind of hard to explain as I've never attempted one myself.

pure lion
#

Just check how old the acc is

#

x)

sudden geyser
#

eh, that's not reliable and prone to more errors

pure lion
#

h

earnest phoenix
#

@quartz kindle

#

Waiting 1 hour

#

Still nit finjshed

#

hurB

quartz kindle
#

jesus lmao

#

well, nothing else you can do but wait

misty sigil
#

hey

distant basin
quartz kindle
#

what version is your discord.js

distant basin
#

v11

quartz kindle
#

then remove cache

misty sigil
#

why did my bot error out, it didn't normally do that ```
TypeError: fields.flat is not a function

quartz kindle
#

that means your node.js is outdated

sudden geyser
#

You need Node.js v12

misty sigil
#

Ah shit.

#

Installed the latest ver

earnest phoenix
#

@Tim#2373 something broken

#

@quartz kindle

pale vessel
#

no?

earnest phoenix
#

Oh it fixed

#

Why o cant install this

pale vessel
#

it wasn't broken to begin with bruh

earnest phoenix
#

1 hour lol

quartz kindle
#

restart your pc and try again

earnest phoenix
quartz kindle
#

maybe something is stuck and restarting will unstuck it

earnest phoenix
#

3 mb /s

#

Good

misty sigil
#

yay

#

it works

earnest phoenix
#

@quartz kindle thanks for helping now i need to install modules

#

Wtf

#

OMG FİNALLY QUİCK.DB

#

THANKS YOU SO MUCH TİM

turbid gust
#

dont use wuick DB

#

quick*

spice pier
#

ever heard of screenshot managers?

earnest phoenix
#

quick*
@turbid gust why

quartz kindle
#

ever heard of print screen lmao

opal plank
#

Sharex?

#

Snipping tools?

#

Prnt Screen + ctrl v?

#

Gyazo?

quartz kindle
#

lightshot

earnest phoenix
#

chrome or discord not installed?

opal plank
#

and the list goes on

spice pier
#

edge?

earnest phoenix
#

edge cant run discord

spice pier
#

bet

opal plank
#

wot

quartz kindle
#

why not

earnest phoenix
#

i personally dont use uploaders that are restricted to a single (public) cdn cause anyone can access the screenshots lol
sharex >>>>>

opal plank
pale vessel
#

why wouldn't a chromium based browser run discord (or any browser)

opal plank
#

it can doe

#

ignore the favela language

spice pier
#

Edge can indeed run discord

pale vessel
#

how surprising lmfao

pure lion
#

Wh

#

How?

opal plank
#

not like anyone would use edge, but its capable, for the sake of the argument

pure lion
#

Omj

spice pier
#

^

pure lion
#

Edge = trash

quartz kindle
#

@earnest phoenix the only reason i dont use sharex is that apparently it cant do what lightshot does (or at least i didnt figure out how)

opal plank
#

which is?

earnest phoenix
#

edge is pretty good, the chromium version that is @pure lion

quartz kindle
#

which is, print and show a small editor before copying to clipboard

pure lion
#

Yeah ngl

pale vessel
#

exactly

pure lion
#

But old edge is okeh

#

💩 💩 💩 💩

spice pier
#

there is an editor before copying

earnest phoenix
#

you can edit your screenshot on the go

#

yeah

opal plank
earnest phoenix
#

before selecting the region

spice pier
quartz kindle
#

yeah but how to display that automatically

#

i tried everything and it always makes me save the pic to disk first

#

and then open the editor from there

earnest phoenix
#

it shows that automatically?

#

you need to not select the region you want to screenshot

#

and instead edit first

#

then select

opal plank
#

right click sharex, after capture tasks @quartz kindle

quartz kindle
#

let me try

opal plank
distant basin
#

v11

quartz kindle
#

@opal plank oh i was looking everywhere in the main window

#

never bothered right clicking the icon

spice pier
#

its in the main menu too

opal plank
#

i havent seen anything that other cropping apps do that sharex doesnt tbh

spice pier
tulip ledge
#

Hey Tim I'm gonna ask my question now as you probably have the answer

opal plank
#

if you want a feature, its likely already there somewhere hidden in the settings

#

can even do some fancy stuff with ffmpeg

quartz kindle
#

well, i still like lightshot better

tulip ledge
#

I have 3 SQL queries. The one is ordered by agility and what I'm doing in all of them is rows[0] but the issue is that even tho I order the first by agility the second and third one aren't ordered by agility. Is there like a way to order the other tables depending on the ID from the user in the other tables ordered by agility?

pure lion
#

Why don't people just use ffmpeg for image manipulation?

#

In bots

#

Can't you upscale or something x)

warm cloud
#

lmao

#

try passing an image into ffmpeg

#

lmk if it works in discord bots

pure lion
#

Okayyyyy

#

It'll be fine

#

Hehehehhehe

quartz kindle
#

@tulip ledge need more info

tulip ledge
#

So

pure lion
#

forEach?

tulip ledge
#

I have 3 querries:

client.con.query(`SELECT * FROM users WHERE id IN (${usercheck}) ORDER BY agility DESC`) // So that the people who are faster go first
client.con.query(`SELECT * FROM inventory WHERE id IN (${usercheck})`) 
client.con.query(`SELECT * FROM skills WHERE id IN (${usercheck})`) 

The first query orders by agility but the other 2 queries order by data created meaning if I would be slower then a user that was added to the database after me he would have my inventory and skills. Is there any way to also order them by agility?

pure lion
#

Not sure how it works but
rows.forEach(row => rows.map(row => row.agility + row.<other stuff>))

Lol I don't know sql

tulip ledge
#

nope

pure lion
#

Dam

#

😔

tulip ledge
#

a row

#

In my database?

quartz kindle
#

@tulip ledge does your inventory and skills tables not have a user id in them?

tulip ledge
#

they do

quartz kindle
#

just map ids to ids

tulip ledge
#

Wait how tho?

quartz kindle
#

sorting should be irrevelvant

tulip ledge
#

I tried that

#

But it didn't work

opal plank
#

hmmm does vsc have a detach window?

quartz kindle
#

the first query should return an array of objects

tulip ledge
#

yes

quartz kindle
#

save all three queries in a variable, then loop over one of them, and build a combined object

tulip ledge
#

Wow

#

YOu're gonna need to guide me through the proccess

#

I don't know how to add all 3 queries to a variable

#

Neither do I know how to build a combined object

pure lion
#

Make an array and push the objects inside?

#

sorry I'm trying my best, I'll get it right one day

tulip ledge
#

That still won't solve it

pure lion
#

What are the names of the params in the object?

tulip ledge
#

Why do you need them?

#

The only necessery ones are discordid and agility

pure lion
#

Cant you sort by alphabetical order?

quartz kindle
#
users;
inventory;
skills;
combined = [];
for(let user of users) {
  let inv = inventory.find(t => t.id === user.id);
  let skill = skills.find(t => t.id === user.id);
  c = Object.assign(user,inv,skill);
  combined.push(c);
}
tulip ledge
#

I don't need that

#

Oh

#

Just gives me it

#

Ok so users is the users row

quartz kindle
#

that will create a combined object, so it only works if there is no conflict in your column names

pure lion
#

*sitting in intrigue*

quartz kindle
#

for example if users have column a, and inventory has column b, the combined will have {a:something,b:something}

pure lion
#

🍿

tulip ledge
#

Oh ok

quartz kindle
#

if you need to separate them better, for example {inventory:{a:something},skills:{b:something}}, you need to adjust it a bit

#

Object.assign(user,{inventory:inv},{skills:skill})

tulip ledge
#

Oh I see

#

Ok ty

#

I have the big row object now

#

Ty verry much!

#

Big brain tim

pure lion
#

I will absorb the knowledge of tim

quartz kindle
#

alternatively, you could also do a JOIN query in your database directly

#

which is probably more performant

#

it reduces 3 queries to 1

pure lion
#

Over time I shall become Tim as he ascends to become one with stack overflow

#

x) jk it's not gonna be me

quartz kindle
#

you overestimate me lmao

pure lion
#

No

#

All hail Tim X)))))))

#

Ok I'll stop now

solemn latch
#

lmao

tulip ledge
#

Tim quick question how long have u been doing JS?

pure lion
#

#

He is js

tulip ledge
#

Woo

#

Are u still here?

topaz fjord
#

Tim lives in develop

#

development

#

no joke he has more messages here than any other channel

tulip ledge
#

Oh

quartz kindle
#

idk

tulip ledge
#

Tim, can you like do the JOIN query with order by?

quartz kindle
#

about 3 years i think

tulip ledge
#

Wait thats how long as I've been doing JS

#

How are u so-

quartz kindle
#

idk

tulip ledge
#

But Tim the JOIN query would also order all the other things?

quartz kindle
#

im obsessive

#

lmao

topaz fjord
#

I mean

#

js isn't that hard

tulip ledge
#

Well I did take a break for a year

quartz kindle
#

yes, you can JOIN and sort

opal plank
#

obsessive is an understatement

tulip ledge
#

Oh cool

topaz fjord
#

all you need is mdn mmLol

opal plank
#

ive been coding in js for roughly 3 months and IM obsessive

#

Tim takes this to a whole new level

topaz fjord
#

I only use js if I'm bored af

#

I mainly stick to koltin and objc

#

kotlin

opal plank
#

just go Scratch, you can never go wrong with scratch

tulip ledge
#

Wait so I could do like
SELECT * FROM users INNER JOIN skills, inventory users.discordid=inventory.discordid=skills.discordid SORT BY agility DESC

#

Like that?

quartz kindle
#

sqlite or mysql?

tulip ledge
#

mysql

topaz fjord
#

SQL injection is real

opal plank
#

Queries are fun

topaz fjord
#

yeah

#

they are

opal plank
#

not

#

never do jsonb

#

ever

topaz fjord
#

json

opal plank
#

jsonB

#

not json

#

this hellish nightmare here

topaz fjord
#

binary form

#

what a meme

#

maybe we should create tson

opal plank
#

never again, -5/10, traumatized, suing for theraphy payment

quartz kindle
#

should be something like SELECT * FROM users INNER JOIN skills ON skills.id = users.id INNER JOIN inventory ON inventory.id = users.id ORDER BY users.agility

topaz fjord
#

suing for emotional abuse

tulip ledge
#

Oh ok

opal plank
#

indeed, while i did learn how to do it, its really complicated and doesnt have too much freedom

#

the one gain is that the queries are faster than running them locally on your code

#

though the learning curve is insane

tulip ledge
#

Yeah I don't think that'll work

#

I tried it and it logs like 6 times the same row

#

Idk why

#

And it also will only work with 1 user and I need to do it on an array

quartz kindle
#

forgot about the IN (user ids) also

#

its just a matter of tweaking it

tulip ledge
#

Yeah

#

I mean it's not slow or anything

#

is 34MB idle alot for 4 guilds?

quartz kindle
#

im testing it in sqlfiddle and it seems to work

misty sigil
#

no

tulip ledge
#

Oh ok

#

Wait sqlfiddle?

#

Is it like a website

quartz kindle
#

yeah

#

for testing sql queries

tulip ledge
#

its like the regex

quartz kindle
#

kinda

tulip ledge
#

Wait so

#

It works with IN?

quartz kindle
#

i did it with WHERE

#

let me check with IN

tulip ledge
#

Alright

quartz kindle
#

yeah it works

#

this is the full query i tested

#

SELECT * FROM Table1 INNER JOIN Table2 ON Table1.id = Table2.id INNER JOIN Table3 ON Table1.id = Table3.id WHERE Table1.id IN ("10","20") ORDER BY Table1.id DESC

tulip ledge
#

😮

quartz kindle
#

gives me combined rows with all columns

tulip ledge
#

I tried to log it but it gave me [object Object]

#

And I need it to be an array

quartz kindle
#

it is an array

#

show code

tulip ledge
#

Ok I managed to fix it

#

It sais typof rows is an object

#

But it acts as an array

#

Wich is weird

#

But it's working

#

So thank you so much ❤️

#

Jup it's fully working!

#

Thank you!

quartz kindle
#

typeof array is always object

#

because arrays are technically objects with indexes as keys

#

in order to differentiate arrays from objects, Array.isArray(obj) exists

tulip ledge
#

Oh

#

Cool

solemn latch
#

can i make a load command? to load new commands without restarting the bot?
load the same way as on startup.

tulip ledge
#

Hey Woo

#

Do you want to fight yourself?

solemn latch
#

or is there a reason no guides do it

#

o sure

tulip ledge
#

I pinged u

quartz kindle
#

yes you can

#

if each command is in their own file, you need to invalidate the require cache

digital ibex
#

quick question

#

i hope

#

i've got this switch statement that does stuff, and i've also got sub commands in the switch

#

and i've got, in the switch statement a default sayign that the subocmmand doesn't exist when u say a tag..

#

so like, this is what i mean

magic jackal
#

@solemn latch Its done by removing the file from the require cache like this

delete require.cache[require.resolve(path.join(filePath, file))]
digital ibex
#

because of the bob on the end, it breaks and says the sub command doesn't exist, any ideas?

magic jackal
#

its how you're handing the args in your tag command or your message handler @digital ibex

digital ibex
#

wot

magic jackal
#

Your message handler is probably trying to run the subcommand

digital ibex
#

its because of the 'default' in the switch statement

#

and im trying to make it, if its 'defualt' and is a valid sub command

copper cradle
#

did you add your "break" statements?

digital ibex
#

and if it isn't, then ^^

#

yeah, i did

copper cradle
#

hmm

magic jackal
#

with a switch you cant do multiple if inside of it or case if you will

#

thats probably the issue, the default can only check one thing

digital ibex
#

ik, im trying to make it check for default and extra

magic jackal
#

You'd need a seperate check for a subcommand

#

and a seperate check for the other thing

#

can you show code

copper cradle
#

show your code

digital ibex
#

kk

misty sigil
#

So I'm using snekfetch for some calls, It is installed but on my VPS it doesn't make the call, It physically doesn't get a response

pure lion
#

switch (args[0]) {
case 'command':
switch (args[1]) {
case 'soup':
//code
break;
}
}

#

x)

stark abyss
#

i am still stuck on the thing

pure lion
#

a!command soup

#

=> output

#

a!command

digital ibex
#
    switch (true) {
    case args[0].toLowerCase() === 'create':
        // code
    case args[0].toLowerCase() === 'list':
        // code
     break;
      case args[0].toLowerCase() === 'remove':
        // code           
     break;
     default:
    message.channel.createMessage(`✘ That subcommand does not exist!`);
 }
pure lion
#

:o

magic jackal
#

@digital ibex wat is the true

digital ibex
#

wdym?

magic jackal
#

its failing because true is not valid

stark abyss
#

there is an easier way to do it

digital ibex
#

no

copper cradle
#

that's not how case works uhhhh

digital ibex
#

no its not

magic jackal
#

thats not how a switch works

copper cradle
#

yeah

stark abyss
#

switch (args[0].toLowerCase()) {
case "your case here":
}

digital ibex
#

i use this all the time, works perfectly fine for me. and i only add the true so i can add other things when comparing

stark abyss
#

do that

#

isn't it true by default idfk

digital ibex
#

no, because i need to do more stuff, hence the true

magic jackal
#

I'm telling you that true is the reason its not working

stark abyss
#

what's the error you getting?

copper cradle
#

that's just a stupid way of doing "if"

stark abyss
#

just use module exports/command handler

digital ibex
#

well, its more faster than a if statement catshrug

#

and if i did use an if statement, it'll be significantly slower, right?

stark abyss
#

yes

magic jackal
#

switch needs an object key to search so it can loop through it to ask if it meets the case

if you put true on the switch its just going to switch over to the default because true is not an object

stark abyss
#

but if you use command handler/module exports it will be faster

digital ibex
#

no thats not what im saying

magic jackal
#

this is a proper switch

stark abyss
magic jackal
#
switch(msg.content) {
    case `++debug` :
      msg.channel.send(`message`)
      break;
    case `++invite` :
      msg.reply(`message`)
      break;
  }```
digital ibex
#

doesn't say the "that subcommand doesn't ecist"

#

because of the sub command onto it

#

it says it

magic jackal
#

That response is not a part of your switch

digital ibex
#

ik...

magic jackal
#

you're not listening

copper cradle
#

^

magic jackal
#

read this

digital ibex
#

im asking how can i make it not listen to that

copper cradle
#

you're oficially lost lmao

stark abyss
#

how to read folder in folder with fs?

magic jackal
#

@stark abyss read the docs

stark abyss
#

what docs?

magic jackal
#

@stark abyss

quartz kindle
#

you still didnt figure it out?

digital ibex
#

1 sec

quartz kindle
#

the problem is not how to use fs, the problem is simple loop logic

stark abyss
#

I am starting programming okay don't get mad at me

quartz kindle
#

im gonna give you an example

stark abyss
#

yes please

magic jackal
quartz kindle
#

using readdirSync because its easier to understand

magic jackal
#

@stark abyss I got u

digital ibex
#

this is how i done it

stark abyss
#

well I was using that then someone told me to use other thing

#

lotta information

quartz kindle
#
fs.readdirSync(folder).forEach(item => {
  fs.readdirSync(folder/item).forEach(file => {
    require(folder/item/file)
  })
})
stark abyss
digital ibex
#

i dont understand how thats gonna stop it erroing, im genuinely confused, i've been using switch(true) everytime i use a switch statement and all i need is just to make it not execute the default if the sub command has been provided

quartz kindle
#

switch is designed to process a single value

#

for example switch(something) case 1, case 2, case 3, etc

digital ibex
quartz kindle
#

all possible values of something

#

if you're not using switch for that, it loses its advantage

#

so you'd be better off using if else

digital ibex
#

yeah, but idk how to make it say something if theres a sub command

#

the thing is

#

i've got quite a lot of cases, more than that... so the code will run slower is my issue

topaz fjord
#

hahaha screw you kotlin react

quartz kindle
#

thats microoptimization, the performance difference is negligible

earnest phoenix
#

kotlin omegaLUL

quartz kindle
#

also, switch loses its performance advantage like that

misty sigil
#

Hey, I'm using snekfetch and await get to call an API from my vps, It works on my PC but not on my vps

digital ibex
#

i've got like 14 cases tho, surely its gonna be a lot slower?

quartz kindle
#

nope

digital ibex
#

oh?

quartz kindle
#

"slower"

#

aka 1 nanosecond slower

digital ibex
#

wait what

quartz kindle
#

the only reason switch is faster than if-else, is that switch is able to index all of its entries

#

so for example if value is 10, and you switch(10)

#

switch will immediately find the correct case, where case is 10

digital ibex
#

yeah

quartz kindle
#

without needing to go through all of them

#

but the moment you use switch(true), you lose that

digital ibex
#

and it takes a nanosecond?

quartz kindle
#

there is no indexing

digital ibex
#

o

quartz kindle
#

you're matching arbitraty conditions, which makes switch have to go through them one by one, like if-else does

digital ibex
#

how else could I do it like that?

#

using a regular switch, is it more than 1 nanosecond?

quartz kindle
#

it doesnt matter

#

rule of thumb is, are your conditions arbitrary? use if-else

#

are your conditions always based on the same thing? use switch

digital ibex
#

oh

#

i've been using switch this whole time if i've got an if else rooDerpy

#

well.. thanks for clarifying tim :)

stark abyss
#

const { prefix } = require('../config.json');
Error: Cannot find module '../config.json'
config json is in different file from the folder but shouldn't it work?

candid hill
#

I'm having trouble uploading images to embeds. Here's what I have so far:

console.log(fs.existsSync('./Images/Thumbnails/completion.png'));
embed.attachFiles(['./Images/Thumbnails/completion.png'])
.setThumbnail('attachment://completion.png')

When I run the code, the embed shows up without a thumbnail (or attachment). The console log is outputing true, so I don't think it's a problem with my file path. I've also tried switching out .setThumbnail() for .setImage() to match with the guide, but still not dice.

digital ibex
#

send a screenshot of the file tree

#

@stark abyss ^

stark abyss
#

i called const { prefix } = require('../config.json'); js in the help.js

candid hill
#

where are you calling help.js from?

digital ibex
#

its

#

../../config

stark abyss
#

what

digital ibex
#

not ../config

stark abyss
#

oh

#

wait what's befroe /config

pure lion
#

z!command

quartz kindle
#

../ would be the commands folder

stark abyss
#

ok

#

that's wat i thoguht

quartz kindle
#

each ../ means go one folder back

stark abyss
#

okay thank you

#

but config isn't in the folder

candid hill
#

you're using command handling with different files for commands, right?

stark abyss
#

yes

digital ibex
#

yeah p025, thats why u add the ../ again

candid hill
#

then you need the path from your command handler to config instead of the path from help to config

digital ibex
#

so

stark abyss
#

oh

digital ibex
#

../../config

stark abyss
#

okay

quartz kindle
#

each ../ means go back one folder

#

you are in classic

#

you use ../

#

now you are in commands

#

you use ../ again

#

now you are in the main folder

stark abyss
#

yes, ok

misty sigil
#

ok i got it working

quartz kindle
#

its literally what lost said

#

im just explaining it so you understand why

stark abyss
#

well thank you

earnest phoenix
#

lol

stark abyss
#

i don't see what's wrong in
const { prefix } = require('../commands/classic/config.json');

#

yikes sorry to irritate you

quartz kindle
#

you are in classic

#

you use ../

#

now you are in commands

candid hill
#

you can't go back by name, gotta use ../

quartz kindle
#

you use /commands

#

now you are in /commands/commands

#

you use /classic

stark abyss
#

const { prefix } = require('../commands../classic../config.json');

quartz kindle
#

now you are in /commands/commands/classic

#

you use config.json

#

now you have /commands/commands/classic/config.json

#

doesnt look right

stark abyss
#

wait what

quartz kindle
#

the help.js file is in the classic folder

#

so if you use ../ from the classic folder

#

you are in the commands folder

#

if you use ../commands

#

you are in /commands/commands

#

it literally means "go back to the previous folder, then open the commands folder from there"

stark abyss
#

const { prefix } = require('../commands../classic../help.js../config.json');

quartz kindle
#

....

#

lmao

stark abyss
#

i am sorry

quartz kindle
#

look

#

each thing in between the / means one instruction

stark abyss
#

okay

quartz kindle
#

the / is just a separator, means nothing by itself

stark abyss
#

oh

quartz kindle
#

and the instructions are in order from left to right

stark abyss
obtuse jolt
#

Does certification have limited slots here? I forget

quartz kindle
#

so ../commands/classic means ".." + "commands" + "classic" which means "go back to the previous folder" + "then open the commands folder from there" + "then open the classic folder from there"

stark abyss
#

oh

#

okay i think i get it now thank you for explaining it

quartz kindle
#

@obtuse jolt its not limited slots, its just that the program is kinda abandoned rn

obtuse jolt
#

oh

quartz kindle
#

nobody is reviewing applications for it

obtuse jolt
#

So there’s like a billion then

quartz kindle
#

probably lmao

obtuse jolt
#

I did big brain thing and added voting rewards for the first time I’ve never done this before

sudden geyser
#

congrats and ew

quartz kindle
#

i've never done it either

#

lmao

obtuse jolt
#

Really?

quartz kindle
#

yup

obtuse jolt
#

Damn

quartz kindle
#

none of my bots have vote rewards

#

because i dont like it

obtuse jolt
#

What are your bots?

#

Why is autocorrect so trash

quartz kindle
#

you can do -bots myid in testing

#

i think

obtuse jolt
#

what do they do?

quartz kindle
#

weird stuff

desert geyser
#

Hello smarter people 🙂
How do i send a message in a specific channel in a specific guild in python using the discord.ext.commands.Bot paradigm ?
I just know how have it respond to specific prodding's like !help, but every morning I want it to post Good Morning in a channel

obtuse jolt
#

You could have some voter exclusive commands tho

#

That could be an insensitive

quartz kindle
#

doesnt apply to my case

obtuse jolt
#

I didn’t do that but

#

Could be good

quartz kindle
#

i have donation features tho

obtuse jolt
#

Well how I’ve done it is you can donate and get unlimited priority scans for the amount of time you are donating or you can vote every 12 hours to get 1

quartz kindle
#

i could have implemented something like that but now its too late

#

my bot stores user-generated charts and graphics

#

there is one user that has like 600 charts by himself

obtuse jolt
#

does that not use like a lot of storage and ram

quartz kindle
#

my bot is very optimized

obtuse jolt
#

I need to remake like 80% of my bot

#

It was so rushed when I first made it

#

And the more I put time on it the better it’s looking

#

75

quartz kindle
#

verify in discord 75

obtuse jolt
#

I made a priority system

#

And didn’t even give myself any tokens

#

I’m so smart

quartz kindle
#

xD

obtuse jolt
#

I wanna show you it

#

Just gotta give myself some tokens

#

There we go

lyric mountain
#

75
@earnest phoenix 76 actually

#

It's 75+ exclusive

misty sigil
#

im gonna sleep now

#

god that was stressing

gray zealot
#

any ideas why this doesnt work? ```js
if (message.content.startsWith ${prefix}8ball){
const eb = require("./8ball.json")
message.channel.send(${eb.answers[Math.floor(Math.random() * eb.answers.length)]});
}

stark abyss
#

if (message.content.startsWith( ${prefix}8ball)){

#

that's the issue

gray zealot
#

ok 😄

#

ty

stark abyss
#

i think

gray zealot
#

I see now

#

🙂

stark abyss
#

ok

gray zealot
#

ty

lyric mountain
#

Just asking, but what IDE do you use?

stark abyss
gray zealot
#

?

#

nvm

stark abyss
#

tim i still can't figure it out

earnest phoenix
#

.help

magic jackal
#

Anyone know how to self mute the bot user this isnt working

#
message.guild.members.cache.get("717080513898217482").voice.setSelfMute(true)```
lyric mountain
#

Why selfmute tho?

magic jackal
#

idk thats why I'm asking

lyric mountain
#

Just dont send audio data

magic jackal
#

I want to to mute itself when its not playing audio

drifting egret
#

Gae

magic jackal
#

I already know that, that is not my question

lyric mountain
#

Yes, I know

magic jackal
#

It's this but it always returns false

#

idk why it does when its in a VC

drifting egret
#

No mo

earnest phoenix
strange trout
#

Do what

earnest phoenix
#

like a error event

lyric mountain
#

Try-catch

earnest phoenix
#

all the code?

lyric mountain
#

No, only stuff you know it's prone to error sometimes

earnest phoenix
#

oh

#

ok

#

thanks

#

or even better, instead of band aiding with try catch, fix the error BigBrain

strange trout
#

Genius

earnest phoenix
#

try catch is heavy on memory compared to rest of operations

lyric mountain
#

There is a way to catch ALL errors if you're using java

#

or even better, instead of band aiding with try catch, fix the error :BigBrain:
@earnest phoenix you can't fix all the errors tho, for example, missing permission stuff

earnest phoenix
#

yes you can

#

check for permissions beforehand

#

fixed

lyric mountain
#

Well, it'll still show an error to the user

earnest phoenix
#

this is api abuse?

     channels.forEach(ch => {
            try {
                ch.updateOverwrite(args[0], {
                    SEND_MESSAGES: args[1]
                });
            } catch (e) {
                console.log(e);
            };
        });
#

no

strange trout
#

Really no reason for the user to see the API error though

earnest phoenix
#

ok, thanks

lyric mountain
#

Yeah

strange trout
#

You should account for it yourself and handle as needed

earnest phoenix
#

@earnest phoenix and if channels size is > 100?

strange trout
#

Dunno

earnest phoenix
#

srry xd

#

if what you're doing has malicious intent, then yes it's api abuse, otherwise it isn't

#

ok

#

is for blockchannels command

strange trout
#

It can be API abuse regardless

earnest phoenix
#

you can't circumvent updating overwrites for example, a mute role or something

#

so you're allowed to do that

#

ok, thanks

stark abyss
#

Error: ENOTDIR: not a directory, scandir './commands/classic/avatar.js'
I don't understand what I am missing

earnest phoenix
#

have you tried reading the error

strange trout
#

That's not a valid directory

stark abyss
#

what would be one

earnest phoenix
sudden geyser
#

not a directory

strange trout
#

Couldn't tell you

stark abyss
strange trout
#

Is your code open source?

stark abyss
#

yes

strange trout
#

Would be nice to see your file structure

cunning gorge
#

Hey, I am trying to download discord.py to my visual studio code folder.
Note:

  1. I have a mac computer
  2. My python version is 3.8

I tried running

python3 -m pip install -U discord.py

But it responded with:

ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chardet-3.0.4.dist-info'
Consider using the `--user` option or check the permissions.

Any help would be greatly appreciated! Ping me if you have an answer 🙂

stark abyss
#

does that help?

strange trout
#

Where are you trying to access avatar.js from

steel heath
#

@cunning gorge try with the --user flag like it says: python3 -m pip install -U discord.py --user

cunning gorge
#

oh ok

#

what will that do exactly? @steel heath

steel heath
#

Idk, maybe try dowloading on another directory? Don't have any idea, that's just what the error suggests

grizzled raven
#

lol didnt know try catch had memory problems, i always disliked it only because of they way it is

cunning gorge
#

oh ok

#

Ok well it worked!
However:

WARNING: The script chardetect is installed in '/Users/
Library/Python/3.8/bin' which is not on PATH.

Gave me this warning, is this an issue for the future?

steel heath
#

I think you'll have to reinstall Python to fix that issue, or add it manually (which I don't recommend)

cunning gorge
#

ah ok

steel heath
#

And make sure to check "Add Python to PATH" or something like that on installation

cunning gorge
#

got it

#

is there a terminal command to uninstall python?

#

nvm i found it

earnest phoenix
#

simp

#

What’s up

stark abyss
#

const { prefix } = require(i want to get config.json here please help me);

#

i am calling it in help.js

opal plank
#

just...require it there?

stark abyss
#

i don't understand the path clearly

opal plank
#

'./' parent dir

stark abyss
#

wat's parent dir

opal plank
#

the directory above it

#

the parent

stark abyss
#

oh

#

./classic

#

then?

opal plank
#

thats one

#

its 2 dirs above

stark abyss
#

./classic/commands/config.json?

opal plank
#

i dont think you're quite getting it

#

config isnt in commands

stark abyss
#

i think you are correct

#

oh

#

right

#

./config.json/commands/classic?

opal plank
#

no

stark abyss
opal plank
#

config.json isnt a folder

stark abyss
#

right

opal plank
#

./folder/folder/folder/file

#

./ brings you one folder above

stark abyss
#

i only have two folder