#development

1 messages · Page 1920 of 1

azure current
#

oh i saw it

earnest phoenix
#

oh you're new

#

alr

#

go on it

azure current
#

i told u :/

earnest phoenix
#

and execute it

azure current
#

im think im done

#

i think*

earnest phoenix
#

execute this on console again:

rm -rf node_modules && rm package-lock.json && npm cache clear --force && npm cache clean --force && npm i
quartz kindle
#

pretty sure the PATH variable is not persistent on replit

earnest phoenix
#

dw we're almost done

azure current
#

on new line ?

earnest phoenix
#

@azure current did u get any error?

earnest phoenix
azure current
#

oh

#

ok

#

mb

earnest phoenix
#

@azure current did u get any error?

azure current
#

did i need to start it ?

#

i mean run it

earnest phoenix
#

oh fuck my bad

#

not on the replit console

#

on replit shell

#

fucking replit has two diff console

azure current
#

oh

earnest phoenix
#

@azure current execute them on shell

azure current
#

do i need to delete on console now ?

#

ok

earnest phoenix
#

optional

azure current
#

no i didnt get a error

#

thanks

earnest phoenix
#

ok next step @azure current

#

execute this on shell again:

rm -rf node_modules && rm package-lock.json && npm cache clear --force && npm cache clean --force && npm i
azure current
#

done

earnest phoenix
#

@azure current no errors?

azure current
#

yes , i dont have

earnest phoenix
#

@azure current can you see package.json? if so remove the scripts: {} and replace them with:

