#development

1 messages ยท Page 1558 of 1

opal plank
#

windows key and search powershell

#

i assume your bots folder is in your desktop?

midnight spoke
#

ye

opal plank
#

then open powershell from the windows key

#

once its open, type cd Desktop

midnight spoke
opal plank
#

then cd <botsFolderName>

#

oh, perfect

#

already there

midnight spoke
#

yep

opal plank
#

now node index.js or whatever .js you named as your main file

#

index.js, main.js, server.js, bot.js

misty sigil
#

wouldn't it be better to run it via pm2

opal plank
#

those are all common names, but it depends on you

#

it would, but running it on terminal is fine too

#

it just wont restart if it crashes

opal plank
#

so now your bot should hopefully be online

midnight spoke
#

when I shutdown my pc it will stop ?

opal plank
#

correct

#

thats precisely why people pay for a hosting VPS, since it stays up 24/7

#

its like a computer they never shut down

tight forum
#

^

midnight spoke
#

I got a Synology - NAS .. Hopefully I will try to host the bot there

#

it doesn't get shutdown only if the The electricity was cut off

opal plank
#

you could use a raspberry pi too

#

but if you're like me and never shutdown your pc, leaving it running is no issue at all

#

bots dont require too many resources, so its basically leaving the pc on idle

midnight spoke
#

Yea a fact

opal plank
#

it of course depends on what you coded your bot to do, but unless you're
on 300+ servers
using presence intents
doing some heravy image generation or stuff of the sort

you shouldnt even notice it running as far as resources are concerned

midnight spoke
#

One told me if your synology nas doesn't get off
I can use docker file and load the command there

tight forum
#

hey mmh i need some help too

#

for perm level

misty sigil
#

Check if the member doesnt have it too

tight forum
tight forum
#

cant remember i guess i tried but didnt work

#

let me try again

delicate zephyr
opal plank
#

also somewhat bad design

#

that return inside a catch block

delicate zephyr
#

yup

midnight spoke
opal plank
#

nope, dont know anything about them

#

also, not only the scope, but also you are returning void if its nothing

#

your options of return for your check() function are true | false | void

#

those types dont match

tight forum
#

then what should i do

earnest phoenix
#

@proven lantern my bot has been up for 24 hours nearly! Thanks for your help yesterday, it helped me much

midnight spoke
modest maple
#

literally use anything which isnt freeโ„ข๏ธ

earnest phoenix
#

wut?

midnight spoke
#

Thats Nice!

earnest phoenix
#

Digital ocean is kinda sketchy with their verification system

#

Yeah, it works like it should

#

Never had downtime

modest maple
#

again, there is no good free host

rigid sandal
#

Ok I get this error when it starts up ReferenceError: prefix is not defined

#

js

#

Its node js using discord js

#

My commands wont work because the prefix is not working

#

lemme check

#

on the main file?

#

ah ok

#

heres mine

#

const fs = require('fs');
const Discord = require('discord.js');
const config = require('./config.json');

#

i got the one for later

#

just not that first one

#

ok

#

thanks

fierce ether
#

if i write ?testing hello? with args.slice(1).join(" ") it returns empty character

mellow kelp
#

wait i just realized voting credits are a thing

#

that's really pog

fair axle
#

in this example max value is 6 ("yardฤฑm")

mellow kelp
#

you can use Object.entries to get key-value pairs and Array.reduce to get the pair with the maximum value

fair axle
#

I'll try

#

what if I sort them and get the first key? @mellow kelp

mellow kelp
#

yeah that also works

fair axle
#

which one is optimized?

mellow kelp
#

i'm not really sure tbh

#

i like Array.reduce because it just leaves one result, but i don't think that affects performance a lot

fair axle
#

I guess I didn't understand the using of reduce in this

quartz kindle
#

reduce should be more efficient i think

#

since you only need the first value, you dont need to sort other values

#

Object.entries(myobj).reduce((a,b) => b[1] > a[1] ? b : a, [,0])

mellow kelp
#

i think it's not necessary to assign a to b, tho

quartz kindle
#

yeah maybe not

fair axle
#

by the way it worked thanks a lot

mellow kelp
#

np

quartz kindle
#

my previous answer had an unnecessary assignment that they pointed out

#

so i edited it

fair axle
#

Oh okey

mellow kelp
#

it's weird how assignments return a value

#

but it's also useful

quartz kindle
#

ye

#

you can do interesting while loops with it

#

its often used in tcp sockets

mellow kelp
#

that's pog

quartz kindle
#

i have a lib that uses it, let me show

mellow kelp
#

yeah those are really useful for while loop assignments

#

they look a bit weird but are useful anywaysgokart_doggo

quartz kindle
#

ye xD

#

one interesting thing i've found about js, is that for loops are actually faster than while loops

mellow kelp
#

wait what

quartz kindle
#

so using while loops pretty much useless now

mellow kelp
#

performance testing is really something huh

brisk gate
quartz kindle
#

returns an array

mellow kelp
#

yea

quartz kindle
#

its not the same as Map.entries()

mellow kelp
#

the one without reduce is Map.entries

#

o

brisk gate
#

Oh, right. My life was lie

lament rock
#

for loops usually only iterate over an InterableIterator while while loops can do things for an indeterminable amount of time unless otherwise specified as an exit condition which can get reached.

quartz kindle
#

yet another diff between Maps and Objects

mellow kelp
#

the virgin Map.entries

brisk gate
#

That's why I always try to use maps

mellow kelp
#

the chad Object.entries

brisk gate
#

For keeping maps

mellow kelp
#

with Map.entries you gotta wrap it around an Array.from

brisk gate
#

Or just for of

delicate zephyr
#

or you can just do

for(let x of y) {}
quartz kindle
#

ye iterators can be looped over in many ways

mellow kelp
#

well yea

#

i mostly use the Array.map function, so i end up using Array.from often

brisk gate
#

I remember at some time people were using nazi airbnb eslint rules which disallowed regular for loops

quartz kindle
#

Lol

delicate zephyr
brisk gate
#

That think was sadist and useless

mellow kelp
#

ah yes, nazi

quartz kindle
#

dafuq

#

thats like anti-performance

#

typical of big companies

#

