#development

1 messages · Page 1053 of 1

mental oracle
#

I could just say

if (content.length == 1) {
    sendSans(message.channel, "give me more than one character, lazy bones!");
}
#

but

#

instead

#

I did a bunch of regex

#

to make case-specific errors

#

that people wouldn't normally do

#

since the word "character" would typically include emojis, letters, unicode characters

#

but, its sans

#

so I gotta be really specific

gilded ice
#

Omg

mental oracle
#

lol

#

I'll add a .fight command to fight monsters and stuff

gilded ice
#

I'll probably end up doing the same for my bot

#

Really specific

mental oracle
#

ah

#

it takes a bit of extra work but

#

it just puts your bot at a bit of an edge

#

over other ones lol

gilded ice
#

How many commands?

#

Also yeah

mental oracle
#

idk exactly how many but

#

I've got a .drumroll command

#

which will join your vc

#

and play mus_rimshot.ogg

gilded ice
#

O-

mental oracle
#

also, a .playall command

#

which will play the entire undertale ost

#

one by one

#

and .playrandom which will play a random track from the undertale ost

gilded ice
#

Loop?

subtle osprey
#

Do you know frontend, backend and data shit?
@gilded ice idk anything about that :(

mental oracle
#

yep I've got loop

#

.loop

#

and .disconnect

#

I've also got a TON of aliases

#

for each command

subtle osprey
#

lol

gilded ice
#

@subtle osprey okay so what you wanna learn is react, HTML and how to use and link your database to your bot and website

subtle osprey
#

you loop the playing song or the all songs in queue?

gilded ice
#

@JustAPie okay so what you wanna learn is react, HTML and how to use and link your database to your bot and website

#

Shit double sent

mental oracle
#

just the current song, I haven't even implemented a proper queue yet, but it wouldn't be hard to make

gilded ice
#

Queue ez

mental oracle
#

"that's a skele-ton!"

subtle osprey
#

queue ez

mental oracle
#

yeah

#

just make an array

gilded ice
#

Omg I'm dead

mental oracle
#

and have it delete the first item from the array when its done playing

gilded ice
#

That's so bad

#

And funi

#

@mental oracle missed your queue construct

mental oracle
#

huh

subtle osprey
#

and have it delete the first item from the array when its done playing
@mental oracle well that thing actually make it hard to loop the queue

#

@mental oracle missed your queue construct
@gilded ice we just need to push data to the queue

gilded ice
#

Queue loop hard, song loop ez

mental oracle
#

I'll try to do it rn lol

gilded ice
#

Queue is a map of the guild ID and the server queue

#

The server queue is an array holding the queue construct

clever vector
#

Hello guys my bot cant add something under the text

gilded ice
#

Epic

subtle osprey
#

wdym?

clever vector
#

like the support channel link

#

and

#

Invite

mental oracle
#

queue looping doesnt sound that hard

gilded ice
#

.addField('gay', text)

clever vector
#

no

#

i want

#

@gilded ice Can you come my test server?

#

the bot test

gilded ice
#

Mkay

subtle osprey
#

queue looping doesnt sound that hard
@mental oracle so, do u have anything to loop the queue but dont have to delete the first element?

gilded ice
#

There's probably a way to push it to the back

subtle osprey
#

is to delete it and push the finished song to the end of the queue

#

but that's not effective

delicate shore
#

Ol

subtle osprey
#

i will tell u why

#

each time u push the song to the end of the queue

#

but if there anyone add anothe song

mental oracle
#
var vc = vcs[voiceChannel.id];

if (vc.looping = true) { 
    vc.dispatcher.removeAllListeners("finish");
    vc.dispatcher.on("finish", () => {
        if (vc.queuePos == vc.queue.length) {
            vc.queuePos = 0;
        }
        if (vc.queue.length > 1) {
            vc.queuePos = vc.queue + 1;
            playAudio(voiceChannel, vc.queue[vc.queuePos]);
        }
    }
}
gilded ice
#

serverQueue.songs.pop()?

mental oracle
#

thats my pseudocode

subtle osprey
#

that song will be at the back of the queue

#

so when loop the queue

#

it won't loop the queue by the wanted pattern

gilded ice
#

Whats your db @mental oracle?

mental oracle
#

I just have a dictionary

gilded ice
#

What

mental oracle
#
var vcs = {};

//when join vc for the first time
vcs[voiceChannel.id] = vcs[voiceChannel.id] || {};
vcs[voiceChannel.id].connection = connection;
vcs[voiceChannel.id].dispatcher = dispatcher;
vcs[voiceChannel.id].sound = sound;
vcs[voiceChannel.id].looping = vcs[voiceChannel.id].looping || false;
vcs[voiceChannel.id].leave = leave;
#

thats it rn

subtle osprey
#

actually rythm bot can only loop song

#

not the queue

earnest phoenix
#

how do I make a discord bot.

mental oracle
#

I make a dictionary for each vc

#

just to make things easier

stiff pond
#

Lmao it won’t let me get mine

#

I’ve been trying to get another bot

mental oracle
#

I'll add queue looping later

#

I want to focus on more functionality than small things like that for now

stiff pond
#

I’ve been trying add one but I just gave up

#

I just made an severe btw

autumn dust
#

who can send simple discord bot script

golden condor
#

Do it yourself

autumn dust
#

no

#

plz

golden condor
#

Y not

autumn dust
#

pls

earnest phoenix
delicate shore
#

I am happy

golden condor
#

Just look it up on YouTube or something

delicate shore
#

90 servers

#

My dream is about to be true

earnest phoenix
#

:PG_pikachuuwu:
@earnest phoenix can you send this emoji's link?

#

Umm it's in my server

earnest phoenix
#

:p

tulip ledge
#
                          partyDisplay = "";
                          accepted.forEach(x => {
                            players.forEach(p => {
                              if(!players.includes(x)) partyDisplay += `**${client.users.cache.get(x).username}** 💀 DEAD\n`;
                              else partyDisplay += `**${client.users.cache.get(p.userid).username}** ♥️ ${p.health}/${p.maxhealth} HP\n`;
                            })
                          })

I am confused this makes it display like this:

golden condor
#

Why do you need to check that

#

You already did players.forEach

tulip ledge
#

Because players has the people that are alive

#

And accepted has all the players

plucky harness
#

my postgressql is only listening on ipv6 i.r tcp6 not tcp/ipv4 help plz

#

Help

pale vessel
#

what's inside accepted?

plucky harness
#

Wdym?

restive furnace
#

dont. do. 2 for each loops ok

#

rather do 2 for loops

#

okM

remote yacht
#
let x = 0;

for (; x < accepted.length ;) {
  //do something
  x++;
};```
pale vessel
#

wtf

quartz kindle
#

lmao

tawny lava
#

why

digital ibex
#

helo

#

does anyone know how I can make the text go up instead of down?

#

but i want it to go 🆙

#

instead of down

quartz kindle
#

are you using flexboxes?

digital ibex
#

im not

quartz kindle
#

maybe you should

digital ibex
#

oh

#

how would i do it with that?

tulip ledge
#

Tim the dungeons are fully working 😄

quartz kindle
#

nice

#

@digital ibex ```css
display: flex;
flex-direction: column-reverse;

digital ibex
#

oh ok

quartz kindle
#

or ```css
display: flex;
flex-direction: column;
justify-content: flex-end;

#

depending on how you want to order the items

digital ibex
#

the first one doesn't work, this is what i donejs msgElement.style.display = 'flex'; msgElement.style.flexDirection = 'column-reverse';

#

i'll try the second

quartz kindle
#

this css should be in the container

#

the box where the messages are in

digital ibex
#

o ok

quartz kindle
#

not the messages themselves

digital ibex
#

quick question

tulip ledge
digital ibex
#

im doing it like this, ```js
const msgElement = document.createElement('div');

quartz kindle
#

lmao woo

tulip ledge
#

It works wiyth up to 4 players

quartz kindle
#

the wrapping happens when you add the element to the parent

tulip ledge
#

Well I haven't tested it with 4 yet only with 3 players

digital ibex
#

oh

#

wait im confused now

gilded ice
#

H e y

digital ibex
#

oh wait

#

i got it

quartz kindle
#

how do you add the message to display it?

tulip ledge
#

who are you talking to?

quartz kindle
#

lost

tulip ledge
#

ah

quartz kindle
#

but seems he got it already

digital ibex
#

yeah, for the background colour

#

i just done msgelemnet.styel.backgrun

quartz kindle
#

elemnet styel backgrun
10/10

digital ibex
#

now its movign the 'Send Message' and the input bar down with it?

#

thank

#

how can i make the send message and the input bar stay in one place?

quartz kindle
#

the flexbox controls everything inside it the same way. if you want the send message bar to be unnaffected, you need to move it out of the flexbox

digital ibex
#

o ok

quartz kindle
#

for example
<send message>
<messages>
<msg>
<msg>
</messages>

honest perch
#

i just make a form that sends a post request

digital ibex
#

ook

honest perch
#

and send it from server side

digital ibex
#

thats smol brain

quartz kindle
#

thats not the point tho

digital ibex
#

you've got to refresh the browser everytime

quartz kindle
#

i mean, this is just user interface

#

doesnt matter where or how the messages come from

honest perch
#

what is the user making

digital ibex
#

its also slow though, you're better off just making ajax requests then

quartz kindle
#

if you want a live chat app, use websockets

honest perch
digital ibex
#

yeah, i am

honest perch
#

is decent

quartz kindle
#

most browsers have built in sockets

digital ibex
#

everything works, but im just trying to make it look nice now

honest perch
quartz kindle
#

make it

pale vessel
#

try harder

#

args._[1]?

digital ibex
#

tim, do u know how i can make it so u can press enter? bc u've got to press the green button

pale vessel
#

use JavaScript

quartz kindle
#

minimist is js lol

gilded ice
#

Well

digital ibex
#

wdym?

quartz kindle
#

on which line?

gilded ice
#

Did you r e a d the error?

quartz kindle
#

show the full error

gilded ice
#

Stacc

#

Also hi Tim I'm retarded

quartz kindle
#

whats mute.js line 12?

digital ibex
#

u just need to show l12

gilded ice
#

I would tell you to use aa!bin but it's not verified yet

quartz kindle
#

of mute.js?

gilded ice
#

Send mute.js

lusty quest
#

i would guess this is the errorif (user.roles.cache.some((r) => r.name === args._[1])) {

quartz kindle
#

users have no roles

#

members do

#

member and user are different things

#

yes, you're getting it as a user

lusty quest
#

your user holds the user object not the member object

quartz kindle
#

you need to get it as a member

#

message.mentions.members.first()

gilded ice
#

members

lusty quest
#

members not member

gilded ice
#

Idk if you're trolling

lusty quest
#

the code where you give the role?

quartz kindle
#

you're not picking a role

#

var role = message.guild.roles.cache.some((r) => r.name === args._[1]);

#

this is for checking if a role exists

#

not for selecting a role

#

to select a role its ...cache.find(...)

remote yacht
#

why do people use some

#

just put a if statement

#

if .some() returns a boolean

quartz kindle
#

thats what hes doing

restive furnace
#

why args._[num]

#

why not args[num]

#

or wut

quartz kindle
#

he said hes using minimist

#

its a command line options/arguments parser

lusty quest
#

wait this exist? and i made a stupid workaround

gilded ice
#

Stupid workaround for?

lusty quest
#

the stuff minimist does

gilded ice
#

uninstall?

dusty onyx
#

hai quick tiny question, if i had a list list = ["a", "b", "c"], and i wanted to check if any of the strings in that list are in a message sent, how would i phrase that?

lusty quest
#

i think message.includes(list) could work

dusty onyx
#

oooh that sounds good

slender thistle
#

One way of doing it is using any on [(x in message.content) for x in my_list]

#

Are we talking Python here?

dusty onyx
#

yea

lusty quest
#

looks like js

#

ohh then my way wont work

dusty onyx
#

oh is that js :(

#

ah fair enough

slender thistle
#

message.content.includes is JS

dusty onyx
#

i used a for statement previously for s in ["a", "b", "c"]: if s in message.content: but that ended up making messages send for each item in the list lol

slender thistle
#

yeah my method might work

#
>>> content = "EEEE a a e"
>>> l = ['a', 'b', 'c']
>>> [(x in content) for x in l]
[True, False, False]
dusty onyx
#

oki :0 sorry at first galnce i thout it was the same as what i'd had

delicate shore
#

how bot does this?

slender thistle
#
>>> result = [(x in content) for x in l]
>>> result
[True, False, False]
>>> any(result)
quartz kindle
#

the includes solution for js wouldnt work that way

#

you'd need to use .some()

lusty quest
#

yea just realized it needs a sting

quartz kindle
#

a sting to sting your enemies with

#

:^)

delicate shore
#

how bot do this

quartz kindle
#

do what?

#

send random messages?

delicate shore
#

yes

#

with my name

#

dad bot does it

quartz kindle
#

oh

#

thats a webhook

delicate shore
#

if i ping someone then with their name

#

o

#

how to tho

quartz kindle
delicate shore
#

oh

#

it's easy

grizzled raven
#

well how the table

rigid maple
#

How do I make a smute that does not even go to reboot

#

pls ticket me

digital ibex
#

wot

lusty quest
#

@rigid maple use a role for muting users. also store the userid of muted users in best case together with a timestamp for automatic unmuting

#

as datastorage use a Database

rigid maple
#

can you throw a sample code

#

@lusty quest

lusty quest
#

language?

rigid maple
#

Turkish

lusty quest
#

and what database?

#

i mean programing language

summer torrent
#

bruh

rigid maple
#

I haven't set up a database since I will use it for my public bot

#

discord.js

lusty quest
#

without any type of persistent storage it makes no sense

summer torrent
#

create a cron job for checking mutes which date same with current date

digital ibex
#

quckk question

rigid maple
#

create a cron job for checking mutes which date same with current date
@summer torrent I couldn't understand because I used translation 😦

summer torrent
#

¯_(ツ)_/¯

digital ibex
#

i've got this: css input :hover { cursor: not-allowed !important; } when i hover over the input, it doesn't change the cursor, any ideas?

#

css ^

pallid zinc
#

Try pointer sir
I mean
cursor: pointer;

peak venture
#

I'm trying to collect multiple rows and put them in a new Array i can use later.
My attempt is to do it like this but the dbPlayerData is not containing any information after this point in the logs.

     let dbPlayerData = [];
      db.query(`SELECT * FROM playerdata WHERE account_id = ${b}`, function(err, rows) {
        if(err) throw err;
        if(rows) {
          rows.forEach(function(item){
            dbPlayerData.push(item)
          })
        }
      })```

Anyone an idea what i did wrong?
gilded ice
#

Which db is that

peak venture
#

mysql

gilded ice
#

oof

lusty quest
#

use a for loop

peak venture
#

for loop had the same output though

lusty quest
#

ye but for some reason i had the same issue with mysql

#

and with a for loop you can use rows[0],rows[1]....

#

this worked for me

lyric mountain
peak venture
#

@lyric mountain to build a new Array to use later?

lyric mountain
#

why not just unload the rows inside the array?

lusty quest
#

if i think about it it makes no sense, since the db already returns a array

lyric mountain
#

yep

#

that's what I'm saying

peak venture
#

@lusty quest

    let dbPlayerData = []
    db.query(`SELECT * FROM playerdata WHERE account_id = ${b}`, function(err, rows) {
      if(err) throw err;
      for(let i = 0; i< rows.length; i++) {
        dbPlayerData.push(rows[i])
      }
    })```
lyric mountain
#

no

lusty quest
#

this makes no sense

gilded ice
#

Mmm learning time
🍿

lusty quest
#

mysql returns a array

lyric mountain
#

dbPlayerData = rows;

#

the loop is completely unnecessary

earnest phoenix
#

what do we do to show badges

peak venture
#

👌 question though; how come it doesnt log like that?

earnest phoenix
#

message.author.?

lusty quest
#

its like getting a box empty it and put the stuff back into the box

gilded ice
#

@earnest phoenix flags

earnest phoenix
#

@earnest phoenix message.author.flags.toArray()

lyric mountain
#

👌 question though; how come it doesnt log like that?
@peak venture because ur sql is broken maybe?

lusty quest
#

@peak venture blame the node console parsing for it

earnest phoenix
#

oh thanks

peak venture
#

🤔

lusty quest
#

it shows rawDataPackage or something like this right?

quartz kindle
#

keep in mind that the query returns a callback

lyric mountain
#

if it shows nothing, maybe ur query ain't returning any value

lusty quest
#

got me confused first time too until i found a old stackoverflow post about it

quartz kindle
#

the value returned is only available inside the callback, not outside, because by the time the callback arrives, any code outside is already long gone

peak venture
#

^

lyric mountain
#

^ that too

peak venture
#

That's basically what i see indeed

lyric mountain
#

so await it

peak venture
#

can i await this somehow?

lusty quest
#

yes

quartz kindle
#

you can wrap it into a promise

peak venture
#

dejavu

#

think i asked this long before also xD

quartz kindle
#
await new Promise(resolve => {
  ...query(..., result => {
    resolve(result)
  })
})
lyric mountain
#

you can also handle all the processing inside the callback

#

if you don't want to use await

peak venture
#

@quartz kindle resolve(dbPlayerData) in that case?

lusty quest
#

you can use util for enabling promises for mysql

earnest phoenix
#

@earnest phoenix writes undefined

lusty quest
#
const util = require('util');
const query = util.promisify(connection.query).bind(connection);
#
 const data = await query(`SELECT `+table+` FROM Serverconfig.config WHERE serverid = ${database}`)
```then you can do this
earnest phoenix
#

@earnest phoenix v11?

lusty quest
#

(i had it wrapped inside a function)

earnest phoenix
#

yes

#

So..

#

you need to on discord.js v12 to use it

#

¯\_(ツ)_/¯

quartz kindle
#

@peak venture you can chose what to resolve. if you resolve rows, you can directly do dbPlayerData = await new Promise(...)

earnest phoenix
#

doesn't it happen in v11

summer torrent
#

user flags is in 12

plucky harness
#

Is there anyone who uses postgresql database here?

earnest phoenix
#

ok

peak venture
#
    let dbPlayerData = []
    dbPlayerData = await new Promise(resolve => {
      db.query(`SELECT * FROM playerdata WHERE account_id = ${b}`, function(err, rows) {
        if(err) throw err;
        rows
        resolve(rows)
      })
    })```
Would be the thing the most likely @quartz kindle
plucky harness
#

My postgressql is only listening on tcp6 not on tcp.

lusty quest
#

@plucky harness did you got something like ufw running?

plucky harness
#

Meaning only ipv6 and not ipv4

#

No

quartz kindle
#

you dont need to define dbPlayerData separately

plucky harness
#

It disabled

quartz kindle
#

and you dont need that rows doing nothing in the middle

peak venture
#

just let dbPlayerData = await new Promise(....

quartz kindle
#

yes

peak venture
#

👌

lusty quest
#

@plucky harness did you bound any ip to your db?

plucky harness
#

Just *

lusty quest
#

ok

plucky harness
#

Local address you mean right?

lusty quest
#

dies netstat -a -n | findstr [Yourport] return something?

plucky harness
#

It returns only

#

tcp6

#

Postgresql

#

::1/my port

lusty quest
#

hmm start postgres with -h parameter

still merlin
#

I get a error

  `Here is ${user1}'s avatar. ${message.user1.displayAvatarURL()}`
                                                    ^

TypeError: Cannot read property 'displayAvatarURL' of undefined``` but it works on my code above
```js
 `Here is your avatar ${
            message.author
          }. ${message.author.displayAvatarURL()}`
        );```
lusty quest
#

with this you can force to use ipv4

plucky harness
#

sudo service postgresql start -h?

lusty quest
#

ohh you run it as service.

plucky harness
#

Yea

#

Am i not supposed to?

lusty quest
#

no its fine

summer torrent
#

@still merlin message.user1 is not a thing

lusty quest
#

does sudo service postgresql status return any error?

still merlin
#

I defined .user1 though

plucky harness
#

I didn't even change anything. I installed postgresql and it's only accepting tcp6. On my port

#

Idk what's wrong

misty sigil
#

then it can be user1 only

still merlin
#

o

lusty quest
#

i never used postgress bcs it can be a pain in the ass to configure

plucky harness
#

What do you use

lusty quest
#

rn MongoDB used before it Mysql

plucky harness
#

Mongo db us hard 8 think

lusty quest
#

also a last resort would be installing docker and run postgress in a docker container

plucky harness
#

With sql u just execute sql commands

#

Oh

#

Which mysql you use?

#

Aiomysql

lusty quest
#

? i switched entirely to Mongo

plucky harness
#

Oh

lusty quest
#

but before just mysql

plucky harness
#

I c

lusty quest
#

Mongo is not this hard if you get into it. i like the ability for horizontal scaling

plucky harness
#

Am figuring out and still haven't found a solution for whole day

#

Yeah I'll look into it

lusty quest
#

if you want to use Postgres install docker and run a postgres container

#

its probably way faster

quartz kindle
#

could also settle for sqlite if you dont need an actual server

lusty quest
#

had initially also issues with installing MongoDB. after a hour i was just fuck it i install docker

earnest phoenix
#

waiting for appproval day 2

lusty quest
#

since then it works like a charm

plucky harness
#

Is sqllite good for bots with big servers

lusty quest
#

not really

misty sigil
#

is mongo good?

quartz kindle
#

depends on what your use case is

plucky harness
#

That's why i don't want to use sqllite

quartz kindle
#

sqlite works very well for me

lusty quest
#

if you store only a few things its fine

plucky harness
#

I store lot of things

lusty quest
#

if you store more complex stuff get a external DB

quartz kindle
#

people tend to underestimate sqlite

plucky harness
#

aiosqlite?

slender thistle
#

Depending on how it's handled

lusty quest
#

i started with Enmap but ran into the issue that enmap needed 1GB ram for "only" storing a little bit of data for 8 servers

plucky harness
#

Shivaco, any idea why my postgressql is only listening on tcp6 ipv6

quartz kindle
#

idk which sqlite libs there are for python, since i use js

slender thistle
#

sqlite3 and aiosqlite

#

aiosqlite apparently only pretending to be async or something, don't remember what was wrong with it

lusty quest
#

@plucky harness like i said try it with docker, i dont know many here that use Postgress

plucky harness
#

Alright I'll try with docker

quartz kindle
#

better-sqlite3 for node.js kinda proves that sqlite is better sync than async

#

the author has a whole explanation about it

plucky harness
#

My sqllite3 is like this

#

Database is locked

#

Because i store too many things in the database

quartz kindle
#

if you need write performance, use WAL mode

lusty quest
#

maybe you store them inefficent

quartz kindle
#

and disable synchronous queries

plucky harness
#

Yeah synchronous writing is problem

#

That's why switching to async version

digital ibex
#

so uh, does anyone know how to make the cursor thing work?

#
   input :hover {
      cursor: not-allowed !important;
   }``` ^
#

it doesn't change the cursor when u hover over it btw

quartz kindle
#

the sync/async is not the problem. you need to toggle the synchronous option in sqlite itself

slender thistle
#

I'm just fine with mongodb and the way data is stored so shrug

misty sigil
#

same shiv

quartz kindle
#

the library that runs sqlite should be sync, the synchronous option in sqlite itself should be set to off via a pragma command

#

although when running in WAL mode, setting synchronous to normal is also fine

peak venture
#

How come that as soon as i parse my data into a function the time(ms) turns into a date in the function?

quartz kindle
#

@peak venture you need to show code

peak venture
#
    //console.log(`Controller: ${dbPlayerData}`) // [object Object], [object Object] etc etc
    
    let apiData = await CollectPlayerShips(client, aNew, a, b, c, cache, start, dbPlayerData)```
plucky harness
#

Maybe it's because i open database on every command and close it

peak venture
#

and then in CollectPlayerShips i console.log(dbPlayerData)

quartz kindle
#

if you log bla ${obj}

#

the object gets stringified

#

the same as doing obj.toString()

tulip ledge
#

Tim. Can you DM me 2 lines for your boss?

#

Like 2 lines your boss should say before the battle starts

earnest phoenix
#

please approved my new bot

tulip ledge
#

Just wait

#

Takes 2-3 weeks

quartz kindle
#

huehuehuehuehuehuehuehuehe
uvuvwevwevwe onyetenyevwe ugwemubwem ossas
@tulip ledge

tulip ledge
#

Ok lmao

earnest phoenix
#

Takes 2-3 weeks
@tulip ledge my bot is approved 1 day

quartz kindle
#

long time ago?

tulip ledge
#

Oh and a type for your boss you can choose between

  • None
  • Undead
  • Dragon
  • Cube
  • Spider
    And Ender
    (Certain enchants deal more damage depending on the type)
quartz kindle
#

whats the strongest lmao

tulip ledge
#

Well it's not really strongest

peak venture
#

@quartz kindle i understand that blabaa.toString() part however i don't get why i dont see all the [object object] from dbPlayerData but i get to see Mon Jul 13 2020 15:15:14 GMT+0000 (Coordinated Universal Time) instead

tulip ledge
#

It's just certain enchants deal more damage if used on an undead mob for example

quartz kindle
#

@tulip ledge none then i guess, that would be no weaknesses and no resistances right?

tulip ledge
#

yup

#

Alright

peak venture
#

😛 that part = 👌

But why do i only get to see 1 part of 1 object isntead of all the objects in the array

quartz kindle
#

which part

#

you should be able to see everything if you do console.log(dbPlayerData)

#

instead of console.log("Controler ${dbPlayerData}")

tulip ledge
peak venture
#
Controller: [{"account_id":"500370681","yr":1222,"winrate":64,"date":""},{"account_id":"500370681","yr":1222,"winrate":64,"date":"Fri Jun 19 2020 15:19:09 GMT+0000 (Coordinated Universal Time)"},{"account_id":"500370681","yr":1222,"winrate":64,"date":"1592580980151"},{"account_id":"500370681","yr":1222,"winrate":64,"date":"1592581051477"},{"account_id":"500370681","yr":1222,"winrate":64,"date":"1594628974000"},{"account_id":"500370681","yr":1222,"winrate":64,"date":"1594628974000"}]

Mon Jul 13 2020 15:20:30 GMT+0000 (Coordinated Universal Time) ```
#

so in Controller is the input into function>
And below that, the actual date of this midday is inside the function after being parsed with

    let apiData = await CollectPlayerShips(client, aNew, a, b, c, cache, start, dbPlayerData) ```
#

though i'd wanted to have all information rather than only 1 date (which is the latst part of dbPlayerData)

quartz kindle
#

you mean you want Fri Jun 19 2020 15:19:09 GMT+0000 (Coordinated Universal Time) instead of 1592581051477 in all of them?

peak venture
#

ahm. No, im fine in having 1592581051477 there.
Just the entire array is what i want to parse.

#

not just the last datestamp

quartz kindle
#

then show code

peak venture
#

In the controller: ```js
let dbPlayerData = await new Promise(resolve => {
db.query(SELECT * FROM playerdata WHERE account_id = ${b}, function(err, rows) {
if(err) throw err;
resolve(rows)
})
})

var cards = new CardCollection();

console.log(`Controller: ${JSON.stringify(dbPlayerData)}`) // [object Object], [object Object] etc etc

let apiData = await CollectPlayerShips(client, aNew, a, b, c, cache, start, dbPlayerData) //CollectAPIPerson
In the function: 
```js
const CollectPlayerShips = async function(client, tld, region, account_id, cache, start, dbPlayerData) {
  // --------------------------------------
  // Syntax Checking
  //---------------------------------------  
  console.log(dbPlayerData.toString())
pallid zinc
#

so uh, does anyone know how to make the cursor thing work?
@digital ibex try pointer sir

digital ibex
#

kk

tulip ledge
#

Not 100% certain but this:
SELECT * FROM playerdata WHERE account_id = ${b}
I'd think account_id is like a TEXT or a VARCHAR so you'd have to do "${b}"

quartz kindle
#

dbPlayerData.toString() will only show [object Object]

peak venture
#

@tulip ledge i do get information back form there though. the 6 rows in this case are resembled in the 6 [Object objects]

quartz kindle
#

also, you're missing a parameter

tulip ledge
#

Oh ok thats odd but it works

digital ibex
#

nope

tulip ledge
digital ibex
#

doesn't change, @pallid zinc

quartz kindle
pallid zinc
#

@digital ibex what u did ?

digital ibex
#
   input :hover {
      cursor: pointer;
   }```
pallid zinc
#

Dont hover

peak venture
#

@quartz kindle didnt notice that. thnk that will prolly fix it

digital ibex
#

???

#

wat

pallid zinc
#

U should remove :hover

digital ibex
#

huh

pallid zinc
#

My English not good

#

Lmao

digital ibex
#

why do i need to remove it?

#

i want it to change when u hover

quartz kindle
#

its redundant

pale vessel
#

how will it even change without hovering lol, you don't have two cursors

pallid zinc
#

how will it even change without hovering lol, you don't have two cursors
....

quartz kindle
#

since the target is the cursor, it will only be targeted when hovering regardless

digital ibex
#

o

pallid zinc
#

No need of :hover

#

Sorry for my bad english

digital ibex
#

yeah it works when i remove the :hover :D

pallid zinc
#

Yup

elfin kiln
#

um

tulip ledge
#

So I have this "player" class and it cotains a propertie totaldmg I have a total of 4 objects constructed with that class now is there a way to sort the array where alle the player objects are stored in to go from totaldmg > totaldmg

quartz kindle
#

array.sort?

tulip ledge
#

Oh

#

Can you do array.sort on keys from objects inside the array?

quartz kindle
#

yup

#

array.sort((a,b) => a.totaldmg - b.totaldmg)

elfin kiln
#

How to create music bot in visual studio code?

#

and tutorial on yt?

quartz kindle
#

swap a and b to invert order

tulip ledge
#

Ok

quartz kindle
#

@elfin kiln do you have any experience with programming/coding? have you ever user a coding language before?

elfin kiln
#

Nope LOL_green

#

but im learning javascript

quartz kindle
#

ah good

#

then look into discord.js

#

they also have a pretty good guide

elfin kiln
#

oki

#

tnx

misty sigil
#

quick question

#

.updateOverwrite (on a channel object) doesn't change it to that, just adds the overwrite for the role?

#

and has the same syntax as .overwritePermissions

quartz kindle
#

the syntax is different

#

overwritePermissions([overwrite1,overwrite2])
updateOverwrite(userorroleid,permissions)

misty sigil
#

Ah thanks!

stark abyss
#

for (category in folder) do require
can someone explain this fully?

earnest phoenix
#

i need help with sharding in discord.js v11.5.1
what i am trying to do is i have a mongodb database.
i am fetching IDs of users from them and i wanna show their username in leaderboard.
so, how can i convert this code in sharding :

if(res.length > 100) {
          for (i = 0; i < 100; i++) {
            let member = client.users.get(res[i].userID) || "Invalid User#0000"
            if (member === "Invalid User#0000") {
               lb.push(`**${i + 1}.** ${member}${res[i].coins.toLocaleString()}  Fren Coins`);
            } else {
               lb.push(`**${i + 1}.** ${member.tag} • Fren Coins  ${res[i].coins.toLocaleString()}`);
            }
          }
        }

i tried almost everything. idk how can i convert this now. even when trying only client.shard.broadcastEval("this.users.get('my-id')").then(u => console.log(u.username)) it shows nothing.

quartz kindle
#

you cannot transfer complex data structures across shards

#

you need to extract the values you want and/or convert them to primitives, such as strings, numbers, etc

earnest phoenix
#

Mhm..

quartz kindle
#

for example, for a username, eval this.users.get(id).username

earnest phoenix
#

hmm

#

lemme try this

quartz kindle
#

that way only the username string is transfered not the whole user data

stark abyss
#

client.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));

for (const file of commandFiles) {
const command = require(./commands/${file})
client.commands.set(command.name, command);
}

How can I have it require more folders then just the folder named commands

quartz kindle
#

for each folder that you want to require, you need to readdir it and loop over its files

stark abyss
#

oh

slender wagon
#

is dotenv flow easier to use than dotenv

tulip ledge
#

I have this array: [50, 20, 10]
Now I want to map or join it like this: 1 - 50\n2 - 20\n3 - 10 I tried some stuff but none worked

still merlin
#

My code keeps changeing when I save it, so my .then becomes undefined.
my code is

  message.channel.send("``:white_check_mark: Restarting!``");
      client.destroy()
      .then(() => client.login(token));```
basiclly my .then goes onto the client.destroy() making it client.destroy().then
#

how can i prevent that

quartz kindle
tulip ledge
#

Oh

#

Cuz I first tried this:

                            let leaderboard = players.map(x => {
                              if(players.indexOf(x) === 0) `🥇 ${client.users.cache.get(x.userid).username} - **${x.totaldmg}**`;
                              else if(players.indexOf(x) === 1) `🥈 ${client.users.cache.get(x.userid).username} - **${x.totaldmg}**`;
                              else if(players.indexOf(x) === 2) `🥉 ${client.users.cache.get(x.userid).username} - **${x.totaldmg}**`;
                              else `${players.indexOf(x) + 1} ${client.users.cache.get(x.userid).username} - **${x.totaldmg}**`;
                            })
#

So I can just do (x,i)

pure lion
#

OHMYGOD HI

tulip ledge
#

[ undefined, undefined ]

pure lion
#

AAAAAAAAAAA I CAN SPEAK

stark abyss
#

for each folder that you want to require, you need to readdir it and loop over its files
@quartz kindle
fs.readdir('./commands/', (err, files) => {
if(err) return console.error(err);
console.log(files.join(' '));
});
i got the folders in in commands what do i do next?

pure lion
#

@stark abyss set them in a discord collection

sudden geyser
#

@still merlin client.destroy() returns void which is basically undefined. What exactly do you want to "prevent"?

tulip ledge
#

Nvm I forgot the "return"

stark abyss
#

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

tulip ledge
#

i fixed it

stark abyss
#

like that?

pure lion
#

No

#

Put it outside the fs.readdir

stark abyss
#

oh

#

i am confused

tulip ledge
pure lion
#

:>
"Woo died"

#

@stark abyss you can write a very effective handler in like 4-5 lines

stark abyss
#

i am not sure i am new to programming

pure lion
#

It's really easy, trust me. I will break it down for you then help you write the code, alright?

stark abyss
#

ok thank you, you are really nice

pure lion
#

:> you're welcome

stark abyss
tulip ledge
#

I'm getting a head ache from my code lmao

pure lion
#

So, discord collections

#

Bruhh take a break

tulip ledge
#

Even though it's work like it should

#

Did u say TAKE A BREAK?!

pure lion
#

*hug* c h i l l o u t t i m e

stark abyss
#

alright so i am loading all folders in this folder
fs.readdir('./commands/', (err, files) => {
if(err) return console.error(err);
console.log(files.join(' '));
});

tulip ledge
pure lion
#

@stark abyss I'll help you write it from scratch

tulip ledge
#

I'll help too

stark abyss
#

ok

tulip ledge
#

I'm gonna take a break from my dungeon command lmao

pure lion
#

Send me the inside of one of your command files

stark abyss
#

module.exports = {
name: 'server',
description: 'Display info about this server.',
guildOnly: true,
cooldown: 5,

execute(message) {
    message.channel.send(`Server name: ${message.guild.name}\nTotal members: ${message.guild.memberCount}`);
},

};

pure lion
#

Okay cool

stark abyss
#

that's one file

pure lion
#

Alright, do 'name', 'description', 'guildOnly' and 'cooldown' appear in all of your command files?

stark abyss
#

yes

tulip ledge
#

tf is an aforementioned DBL member

pure lion
#

Okay good, thats good

stark abyss
#

there is also aliases: ['name2', 'name1'],

pure lion
#

Oh okay, that's good too

#

In your index you wanna make a new collection and call it command

#

Wait I'll go to my pc so I don't fuck up

stark abyss
#

ok

pure lion
#

Alright

stark abyss
#

const command = require(./commands/${file}) is what i had before

pure lion
#

Yeah that's good too, but what you wanna do is make a new Discord.collection()

earnest phoenix
#

@quartz kindle any idea what is wrong in this code?
the leaderboard embed is empty.. and sorry for the ping... u r the only one who replied to my issue xD not even in Discord.js web i got any help xd

if(res.length > 100) {
          for (i = 0; i < 100; i++) {
            client.shard.broadcastEval(`this.users.get('${res[i].userID}').tag`).then(u => {
              //let member = u || "Invalid User#0000";
            if (u === undefined) {
               lb.push(`**${i + 1}.** Invalid User#0000 • ${res[i].coins.toLocaleString()} :frencoin: Fren Coins`);
            } else {
               lb.push(`**${i + 1}.** ${u} • Fren Coins :frencoin: ${res[i].coins.toLocaleString()}`);
            }
            })
          }
        }