"scripts": {
    "start": "node ."
  }``` and then start your repl
quartz kindle
#

to check if the version is correct, add console.log(process.version) somewhere in your index.js file

earnest phoenix
#

^

azure current
#

done

earnest phoenix
#

@azure current start it

azure current
#

done

#

oh

#

thanks

earnest phoenix
#

it started perfectly?

#

no errors?

quartz kindle
#

which version does it show?

azure current
azure current
earnest phoenix
quartz kindle
#

just say which version it is

azure current
#

where need to see it ?

earnest phoenix
#

im sure its v16

quartz kindle
#

did you add console.log(process.version) in your index.js?

earnest phoenix
#

@lyric mountain sorry but it works fine anyway I just didn't think about how I'm going to update it if a new command or plugin gets added to the system is there anything tipped maybe?

#

because discordjs will return an error if its outdated

lyric mountain
#

gotta say, the system you have currently is not scallable at all

earnest phoenix
#

why?

lyric mountain
#

use blacklisting instead of adding all commands in a table

lyric mountain
#

with 1000 servers that's 30000 entries in a table

#

with blacklisting you can store disabled commands in the same table as server configs

#

and for premium commands you can just use a boolean field to decide whether to allow or not

earnest phoenix
#

so what would be the problem so i know the load problem can't come from having a lot of entries in a table

lyric mountain
#

the load problem does come from a lot of entries

#

imagine you update a command's name

#

or add new commands

#

you gotta update for ALL guilds

#

title cant have markdown

#

neither title nor footer

#

and markdown includes mentions

#

or author

#

which is a smaller title

#

no mention for u then

earnest phoenix
lyric mountain
#

but embeds don't ping anyway, so just go with user name

lyric mountain
#

ye

earnest phoenix
lyric mountain
#

if you change command name you'll lose parity

#

and if you create a new command that's O(n) inserts

#

meanwhile a blacklist would be O(1)

#
guildid | disabledCmds
1234567 | [1, 2, 3] 
#

instead of

guildid | commandId | disabled
1234567 | 1         | true
1234567 | 2         | true
1234567 | 3         | true
1234567 | 4         | false
1234567 | 5         | false
1234567 | 6         | false
1234567 | 7         | false
1234567 | 8         | false
1234567 | 9         | false
earnest phoenix
#

there is a plugin that is not preenium but it has a command that asks for a prenum

#

so what do i do with the blacklist ??
because I don’t just need to know if it’s on or off
but i need to know if the plugin is turned on i also need to know how to claim this premium
i also need to know that the pranacs inside the plugin are turned on
and asks for this premium

verbal summit
#

how can i add page frame like this to your bot description

earnest phoenix
verbal summit
#

thanks a bunch

lyric mountain
#

const premium = true

earnest phoenix
lyric mountain
#

Then when executing the command just check if (cmd.premium && !guild.premium) return;

lyric mountain
earnest phoenix
#

khm 6 tables

lyric mountain
#

That's confusing

#

Like, the 2 last tables are useless

earnest phoenix
lyric mountain
#

They could be a single column with an array of ids

#

But let's say you want those tables

#

Use blacklisting instead of whitelisting

#

So you exclude commands instead of including

earnest phoenix
#

why when cmd_list contains the basic settings of the command server_setting _cmd contains the command settings set on the server

spark flint
lyric mountain
#

Most settings can be reused on other commands

blazing sand
#

Hello

#

I want to HOST for My BOT in githab

earnest phoenix
lyric mountain
#

That's what I'm saying, you don't need to have a "disabled commands" table

#

Use a single column because it's VERY unlikely for the user to disable more than half the commands

lyric mountain
#

It'll probably be 3-4 commands disabled at most

slender thistle
lyric mountain
earnest phoenix
lyric mountain
lyric mountain
#

You could just store the disabled commands on a single array column

slender thistle
#

My brain is fried, I don't know

lyric mountain
#

And premium and type columns can be stored in the commands table

earnest phoenix
#

but these are not exactly disabled

earnest phoenix
#

now setprefix is disabled

lyric mountain
#

But why have that structure

earnest phoenix
lyric mountain
#

You're storing way more data than needed

#

Later I'll show u what I mean

earnest phoenix
lyric mountain
#

Relational database doesn't mean you need to use 30 tables for 30 settings

#

It just means tables can be related to each other

earnest phoenix
#

If you are working with data, we do not store JSON and other array formats in columns

earnest phoenix
lyric mountain
slender thistle
earnest phoenix
earnest phoenix
#

okey I just offered

zinc salmon
#

hi

earnest phoenix
lyric mountain
#

Sure, just wait till I get in my pc

earnest phoenix
#

my time is like the sea

lyric mountain
#

I chose to use multiple tables due to the amount of configurations I have inside guildconfig

#

all the sub-tables (except rules) are blacklists

#

inside disabledcommands I list only disabled command names (which I check before executing it)

delicate shore
#

Can I overwrite a css property through a js function?

#

Like
Function fetches something
Changes the count to whatever the response is

lyric mountain
#

u don't need to ovewrite a css property for that

earnest phoenix
delicate shore
#

I mean I need to overwrite an already existing text

lyric mountain
#

guildconfig contains actual settings

#

disabledcommands only disabled command names

delicate shore
#

Like let's just say I want to change the test "YouTube" on YouTube.com to "Shittube" after fetching something

#

Is it possible

lyric mountain
#

same for anything else

#

the master table is guildconfig, which holds all custom settings a guild can have

earnest phoenix
lyric mountain
#

all commands use those settings

#

postgresql

earnest phoenix
#

I use MariaDB

lyric mountain
#

just use dynamic values, easy

#

no property ovewriting

delicate shore
#

Does chrome extension support php

cinder patio
delicate shore
#

Also I don't want to change any dynamic value

lyric mountain
delicate shore
#

It's like a changing value

#

Ima go n study more about this topic myself and come back then
Thanks GoogleFeud and KuuaKu for help

earnest phoenix
lyric mountain
#

if you already have a well estabilished db it isn't worth it to migrate

earnest phoenix
#

because i have to make a final decision i don't want to make 8 kinds of databases

lyric mountain
#

you only need 1 database at all

earnest phoenix
#

not ready yet this is still very basic

lyric mountain
#

2 if you want a caching database

#

but nothing more

#

use a lib

delicate shore
lyric mountain
#

or make a converter yourself

earnest phoenix
#

the problem is that what you started with the database is very basic so not even half of it is ready and so you can change it at any time

lyric mountain
#

sure, at the beginning you have the freedom to choose where you want to park your horse

earnest phoenix
#

yes the only question is where

lyric mountain
#

people have too much trouble writing json for some reason

earnest phoenix
#

damn it i can't decide what

lyric mountain
delicate shore
#

I don't have a dashboard for my bot because I'm lazy

earnest phoenix
#

because now we should figure out how to store the data

delicate shore
#

And I don't have any idea

#

How do work with discord api for dashboard

lyric mountain
#

sure

#

your current structure is not bad at all

#

you just need to switch to exclusive method instead of inclusive

#

instead of saving available commands, save unavailable ones

#

you also don't need a commands table, just use files for that

#

about premium? a single boolean property on each command

lyric mountain
earnest phoenix
lyric mountain
#

it just generates json to be used with the command

lyric mountain
#

make a property on each command to hold what category they belong to

earnest phoenix
#

By plugin I mean eg section
random command,
interaction

earnest phoenix
#

should i write from scratch or can i still convert?

lyric mountain
lyric mountain
#

in my case

#

then on a command:

earnest phoenix
#

i use Node.js

lyric mountain
#

same principle

earnest phoenix
#

true

#

only i would store the categories in the database as well as the commands belonging to the ahot because it is easier to get the commands belonging to the category on the web dashboard

lyric mountain
#

sure, up to you

#

just keep things minimal

#

choose the option that uses less database storage

#

and returns results faster

earnest phoenix
#

just how do i start converting my current database and code

lyric mountain
#

I'll leave that to you, but I recommend using an actual database manager for making structure

#

unless you like writing ddl

earnest phoenix
#

because I like the look

#

idea good?

#

and then nicely [id, id, id, id]

lyric mountain
#

you don't need premium columns

#

and use TEXT for those data

#

varchar is not big enough

#

actually, if you're gonna use ids then it's fine

earnest phoenix
#

why is there no need for a premium?

lyric mountain
#

cuz u can store that on master guild table

#

and command table

#

just a boolean field with false for normal and true for premium

earnest phoenix
#

i will try to do it afterwards i would like to show that this idea is good

#

anyway how many characters a server id because so far i always give it 255 varchar

lyric mountain
#

for mysql-based dbs I'd not risk more than 191

earnest phoenix
#

okey

#

I'm still here

lyric mountain
#

ye

earnest phoenix
#

I store so much information about the server and make a separate table for the plugins like the welcome system

lyric mountain
#

yes I guess so, it's hard to visualize the entire structure without the plan

slender thistle
#

Prenium

earnest phoenix
#

at the moment i am doing this kind of structure because that way I can do things nicely separately

#

now that it has it i should upload data to the lists and then write it to the bot on the server joint

lyric mountain
#

I guess so

earnest phoenix
#

Im trying to randomise a word, well characters of a word

var word = "mother".split('');
_ = require("underscore");

var toguess = "";

for (var i = 0; i < 5; i++) {
    var index = Math.round(Math.random()*word.length);
    toguess += word[index];
    word = _.without(word, word[index]);    
}

console.log(toguess)

Output:

[ 'm', 'o', 't', 'h', 'e', 'r' ]
ormeh

sometimes its undefined

delicate shore
#

I want bot to learn from previous messages and send random output
Well not really but like

For eg - 1+1 is 2 , this is gay and etc

Bot randomly generates sentence by taking random words from each sentence like "1+1 is gay"
Should I use AI or just use a randomise function

wide sage
#

How to fetch the name or ID of the user who voted the server?

earnest phoenix
#

if thats what u meant

delicate shore
#

And I can randomise the [index] using another function

#

and ya that's what I mean

earnest phoenix
#

yeah message[random]

delicate shore
#

Ight thanks

lyric mountain
#

and please

#

FOR THE LOVE OF GABE

#

stop using var

earnest phoenix
#

i didnt know sort exists

lyric mountain
#

var is bad, it hates you and you should too

earnest phoenix
#

but thanks

#

isnt it the same

lyric mountain
#

no, like, var is really really really bad

earnest phoenix
#

var is just global?

lyric mountain
#

var is not exactly global

#

var is hoisted

earnest phoenix
#

that

lyric mountain
#

that means it gets declared before you even create it in the code

#

and this leads to VERY weird errors

#

plus every single IDE will scold you for using it

earnest phoenix
#

@lyric mountain
since i thought this doesn't work the previous method so i wrote it but i think this can be simplified as well

let disabled_category = [];
        let disabled_commands = [];
        con.query(`SELECT * FROM category_list WHERE category_default_type=?`, [0], (err, cat_list) => {
          cat_list.forEach(cat_list => {
            disabled_category.push(cat_list.category_id);
          });
        });
        con.query(`SELECT * FROM commands_list WHERE commands_default_type=?`, [0], (err, com_list) => {
          com_list.forEach(com_list => {
            disabled_commands.push(com_list.commands_id);
          });
        });
        con.query(`INSERT INTO server_settings (sid, server_prefix, server_lang, server_prenium, disabled_category, disabled_commands) VALUES (?,?,?,?,?,?)`, 
        [message.guild.id, '-', 'en', 0, disabled_category, disabled_commands])
lyric mountain
#

you should use for-each instead of forEach btw

#
for (const cat of cat_list) {
  // Do stuff
}
#

you're also redeclaring the variable inside those forEaches

earnest phoenix
lyric mountain
earnest phoenix
lyric mountain
#

cat.category_id

earnest phoenix
#

uff

lyric mountain
#

not cat_list.category_id

earnest phoenix
#

okey

#

sorry

#

he wandered over my eyes

earnest phoenix
#

just realised

lyric mountain
#

errr it shouldn't

#

it'll roll a value between 0 and 1

earnest phoenix
#

it keeps reversing it

lyric mountain
#

show how you're doing it

earnest phoenix
lyric mountain
#

...

#

you're rounding it

#

just write it exactly how I did

earnest phoenix
#

ah i always round it thats why

lyric mountain
#

not only that

#

but it'll never be higher than word.length

#

it'll always be a value between 0 and 1

earnest phoenix
#

@lyric mountain
HMMM
this is not how it should look

lyric mountain
#

?

earnest phoenix
#

it works fine now, thanks

earnest phoenix
#

[1]
[2]

lyric mountain
#

you're probably storing as a single value

earnest phoenix
#

I'll give him one more

lyric mountain
#

actually

#

try JSON.stringify(disabled_commands)

earnest phoenix
#

shit

lyric mountain
#

where is that?

earnest phoenix
#
sql: "INSERT INTO server_settings (sid, server_prefix, server_lang, server_prenium, disabled_category, disabled_commands) VALUES ('905339502569086986','-','en',0,1,2, 3)"
lyric mountain
#

stringify it

earnest phoenix
#

one minit

lyric mountain
#

it's taking the array as inputs not as a whole thing

earnest phoenix
lyric mountain
#

to revert just use JSON.parse()

earnest phoenix
#

sorry I'm asking for so much help but I haven't had anything to do with this kind of storage yet

#

but is that a good way to think?

#

sorry for the stupid question but where are you real

#

How can I make it so it deletes its previous message, so it does not spam in-between messages?

#

perrty good

#

@lyric mountain
this is how it looks now
Thank you so much for every help you gave me because it helped a lot. I'm trying to prosper with it but if I have any other problems I hope I can turn to you. Really thank you so much and have a great day 😉 ❤️

twilit pecan
#

is possible bot start audio call in dm?

earnest phoenix
twilit pecan
#

oh ok

lyric mountain
sterile brook
#

what reason of reaction collector doesnt work and i dont get any error logs

worn lynx
#

Hi

sterile brook
#

nah nvm, i just forgot about Intent

slow egret
#

Hi

spark flint
#

I'm trying to store api keys with their associated owner, and then store image ids with the api key which uploaded them, and I can't find how in JS

split hazel
#

you need to be more specific

#

have you got the database set up?

#

with columns including the image id and api key?

spark flint
#

No database yet

#

I'm stuck between mongo and mysql

#

what would be best for my use case?

cobalt junco
spark flint
#

Storing in the format

key: XXXXXXXXXXXXXXX-XXXXXXXXXXXXXX
owner_id: 0000000000000000000000

then a different table

imgid: XXXXXXXXX
key: XXXXXXXXXXXXXX-XXXXXXXXXXXXXX```
lament rock
#