bloat everywhere

mellow kelp
#
  • no variables with names that contain "jew"
delicate zephyr
#

Tim, we don't question big corpo's we just hold until they scream

quartz kindle
#

buy GME

brisk gate
#

On the contrary, Google's style guides are the best :)

quartz kindle
#

google is okay i guess

#

fuck facebook tho

#

and everything they make

brisk gate
#

Lol, ok

#

You can like the company tech and appreciate their advancements and hate their politics at the same time

#

It's not black and white

fair axle
#

I have a problem. I'm not sure it is about development. I am sending an image in Embed. but the original image and seen image are not the same. First one is the seen image and when I click open original it is the original image

quartz kindle
#

i dont like facebook tech, thats what im saying

mellow kelp
#

i mean

quartz kindle
#

its not about politics lmao, thats secnd plane

mellow kelp
#

facebook made react

quartz kindle
#

exactly

mellow kelp
#

at least that one's good

quartz kindle
#

thats my point

#

react made half the internet slow

brisk gate
#

But it made it more accessable and reusable

fair axle
brisk gate
#

That's an elitists pov

mellow kelp
quartz kindle
#

maybe xd

mellow kelp
quartz kindle
#

why not?

#

looks like a dev issue

#

although i too have no idea wtf

mellow kelp
#

it's about a discord image or something

#

might be like the find-waldo-rickroll thing

fair axle
#

I think I have a theory

#

The data comes from twitch api and the image is the thumbnail of the stream data.

#

and twitch is only changing the image not url

quartz kindle
#

so you're not sending your own image? is it an image url?

fair axle
#

yes

#

I think Discord really have problems about updating messages or whatever

#

Okey I see the problem thanks for your help

quartz kindle
#

i dont think they update it

#

they probably save a snapshot of the image for previewing purposes

#

and that doesnt change unless you edit the message

#

if the image leads to an external url tho, they dont control that url

#

but they do control the preview

fair axle
#

It doesn't matter you delete message and resend it. They just send preview. Because of that it doesn't update and there is no solution of my problem

#

The only solution is dynamic url

delicate zephyr
#

they cache image previews

fair axle
#

as I think

delicate zephyr
#

No, they do, and it's fairly easy to prove this

#

they do it with link embeds too

#

they're cache for 1-2 hours client side and server size afaik

#

so yea, your only solution would be dynamic links

#

because its the only way to bypass the cache

fair axle
#

I was trying to say I agree with you

delicate zephyr
#

ah

#

sorry

fair axle
#

By the way I hate cache

delicate zephyr
#

XD

#

yea

fair axle
#

xd

delicate zephyr
#

We all do

#

The "Disable cache when development console" is open is the mans best friend

fair axle
#

yes it is

quartz kindle
#

you hate cache until you run a service and get flooded by requests

#

:^)

delicate zephyr
#

I mean

#

caching is really nice

#

for production

#

for development

#

holy fuck

quartz kindle
#

xD

modest maple
#

Firefox recently got more agro with caching

#

and i keep forgetting about it

#

so wonder why nothing changes to realise its ff

#

now we got custom cache controls though

quartz kindle
#

๐Ÿ‘

sudden geyser
#

It's easier than running another script.

mellow kelp
quartz kindle
#

wat

mellow kelp
#

i made this thing into an actual package

quartz kindle
#

lmfao

summer torrent
#

thanos js wtf

modest maple
#

reasons to not have eval in every bot:

  • Insecure
  • Hard to setup correctly when clustering
  • pretty easy to fuck something up when testing on the prod bot
mellow kelp
#

isn't it automatically secure when you make it owner-only?

modest maple
#

not really

mellow kelp
#

why pEnSiVe

quartz kindle
#

eval thanos.js in production

modest maple
mellow kelp
#

half the bot files deleted KEKW

lament rock
#

Insecure??? What? If a command that is locked behind specific authentication layers and the users who have effective access are competent enough to not execute potentially destructive operations, why should it be considered insecure?

modest maple
#

You know how many people ive seen add owner only checked then accidentally remove said auth when they're developing stuff

#

wayyyyyyyyyyyyy too many

mellow kelp
#

well what if i never do that

#

heck, what if i never touch the eval.ts file again?

modest maple
#

you can also still eval stuff leading to code changes or breaking things in production

#

just use a test bot ez

mellow kelp
#

i'm not stupid

lament rock
#

Like I mentioned, not everyone is as stupid as the next

quartz kindle
#

you cant use a test bot to inspect caches and memory usage

mellow kelp
#

i guess it depends on the person

#

but most people aren't that stupid

modest maple
#

have you seen the general userbase on discord mmLol

lament rock
#

Peeking into cluster memory usage is also very important to me

quartz kindle
#

ram go brrr

lament rock
#

heap size: 200MB. Snapshot size: 34MB

modest maple
quartz kindle
#

i prefer heap 60mb rss 130mb

modest maple
lament rock
#

Gotta remove in mem guild caches as soon as I get a postgres server set up

#

Then index stuff

modest maple
#

that seems.... Dumb

#

if you need the cache then you should use the cache

quartz kindle
#

guild cache is the single most useful cache

modest maple
#

the whole point of cache is to provide quick access to something you repeatedly use

quartz kindle
#

the most useless cache imo is channels

modest maple
#

generally yeah

#

you can normally do most stuff as a partial id

rigid sandal
#

Is it possible to integrate both libs? discord.js and discord.io?

quartz kindle
#

no

modest maple
#

please dont try

quartz kindle
#

and why

rigid sandal
quartz kindle
#

why

rigid sandal
#

not in use tho

lament rock
#

okay here me out here. You can use both but it is very jank

quartz kindle
#

its been dead for years

rigid sandal
#

really?

quartz kindle
#

yes

rigid sandal
#

Well im still using discord.js

modest maple
#

Cache is a good thing

rigid sandal
#

but how do we show all commands when !help is used

quartz kindle
modest maple
#

if you need the member cache and use it, then well... use it

#

postgres is going to be no where near the speed of cache

rigid sandal
#

cause thats a requirement to get it on top.gg

modest maple
#

and also produce alot of problems in itself

#

like yano, how you handle and protect that data

#

how postgres caches the stuff

#