pure lion
#

E.g

tulip ledge
#

Why do u ping him?

#

@earnest phoenix

earnest phoenix
#

i wrote that why i pinged him xd

tulip ledge
#

You can't just randomly go ping people

earnest phoenix
#

he replied to my same question a few min ago

pure lion
#

client.commands = new Discord.collection()

Client relates to the client, it's where you're assigning the collection and commands is the name of the collection @stark abyss

stark abyss
#

oh

earnest phoenix
#

bruh i didn't ping RANDOMLY

digital ibex
#

chill chicken

#

ronak, do u know where its breaking?

#

wi

#

t

#

it snotn breaking

stark abyss
#

so what do i do next

tulip ledge
#

Wdym chill? I just read out the rules

earnest phoenix
#

Discord.Collection()

tulip ledge
#

Why do u always say chill to me? xD

digital ibex
#

if u run the command, what does it respond with?

sudden geyser
#

this.users.get('${res[i].userID}').tag
Would that not throw an error if the user is not cached?

pure lion
#

Then you wanna read the dir (fs.readdirSync('dir name').filter(f => f.endsWith('.js'))

digital ibex
#

cuz u do need to chill shrug

tulip ledge
#

I think so

earnest phoenix
#

when i run the cmd, the embed of leaderboard is empty

tulip ledge
#

I just read out the rules 🤷‍♂️

earnest phoenix
#

Would that not throw an error if the user is not cached?
@sudden geyser how can i prevent this ._.

digital ibex
#

how r u getting the members?

earnest phoenix
#

this sharding is just frying my brain... :/

stark abyss
#

const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));