Use postgres over mysql/maria

spark flint
#

Or uploader ID

lament rock
#

if you absolutely were dead set on going mysql, use Maria (it's a compatible fork of mysql and is better)

spark flint
#

Thats what my webserver uses

lament rock
#

I'd just keep everything in one db then

#

for related projects that is

spark flint
#

One DB, two tables

cobalt junco
spark flint
#
key: XXXXXXXXXXXXXXX-XXXXXXXXXXXXXX
owner_id: 0000000000000000000000``` in the table api

imgid: XXXXXXXXX
owner_id: XXXXXXXXXXXXXX-XXXXXXXXXXXXXX``` in the table images

#

same database, different tables

lament rock
#

That's a good format

spark flint
#

Its more how do i do it in js Lmao

lament rock
#

What part exactly

spark flint
#

Getting the data from it

#

and saving it lmao

#

I usually use Python and I'm only just able to use EJS, so I'm clueless with databases

cobalt junco
spark flint
#

I'm using that

#

But I don't know how to get data from it

cobalt junco
split hazel
#

if you really don't know anything about sql/mysql you might want to use the sequelize driver which abstracts the sql queries behind json queries and documents

#

or just use mongodb

#

which is schema less and easy to learn

spark flint
#

I use MySQL in python

#

Its more in JS

#

idk how

split hazel
#

you type your sql query in the string

#

and then you can use fields to iterate over the rows

hallow shell
#

yoooo text input component pog

#

wait i hope that doesn't count as advertising

#

lemme delete the invite

lyric mountain
#

I'm more interested in that embed actually

grim aspen
#

That was quite an embed

spark flint
#
con.connect(function(err) {
  if (err) throw err;
  var sql = "INSERT INTO images (imgid, owner_id) VALUES (`${imgid}`, `${result.owner_id}`)";
  con.query(sql, function (err, result) {
    if (err) throw err;
    res.send("etc etc")
  });
});```
lyric mountain
#

I see concatenation, no good

woeful pike
#

plz use promise based db drivers woeisme

split hazel
#

other than sql injection and callback hell good start

lyric mountain
#

I also see var

spark flint
#

i'm only working on the getting of the data now

woeful pike
#

also if (err) throw err; is a good way to crash your app

spark flint
woeful pike
#

yeah stop using it

spark flint
#

what db should i use then

split hazel
#

oh dear

#

it's much better

#

and supports cleaner syntax

spark flint
#

ok

woeful pike
#

yes

#

idk where people are seeing this if err throw err pattern though it's really bad

quaint wasp
#

sup

#

How do you use this in onather place?

hallow shell
quaint wasp
#

Havent programed in a while so kinda forgot some things

split hazel
#

only in development though

quaint wasp
woeful pike
#

people think they can catch that error too which is also problematic

quaint wasp
#

Also this bot is going to have like 1-5 commands

split hazel
#

doesn't use await yet its non blocking

hallow shell
#

i've actually never used it before, dont know sql 😬

spark flint
#

it now returns what i need

split hazel
#

nice

slow terrace
#
          const fetchedLogs = await channel.guild.fetchAuditLogs({
            limit: 1,
            type: 'CHANNEL_CREATE',
        });
        // Since there's only 1 audit log entry in this collection, grab the first one
        const channelLog = fetchedLogs.entries.first();
      
        const { executor, type, id, name } = channelLog;
        if(!channelLog || !channelLog.available) {
          return;
        } 

why not working but if i did it

        if(!channelLog) {
          return;
        } 

only it works

spark flint
#

New issue

split hazel
spark flint
#

yep

split hazel
#

update your node version to >= 16

spark flint
#

ok

split hazel
#

because they insist on using the newest features the language has to offer not considering older programs

spark flint
#

just gonna use node-fetch with the api

split hazel
spark flint
earnest phoenix
#

@spark flint help me?

spark flint
#

with...

earnest phoenix
#

If anyone can explain to me how to send my bot for examination, that top.gg

spark flint
#

a bot review will invite it to the test server

#

the bot is in a queue atm

earnest phoenix
#

How long is that Waiting?

split hazel
#

a few weeks

#

I think

earnest phoenix
#

Tnx

spark flint
#

getting this

#

even tho i do js app.post('/upload', async (req, res) => {

quartz kindle
#

in order to use await, the parent function must be async

#

which means the function or callback that is the direct parent of your current block of code

nova basin
#

Help me please

Error: Cannot find module '../botconfig/config.json'
Require stack:
- /home/runner/jhgfrftgyhzujidkuhdnjyioqsminfbqheinjsbdiquhizn-1/dashboard/modules/auth-client.js
- /home/runner/jhgfrftgyhzujidvfdjhednjyioqsminfbqheinjsbdiquhizn-1/dashboard/modules/sessions.js
- /home/runner/jhgfrftgyhzujidkoluhdnjyioqsminfbqheinjsbdiquhizn-1/dashboard/modules/middleware.js
- /home/runner/jhgfrftgyhzujidkolcvfdjheduhdnjyioqsminfbqheuhizn-1/dashboard/index.js
- /home/runner/jhgfrftgyhzujidkolcvfdjheduhdnjyioqsminfbqheinjsbdin-1/bot.js
quartz kindle
#
async function() {
  something(() => {
    // this is not async
  })
}
#

whats your folder structure?

spark flint
quartz kindle
spark flint
#

ah

quartz kindle
#

and wtf is that indentation

spark flint
#

god knows

#

will fix it

quartz kindle
#

is line 44 supposed to be the end of the err => function, or the end of the post function?

spark flint
#

i'm not sur

#

but when i remove it, i get an error

quartz kindle
#

lel

spark flint
#

new issue

#

oh wait

#

i think i know

#

yep i know

#

i did key instead of apikey

quartz kindle
boreal iron
earnest phoenix
errant flax
#

why isnt it setting the key "foo" to my redis db

#
const redis = require("redis")
const redisClient = () => {
	return new Promise((resolve,reject)=>{
    const client = redis.createClient({
      url: process.env.redis,
			no_ready_check: true
    })
		client.on("ready",()=>{
			resolve(client)
		})
    client.on("error",(e)=>{
			reject(e)
		})
  })
}
const a = async () =>{
	try {
	  const client = await redisClient()
    client.set("foo","bar")
		console.log("hi")
	} catch(e) {
    console.log("error",e)
  } finally {
		//client?.quit()
	}

}
a()
#

code ^

lament rock
# spark flint

dont create a connection in a function that will be run often. Make 1 connection or a pool of connections

nova basin
quartz kindle
quartz kindle
#

thats not what i asked lol

earnest phoenix
#

@nova basin try using js require(`${process.cwd()}/botconfig/config.json`)

#

the "../" arg i mean

quartz kindle
#

its just a matter of using relative paths properly

#

and even if you want absolute paths, its probably better to use process.cwd() instead of hardcoding it

earnest phoenix
#

oh yeah

quartz kindle
nova basin
#

yes

quartz kindle
#

that was a question

#

which file?

nova basin
#

yes i have

quartz kindle
#

...

#

what language do you speak?

earnest phoenix
#

lmao

nova basin
quartz kindle
#

dans quel fichier as tu ce code ?

earnest phoenix
#

dans quel fichier avez-vous le require() ?

nova basin
#

ah shit

quartz kindle
#

lol

earnest phoenix
#

alr u got this Tim

nova basin
quartz kindle
#

not that one

#

Error: Cannot find module '../botconfig/config.json'

nova basin
#

wait

boreal iron
#

Poor Tim… trying hard even in baguette language freerealestate

quartz kindle
#

omelette au fromage

nova basin
# quartz kindle `Error: Cannot find module '../botconfig/config.json'`
- /home/runner/jhgfrftgyhzujidkuhdnjyioqsminfbqheinjsbdiquhizn-1/dashboard/modules/auth-client.js
- /home/runner/jhgfrftgyhzujidvfdjhednjyioqsminfbqheinjsbdiquhizn-1/dashboard/modules/sessions.js
- /home/runner/jhgfrftgyhzujidkoluhdnjyioqsminfbqheinjsbdiquhizn-1/dashboard/modules/middleware.js
- /home/runner/jhgfrftgyhzujidkolcvfdjheduhdnjyioqsminfbqheuhizn-1/dashboard/index.js
- /home/runner/jhgfrftgyhzujidkolcvfdjheduhdnjyioqsminfbqheinjsbdin-1/bot.js
quartz kindle
#

sigh...

quartz kindle
#

dans quel fichier as tu ce code ?
require("../botconfig/config.json")

quartz kindle
#

@_@

nova basin
quartz kindle
#

.>

#

show your bot.js

nova basin
#

I had changed with .../.../

nova basin
quartz kindle
#

if you have:

  • bot.js
  • botconfig
    • config.json
#

then its ./botconfig/config.json

#

not ../

#

you use ../ to go one folder backwards
for example if you have:

  • somefolder
    • bot.js
  • botconfig
    • config.json

then you use ../ in bot.js

#

./ = this folder
../ = previous folder / 1 folder back

nova basin
#

hum okeyy

quartz kindle
#
  • file1.js
  • folder1
    • file2.js
    • folder2
      • file3.js
      • folder3
        • file4.js
        • file.js <- require("./folder4/file5.js"); require("./file4.js"); require("../file3.js"); require("../../file2.js"); require("../../../file1.js")
        • folder4
          • file5.js
boreal iron
#

Might be a good idea to set an environment var with the absolute root path of your project at some point

#

Instead of jumping 1000 times to the parent folder

#

Imagine changing the structure once

quartz kindle
#

or just use process.cwd()

boreal iron
#

Now have fun explaining that in French

quartz kindle
#

yea no

#

:^)

boreal iron
#

I fucked up my home server

nova basin
boreal iron
#

Shouldn’t have shopped hardware before experimenting with the limits

quartz kindle
#

rip

#

what happened?

boreal iron
#

Bought NVME drives mounted on PCIE cards as RAID1 OS drive

#

Turned out the board doesn’t support booting from PCIE

#

Not without modifying the BIOS

quartz kindle
#

rip

boreal iron
#

I still lots of other RAIDS also a RAID1 SSD but they are significantly slower than NVME of course

#

Since they are SATA

#

Qvo

#

Having like a dozen VM on SSDs with just ~ 500 MB write speed instead of 3500 is eww

quartz kindle
#

are you gonna put linux on it?

#

or win

boreal iron
#

Well it was supposed to run Proxmox

quartz kindle
#

is proxmox based on linux?

boreal iron
#

Now I’m forced to go with Windows to test if there’s a driver supporting NVME PCIE boot

boreal iron
quartz kindle
#

if so, then you only need a non-pci drive for /boot

#

everything else can be mounted in the pcie

boreal iron
#

Yeah all drives can be used, that’s not the issue

#

The issue is any other drives are connected via a hardware RAID controller which isn’t supported by Proxmox

quartz kindle
#

rip

boreal iron
#

And yeah the RAID SATA SSDs should be the database

quartz kindle
#

patch the bios, if anything goes wrong, RMA the boards :^)

boreal iron
#

Now since I can’t boot from the PCIE NVMEs it will get the database

#

Which is overkill

boreal iron
#

Modding the BIOS

quartz kindle
#

not really, but i've seen plenty of universal uefi bios patches for nvme related stuff

boreal iron
#

A server board btw not a common consumer board

#

Frustrating

quartz kindle
#

does it use AMI bios?

boreal iron
#

Yeah

boreal iron
#

Let me get the name real quick

#

lol saw that article a few seconds ago, too

#

Can’t open it

#

Blocked by pihole

#

Yeah the board has an Intel gen 6 chipset

quartz kindle
#

you and your pihole

boreal iron
#

It’s supported since gen 9 or something

quartz kindle
#

if you dont want to mod the bios

#

Alternative methods to use an NVMe SSD as bootable drive with older systems (no BIOS modding required):
"Clover-EFI Bootloader Method" (the related guide written by our Forum member Nyctophilia can be found >here<)
"DUET-USB Boot Method" (the related guides written by our Forum members noInk resp. mireque can be found >here<, >here< and >here<)

boreal iron
#

It is no problem to get a PCIe or M.2 connected NVMe SSD working with any Intel Chipset system from 6-Series up without modifying the mainboard BIOS, if
a) the NVMe SSD will be used for the storage of data (as drive D:, E: etc.) and
b) an appropriate NVMe driver is present within the Operating System (either natively or loaded/integrated),
but the usage of such SSD as bootable system drive C: (incl. the boot sector) usually requires a special mainboard BIOS EFI module, which has to be loaded while booting.

#

quote goes wrong

#

There’s probably no appropriate driver, that’s the issue I mentioned

#

That’s why I said I will need to test Windows

#

Note: Some NVMe SSDs like Samsung's 950 Pro SSD are natively bootable in LEGACY mode (CSM and loading of Option ROMs has to be enabled within the BIOS), because their Controller chip contains its own NVMe supporting Option ROM module.

#

Also tried that

#

But no

#

I’ve got 870 Evos Plus

#

Err 970

boreal iron
#

Looks like it could work, maybe

#

Oh gosh I see it’s getting complicated

#

Could use the small SATA SSD as bootable device installing grub and moving the boot partition to the PCIE

#

Since I don’t need the small SSD anyways

#

Well I guess I can only fuck it up since I haven’t tried that before

pale vessel
#

Try to fetch a user by that ID

#

No, user

#

users.fetch(id)

lament rock
#

You could avoid doing fetching as much as possible if you check if the string matches /\d+/ and if you deconstruct the ID, the timestamp should be less than the current timestamp (0 is Clyde's ID, so it is valid. Discord's Snowflakes start at 0 which is when Discord's Epoch was.) If either of those return false, then you know it isn't an ID. Otherwise, you will have to try to fetch it via client.users.fetch(id) and handle possible promise rejections appropriately.

If you know how, I think HEAD requests work on /users/user_id

shy turret
#

when i do kill("SIGINT"); on a child process (child process is started with: const { err, stdout, stderr, kill, pid } = exec('funny_child.bat', { async: true, silent: true });), does anyone know why it outputs "TypeError: Cannot read property '_handle' of undefined"

#

(its an error)

lament rock
#

was the child already killed? Are you using some kind of child_process wrapper?

#

The process will exit when it reaches end of code execution

shy turret
#

ohh

#

that makes sense

lament rock
shy turret
#

bru

lament rock
#

cant kill whats already dead

shy turret
#

killing children intensifies

lament rock
shy turret
#

i hate my life ill figure it out

#

(if you wonder why it says error, i made it an error lmao)

#

spawn("taskkill", ["/pid", pid, '/f', '/t']); because its windows .-.

#

bru

#

thx

earnest phoenix
#

snake_case_in_js Thonk

wheat mesa
#

what_in_the_python_fuck

earnest phoenix
wheat mesa
#

you used djs until recently angeryBOYE

earnest phoenix
#

people learn from their mistakes

earnest phoenix
#

question:
in this react component:

function Timer() {
  const [time, setTime] = useState(0);
  
  function start() { /* ... */ };
  function stop() { /* ... */ };

return (<div className="container has-text-centered">
  <h1 className="title is-family-monospace is-1">0.00</h1>
  <div className="buttons">
    <button className="button is-black" onClick={start}>Start</button>
    <button className="button is-danger" onClick={stop}>Stop</button>
  </div>
  </div>);
}

the start and stop functions are recreated every time the component rerenders
how do I make it so they're only created once?

#

bulma didn't even center the buttons

earnest phoenix
#

you can use this too ```xml
<div class="box has-text-centered">

earnest phoenix
#

`totalmembercount = len(guild.members)
membercount = len([m for m in guild.members if not m.bot])
botcount = totalmembercount - membercount

if botcount > 100:
await guild.leave()`

#

Can I use this in owner only command ?

slender thistle
#

Aka file-level functions

round cove
slender thistle
#

Ah

round cove
slender thistle
#

Not familiar with hooks personally

round cove
#

You can read about useEffect and useCallback or useMemo if you really want to get into keeping track of state and preventing rerenders based on specific inputs.

slender thistle
#

Thanks

earnest phoenix
#

`@client.event
async def on_guild_join(guild):
totalmembercount = len(guild.members)
membercount = len([m for m in guild.members if not m.bot])
botcount = totalmembercount - membercount

if botcount > 30:
      await guild.leave()`
#

i used this

#

but still my bot havent left any servers

small tangle
#

i just discovered property files and they are awesome peepoAwesome

earnest phoenix
#

i have to verify my but if someone not invited my bot to any bot farms

#

no errors?

earnest phoenix
#

did u turned on intents already?

earnest phoenix
earnest phoenix
#

on_guild_join will only work if the bot is invited in new guild

#

oh

#

try creating a new server and invite your bot

#

so

earnest phoenix
#

can i make a command ?

#

@earnest phoenix

#

my friend has 30bots+ in his server

#

yea

#

ok

#

tell him to invite

#

@dense flame can i send them the server invite

dense flame
#

if they asked for it then sure

earnest phoenix
#

does it count as adv

#

alr

#

: )