network latency

#

storage space

quartz kindle
#

caching hot data yes, but the problem is that most of discord data is cold data

#

caching cold data is useless

modest maple
#

cache stagnation or in your case disk stagnation

modest maple
quartz kindle
#

ye

modest maple
#

cuts out about 7 Million users in a instant that dont need caching

quartz kindle
#

i dont cache anything other than guilds

#

and the few users i fetch i delete after 24 hours

modest maple
#

AVC needs both presence and members

rigid sandal
#

how do we get the directory with the commands to fully connect to your main file?

quartz kindle
#

damn rip

modest maple
#

so smart caching is important

rigid sandal
#

because I believe I've got the entire thing connected but it's not wanting to run any commands

modest maple
#

blobpain Otherwise the bot just oofs

lament rock
# modest maple that seems.... Dumb

logic behind it is that it has to be accessed by multiple workers across different machines. Some operations which are essential to my bot's dashboard is more effective to setup a db cache than for the website to open a bunch of socket connections to worker threads

modest maple
#

Okay.... But discord's cache is mostly stateful

#

A cluster only caches what shards it owns (or should atleast)

#

it doesnt need anything else because it will never interact with anything outside of that cache

rigid sandal
#

@quartz kindle lemme open discord on the pc

modest maple
#

secondly if you need a global cache then dont use postgres because you're going to kill your bot, server and DB because postgres was not made to be a cache db

quartz kindle
#

the db is not an issue

lament rock
#

I've already discussed this with multiple people

quartz kindle
#

pretty much any db can do the job successfuly, if you use it correctly

rigid sandal
#