#

yeah? @pure lion

digital ibex
#

and cache all users in the client options

sudden geyser
#

There are many ways you could avoid it. You could remove the .tag part, or use the optional chaining operator if you're on Node.js v14.

Is res.length > 100 true in your if condition?

#

Can you upload more of your code to a site like hastebin

digital ibex
#

dont use d.js' wack shard handler mmLol

#

dont use d.js at all in fact

earnest phoenix
#

well, the other part is of just sending embed by joining the lb arrays.

sudden geyser
#

Discord.js is fine.

earnest phoenix
#

should i send it completely still?

digital ibex
#

how r u getting the members, ronak

pure lion
#

Wjdjaodjeosj

#

Pleasee use code blocks

stark abyss
#

oh

earnest phoenix
#

MongoDB database has User Ids... i am just importing the User IDs... res is the value containing the db...

restive furnace
#

yes i use code::blocks

#

the ide

#

sometimes

#

but i prefer vs2019

earnest phoenix
#

just a sec... lemme send the upper portion of the code

digital ibex
#

console.log(res)

#

ronak

stark abyss
#

@pure lion what do i do next?

#

if you are busy then it's okay

earnest phoenix
#
Money.find().sort([
        ['coins', 'descending']
      ]).exec(async(err, res) => {
        if (err) console.log(err);

        let lb = [];
if(res.length > 100) {
          for (i = 0; i < 100; i++) {
            client.shard.broadcastEval(`this.users.get('${res[i].userID}').tag`).then(u => {
              //let member = u || "Invalid User#0000";
            if (u === undefined) {
               lb.push(`**${i + 1}.** Invalid User#0000 • ${res[i].coins.toLocaleString()} :frencoin: Fren Coins`);
            } else {
               lb.push(`**${i + 1}.** ${u} • Fren Coins :frencoin: ${res[i].coins.toLocaleString()}`);
            }
            })
          }
        }
#

wait how do u get ur message like that

pure lion
#

I'm just struggling to focus and compose myself 😅

opal plank
#

js

tulip ledge
#

Seeing this get's me scared for whenever my bot requires shards

#

It's already hard enough to make my bot function lmao

earnest phoenix
#

._.

opal plank
earnest phoenix
#

alr

sudden geyser
#

broadcastEval also returns a promise, so there's no guarantee the array will have the exact content you're looking for on time. Also, do you really need to broadcast over 100 times

opal plank
#

markdown is cool

stark abyss
sudden geyser
#

the dark days were the time of bb code

#

looking at you steam

earnest phoenix
#

how will i get 100 users then :p

digital ibex
#

@earnest phoenix afaik, u can't use .sort like that, but... log Money.find().sort(['coins', 'descending']);

earnest phoenix
#

it is working well with no sharding xD

#

but in sharding, i am facing prob

digital ibex
#

what does broadcast eval even do?

#

just get info from all shards?

sudden geyser
#

runs an eval on every shard and returns an array of the result

earnest phoenix
#

it runs a script in all the shards

digital ibex
#

oh right

opal plank
#

👀 its tim

quartz kindle
#

@earnest phoenix you can just do if(res.length > 100) { res.length = 100 }

earnest phoenix
#

even in Discord.js official servr i got no reply for my prob -_-

quartz kindle
#

and dont use a for loop

earnest phoenix
#

Mhm..

#

and... then how will i get 100 user tags?

#

without loop?

restive furnace
#

why no for loop

#

it is best

quartz kindle
#
...broadcastEval(`
  let users = ${JSON.stringify(res)};
  users.map(t => this.users.has(t.userID) ? this.users.get(t.userID).tag : null).filter(Boolean)
`).then(results => {
  let tags = [...results].filter(Boolean)
})
earnest phoenix
#

hmm

restive furnace
#

thats better

earnest phoenix
#

lemme try it

magic jackal
#

Hey weird question but not sure if this goes here.

I use the Remote development extension on VSCode for connecting over SSH to my server to edit files and code, however as soon as I save a file using this extension (it seems like), the bot will start replying 3-5 times in one command, however another node instance cant be found in my htop or process list.

Has anyone experienced this before?

lusty quest
#

did you start them with nodemon or something like this?

magic jackal
#

Nope, just npm start

#

or npm run start

lusty quest
#

maybe a login loop?

magic jackal
#

Possibly, could be a SSH command issue with the extension

#

its weird

lusty quest
#

i could understand it could be a ssh issue if you get 2 instances running but 3-5 sounds like a duplicated login

magic jackal
#

its strange because even if I dont start the bot or even change anything, it still happens

lusty quest
#

if you run it without the remote development it just starts 1 instance?

barren basin
#

Hello, i have a little issue with my discord bot: after some time, my bot user goes offline while no issue is reported by visual studio code... Can someone help me ? (I'd rather to discuss in dm)

magic jackal
#

It seems like so @lusty quest

lusty quest
#

thats strange

magic jackal
#

But then again could be my VSCode install, is there any way to see what it's using for commands?

lusty quest
#

maybe but idk

magic jackal
#

Yeah it just did it again, must be the way it saves files

#

it has to be this extension

#

no other way I can think of it

pure lion
#

font registering isnt working for some reason

#
        Canvas.registerFont('BebasNeue-Regular.ttf', {family: 'Sans Serif'})
#

im getting the couldnt load font err

errant perch
#
bot.on("message", message => {
  if (message.channel instanceof Discord.DMChannel)
  return;

  let args = message.content.substring(PREFIX.length).split(" ");

  switch (args[0]) {
    case `help`:
message.channel.send("help")
break;
)}
}```
#

PREFIX = "-"

#

but it responds to other prefixes like

#

?

lusty quest
#

add something like this ```
if (message.content.indexOf(prefix) !== 0) return;

crimson vapor
#

you are only checking the length

pure lion
#

aaaaaaaa

errant perch
#

thank you

#

sorry if it was a vague question

misty sigil
#

nice switch/case

errant perch
#

i have a hard time explaining things

pure lion
#
        Canvas.registerFont('BebasNeue-Regular.ttf', {family: 'Sans Serif'})

hep

quartz kindle
#

show full error

north hollow
#

i need a api for a random cat image

misty sigil
#

i think

lusty quest
north hollow
#

thx

pure lion
#
(process:25904): Pango-WARNING **: 18:08:22.528: couldn't load font "Bebas Neue Not-Rotated 50px", falling back to "Sans Not-Rotated 50px", expect ugly output.

@quartz kindle

misty sigil
#

yo wtf

#

ghost ping

pure lion
#

x)

north hollow
#

yo

quartz kindle
#

is the font in the same folder as your bot?

tulip ledge
#

Why do people always ping Tim?

north hollow
#

it did not work for this code @misty sigil

misty sigil
#

cuz tim is good

north hollow
#
client.on("message", async(message) => {
  const command = message.content.toLowerCase();
  if(command === Prefix + 'cat') {
    let msg = await message.channel.send("**Fetching...**");
    fetch('https://aws.random.cat/meow')
        .then(res => res.json())
        .then(json => {
            let embed = new Discord.MessageEmbed()
                .setTitle(json.title)
                .setImage(json.url)
                .setFooter(`Link: ${json.postLink} | Subreddit: ${json.subreddit}`)
            msg.edit(embed)
})  //this is for ending the .then code
} 
}); 
pure lion
#

ye

north hollow
#

@misty sigil

tulip ledge
#

But still you shouldn't randomly ping people tho

misty sigil
#

its not a reddit thing

tulip ledge
#

https://aws.random.cat/meow you are fetching this

#

But are doing json.subreddit?

misty sigil
#

did you even look at it's output?

north hollow
misty sigil
#

it outputs
{"file":"https:\/\/purr.objects-us-east-1.dream.io\/i\/O376H.png"}

#

thats your code problem

north hollow
#

o ok

lusty quest
#

you dont have a title and only a file key that contains the url

quartz kindle
#

that error is not even from there

pure lion
#

:o

quartz kindle
#

@pure lion show code

pure lion
#

okok

#

wait ill bin it

#

^bot command x)

pale vessel
#

shouldn't you add quotes if the font name has space?

#

like in CSS

pure lion
#

it worked in my other project

pale vessel
#

i see why

pure lion
#

the ttf was moved too

pale vessel
#

you need to load it before creating the canvas

pure lion
#

oooooooooooooooooo

quartz kindle
pale vessel
#

also, you set the family as Sans Serif but you used "Bebas Neue" in code

quartz kindle
barren basin
#

could someone help me please ?

misty sigil
#

tell us what you need help with

hot comet
#

anyone know a place to host a bot or should I just keep self hosting

lusty quest
#

free or paid?

hot comet
#

either works

misty sigil
#

vps

lusty quest
#

get a vps

hot comet
#

from where

misty sigil
#

anywhere

lusty quest
#

digitalocean as example

hot comet
#

ok

lusty quest
#

5$/Month

#

there are cheaper ones

hot comet
#

thats not bad

misty sigil
#

yea

lusty quest
#

amazon aws / google also offers vps (both need a valid credit card)

hot comet
#

doesnt aws have a free vps?

lusty quest
#

yes 1 year free

#

after this you need to pay

#

but they are fine

hot comet
#

Hmm

lusty quest
#

nothing to expensive

hot comet
#

Ye ok.

tulip ledge
#

Any idea why my botstats command sais this:
Process memory: 88.28MB
But in the panel it shows that it only uses 28 MB ram?

quartz kindle
#

what panel

lusty quest
#

i have also differences between PM2 and the command

tulip ledge
#

pte panel

#
        let processMemory = 0;
        let used = process.memoryUsage();
        for (let key in used) {
          processMemory += Math.round(used[key] / 1024 / 1024 * 100) / 100;
        }

This is how I'm calculation the memory

iron tapir
#

hi discord bot list famly

quartz kindle
#

thats wrong lol

barren basin
#

tell us what you need help with
@misty sigil my bot goes offline for no reason and in VSC everything is like if it's running correctly

tulip ledge
#

oh

quartz kindle
#

you're not supposed to join all the memory usage

tulip ledge
#

oh

quartz kindle
#

they represent different things

tulip ledge
#

what do I do then?

lusty quest
#

pm2 reports me 90MB while my command reports 250MB.

quartz kindle
#

.rss would be the most accurate measurement on linux and non-swapped systems

#

.heapUsed is the memory your actual code and libs are using, without counting node.js and the process itself

#

in most cases .rss is good enough

#

except in weird situations when rss gets swapped out

tulip ledge
#

so process.rss

quartz kindle
#

process.memoryUsage().rss

tulip ledge
#

Still isn't rlly accurate but sure

quartz kindle
#

69 sounds more accurate than 25

#

idk where/how that panel gets its stats from

grizzled raven
#

you are use 25 ram

quartz kindle
#

@lusty quest how does your command report it?

lusty quest
#

i used the os-utils package

#
  const mem = Math.floor(os.freemem())+"/"+Math.floor(os.totalmem());
quartz kindle
lusty quest
#

yes

quartz kindle
#

last publish 8 years ago?

#

lmao

lusty quest
#

rip

quartz kindle
#

anyway that's for the system's entire memory

#

including all other processes

lusty quest
#

the downside if you lurk around stack overflow and dont check the age

quartz kindle
#

and kernel, and os, and shit, hence why its much higher than what pm2 reports

tulip ledge
#

It's funny how my bot's CPU usage spikes up to like 20% when doing botstats command but my dungeon command only uses like 1-2% CPU

grizzled raven
#

okay so does anyone know which is faster?

guild.members.fetch({ user: "123" }) 
// fetch one member, open to errors (which i can catch and handle but still
guild.members.fetch({ user: ["123"] }) 
// fetch one member, returns an empty collection if not found instead of erroring
tulip ledge
#

I don't think there's really a difference but maybe like a 0.001 second difference

#

Like you're not gonna notice it

quartz kindle
#

the first one uses the rest endpoint

#

the second one uses the gateway

tulip ledge
#

Tim big brain

sudden geyser
#

it's also the answer that error on line 32

quartz kindle
#

Lol

tulip ledge
#

I mean if wasn't saving for a PC I'd prob get it for at least a month lmao

lusty quest
#

interestening process.memoryUsage().rss returns 0 while process.memoryUsage() returns 170MB used Vs Pm2 reporting 80MB

amber fractal
#

Tim already helps all programming issues

sick fox
#

lol

quartz kindle
#

wtf

#

process.memoryUsage() should return an object, not any direct value

lusty quest
#

yea found the issue

grizzled raven
#

@quartz kindle yep, thats really why i'm asking

#

would the gateway be slower?

quartz kindle
#

from my tests not really

pure lion
#

Oh btw the font thing works now thanks Tim and flaz

quartz kindle
#

the gateway should be slightly faster

#

but discord.js uses the rest endpoint by default when doing .members.fetch(id)

marble scaffold
#

I keep on getting errors "../config.json") I keep on changing the quantity of “.” But it is still not working