earnest phoenix
#

counted as help

#

: )

#

@earnest phoenix oh wait, dm me your bot invite

#

ill invite it

#

ok

earnest phoenix
#

any idea how do i creat my own discord bot widget not with top.gg?

earnest phoenix
#

hello only i experience that node js in the client.memers.cahce.size / guild.memers.cahce.size does not return the real value?
returns the number of the word but the real one

#

pl

#

the bots are filtered, 4 of which are on the server

#

but isn't that a good number?
Does anyone know anything about this?
what it is and how it can be remedied

surreal sage
#

What was the html thing with $('element') etc

#

What was it called

surreal sage
#

client.members.cache.size

#

It's cache

#

It's almost never correct

pale vessel
surreal sage
#

i got it 15 seconds ago yea

earnest phoenix
surreal sage
earnest phoenix
#

because if I write client.members.size it will return an error anyway

#

yes but i would like to filter out eg only online users or not to bots in etc ...

#

my code
not bot

guild.members.cache.filter(member => !member.user.bot).size```
not offline user and not bot
```js
guild.members.cache.filter(member => member.presence !== null && !member.user.bot).size
#

does not return an error but returns untrue numbers

#

exactly

#

I understand but it is possible not to get it from the cache and be able to filter it

boreal iron
#

Not all members are cached at any time
The presence requires an privileged intent btw.