client.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
client.once('ready', () => {
console.log('Ready!');

quartz kindle
#

database design matters much more than the actual database software

modest maple
#

Still just cuz postgres will do it doesnt mean you should mmLol

quartz kindle
#

if you design it well, why not

rigid sandal
#

no

#

thats the portion connecting to the commands directory

modest maple
#

Extra ram usage + cpu usage + disk read writes + being influenced directly by other heavy operations

#

Like you can use postgres

lament rock
#

For context, I'm already using redis and the design decisions I've had to make are horrendous at best. It's also not suited for my use case as I need specific key value lookup which Redis doesn't offer as far as I know

modest maple
#

but its going to be slower than an actual cache system

quartz kindle
modest maple
#

there is also the issue that if your cache doesnt update often enough your db is gonna contain all sorts of dead data

#

that is completely invalid

rigid sandal
#
const Discord = require('discord.js');
const config = require('./config.json');

const client = new Discord.Client();
const prefix = "!"
client.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
client.once('ready', () => {
    console.log('Ready!');
});

client.login('');
client.on('message', message => {
    if (!message.content.startsWith(prefix) || message.author.bot) return;

    const args = message.content.slice(prefix.length).trim().split(/ +/);
    const command = args.shift().toLowerCase();
if (!client.commands.has(command)) return; 

try {
    client.commands.get(command).execute(message, args);
} catch (error) {
    console.error(error);
    message.reply('there was an error trying to execute that command!');
}
    });```
quartz kindle
#

code blocks please

lament rock
#

anything networked is gonna be slower than actual cache

rigid sandal
#

oh whoops

modest maple
#

Yes and disk ops on top make it even slower mmLol

#

your issue can low key be done by setting up a gateway though but meh

lament rock
#

If you're using a high performance SSD, does it really matter

modest maple
#

I mean yeah?

rigid sandal
#

Im using a mini board computer for mine

quartz kindle
modest maple
#

"I wonder if hitting my SSD with hundreds of thousands of hits a second is gonna cause issues"

lament rock
#

The SSD is rated for a high volume of iops

quartz kindle
#

you create a command list but dont put it in the client

rigid sandal
#

@quartz kindle using the if statement?

lament rock
#

Either way, I was gonna use an in mem relational DB

fierce ether
#

how can i slice first word then join the rest?

quartz kindle
#

database softwares use smart internal caching

#

requesting data from the db doesnt necessarily mean disk operations

modest maple
#

Postgres' default setup generally will unless its a perpendicularly hot collection

quartz kindle
#

if your text is not split yet, text.split(" ").slice(1).join(" ")

modest maple
#

and also if you have a very big cache each lookup is also gonna be a log(n) lookup time which can get pretty expensive as it gets bigger

rigid sandal
#

@quartz kindle module.exports = { name: 'ping', description: 'Ping!', execute(message, args) { message.channel.send('Pong.'); }, };

#

this is one command

modest maple
#

Maybe im thing about this in too much of a production way

rigid sandal
#

in a seperate file

quartz kindle
#

the issue is your command list is empty

#

your client.commands is an empty collection

rigid sandal
#

how do i add it without the if statement

#

i dont want to make a mess in it

quartz kindle
#

what if statement, there is no if statement

rigid sandal
#

when i was learning a week ago there was

quartz kindle
#

you dont need an if statement

#

you just need to actually put the commands in there

rigid sandal
#

so id put !ping?

lament rock
#

I wasn't going to be using Postgres' default configuration. Like I mentioned, I'm gonna be indexing specific columns so that lookup times are minimal

rigid sandal
#

or a different format

fierce ether
#

@quartz kindle i tried using args.slice(1).join(" ") but it kept slicing and return empty characters

modest maple
#

cuz its a B-Tree search

quartz kindle
#
commandFiles.forEach(file => {
  let name = file.split(".")[0];
  let command = require(`./commands/${file}`)
  client.commands.set(name, command)
})
#

@rigid sandal

rigid sandal
#

oh is that why they wont work?

quartz kindle
#

yes because you didnt actually load the commands

#

you just made a list of files

rigid sandal
#

lol

quartz kindle
#

you have to take each file, require it and then put it in client.commands

quartz kindle
#

and example text you want to slice

fierce ether
#

im trying ?command suggest and then if i dont write anything else after, it goes blank

quartz kindle
#

arent they log(1)?

#

isnt that what indexes are for? hash tables?

quartz kindle
modest maple
#

SQL systems use B-Tree's on their hash

snow tendon
#

does anyone know some good bot hosting services?

#

cuz mine keeps getting declined for being offline

#

while I sleep

modest maple
#

A index produces a B-Tree where it's order is determined by its Hash

fierce ether
#
switch(args[0]) {

            case "report" : {

            } break

            case "suggest": {
                await client.sendSuggestion(message, client, words, args)
            }
        }```
modest maple
#

Why? Idk they probably have some reason to choose a B-Tree

mellow kelp
modest maple
#

i imagine because using a O(1) solution causes UPDATE queries to become O(n)

dusky sundial
#

I use GalaxyGate, they're pretty cheap for a decent VPS

fierce ether
#
     const suggestion = args.slice(1).join(" ")
    if(!suggestion) return NoInput(words, "suggestion", "suggestion")```
dusky sundial
#

If you don't plan on hosting for a full month, I'd recommend Vultr as you pay per hour, rather than paying the full amount at the start of the month

quartz kindle
modest maple
#

There are different types of indexes though so yeah

#

The defaults though a B-Trees

quartz kindle
#

how would an update query be o(n)?

modest maple
#

It may be different for hashmap based indexes but generally if its modifying the data it requires updating all instance where the data size has changed because it start and end pos will be different than the original

quartz kindle
#

but you dont need to do that

modest maple
#

You do if you're altering it on Disk

#

cache sure

quartz kindle
#

you dont

#

you create a new address location and mark the old one as sweepable

#

and point the index to the new address

modest maple
#

Didnt let me finish my next point blobpain

#

Was getting to that

quartz kindle
#

lol sorry

rigid sandal
#

hey

#

its duping output

modest maple
#

which is why DBs generally go with the delete and re-insert it again approach, which is obviously alot cheaper

rigid sandal
#

why is it doing this?

modest maple
#

Cassandra and Scylla both require this being done explicitly so using UPDATE actually requires an environment variable being set on the DB's runtime

dusky sundial
modest maple
#

all of this is completely ignoring MongoDB btw

rigid sandal
#

no not to my knowledge

modest maple
#

no fucking clue how they work their system

#

cuz the BSON structure is just thisisfine

rigid sandal
quartz kindle
#

but why would one ever do a full resize for an update operation?

rigid sandal
#

i wanna add a caching system for a feature ill be adding

modest maple
quartz kindle
#

i mean, sure, if you reach a size threshold you need to resize, but you dont need to reallocate all entries

modest maple
#

sometimes its cheaper to simply spend the time to re-index over having duplicate data sets

#

only time i can imagine it being reasonable

#

every other time though its easier

quartz kindle
#

also dont dbs keep data in memory for a bit before flushing it to disk?

#

so it has plenty time to optimize disk writes

#

and avoid anything o(n)

modest maple
#

SQL normally does yeah

#

or well buffers it

#

why inserts are so cheap

#

meanwhile with mongo ```
{"hello": "world"} โ†’

\x16\x00\x00\x00 // total document size
\x02 // 0x02 = type String
hello\x00 // field name
\x06\x00\x00\x00world\x00 // field value
\x00 ```

rigid sandal
#

sql is a big help for functions on logging usernames and passwords

quartz kindle
#

mongoose?

#

make sure your schema is correct

rigid sandal
#

Im actually coding a website that will have a signup and login function

modest maple
#

Just noticed mongo limiting collection sizes to u32 ๐Ÿ‘€

quartz kindle
#

mongoose only returns the value if your schema contains the value

rigid sandal
#

TypeError: client.commands.get(...).execute is not a function

quartz kindle
#

lmao

rigid sandal
#

that wasnt there before

quartz kindle
rigid sandal
#

oh

#

is it where server.js is empty?

#

@low orbit thats simliar to the sql script i wrote for storing names

quartz kindle
#

see, your schema doesnt have message and channel in it

#

so you cant access them

modest maple
#

Honeslty their data structure on disk is a lil mad

quartz kindle
#

im happy i never got into mongo

modest maple
#

Mongo is great for small projects tbh

quartz kindle
#

idk, i dont use mongoose/mongo, but required makes more sense

modest maple
#

I have a mongo instance that does all my lil projects dbs

#

Nop

quartz kindle
#

i dont like mongo for small projects

#

because why would you run a full db server application for a small project when you can use sqlite

modest maple
#

Theyve used a fork of mongo for a while dont knoe if they still do

modest maple
#

But sometime nice being able to link projects

quartz kindle
#

ye if you need cross-process synching, then ye

#

im happy with my sqlite and internal sharding

lament rock
#

My senior dev recommended a few in memory relational database I've never heard of such as MonetDB which I might use, but they also highly recommended Postgres for whatever reason. Under normal circumstances, I wouldn't have chosen it since I've never heard of it applied in that scenario, but my senior is considerably smarter than I am in multiple fields.

#

This is why I'm asking multiple people. Just to get a general idea of what I actually want

quartz kindle
#

i've never used postgre, but i always heard good things about postgre

#

from reading a few docs about it, it feels like postgre is the linux of databases

#

incredibly powerful but incredibly complex as well

#

so surely you cant go wrong with postgre

#

as long as you can set it up correctly for your use case

lament rock
#

We'll see

modest maple
#

Ree missing the s off postgres

#

Postgres is incredibly powerful yeah

#

Just unbelievably complex especially caching, in memory tables, allocation, pgsql lang etc...

#

Mastering postgres is like mastering another language

#

Biggest peeve with it though is its incredibly awkard to scale compared to other dbs

#

Or well to be specific nosql dbs like mongo, cassandra etc....

lament rock
#

I was also recommended Apache Ignite

#

Tim and I discussed at an earlier date and he mentioned that he was able to get good performance with an SQL based solution acting as a cache

modest maple
#

Sql is pretty suited to discord type data

#

But equally its not specifically designed by default to be used like a cache

prisma locust
#
$(document).ready(function(){

    var cnt = 2;
    $(".addCF").click(function(){
        $("#westarz").append('<input type="text" name="kod'+cnt+'"> <a href="javascript:void(0);" class="remCF">delete input</a>');
        cnt++;
        
    });

    $("#westarz").on('click','.remCF',function(){
        if (confirm("delete?"))
        {
        $(this).parent().parent().remove();
        }
    });    
  
    
});
    
</script>
           
  <input type="text" name="kod">
<a href="javascript:void(0);" class="addCF">add</a>

Hi, I created a code to create a new input when I click on the add button here, but it didn't work, do you know how to help?

modest maple
#

Though theh have the infa to act like one, better solutions exist now mostly in the realm of nosql

lament rock
#

What seemed non negotiable to give up was both in memory and relational

#

I wanted to try to create my own proprietary solution, but I am no data scientist

modest maple
#

I mean cache in general doesnt really need to be relational

modest maple
#

Becahse its cache, generally its quickly accesable via a single key and is designed to be hit hard and fast

#

Relational designs are for data storage efficency rather than speed of operation

lament rock
#

Well. For my use case, I might need to create relations between two different tables based on a specific query. Although perhaps not so necessary if I don't be stupid when I try to find what guilds a user is in.

modest maple
#

You said this was for your dashboard yeah?

lament rock
#

Also for other worker threads like clusters and some other micro services

modest maple
#

I mean for the dash that can be done all with oauth2

lament rock
#

I know

#

I'm migrating to that

quartz kindle
#

think of the node process itself as a cpu cache/register

#

if you need it more than once in the next 10 seconds, store it there

#

if not, store it in a secondary cache

#

some in memory database

modest maple
#

Cache it all crazylaugh

quartz kindle
#

if you ever need 3 layers of storage

modest maple
#

Das getting a lil extreme

zenith knoll
#

if (message.channel.id != 788598477231620096 || message.channel.id != 795802857046540320 || message.channel.id != 788598399326355457 || message.channel.id != 788598418460639233)

But it goes in for every channel

modest maple
#

Btw timmmm

#

Your Brazilian cor4ect?

#

Or am I thinking of dep

quartz kindle
#

im not brazilian, but i did live in brazil for 10+ years

modest maple
#

Do you speak pr br fluently?

quartz kindle
#

or with the code to run?

quartz kindle
modest maple
#

Can you give a hand understand this guy in my support server blobpain

quartz kindle
#

lmao sure

gritty bolt
#

my code is not working and there are no errors

#

it was working fine 5 minutes ago

zenith knoll
gritty bolt
#

and it doesnt now

zenith knoll
#

well

#

so

#

it will update the json file

#

but it always updates

#

even tho i told it to ONLY run if its not the channel

#

or channel(s)

quartz kindle
zenith knoll
modest maple
#

Why not just use a array

#

I may not be js savvy

#

But a massive block like that is

#

Unhealthy

quartz kindle
#

so you need IF != AND != AND != -> return

gritty bolt
quartz kindle
#

if you want to only allow those channels

zenith knoll
#

ok

#

let me think it over

#

10iq brain cannot mentally think

gritty bolt
lament rock
#

Yikes. Writing to the global const

gritty bolt
#

me?

rigid sandal
#

big question

gritty bolt
#

its a bad habit ik

lament rock
#

Yes

gritty bolt
#

im honestly just trying to get it working

rigid sandal
#

how do i start a nodemon so my bot can restart to the slightest changes

gritty bolt
#

for now

lament rock
#

Never do that for a command. That's a race condition waiting to happen

gritty bolt
#

yeah

#

do you happen to have any ideas as to why it might not be working

rigid sandal
#

I need it perfect lol

gritty bolt
#

it legit did stuff 5 minutes ago

#

i dont get it

lament rock
#

define not working

gritty bolt
#

like

spare goblet
#

Are you getting an error

gritty bolt
#

it does nothing

#

no errors

spare goblet
#

Try logging everything till you get an error lmao

lament rock
#

I can already see plenty of issues

quartz kindle
#

wtf is this if(isNaN(global.time === false))

lament rock
#

if (isNaN(global.time === false))
=== returns a boolean
isNaN accepts a number

#

LOL

gritty bolt
#

oh

#

thats

spare goblet
gritty bolt
#

thats probably it

quartz kindle
#

lmao

gritty bolt
#

wait then why did it work before

#

im so confused now lol

lament rock
#

boolean could be coerced to a number

#

0 and 1 respectively

gritty bolt
#

i think i was trying to do something if it was 0 or 1 and just

#

got stupid?

spare goblet
#

isNaN false would return false lol

quartz kindle
gritty bolt
#

i honestly have no idea

#

what i was doing

#

honestly no idea

lament rock
#

what about true, Tim?

gritty bolt
#

i dont know how it got there

quartz kindle
lament rock
#

oh wait

#

I am blind

quartz kindle
#

yes you're blond

lament rock
#

blonde

spare goblet
#

Blond noises

lament rock
#

r word

gritty bolt
#
            const db = mongoose.connection;
            db.on('error', console.error.bind(console, 'Connection Error:'));
            db.once('open', function() {
                console.log("four");```
this is where the issue is
#

its one of those three lines

quartz kindle
#

what is the issue?

#

and is that inside a command?

gritty bolt
#

yes

#

it is

#

i connect above it fine

lament rock
#

Do you remove the listeners at all

gritty bolt
#

i dont beleive so

quartz kindle
#

its a really bad idea to create listeners inside code that runs more than once

#

every time you run that command, you will have more and more error event listeners

#

when an error happens, it will log 500 times

#

if you used the command 500 times

gritty bolt
#

ok

#

good to know

#

i still dont understand what the issue is in those 3 lines

#

we dont make it to four

#

is that it?

quartz kindle
#

probably because the database is already open

spare goblet
#

I've literally never seen anyone interact with their mongodb like that

urban surge
#

Can anyone help me?

gritty bolt
#

it happens on a fresh start

spare goblet
#

You should have a pool w a connection in your main file

fathom furnace
#

Woww
that's the best course I've ever seen!
thank you so much!

spare goblet
#

Or a single connection in your main file lol

gritty bolt
#

i think I have one in my main file

#

I reconnected there because it wasnt working

spare goblet
#

Then why a-

gritty bolt
#

and magically that worked for a little bit

spare goblet
#

This clownery

gritty bolt
#

its bad

spare goblet
#

Stop looking for bandaid solutions lmao

gritty bolt
#

ik

quartz kindle
gritty bolt
#

ima look back here after this is over and think

#

wth was i on

spare goblet
#

Imo revert back to your old code where you handle your db in your main file lul

#

And fix it from there

#

Cuz what you're doing rn is not scalable

gritty bolt
#

im trying to do that

#

i dont remember how I carried over the connection though

#
setInterval(() => dbCheck.dbCheck(bot), 60000)``` this is how I start it, could I just pass everything through there?
#

like my db connection?

spare goblet
#

erm can you give me more context with your main bot file of what you're doing

#

you should be able to pass it through as a param/arg

#

im not too familiar w mongoose so i have to check the docs a bit tho

gritty bolt
#
reminderAdd.messageReminderAdd(bot, db);``` this is how I start the function
lament rock
#

seems as though you're already passing the state of the DB connection

#

so you shouldn't need to create new ones

gritty bolt
#

i want to pass the db itself

#

so i can do db.once()

#

and preform the action that way instead of opening it 5 million times

#

if i do that tho, its undefined

#

scratch that

#

it just doesnt work no error

lament rock
#

so then you're passing something undefined, so it's a deeper issue than that

gritty bolt
#

no its defined

#

thats why i said scratch that

#

i was scrolled up lol

#
db.once('open', function() {```
this right here is the issue
#

i just dont know how to find out what it is

rigid sandal
#

-bash: line 7: nodemon: command not found

#

its so i can use rs

#

to restart

#

when i make a change

#

but gave me that error

merry vale
#

Hi

#

I get some trouble

#
 at VoiceConnection.authenticateFailed (/app/node_modules/discord.js/src/client/voice/VoiceConnection.js:296:27)
     at /app/node_modules/discord.js/src/client/voice/VoiceConnection.js:324:61
     at Timeout.<anonymous> (/app/node_modules/discord.js/src/client/BaseClient.js:83:7)
    at listOnTimeout (node:internal/timers:556:17)
    at processTimers (node:internal/timers:499:7) {
  [Symbol(code)]: 'VOICE_CONNECTION_TIMEOUT'
}
limpid moth
#

Should I learn how to use a database or use a json file for storing data?

quartz kindle
#

database

#

json is only good for read-only data

#

like config files

limpid moth
#

Is there a suggested guide and database for discord.js?

quartz kindle
#

i recommend learning SQL and using better-sqlite3

#

sqlite is an embedded database, it runs together with your code, doesnt need a dedicated process

#

and learning the SQL language will make it easy to use many other databases out there later if need be

limpid moth
#

Ty

gritty bolt
#

is mongo harder than just standard SQL?

quartz kindle
#

mongo is easier to start with, but harder to configure and use right

gritty bolt
#

yeah that sounds just like my experience lol

trim anvil
#

Recommend using postgreSQL with something like DBeaver to start with

rigid sandal
#

nvm

#

wrong directory

odd stratus
#

I use postgre

limpid moth
#

Should I get the DB browser for SQLite?

quartz kindle
#

its good to help you visualize your data

limpid moth
#

Ok

gritty bolt
#

@quartz kindle im still having the same issue from earlier but i've tried messing around with it for an hour or so,

//MongoDB Connection
mongoose.connect('redacted', {useNewUrlParser: true});
global.db = mongoose.connection;
const db = global.db```
this is my index file,

```js
db.once('open', function() {```
in my other file doesnt work and i dont know any other way to use it across other files without using global
#

like im stuck

pale vessel
#

hmm global

gritty bolt
#

how else do I do it

#

its the only way i've gotten my db into the other file

#

and i dont get why it still doesnt work

lament rock
#

Have both files require a file which exports only an Object and then Object.assign to that Object

gritty bolt
#

so like a file that connects to the db, then export the db object to other files?

lament rock
#

No. You can connect to the db in the main file and then require the file which exports an Object then Object.assign(objectFile, { db: mongoose.connection });

#

You'll have to require the command files after this is done, though as trying to destructure an object which may not have a property yet, might throw an error

gritty bolt
#

well i already have a file where i export variables

#

so would adding it there work?

#

its actually where I store all the schemas and models

#

๐Ÿคฆโ€โ™‚๏ธ

gritty bolt
#

i've used module.exports but to be totally honest I dont get what that means

#

like can I have an example

#

of just like anything using that

lament rock
#

{} is an Object

#

Object.assign(targetObject, properties)
both targetObject and properties is an Object and targetObject is getting the references from properties duplicated into it.

gritty bolt
#

what is .assign doing though?

#

like i dont understand how I can use that now in my context

lament rock
#

example usage

const oldObject = { test: 1 };
const newObject = { something: 2 };
Object.assign(newObject, oldObject); // { test: 1, something: 2 };

Implementation:
index.js

const passthrough = require("./passthrough.js"); // {}

const mongoose = getMongooseDBConnection(); // probably not actually named this. Just for demonstration.
Object.assign(passthrough, { db: mongoose.connection });

require("./add.js"); // notice how this is after the assign.

add.js

const passthrough = require("./passthrough.js");

const { db } = passthrough;

db.doWhatever()
#

This is more efficient than passing the state of something through a function

gritty bolt
#

so the first block is add.js, a seperate file right?

lament rock
#

What? No. The first block is a demonstration. Look at the implementation

gritty bolt
#

oh oh oh

proven lantern
#

why not use the spread operator? const x = {...{test: 1}, something: 2}

gritty bolt
#

i meant passthrough

lament rock
#

spread duplicates the data instead of passing the references afaik

#

not memory efficient

gritty bolt
#
const passthrough = require("./passthrough.js"); // {}```
basically what is this referencing
#

an empty file I make?

lament rock
#

an empty file which only exports {}

gritty bolt
#

okay

#

so literally

#

just nothing in it

#

right?

#

i want to be totally sure

lament rock
#

I mean. You can put stuff in it, but I keep it empty and assign stuff to it

odd stratus
#

Does anyone know any good and reliable websites for hosting websites

lament rock
#

If it's just a static website, Heroku

proven lantern
proven lantern
gritty bolt
#
Error: Cannot find module './Functions/empty.js'```
#
//MongoDB Connection
mongoose.connect('', {useNewUrlParser: true});
Object.assign(empty, { db: mongoose.connection});
require("./reminderAdd.js");```
lament rock
#

Then you're not providing a valid path. require only accepts relative paths to the file you're currently in or absolute paths.

#

not the cwd

gritty bolt
#

ok wait

#

it worked

gritty bolt
#

that was weird

#

alright gonna try it

#

im praying that it works

#

and that i didnt mess it up somehow

lament rock
#

If you didn't resolve that cannot find module error, then it won't

gritty bolt
#

i did

lament rock
#

ok

gritty bolt
#

nothings happening

#

whatsoever

lament rock
#

did you restart after you fixed it

gritty bolt
#

yes

#

nothings loading now

#

which means

#

i messed it up somehow?

lament rock
#

Are you attempting to require that file before the Object.assign through some sort of readdir

gritty bolt
#

no

lament rock
#

show index code

#

Obviously remove credentials

gritty bolt
#

thats index

lament rock
#

Why do you export stuff in the index NotLikeCat

gritty bolt
#

this is what add.js would be

#

oh thats to get the bot to work in other files

lament rock
#

You can use the passthrough for that now Smile

#

You shouldn't require the index

gritty bolt
#

true

lament rock
#

what is line 74

gritty bolt
#

of which

#

index?

lament rock
#

yeah

gritty bolt
#

its to call functions in other files?

#

didnt mean the question mark

#

whoops

#

lol

lament rock
#

did you mean to use the variable you declared at 52

gritty bolt
#

that used to be defined somewhere else

#

as the function

#

so yes i was gonna try and use that

#

assuming i cant?

lament rock
#

assigning to global notLikeCat

gritty bolt
#

oh yeahhh catcherror ignore that hashflushed

#

it doesnt need to be there

lament rock
#

Oh my god

require('events').EventEmitter.prototype._maxListeners = 100;
gritty bolt
#

LOL

#

I FORGOT ABOUT THAT

#

OH GOD

#

i wrote that 3 or 4 years ago

#

back when I used this for something else

#

some random person told me to

#

so I did

#

ยฏ_(ใƒ„)_/ยฏ

#

just gonna delete that real quick

lament rock
#

That random person who told you to do that is retarded

gilded olive
gritty bolt
#

yeahh

#

i need to fix a lot

#

probably why i cant find out which of the 50 million issues is causing everything to go down

lament rock
#

How was "./Functions/reminderAdd.js" being required previously

gritty bolt
#

just at the top of the function

#

as messageReminderAdd

#

as a const

lament rock
#

Ah. I see. Okay. So, what are you using messageReminderAdd for in the index

gritty bolt
#

it's supposed to link to the file where the messageReminderAdd function actually is

#

i pretty much just split up every function into its own file

#

so i didnt have a massive index

lament rock
#

???
The variable messageReminderAdd isn't being used at all in the index. Why is it being required in the first place?

gritty bolt
#
reminderAdd.messageReminderAdd(bot);```
#

should be it

lament rock
#

So. You assign something to the global variable when you could just export it?

gritty bolt
#

i required it before

#
const reminderAdd = require("./Functions/reminderAdd.js");```
lament rock
#

That's not in the index

gritty bolt
#

yeah I thought I had to take it out

#

for the other thing to work

lament rock
#

no???

#

reminderAdd.messageReminderAdd(bot); would currently throw an Error since reminderAdd is undefined

gritty bolt
#

ok

#

readded it

lament rock
#

If you're just trying to pass the state of bot to reminderAdd, you can use the passthrough as well

gritty bolt
#

still nothing happening

#

why do I need the passthrough in the first place though, is there not a simpler way just to pass my db variable into the file?

lament rock
#

No

gritty bolt
#

I can do it with my bot variable

#

so why cant I with that>

lament rock
#

In all honesty, you can but it's not clean.
Would you rather pass the state of something into a function every time you try to call that function, or just have it be a 1 and done and actually have that function have parameters it only needs

gritty bolt
#

obviously i'd rather do the second way

#

but i think im not understanding how to do it

lament rock
#

Put console logs in your add file to see if it's loading properly and if functions are actually being called

gritty bolt
#

i have

#

commands dont load

lament rock
#

Okay. So. What debug info are you getting

gritty bolt
#

i know its not getting past where I hit the Object stuff

lament rock
#

then try console logging before the Object stuff

gritty bolt
#

well i know that works through that

#

all my console.logs work until right there

lament rock
#

Oh my god

bot.on('message', (message) => {
        bot.user.setStatus('online');
        bot.user.setActivity('')
    });
gritty bolt
#

oh yeah

#

thats

#

pointless

lament rock
#

put a console log before and after the mogoose connect

gritty bolt
#
Object.assign(blank, { db: mongoose.connection});

doesnt go past here

#

according to console.logs

#

woah wait

#

i restarted

#

and it just did it?

#

wth

lament rock
gritty bolt
#

ok

#

so we make it into the other file

#

with our db

#
db.once('open', function() {```
#

still does nothing

lament rock
#

Probably because it's already open

gritty bolt
#

so what do I do instead?>

#

remove the open?

lament rock
#

Yeah

gritty bolt
#
TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type function. Received undefined
    at checkListener (events.js:112:11)
    at NativeConnection.once (events.js:435:3)
    at MessageCollector.<anonymous> (C:\Users\Sam\Desktop\RemindMe\Functions\reminderAdd.js:53:16)
    at MessageCollector.emit (events.js:315:20)
    at MessageCollector.EventEmitter.emit (domain.js:467:12)
    at MessageCollector.handleCollect (C:\Users\Sam\Desktop\RemindMe\node_modules\discord.js\src\structures\interfaces\Collector.js:100:12)
    at processTicksAndRejections (internal/process/task_queues.js:93:5) {
  code: 'ERR_INVALID_ARG_TYPE'
}```
#
            db.once(function() {```
lament rock
#

You don't need the once

#

you don't need that function if the db is already open

gritty bolt
#

what do I use instead

lament rock
#

nothing

gritty bolt
#

so just

#

straight in?

lament rock
#

just do the code that's inside that function

gritty bolt
#

ok so it works

#

i'll come crying back if I have more issues

#

thanks so much

lament rock
#

Preferably don't cry about it

gritty bolt
#

yeah

#

i'll uh

#

sob to myself

#

then come

earnest phoenix
#

can someone tell me about context and pass context

sudden geyser
#

Can you explain your issue? I don't know what you mean by context and pass context, so explaining may help.

earnest phoenix
#

i want to know what is context

#

๐Ÿ˜

sudden geyser
#

Yes, but context in what context? Variables? Scopes? Language use?

earnest phoenix
#

variables

sudden geyser
#

Context is broad, so the definition of context may suit you. Sometimes, a variable's context may mean the value / what it currently represents, like a user.

earnest phoenix
#

oh thanks all

lament rock
#

Variables can be block scoped which means they're limited to a specific context. This means that you cannot use it outside of that scope

earnest phoenix
#

tysm

gritty bolt
#

@lament rock it works btw

#

thanks again

earnest phoenix
#

a context class in a library is quite literally a textbook definition of the word context

it couples variables together in a single class, ergo context

gritty bolt
#

i can sleep happily now

#

๐Ÿ™‚

tribal siren
#

bruh

gilded olive
#

iirc that is outdated code and you don't need to worry about that.

earnest phoenix
#

anyone here knows how to fetch data from a tuple list?

placid iron
#

What

earnest phoenix
#

hello im need of help

#

currently im hosting a lavalink server but is not using the correct port why?

misty sigil
#

can i see your config @earnest phoenix

earnest phoenix
#

which one?

misty sigil
#

the lavalink one

earnest phoenix
#

oh yes

lyric mountain
#

Guys, the MANAGE_CHANNEL permission includes MANAGE_PERMISSIONS, right?

misty sigil
#

it'll be listening on 2333 then

#

you've gotta change it

earnest phoenix
earnest phoenix
#

lavalink start up with 8080

#

so i change it to 8080? right @misty sigil

lyric mountain
#

Like, for changing channel permissions

earnest phoenix
#

it doesn't

lyric mountain
#

Damn, I'll have more stuff to solve then

#

Like, I have a lock/unlock commands

#

But I can't lock the channel if the bot doesn't have manage_perms perm

#

If only the logger threw any error at all

earnest phoenix
#

this i what i get it

#

Bro why
commands.has_permissions(manage_server=True)
Not working ?

misty sigil
#

Thatโ€™s unauthorised @earnest phoenix

coral meadow
#

how can i turn a user ID into an avatar URL?

pale vessel
#

you need the avatar hash

coral meadow
#

how can i get that?

pale vessel
#

from the user object

coral meadow
#

i have the user object, because i can get the username of it and everything

#

but it cant get the avatarURL

earnest phoenix
#

im getting sleepy on no

earnest phoenix
#

๐Ÿฅบ

coral meadow
#

i have the user object, but when i try to turn it into an avatar url it says nothing in console and doesn't even send the message

coral meadow
earnest phoenix
placid iron
#

@earnest phoenix it's manage guild

#

Bro

earnest phoenix
#

Oh

#

๐Ÿ˜‚

placid iron
#

Read the docks

earnest phoenix
#

Thanks

placid iron
#

Np

coral meadow
#

dbl.getUser(vote.user).then(user => {})

pale vessel
#

bruh

#

Log the user

coral meadow
#

k

placid iron
#

Loggers

pale vessel
#

You'll see the avatar property

coral meadow
#

hm

earnest phoenix
#

i dont think i will be able to setup this today ugh

coral meadow
#

it doesnt even detect a vote anymore

pale vessel
#

Use https://cdn.discordapp.com/avatars/<user id>/<avatar hash>.png?size=<size>

earnest phoenix
#

Is node.js better than python ?

coral meadow
#

i had it working earlier

earnest phoenix
#

๐Ÿฅบ

earnest phoenix
mellow kelp
#

"how to start a civil war in one step"

coral meadow
summer torrent
earnest phoenix
#

every language excels at something but falls flat in something else

coral meadow
#

LOL

placid iron
#

Bro

#

Binary is the best

earnest phoenix
#

"is x better than y" is very dependent on your use case

placid iron
#

No cap

pale vessel
#

Go away

mellow kelp
#

real programmers use a pen to physically write code into their hard drive

placid iron
#

Hmm

earnest phoenix
#

punch card programming

coral meadow
#

AAAAAAAA

#

please

mellow kelp
#

i just realized intellij looks a lot nicer now

coral meadow
#

just

#

leave

solemn latch
#

Pls no emoji spam

earnest phoenix
#

@misty sigil u still there?

#

god i love designing apps

#

smexy

pale vessel
#

pog invite url

earnest phoenix
#

yes it's my secret hentai server

summer torrent
#

๐Ÿ˜ณ

pale vessel
normal girder
#

Hi, all! I have a question about bot submission: do I have to provide a link to my bot's code?

earnest phoenix
#

no

#

doesn't matter if your bot is open source or closed source

#

as long as it isn't a carbon copy of another bot

normal girder
#

It's my own bot, not a copy. Thank you. ๐Ÿ™‚

#

Also, on the "Bot Edit" page on top.gg, there are some numbers listed in grey in the "Other owners of this bot" and "Servers this bot is in" fields. Are those numbers random, or pre-populated based on some information?

vocal oyster
#

placeholders

#

just showing you the proper format

normal girder
#

Ok, thank you! ^_^

rustic nova
#

no clue, what's the error maybe

earnest phoenix
#

There are so many redundant things. Why are you assigning userAvatar but not using it? Is user even defined? str(user) str() there is kinda useless. Also, there's a shortcut for ctx.message.author which is ctx.author

earnest phoenix
# rustic nova no clue, what's the error maybe

line 94, in wrapped raise CommandInvokeError(exc) from exc discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Expected discord.Colour, int, or Embed.Empty but received type instead.

#

You need to pass either an instance of discord.Colour, int or Embed.Empty, not a class type to the color kwarg as the error says

earnest phoenix
#

@earnest phoenix bro bro

#

@earnest phoenix

#

i am so happy

#

yeah

#

i had copied the code

#

and it worked that time

#

but stoppped working

#

now i got it

gilded olive
#

What you posted there would never work

earnest phoenix
#

and error gone

#

i am actually learning it yeah

#

๐Ÿ˜

earnest phoenix
#

๐Ÿ˜ญ

#

I was just saying what the error says, but np

uncut river
#

how can i use a custom font for styling my page