quartz kindle
#

they must have a reason for that

pure lion
#

@marble scaffold show me your file structure/code

stark abyss
#

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

for (const file of files) {
const command = require(./${files}/${file})
client.commands.set(command.name, command);
console.log(./commands/${file})
}

#

Error: Cannot find module './classic,gambling,ping.js/classic'

#

classic and gambling are folder ping.js is a file

#

i am not sure how to fix this error

pure lion
#

Always use /

grizzled raven
#

files is an array of files, ["a.js", "b.js"]

pure lion
#

Dont use commas

stark abyss
#

oh

#

well i am still not exactly sure how to fix that

quartz kindle
#

you're doing require(files/file)

#

files is [classic,gambling]

opal plank
#

yo, question

stark abyss
#

right

earnest phoenix
#

Does anyone know how to fix this? I added my bot scripts and folders and stuff to github and then to Heroku. Everything works when i run it there except one thing

    msg1 = message.content.toLowerCase()
    if(msg1.startsWith (`${prefix}stonks`)) {
        message.channel.send ('Who said Stonks?', {files:['./assets/Stonks/stonks.png']} )
    }
}`)```                                                                                                                                                                                                                                                                                                                   thats the script. The thing that does not work is that my picture doesent exist when it starts in heroku. Its the exact same files except its in a github folder instead of on my desktop. If anyone would know pls help! The error is the error is ```(node:4) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, stat './Assets/Stonks/stonks.png'```
opal plank
#