#

There’s a property you can access called memberCount with the guild object

earnest phoenix
boreal iron
#

The current member count is only being sent in the ready event or guild_create

boreal iron
boreal iron
#

That array is useless
If you already loop the guilds, simply access the property

#

Just use the channel search, it’s useful sometimes

#

One of 1000 examples

slow terrace
#

How can I do like that?
I need to force the bot to wait and if it got any other embeds to send it send them all in the same message

earnest phoenix
#

i think they meant batching multiple logs into one message

earnest phoenix
#

$$ => document.querySelectorAll

slow terrace
#

I need them all in same message

#

Oh

#

How can I clear it?

earnest phoenix
#
const logs = [];

setInterval(() => {
  logChannel.send({ embeds: logs.map(log => new MessageEmbed()) });
  logs = [];
}, 5000);
#

and you need to remember to only send the first 10 items

earnest phoenix
#

.shift the array 10 times

earnest phoenix
#

yeah

#

forgor

hybrid cargo
#

pushing to an array doesnt modify he whole variable. Unless he is totally modfying what logs is, he can use const

hybrid cargo
#

Oh that one oh yeah

#

I did not see that 💀

earnest phoenix
#
let logs = [];

setInterval(() => {
  logChannel.send({ embeds: logs.slice(0, 10).map(log => new MessageEmbed()) });
  logs = logs.slice(10);
}, 5000);
#

I hope I put the correct indices

slow terrace
#

👌

boreal iron
#

@quartz kindle I'm fucking DOING IT!11! Wish me luck modding the BIOS

#

what can go wrong

quartz kindle
#

lmao

#

good luck

earnest phoenix
#

KERNEL.SUS

boreal iron
#

Omg thought I’m dead after fan spin and 4 th reboot

#

Back in BIOS

#

But still doesn't mean it worked

#

Need to figure that out yet

earnest phoenix
#

do what

boreal iron
#

I swear I’m sweating… oldEyes

woeful pike
#

I'm being gaslit

earnest phoenix
boreal iron
#

Guess he means creating a map

#

Or collection if djs

woeful pike
earnest phoenix
#

use js

#

best dynamically typed language

woeful pike
#

theyre the same thing

#

equally terrible

earnest phoenix
#

yes but python is more terrible

#

and you're forced to use js for browser cuz there totally isn't smth that starts with web and ends with assembly that can run any programming language in the browser

#

since when does js have a purpose

#

other than annoy

feral aspen
feral aspen
# feral aspen

How can I pop out an attachment after following up when updating using the .update() method?

earnest phoenix
#

tell me this is not for testing

feral aspen
#

When I added an attachment, that's fine, but when I .update(), I have two attachments, how can I remove the old one?