can i do functions inside classes?

pale vessel
#

aren't those methods?

quartz kindle
#

/classic,gambling/ping.js is not a valid path

#

unless you have a folder named "classic,gambling"

stark abyss
#

i do not

#

it's commands/classic or gambling

quartz kindle
#

then the answer is obvious

earnest phoenix
#

the error is (node:4) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, stat './Assets/Stonks/stonks.png'

stark abyss
#

i tried replacing the first files with commands

#

but it still didn't work because of classic,gambling

magic jackal
#

@quartz kindle Can you add me real fast?

opal plank
#
   /**
     * Does Something.
     */
    be: (something: string, message: string + function a() {}) => Promise<any>;

adding a function in the middle of a class is fine?

earnest phoenix
#

i need like helpp rn plz doesent anyone know

stark abyss
#

i got Error: Cannot find module './commands/classic'

#

classic exists in commands tho

opal plank
#

path error, likely

stark abyss
#

hm

opal plank
#

also im unsure if it sets files to be defaulted to js

#

'./commands/classic.js'

golden condor
#

@opal plank it does

stark abyss
#

classic is folder like i said

#

is that the problem?

#

@opal plank

opal plank
#

code?

stark abyss
#

client.commands = new Discord.Collection();

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

for (const file of files) {
const command = require(./commands/${file})
client.commands.set(command.name, command);
console.log(./commands/${file})
} @opal plank