earnest phoenix
#

can you even edit a message's attachments?

#

you can't add a new one to the same message

feral aspen
#

I'm just trying to pop out an attachment. lmao

feral aspen
#

When you are editing, check my code.

earnest phoenix
#

discord constantly changing api features

#

brb

#

have to reread the docs again

feral aspen
#

???

#

Banana apple apple.

#

More information, please.

feral aspen
#

How can I remove an attachment when I do .update() since it sends with a message and I don't want that.

Basically when I attach something to send with a message, I want to edit it afterwards and use a different attachment, but the previous attachment is yet there, how can I remove the previous one?

spark flint
#

change nickname = change own nickname

#

manage nicknames = manage others nicknames

split hazel
earnest phoenix
split hazel
#

im trying to download jdk but the page is just white

earnest phoenix
#

Whats the error

split hazel
#

its task not tasks

split hazel
#

hm yeah their website is broken

#

im trying to download jdk

pale vessel
#

Go to one of those filehippo URLs

pale vessel
#

Real and legit

split hazel
#

is that sarcastic

pale vessel
#

Some of them are legit

#

Oh

#

My bad, not me

slow ibex
#

Uuuh.. okay.. from one day to another my Bot wont start.

#

Because of "Dogstats".

split hazel
#

i am downloading it and slightly concerned

slow ibex
#

For some reason:

pale vessel
#

It is okay

#

I am here for you just in case your computer gets infected

split hazel
#

thank you

#

windows defender will protect me

#

its like an overprotective parent

pale vessel
#

Oh, really?

#

My Windows Defender went to get the milk

split hazel
#

uh i need jdk 16 lmfao

#

im trying to start a local papermc server

#

well "java 16"

split hazel
#

oh their archive page works

#

thank you

#

i thought i had to login

#

i usually make a new oracle account each time

feral aspen
#

How yall doing?

spark flint
wheat mesa
#

res.send is not a function

#

What’s your code for that

#

Maybe you put (res, req) => instead of (req, res) =>

spark flint
#

@wheat mesa ^

wheat mesa
#

Oh, never used axios. Thought you were using express

#

I’m going to assume that res is not the type you think it is though

spark flint
#

I'm using Axios to sent requests

wheat mesa
#

Try logging res

#

(In your .then())

#

Also pro tip: use ESLint or something similar and set it to format on save so your code looks consistent, that was a life saver for me when I started to use a linter

spark flint
#

i removed .then

wheat mesa
#

await is usually the way to go

earnest phoenix
#

how do i break out of a foreach loop

guild.channels.cache.forEach(channel => {
  if (channel.type === "GUILD_TEXT" && channel.permissionsFor(guild.roles.everyone).has("SEND_MESSAGES")) {
    channel.send(cum).catch(err => {
      if (err) {isErr = true;}
    });
  }
  return;
});
wheat mesa
#

You can’t iirc

#

Use a for..of loop instead

fluid orbit
#

Can you guys suggest to me a good hosting provider

spark flint
earnest phoenix
#

so it doesnt spam every single text channel

woeful pike
#

so you want to find the first channel that matches the if statement?

earnest phoenix
#

yeah

#

but i fixed it

woeful pike
#

use find then, not forEach

#

go look at all the array methods on mdn, you very rarely need for loops or forEach

earnest phoenix
#

already fixed but thanks

#

foreach wanst a good idea anyway ;d

quartz kindle
#

the only way to stop a forEach is to throw an error

split hazel
#

foreach if you do not stop i will have to take drastic measures

earnest phoenix
#

how was it to fusion 2 arrays?

#

oh .concat

quartz kindle
#

concat is slow

earnest phoenix
#

passed like 1 month since i did a question here

earnest phoenix
quartz kindle
#

the spread operator is faster

earnest phoenix
#

the ...?

quartz kindle
#

array = [...array1, ...array2]

earnest phoenix
#

ok

#

thx @quartz kindle but

#

(node:787) UnhandledPromiseRejectionWarning: TypeError: array5 is not iterable

#

what does mean that?

quartz kindle
#

its not a valid array

#

how did you define it?

earnest phoenix
#

let array5 = db.get(leg_${message.author.id});

quartz kindle
#

console log it

#

to see what it is

earnest phoenix
#

ok

#

wait a sec

#

it's null

quartz kindle
#

so theres your answer

earnest phoenix
#

i'll make a if

#

and give it []

#

if null

earnest phoenix
quartz kindle
#

👍

earnest phoenix
#

i knewed that top.gg was the best way to get help

lyric mountain
quartz kindle
#

or null coalescing assignment

earnest phoenix
quartz kindle
#

array5 ??= [array5]

lyric mountain
earnest phoenix
#

^ need node > v16 for it

small tangle
#

C# has it too

lyric mountain
#

yet noone invented a sqrt operator yet

small tangle
#

squirt operator FeelsSmartMan

lyric mountain
#

bonk

small tangle
quartz kindle
#

they could use // for it no?

#

or not

lyric mountain
#

I guess so

quartz kindle
#

thats comments lmao

lyric mountain
#

since pow is **

#

ah true

split hazel
#

i always think squirt when i see sqrt

#

goddamnit

lyric mountain
#

they could use like /*

#

oh wait

quartz kindle
#

also comments lmao

#

sqrt ruined by comment syntax

lyric mountain
#

/*/

quartz kindle
#

really it makes no sense

small tangle
#

just use √ duh

lyric mountain
#

stop bragging abt ur keyboard with sqrt symbol

quartz kindle
#

++, --, ** are all math operators, why the fuck is // a comment

small tangle
#

what i just copy pasted from the ascii table LULW

quartz kindle
#

just make comments use # instead

#

and free the //

wheat mesa
#

But preprocessor directives angeryBOYE

split hazel
#

tim you would singlehandedly make millions of js programs fail

quartz kindle
#

lmao

small tangle
#

Tim, Finisher of JS

split hazel
#

for fucks sake

lyric mountain
#

ok ok, listen, let's use trema for comments

#

¨¨

split hazel
#

i was downloading a huge file on my slow internet and it kept going "network error" and i accidentally clicked cancel

quartz kindle
#

Lol

split hazel
#

this is why i use torrents

split hazel
#

i am downloading intellij idea ultimate to flex my student subscription

lyric mountain
#

jet gang

#

actually, they could make a sick ads punchline with that

#

"Why XXX when you can have a jet!"

small tangle
split hazel
#

yeah i just renewed it too

small tangle
#

cause my email is still valid

split hazel
#

still in school though just higher

#

ffs being an adult is going to be hell

#

not only am i not able to take full advantage of my work income due to salaries being taxed to hell in the uk but i have to manage tons of other things

#

corrupt government

#

#taxtherich

quartz kindle
#

thats why people become pirates

split hazel
#

lol

#

jesus tax rates in sweden are 57.1%

#

how do people live there

novel hollow
#

Traceback (most recent call last):
File "C:\Users\DragonGod\AppData\Local\Programs\Python\Python310\lib\site-packages\diskord\application\command.py", line 424, in sync_application_commands
cmds = await self._state.http.bulk_upsert_guild_commands(
File "C:\Users\DragonGod\AppData\Local\Programs\Python\Python310\lib\site-packages\diskord\http.py", line 365, in request
raise Forbidden(response, data)
diskord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access

what does this mean?

jolly notch
quartz kindle
#

salaries are probably like 4k euros

split hazel
#

lmao

novel hollow
#

uh hello

quartz kindle
#

missing access

earnest phoenix
quartz kindle
#

you tried to access something that you have no access for

jolly notch
wheat mesa
quartz kindle
#

for example a message in a channel that the bot cant use

split hazel
#

i was kind not to include america

jovial imp
#

hi

split hazel
#

some people rather would die than face the medical bills

novel hollow
jolly notch
quartz kindle
jolly notch
split hazel
#

what do you consider better

quartz kindle
#

thats what they say lmao

wheat mesa
#

I don’t know what the nhs is but it’s probably far better than American dogshit

quartz kindle
#

but its likely not true

split hazel
#

if they manage to fix you up thats all that matters lmao

wheat mesa
#

I’m a diabetic and until recently (when they passed a new law in Texas) my family was paying $800 for 1 month of insulin supplies

#

And that’s WITH insurance

quartz kindle
#

jesus fucking

#

christ

wheat mesa
#

Imagine if I was uninsured

#

3k+

#

A month

jolly notch
split hazel
#

that is a fucking scam

wheat mesa
#

For insulin that costs companies $70 per year per patient to make

#

It should be completely illegal

#

To sell insulin at that high of a profit margin

jolly notch
#

Good money though

wheat mesa
#

That’s literally a monopoly

#

Because I can’t live without it

split hazel
#

as long as the economy is thriving they dont care

wheat mesa
#

Literally can’t

wheat mesa
#

They have politicians in their pockets too

quartz kindle
#

america is a corporation and its people are its assets/products

wheat mesa
#

That’s why nothing ever gets done about it

#

It’s ridiculous that people should even have to pay for medicine that they require to live

#

It’s putting a price tag on your life

novel hollow
jolly notch
split hazel
#

and still most people really dont realise how cruel the world is

earnest phoenix
wheat mesa
#

Insulin is only the surface of overpriced medicine

jolly notch
novel hollow
# earnest phoenix What is your error

Traceback (most recent call last):
File "C:\Users\DragonGod\AppData\Local\Programs\Python\Python310\lib\site-packages\diskord\application\command.py", line 424, in sync_application_commands
cmds = await self._state.http.bulk_upsert_guild_commands(
File "C:\Users\DragonGod\AppData\Local\Programs\Python\Python310\lib\site-packages\diskord\http.py", line 365, in request
raise Forbidden(response, data)
diskord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access

wheat mesa
#

People get into 100s of thousands of dollars of debt because they have a heart attack and require surgery and stuff like that

earnest phoenix
#

What exactly are you trying to do

boreal iron
earnest phoenix
#

Cause you clearly don't have the correct permissions to do it

jolly notch
wheat mesa
#

Even if you get saved by the doctors your life is essentially condemned into death by debt

split hazel
novel hollow
earnest phoenix
#

What?

wheat mesa
split hazel
#

and a lot of the time the insurance refuses to pay more

wheat mesa
#

Yeah

#

I suppose this isn’t development related

quartz kindle
#

there are tons of people who beg doctors not to save them, but doctors do it anyway

wheat mesa
#

Should probably move to general

earnest phoenix
#

Why are we talking comas in a dev channel

#

👀

split hazel
#

because people in this chat have more developed brains

novel hollow
# earnest phoenix Why are we talking comas in a dev channel

PS C:\Users\DragonGod\Downloads\Dragon_bot_demon> c:; cd 'c:\Users\DragonGod\Downloads\Dragon_bot_demon'; & 'C:\Users\DragonGod\AppData\Local\Programs\Python\Python310\python.exe' 'c:\Users\DragonGod.vscode\extensions\ms-python.python-2021.11.1422169775\pythonFiles\lib\python\debugpy\launcher' '59266' '--' 'c:\Users\DragonGod\Downloads\Dragon_bot_demon\main.py'
Loaded addrole.py
Loaded ban.py
Loaded giveaway.py
Loaded hackban.py
Loaded kick.py
Loaded mute.py
Loaded muterole.py
Loaded purge.py
Loaded slowmode.py
Loaded unban.py
Loaded unmute.py
Logged in as Dragon Castle#1377!
Traceback (most recent call last):
File "C:\Users\DragonGod\AppData\Local\Programs\Python\Python310\lib\site-packages\diskord\application\command.py", line 424, in sync_application_commands
cmds = await self._state.http.bulk_upsert_guild_commands(
File "C:\Users\DragonGod\AppData\Local\Programs\Python\Python310\lib\site-packages\diskord\http.py", line 365, in request
raise Forbidden(response, data)
diskord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access

trying to do this with slash commands

earnest phoenix
#

So ima assume you don't have the correct scopes then