opal plank
#

code blocks

#
client.commands = new Discord.Collection();

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

for (const file of files) {
  const command = require(`./commands/${file}`)
  client.commands.set(command.name, command);
  console.log(`./commands/${file}`)
} ```
stark abyss
#

sorry

#

i don't know what i am doing

opal plank
#
let dir = './commands'
readdirSync(dir).forEach(sub => {
        const commands = readdirSync(`${dir}${sep}${sub}${sep}`).filter(f=> f.endsWith(".js"));
        for (const file of commands) {
            const call = require(`${dir}/${sub}/${file}`);
                        //rest here
stark abyss
#

oh

#

thank you erwin

opal plank
#

dont copy it

#

learn from it

#

apply to your code

quartz kindle
#

sep sub sep lmao

stark abyss
#

okay

opal plank
#

separator, subfolder

#

¯_(ツ)_/¯

stark abyss
#

nice

opal plank
#

yo tim

#

mind a hand here rq?

quartz kindle
#

wat wit wit wat

opal plank
#

trying to think of a clever way to change a method in a class extension to bypass something

#

without having to add it myself in every call

fast yacht
#

developers that have 100 users or more on their bot, how did you do it?

opal plank
#
    say: (maybeChannel: string, message: string, ...messageArgs: string[]) => Promise<any>;```
what i was thinking of would be doing a function onto message: string + function() {
generates between 1 and 10 CharCode 8203
}
then append it in the end
#

its basically a cheap bypass to repeated messages to prevent blockage with spam flags

quartz kindle
#

i dont get it

opal plank
#

say() => method

#

param message is a string

#

client.say('this') => message = 'this'

#

what i was trying to do is
instead of
client.say('this' + N char8203)
was change the method to append it for me

quartz kindle
#

how are you extending it?

opal plank
#

im not, im hardcoding it

quartz kindle
#

you're not doing a class extension?

opal plank
#

im changing it on the declaration instead of extending

#

declare class Chat extends EventEmitter<EventTypes>

#

well, thats what i was trying to do at least

#

not sure thats a good approach now

quartz kindle
#

the say method belongs to event emitter?

#

or to the chat class?

#

i mean, i dont even use ts

#

if i was already extending something, i'd just add it there, otherwise i'd add it to the prototype

opal plank
#

hmmm not sure i get it

quartz kindle
#

show your code

opal plank
#

technically not mine, im patching it, here here it is

#

cropping it due to length

#

what im trying is patch that say method to append those extra chars before it gets sent out

quartz kindle
#

pretty sure you cant do anything on declaration

#

you have to change it in the actual extension

opal plank
#

hmmm thats gonna be a pain, but i think i can pull it off

quartz kindle
#

then just edit the prototype

#

i mean, thats still js right?

opal plank
#

yeah

#

actually

#

no

#

its ts

quartz kindle
#

yeah the declarations file wont do

#

it needs to be the actual index file

#

if you wanna extend it yourself: ```js
class newChat extends Chat {
say(channel,message,messageArgs) {
return super.say(channel,message + "hue",messageArgs)
}
}

#

but then you need to make sure the extended class is used everywhere instead of the original.

#

if you cant guarantee that, you can hack the prototype