#development

1 messages ¡ Page 1626 of 1

sterile lantern
#

oof

nimble kiln
#

toLowerCase()

sterile lantern
#

oh

nimble kiln
#

:]

sterile lantern
#

ty

#

also for ms

#

what would 1 hr 30 be

#

60 * 60 * 30

#

prolly not

#

oh wait

#

1000 * 60 * 60

#

most likely

nimble kiln
#

Too much math for me tbh

compact prairie
#

can someone help I keep getting this error and there is a file called ../../afk.json

Unhandled Rejection at:  Promise {
  <rejected> Error: ENOENT: no such file or directory, open '../../afk.json'
      at Object.openSync (fs.js:476:3)
      at Object.readFileSync (fs.js:377:35)
      at play (C:\Users\KPC\Desktop\Discord Bots\JavaScript\PyroBot\src\commands\music\play.js:102:31)
      at Object.run (C:\Users\KPC\Desktop\Discord Bots\JavaScript\PyroBot\src\commands\music\play.js:156:9)
      at processTicksAndRejections (internal/process/task_queues.js:93:5) {
    errno: -4058,
    syscall: 'open',
    code: 'ENOENT',
    path: '../../afk.json'
  }
} Reason:  Error: ENOENT: no such file or directory, open '../../afk.json'
    at Object.openSync (fs.js:476:3)
    at Object.readFileSync (fs.js:377:35)
    at play (C:\Users\KPC\Desktop\Discord Bots\JavaScript\PyroBot\src\commands\music\play.js:102:31)
    at Object.run (C:\Users\KPC\Desktop\Discord Bots\JavaScript\PyroBot\src\commands\music\play.js:156:9)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)```
nimble kiln
compact prairie
#

oh is that the issue

nimble kiln
#

Not sure

#

Worth a shot 😄

lament rock
#

Pretty sure fs dirs resolve based on cwd if you pass relative dirs. You should use the path module to path.join(__dirname, "../../") and get an absolute dir and pass that

nimble kiln
#

but yeah what PapiOphidian said is true. It goes back two directories from where play.js is

So it would look in C:\Users\KPC\Desktop\DiscordBots\JavaScript\PyroBot\src\ if i'm not mistaken

compact prairie
#

i dont get it bc there is a file

#

it is there

nimble kiln
#

in the src directory?

compact prairie
nimble kiln
#

well

compact prairie
#

is it not

nimble kiln
#

in that case it's just ./afk.js

lament rock
#

you give it a relative path. It might exist relative to the __dirname, but it's not relative to the process.cwd()

nimble kiln
#

because you're already in the music directory from where you're calling it (play.js)

compact prairie
nimble kiln
#

oh oops

#

no

#

I mixed your afk.js with your afk.json

compact prairie
#

lol

nimble kiln
#

It's only 1 directory back

#

..\afk.json

#

I can't even tell if what I'm saying is true

compact prairie
#

its only one

nimble kiln
#

Go with PapiOphidian's way maybe

lament rock
#

2 dirs back from music dir

nimble kiln
#

So it works now?

compact prairie
#

../../afk.json

boreal iron
compact prairie
nimble kiln
#

Show us the full filepath for your afk.json

compact prairie
#

wdym

nimble kiln
#

open it with your editor or something and show us the full C:\Users\ etc. path

#

if it shows up anywhere

compact prairie
#

im in play.js

nimble kiln
#

it's hard to tell by that screenshot

compact prairie
lament rock
# compact prairie ../../afk.json

This is all an example

process.cwd(); // /home/user/bot/src
__dirname; // /home/user/bot/src/commands/music

// fs.readFileSync accepts relative paths based on process.cwd()
// if you tried to do relative without accounting for process.cwd(), ../../ would resolve to
// /home/user
const path = require("path");

const afkjsonpath = path.join(__dirname, "../../");
fs.readFiledSync(afkjsonpath + "afk.json"); // /home/user/bot/src/afk.json
boreal iron
#

U are using the fs function to get the directory?

nimble kiln
#

Ok so your afk.json is in the commands directory

compact prairie
#

no

compact prairie
lament rock
#

It's not in the commands folder

#

it's in the same dir as the commands folder

boreal iron
sterile lantern
#
var random = ['#1d4e7a', '#2f1d65', '#99047f', '#c0ed0c']
let randomcolor = random[Math.floor(Math.random() * random.length)];
module.exports = {
    prefix: ';',
    colors: {
        info: '#5b57d9',
        error: '#de554e',
        neutral: '#f2f255',
        success: '#43d177',
        random: randomcolor,
    },
}```

`randomcolor` only returns the first string
#

anyone know why

#

first color* #1d4e7a

nimble kiln
#

looks to me like it's in the commands folder 😄

#

freakin IDE's man

boreal iron
#

Using __dirname for example
Which will NOT work on Windows without replacing \ with / in the path

#

__dirname.replace(/\\/g, "/");

sterile lantern
#

weird

lament rock
sterile lantern
#

ah nvm i see whats wrong here

#

wait so how would i reassign

#

Object.addProperty?

#

hm

lament rock
nimble kiln
#

@compact prairie Can you do me a favor and collapse ("unexpand") the commands folder? I'm curious now 👀

remote seal
#

Is Phyton a good program to program bots?

boreal iron
lament rock
#

Even if it didn't, it'd resolve with \\ which is also compatible with path resolvers

boreal iron
#

Misunderstood, yes it does lmao

#

That’s why you need to replace it for fs functions

lament rock
#

fs path resolving accepts \\

boreal iron
#

Yeah there you got your escaped \ already but not if you call the dirname const

compact prairie
#

@nimble kiln

nimble kiln
#

aha!

#

ok yeah

compact prairie
#

what

#

lol

nimble kiln
#

it is two directories back 😄

compact prairie
#

lol

lament rock
#

just use path.join(__dirname, "../../") to get an absolute dir NotLikeCat

nimble kiln
#

Try it with backslashes then I guess? ..\..\afk.json

#

or use the absolute dir what PapiOphidian recommends

boreal iron
lament rock
#

why are you using the spread operator on a string

compact prairie
#

yo

#

@lament rock's meathod worked

#

but now the music wont play

nimble kiln
#

probably windows being windows

compact prairie
#

and no errors

#

and i have no idea why

#

so yeah

#

if anyone knows why HELP

lament rock
#

We gotta have errors to help

lyric mountain
#

check if bot is plugged in the energy

#

and if it ain't muted

compact prairie
#

whatever i give up ill rewrite it

lament rock
#

Mood

tawny cosmos
#

Excuse me everyone my phone has not been charged all night it's on the charger and I'm trying to process this

sudden geyser
#

Does another charger work?

tawny cosmos
#

I'm not using anything right now

#

All I've been doing is reading

vivid fulcrum
#

sticking it in the microwave will supercharge it /s

sudden geyser
#

But does another charger work

boreal iron
tawny cosmos
#

All that you guys have to say is wrong I told you guys before I even drink this class somebody hacked in all of my products costing me money to put my new tablet in the shop including a deductible I just bought for Christmas otherwise I'll be advancing right about now on your level instead of using my cell phone

#

I'm trying to figure this out too I told you guys we have a mastermind manipulator and a hacker and our entity and you guys refuse to acknowledge that

vivid fulcrum
#

damn that sucks

tawny cosmos
#

I got to get on board the best way I can with the processing that I do have because I don't have a tutor I don't have a friend and I don't have any family but my man that I've been with for four f****** years excuse my language everyone is my heart pain cyberbully and hacker and you guys are acquainted with him thank you very much

vivid fulcrum
#

that message is english but when you try to connect two or more words together, it doesn't make sense at all

tawny cosmos
#

You know I didn't get this far in this world cheating myself I'm only human

vivid fulcrum
#

are you mashing your keyboard suggestions

boreal iron
#

hmm even if English isn’t your main language

tawny cosmos
#

You can believe what you don't want to believe in or whatever you be with somebody and you find out their darkest secrets and just for them to cover it up they'll sit there and spit in your

vivid fulcrum
#

it's funny the first time

#

now you're annoying

tawny cosmos
#

black lives do matter I don't I haven't got this far lying and cheating that's why I want to go to school so I can advance to get on this level out of understanding

vivid fulcrum
#

@split hazel

boreal iron
#

And not developed relevant anyway

vivid fulcrum
#

they're trolling

boreal iron
#

Obviously yeah

tawny cosmos
#

I have evidence of him admitting recently of his hacking and etc even still in my identity

split hazel
#

@tawny cosmos please stop

boreal iron
#

Reading that shit brought me close to the tree near the street I’m driving on

tawny cosmos
#

Agreed I'll stop right there I'll step back because I'm more of a man than anything

sudden geyser
#

this is just painful to read

stark abyss
#

i feel like I am gonna get shout at but...

umbral zealot
#

whatever ID you got from addUsers[0] wasn't valid as a member

#

or the member wasn't cached.

pallid quail
#

members.resolve(...) instead of members.cache.get(...) maybe?

stark abyss
#

okay

lament rock
#

Yeah. You'd possibly have the fetch the user and possibly account for the fact that the member isn't in the guild anymore

stark abyss
#

ty

hasty mulch
#
Ignoring exception in command give:
Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "/home/pi/Documents/Central_Communications/cogs/central-economy.py", line 87, in _give
    await db.execute(f"UPDATE economy SET money = {currentbalance + amount} WHERE user_id = {member.id}")
TypeError: can only concatenate tuple (not "str") to tuple```
```py
@commands.command(name='give')
@commands.has_permissions(manage_guild=True)
async def _give(self, ctx, amount, member: discord.Member = None):
    if not member:  # if member is no mentioned
        member = ctx.author  # set member as the author
        
    async with aiosqlite.connect('/home/pi/Documents/Central_Communications/database/economy.db') as db:
        cursor = await db.execute(f"SELECT money FROM economy WHERE user_id = {ctx.author.id}")
        currentbalance = await cursor.fetchone()
        await db.execute(f"UPDATE economy SET money = {currentbalance + amount} WHERE user_id = {member.id}")
        print(f'Gave {member} {amount} K-Bucks')
        await db.commit()
        print('Saved!')
        pass
    embed=discord.Embed(
            type='rich',
            colour=discord.Color.dark_green(),
            description=f'{ctx.author.mention}: Gave {amount} K-Bucks to {member.mention}!'
            )
    embed.set_author(name=ctx.author, icon_url=str(ctx.author.avatar_url))
    embed.set_footer(text="Developed by LIPD Productions Inc.#1205", icon_url=str(ctx.guild.icon_url))
    embed.timestamp=datetime.datetime.utcnow()
    await ctx.send(embed=embed)
    pass```
#

How do I get the new balance into a tuple so SQL will be happy with it?

earnest phoenix
#

yikes f string

#

well seems fetchone returns tuple and amount is string, so you can't concatenate them

hasty mulch
#

So, what do I do?

earnest phoenix
#

What's money type in the db?

hasty mulch
#

Int

earnest phoenix
#

So you should index the tuple so that you get the money ig and also you want to type hint the amount to int so d.py cast it as int for you

#

omg lol

hasty mulch
earnest phoenix
#

What does print(currentbalance) output though?

hasty mulch
#

Checking

earnest phoenix
#

see you need to do index it

#

Anyway, wouldn't SET money = money + amount work?

hasty mulch
#

No because money is the column

earnest phoenix
#

Have you ever try it

boreal iron
earnest phoenix
#

thanks for confirming

#

Also don't use f string, you can use ? in sqlite for the placeholder

#

well probably in this case it doesn't really matter since the values are int

hasty mulch
lament rock
#

? is prepared statements. Sometimes, prepared statements are not appropriate to use considering they cause 2 queries instead of 1

#

For statements which accept non arbitrary input, prepared statements are not necessary

boreal iron
#

I don’t magically know your table layout.
If you’re using a different name for the column then adjust it of course.

modest maple
#

Mosttt of the time prepared statements are worth it

#

Unless you're running the query once

#

Once a prepared statement is made generally the db caches it for a considerable amount of time

grizzled raven
#

if you're planning to have some sort of api which needs the bot instance, would it be better to host the server on the same process as the bot?

lament rock
#

What do you need the bot instance for? You could have a socket based IPC where the client connects to the api to serve data or respond to actions. Or if it's to do rest actions, you could use a modular interface for rest actions only, considering the gateway and rest can be used completely separately

earnest phoenix
hasty mulch
earnest phoenix
#

SET money = money + {amount}?

hasty mulch
#

I don’t get why it won’t update the damn field

delicate zephyr
#
f"UPDATE `economy` SET `money` = {amount}"

try this?

hasty mulch
delicate zephyr
#

oh

#

ok then

#

oh right

#

yea

#

You're adding to the column ok

boreal iron
delicate zephyr
#

eh, we all make mistakes

boreal iron
#

huh... didn’t select your message to answer

#

Fuck discord mobile shit

boreal iron
quaint wasp
#

Why do I get this error?

#

Isnt that like..

#

in defineing part?

#

I used toLowerCase before in the code

#

😐

lament rock
#

args is an empty array

#

the user never passes any arguments

quaint wasp
#

This.. tells me smth else..

#

😐

#

It suggested that tho.

quaint wasp
frozen field
#

therefore, the args array is empty

earnest phoenix
quaint wasp
#

oh

#

so i just add this like it says? if (!args.length)

#

also

#

I am big brain

#

I AM ACITUALY am reading the docs..

lament rock
#

That is correct. If there are no args, state that you require arguments

#

also, those aren't docs. That's a user guide to help newer users understand concepts and practice how to handle arbitrary input and user-proof your applications

quaint wasp
#

😐

#

...

frozen field
#

This is the official documentation - https://discord.js.org/#/docs/main/stable/general/welcome

quaint wasp
#

OH

#

Wait..

#

I added if (args.length) {//code } and it still gived me the same error..

#

  const name = args[0].toLowerCase();
  const command = commands.get(name) || commands.find(c => c.aliases && c.aliases.includes(name));
  
  if (!args.length) {
  if (!command) {
    return message.reply('that\'s not a valid command!');
  }
  
  data.push(`**Name:** ${command.name}`);
  
  if (command.aliases) data.push(`**Aliases:** ${command.aliases.join(', ')}`);
  if (command.description) data.push(`**Description:** ${command.description}`);
  if (command.usage) data.push(`**Usage:** ${prefix}${command.name} ${command.usage}`);
  
  data.push(`**Cooldown:** ${command.cooldown || 3} second(s)`);
  
  message.channel.send(data, { split: true });
  }```
lament rock
#

you don't do anything if there aren't any arguments. In fact, if arguments were provided, then the command wouldn't even run, because you locked it under a conditional scope. You need to return if there aren't any arguments and you require them.

earnest phoenix
#

Also, you accessed the args before even checking if it's empty or not

lament rock
#

@earnest phoenix when did you start trying rs? 👀

thorny flume
#

I am running my bot code and it is not going online and it is not giving an error. Can someone help me?

earnest phoenix
lament rock
#

pain.

earnest phoenix
#

I started reading the book months ago though I'm still half way reading that cri

quaint wasp
lament rock
thorny flume
#

Yes, I don't know if I banned with some shards I was not notified by the discord

lament rock
#

Discord will always notify you if your client's token has been reset

#

Probably a cloudflare issue. What you can do is listen for client debug events

quaint wasp
#

and shows an error

thorny flume
#

yes, but i don't know what would happen if i banned my bot or some fragments, it just doesn't go online, even with the code running

#

ok

lament rock
# quaint wasp I did returned..

No you didn't. On the top of the code block, you tried to access args[0].toLowerCase without checking if args was an empty array or not prior to that. Furthermore, you only added entires to the data array if there was no args

lyric mountain
#

Actually, you probably shouldn't even have shards

lament rock
#

cf can ban your ip

lyric mountain
#

Well, yeah but that's temporary

#

1 hour iirc

delicate zephyr
#

yea

#

its 1 hour

lyric mountain
#

It happens when you spam reconnect queue

granite crest
#

Wow

lyric mountain
#

Happened with me once during one of that discord falls

quaint wasp
thorny flume
#

@lyric mountain I have a bot with more than 2500 guilds

lyric mountain
#

That's a listener

lyric mountain
thorny flume
#

can this problem go away after 1 hour?

lyric mountain
#

Check the console

#

It'll output the remaining time

lament rock
#

before you try to access args[0], you should do

if (!args.length) return;
#

only has to be 1 line

thorny flume
#

the bot simply did not notify me and went offline, nor did an error appear

lyric mountain
#

if (!args) return;

#

Less code

#

Empty arrays are falsey

lyric mountain
#

An error MUST popup

boreal iron
lyric mountain
#

No bot will fail silently

boreal iron
#

Therefore if 0 doesn’t exist, no items exist

lyric mountain
#

Unless you're muting errors

earnest phoenix
thorny flume
#

@lyric mountain I tried to connect several times and it didn't even give an error

lyric mountain
#

Impossible

#

Run the code in debug level

#

If it still doesn't show anything run in trace level

#

If it STILL doesn't show anything, your vps is dead

thorny flume
#

ok

boreal iron
#

How did you spam the gateway that much?
If I remember right the limit was 1000 logins per 24h.

delicate zephyr
#

its 1000 before discord resets your token

boreal iron
#

Clients are limited to 1000 IDENTIFY calls to the websocket in a 24-hour period. This limit is global and across all shards, but does not include RESUME calls. Upon hitting this limit, all active sessions for the bot will be terminated, the bot's token will be reset, and the owner will receive an email notification.

#

But if so he would receive an email

quaint wasp
#

What.... does that mean?

#

wait

#

nvm

#

I might be able to fix that

boreal iron
#

How can you drink water from a bottle BEFORE water got filled into the bottle?

quaint wasp
#

Ye...

#

I got it.

#

wait..

#

I didnt.

#

But it says its not a function.

#

So Its not soppuce to be in the if message thing?

boreal iron
#

You’re defining it const = command;
There are no functions defined in it (or properties)

#

Just send a few more lines to see what you actually wanna do

quaint wasp
#

well if this is few..

#

here

#

  const name = args[0].toLowerCase();
  const command = commandFiles.get(name) || commands.find(c => c.aliases && c.aliases.includes(name));
  
    if (!command) {
    return message.reply('that\'s not a valid command!');
  }
  
  data.push(`**Name:** ${command.name}`);
  
  if (command.aliases) data.push(`**Aliases:** ${command.aliases.join(', ')}`);
  if (command.description) data.push(`**Description:** ${command.description}`);
  if (command.usage) data.push(`**Usage:** ${prefix}${command.name} ${command.usage}`);
  
  data.push(`**Cooldown:** ${command.cooldown || 3} second(s)`);
  
  message.channel.send(data, { split: true });
#

so I basicly need to get it out of the thing that listens to the messages?

lyric mountain
#

Cloudflare is a bit more annoying

lyric mountain
quaint wasp
#

😐

#

good point..

boreal iron
quaint wasp
lyric mountain
#

Command does not exist before you finish "const command = ..." declaration

boreal iron
#

Guessing his IP, country or range got banned for malicious actions etc.

quaint wasp
#

but I did finish it

lyric mountain
#

No no, mostly because request spam

quaint wasp
lyric mountain
#

Always happens if you don't shutdown your bot during discord seizures

quaint wasp
#

lol

lyric mountain
#

Unless your lib limits reconnect requests itself

#

@quaint wasp

#

It does not exist

#

Ah, nvm, that's commands

#

What's the error again?

boreal iron
#

That’s his error.

lyric mountain
#

No, not that

#

He mentioned the error changed

boreal iron
#

Oh huh missed that I guess

lyric mountain
quaint wasp
#

uhh

#

yes.

lyric mountain
#

Show error

quaint wasp
#

its not a function

#

here

#

also

#

Ill change commands to commandFiles

tawny cosmos
#

Same here I agree no man or woman in this world ever done anything for me

quaint wasp
#

sence thats how it is in my code..

lyric mountain
#

What is "commandFiles"?

lyric mountain
#

No

boreal iron
#

@rustic nova Got warned by Speedy already and is trolling again

solemn latch
#

Has been warned a few times in support too

rustic nova
#

@tawny cosmos Very last warning, stop these message

#

next one is a mute

lyric mountain
#

Next one is a trout to the face

rustic nova
#

ping me when they're doing it again

boreal iron
#

Damn lost the context... mobile Discord sucks

lyric mountain
#

Anyway, so what is "commandFiles"?

#

Hope could u delete that message?

rustic nova
#

yup

lyric mountain
#

Like, to free space

rustic nova
#

oh there was a bigger message i just saw

boreal iron
#

Alright ty

rustic nova
#

sorry i missed that lmao

lyric mountain
#

Thx

quaint wasp
#

😐

boreal iron
#

Is he still here

quaint wasp
#

so were still talking about her?

#

realy

boreal iron
#

Speaking about you

quaint wasp
#

oh

#

🙂

quaint wasp
lyric mountain
#

Nono, I mean how are you defining it

quaint wasp
lyric mountain
#

Not the folder itself, the variable

quaint wasp
#

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

umbral zealot
#

So that's an array

#

not a Map

#

arrays don't have get()

quaint wasp
#

whats a map?

#

I mean

#

Ik what a map is

umbral zealot
#

Or a collection

quaint wasp
#

but in coding

lyric mountain
#

Maps are like jsons

umbral zealot
#

no

#

what the fuck

#

Map() is a data structure

lyric mountain
#

I mean, the structure

#

Key-value

umbral zealot
#

"JSON" means nothing

lyric mountain
#

Jsons are also key-valued

umbral zealot
#

other than "a file-based version of a javascript object ro array or value"

quaint wasp
#

bot review VS bot developer

umbral zealot
#

I think you got your terminology confused

quaint wasp
#

So funny sometimes in here.

umbral zealot
#

"JSON" is a string-based version of a javascript variable

lyric mountain
#

Both jsons and maps are a key-value structures

quaint wasp
#

lol

umbral zealot
#

W3Schools seriously has corrupted people with their shitty fucking terminology

#

Stop using the word "jsons" it's not a structure

#

It's an OBJECT that you're talking about

quaint wasp
#

™️

lyric mountain
#

Ok, so what?

umbral zealot
#

So stop using the wrong word for it

lyric mountain
#

Are you JS attorney?

umbral zealot
#

yes

#

I'm the JS Gordon Ramsey and your chicken is RAW.

quaint wasp
#

guys stop this its not going to get any of you any where.

boreal iron
#

lmao

quaint wasp
#

its kinda funny tho

umbral zealot
#

Now stop calling them "JSON". They're objects. Use the real word like real developers.

lyric mountain
#

Like, fckin gatekeepers

quaint wasp
#

passing filters ^ (if there are filters)

slim obsidian
#

Anyone have any ideas for “fun” commands. Ive been trying to expand on the fun section of my bot. So far it’s just memes and reddit

umbral zealot
#

Yeah well try telling that to an interviewer when he laughs at your face for calling an object "jsons".

lyric mountain
#

It's like arguing why someone who has common rigs are gamers or not

quaint wasp
#

(something)-facs

#

facts

#

avatar

#

ping

umbral zealot
lyric mountain
#

Or whether someone who watched only 2 anime are otakus or not

quaint wasp
#

STOP guys its getting anoying!

umbral zealot
#

@quaint wasp there's plenty of existing guides and tutorials on how to make a command handler

#

maybe follow one that's good?

quaint wasp
#

I am following one

#

and it gived me errors

boreal iron
#

@quaint wasp they told you already get() can’t be used on an array

quaint wasp
#

so im asking them here

umbral zealot
#

Ok but no, what you're doing is trying to use the wrong things in an array

quaint wasp
#

after I tryed to fic the,.

umbral zealot
#

Follow that guide, it'll be fine

#

if you have any issues with that guide, let me know and I'll help you

quaint wasp
#

wait..

#

😦

#

I am not an idiot tho.

umbral zealot
#

I didn't say you were

#

I'm just saying you're tryign to use a Map() method on an array

quaint wasp
umbral zealot
#

and that doesn't work

#

The person that wrote it is the idiot

#

don't worry about the name of the thing just read it and learn

quaint wasp
#

oh ok, then that works.

umbral zealot
#

I'm sure you're also not smug and you're not a killer.

#

So maybe don't think too much about it

boreal iron
quaint wasp
#

Kiler

umbral zealot
#

ok.

quaint wasp
#

one l.

umbral zealot
#

well whatever

#

Just read the guide and learn kekface

quaint wasp
#

... Why do u need an events folder when u can just have it in your index?

#

like so

umbral zealot
#

Because there are many events and it makes for better separation of concern while programming

#

It's easier to read than having 8000 lines in your index

mint vortex
#

Why does this happen?

quaint wasp
#

lol..

umbral zealot
quaint wasp
#

pins

umbral zealot
#

Safari is crap

quaint wasp
quaint wasp
#

And because of that it just wont read it,.

#

😐

umbral zealot
#

uhhhh

#

what

quaint wasp
#

@umbral zealot thats a shitty command handler you sent me over there.. 😐

umbral zealot
#

no it's not

#

it's literally the one most people use

#

a lot of people have copied it and adapted it

#

If you're having issues using it, it's not the handler's fault I promise you

quaint wasp
#

Ik

#

But I want an advanced one.

#

Mine is

#

but..

#

I just ran into an isseu while I was advencing it.

umbral zealot
#

your isn't advanced, yours is broken

quaint wasp
#

Doesnt mean I should start over

boreal iron
#

You’re not supposed to use the structure mentioned on the website, it just should help you understand how to read the files and to use it in combination with the inbuilt djs command handler.

umbral zealot
#

Yeah I mean, you could just write your own but clearly at this moment you're not capable of doing that

quaint wasp
#

oh

#

shoot

#

thats my cmd handler

#

some lines are useless..

#

Like comments

#

but nvm that

lyric mountain
#

Simplicity is the utmost advancement

#

Don't try to go advanced if you don't need it

umbral zealot
#

ok but you're literally using the same command handler

#

just worse

quaint wasp
lyric mountain
#

Complexier handlers won't make the bot better

#

Will only make your life hell

umbral zealot
#

What makes the bot good or better is your ability to code it right - not to add fake complexity and pretend it's "good"

quaint wasp
#

My life is already hell af so i dont mind.

lyric mountain
#

Hell has 9 circles

quaint wasp
#

im on all 10.

umbral zealot
#

So here's the thing ```js
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);
}

That's your handler. 

```js
client.commands = new Discord.Collection();

fs.readdir("./commands/", (err, files) => {
  if (err) return console.error(err);
  files.forEach(file => {
    if (!file.endsWith(".js")) return;
    // Load the command file itself
    let props = require(`./commands/${file}`);
    // Get just the command name from the file name
    let commandName = file.split(".")[0];
    console.log(`Attempting to load command ${commandName}`);
    // Here we simply store the whole thing in the command Enmap. We're not running it right now.
    client.commands.set(commandName, props);
  });
});

That's mine.

quaint wasp
#

😐

#

u copied it.

#

clearly.

umbral zealot
#

... no

#

I wrote the guide I linked you to.

dusky sundial
#

Just because it has comments doesn't mean it's copied ^^

umbral zealot
#

I've been doing this for 4 years

quaint wasp
#

WOW..

#

your part of idiots guid?

#

dang

umbral zealot
#

I wrote 90% of that site

quaint wasp
#

I was in there support server but got banned for being to annoying

umbral zealot
#

yeah I know you were

quaint wasp
#

😐

#

so ur evelyne?

umbral zealot
#

Yes.

quaint wasp
#

WOWOWOWOW

umbral zealot
#

So now have we at least established that the handler isn't crap?

quaint wasp
#

I thought you were a male for some reason before.

umbral zealot
#

A common mistake to make.

quaint wasp
#

(Probobly because lots of males use discord..)

craggy pine
#

wat i mean, a lot of females do aswell

lyric mountain
#

Back to topic, rewrite ur handler

quaint wasp
#

SO I got to get rid of EVERYTHING?

craggy pine
#

you can.

#

Or you can rewrite it

quaint wasp
#

mine is only 156 lines long..

craggy pine
lyric mountain
#

Go simple, then upgrade it as you go

#

Don't try to build a skyscraper from terrace down

quaint wasp
#

I think this is better:

umbral zealot
#

ok if you say so

craggy pine
#

Copying a handler and not knowing how to work with it / understand it will just result in a similar matter.

umbral zealot
#

It's not, but either will work, at least.

drifting wedge
#

just use dpy

#

problem solved

umbral zealot
#

Nah that doesn't solve the problem

drifting wedge
#

yes it does

umbral zealot
#

STK is just a person that refuses to take the time to learn

drifting wedge
#

for a handler

#

?

umbral zealot
#

A nice help vampire/tyler

drifting wedge
#

?

lyric mountain
#

He's using js

umbral zealot
#

whatever you give him, he'll still not be able to code a bot

drifting wedge
#

ik ik

quaint wasp
#

ya

boreal iron
drifting wedge
#

lol

#

haha

quaint wasp
#

idk how to use py.

drifting wedge
#

so basically how i would make a handler

quaint wasp
#

Ill use that when ik how to use js.

drifting wedge
#

a function where on message, check if prefix is good

#

then run a function that is that command

#

?

quaint wasp
#

Nah

#

thats..

#

will

#

thats for small bots.

#

and mine..

drifting wedge
#

i dont think so

quaint wasp
#

oop.

lyric mountain
#

Dude

drifting wedge
#

yours is small

#

100%

craggy pine
quaint wasp
#

Its when all commands are in teh index.

#

MINE HAS 26+ COMMANDS

#

how is mine small?

drifting wedge
#

OH wow so scary

craggy pine
#

That isn't that big

lyric mountain
#

There's no "small bot command handler"

quaint wasp
#

I couldnt fit 16 commands onto index

lyric mountain
#

Cmd handlers are cmd handlers

#

Period

drifting wedge
#

would my method work?

quaint wasp
#

it said "Your file is to big to read"

drifting wedge
#

or not?

quaint wasp
#

or smth

drifting wedge
#

i do mostly py so js isnt my main

quaint wasp
#

said its over 2000 charecters

drifting wedge
#

so idk how that would work

#

but would it?

#

having an index function

umbral zealot
#

1 command or 20534623462 commands won't change the handler

lyric mountain
umbral zealot
#

the handler is the same

drifting wedge
#

which calls the commands function?

#

it wouldnt be a handler

lyric mountain
#

Command count doesn't define whether a bot is big or not

drifting wedge
#

it would be like a walmart handler

#

cuz u need case stuff

umbral zealot
#

This entire conversation stems from the fact that with 2 command handlers you've been shown (and I know for a FACT you've seen months ago) you're still unable to do a simple thing like "call get() on the correct variable".

#

Programming isn't supposed to be that hard.

drifting wedge
#

me? or the other person?

umbral zealot
#

Smug

lapis geode
#

Cmd handlers are godsent FlushedWithLove

drifting wedge
#

oh ok

#

note though, the dpy command handler is amazing

#

and its default

#

and i 100% encorage someone to make it in js

umbral zealot
#

I mean it's been done already

#

lol

drifting wedge
#

what package is it?

umbral zealot
#

Eris had one like 5 years ago

quaint wasp
#

guys

drifting wedge
#

oh

quaint wasp
#

guess wut

umbral zealot
#

And there's a dozen frameworks out there

drifting wedge
#

cool

#

welp good luck js devs

#

imma stick with snakes

quaint wasp
#

Im eating McChekin from McDonalds.

lyric mountain
drifting wedge
#

snake charming > java but its called javascript

#

@lyric mountain my snakes have mutations

umbral zealot
drifting wedge
#

alr gn nerds

#

talk to you later

boreal iron
drifting wedge
#

on why snakes > coffee

lapis geode
#

You can relatively easily write without a cmd handler in js and convert the code when you have the time to understand it and set it up, that's what i did

lyric mountain
#

Snakes are cold, coffee is hott

drifting wedge
#

urmom was ~~hot ~~warm last night

lyric mountain
drifting wedge
#

warm i mean

#

due to body heat

#

ofc

boreal iron
#

That’s the reason I’m even following this chat while driving...

#

Can’t get enough of it lmao

drifting wedge
#

fucking drive and be careful to not run over small children

#

or big children

#

just dont run over people

boreal iron
#

Well GTA told me to do so, not my issue I guess

quaint wasp
#

whats commando?

drifting wedge
#

lol

lyric mountain
quaint wasp
#

😐

#

ok.

lyric mountain
#

Using a lib won't solve ur issue

quaint wasp
#

lib?

lyric mountain
#

Library

#

Library, package, dependency, call it how you want

empty vault
#

hmm

snow portal
#

Why is it so hard for me to balance learning java and still doing my daily dose of python Bruh

lyric mountain
#

Both are quite distant

snow portal
#

ikr

sudden geyser
onyx hare
#

for some reason this isnt showing the names,
.setTitle(`${message.author.name} Has Hugged ${message.mentions.name}`)
mention finder

if (message.mentions.members.size === 0)
    return message.reply("Please Mention A User To **Hug**");
crimson vapor
#

username KEKW

onyx hare
#

still getting undefined for the second name

river panther
#

wait what

#

it will be username

#

bruhhhhhhhhhhhhhhhhhhhhhh

onyx hare
#

.setTitle(`${message.author.username} Has Hugged ${message.mentions.username}`)

river panther
#

arrey man

#

do you not know the basics of d.js?

#

it will be

#

message.mentions.users.first().user.username

onyx hare
#

oh im still newish to doing mentions in embeds n what nto

river panther
#

eh, ok ok

#

what did you say in the second part of the message?

earnest phoenix
river panther
#

oh yes, i meant that

opal plank
river panther
#

its hindi

opal plank
#

hmmm i see

blissful coral
#

How can I vertically center this text

#
<div class="member dark">
        <img src="https://cdn.discordapp.com/avatars/312972248241668096/5a474732aab914eddb15d379d3492a2c.webp"><p>pog</p></div>
    </div>
#joins .member {
        margin: auto;
    }
    #joins .member img {
        border-radius: 50%;
        height: 58px;
        width: 58px;
        padding: 10px;
        padding-right: 3px;
        float: left;
    }
    #joins .member p {
        text-align: center;
    }```
waxen meteor
#

this trick has worked for me before

[thing you want centered] {
    display: flex;
    align-items: center;
    justify-content: center;
}
#

just make sure the thing you want moved around is a separate element inside of the flexed element and that the flexed element is resized to be as large as possible (width: auto; height: auto;, maybe? I'm not sure exactly)

sour warren
#

how do i make commands/help.js work?

sudden geyser
#

do magic

river panther
#

why is it wrong?

#

i tried member.guild.me.user.haspermissions also

#

nvm

#

worked

sour warren
#

how do i make commands/help.js work?

spice panther
#

i voted in poketwo but the box didnt come

umbral zealot
spice panther
#

WTF

umbral zealot
#

What exactly did they tell you

spice panther
#

they told me its top,gg problem not ours

umbral zealot
#

There's nothing we can do for you until the site's back online fully

#

not sure why they sent you here

#

they know it's not fixed yet.

spice panther
#

in poketwo it says you can vote and in top.gg it says you already voted

umbral zealot
#

ok well that's a different story

#

smh people are so bad at describing issues

#

You're limited to 2 votes per IP per bot per day

spice panther
#

-_-

umbral zealot
#

so if anyone else on your IP address (home, or VPN if you're using one) has already voted, you can't.

spice panther
#

nobody uses bots in my home

#

except me

umbral zealot
#

Ok well that's all I Can tell you

spice panther
#

that didnt help me at all still thank you

umbral zealot
#

The indicator that you've already voted only happens if there's already been a vote in the last 12 hours from your IP

blissful coral
#

Soooo

umbral zealot
#

But there is a known problem with votes.

blissful coral
#

I am using display: flex

#

How can I make it to where they don't all adjust?

#

To what the others sizing is

#

nvm fixed it

earnest phoenix
#

Hello I am new to discord

#

hello i am old to discord

#

desktop reveal
yes i switched to linux
but idk how to change partition size so i'm stuck with 300 MB of storage
is there a way to change partition size for linux through linux

old cliff
#

Maybe

#

You can maybe do it from bios

river panther
#

it depends on how you have coded the bot

#

some peopel use a command handler

#

others idk what do

edgy tapir
blissful coral
#

Is there a way to check if something is a snowflake?

pale vessel
#

of course, download the is-snowflake module

blissful coral
#

is that the exact name?

pale vessel
#

can't you just check the string is an int and make sure the length is between 17 - 19

pale vessel
blissful coral
#

oh yeah true

#

I mean I could try this too

pale vessel
#

that generates

blissful coral
#

Oh wait

#

LMAO

pale vessel
#

ah you're right

#

you can use that class

blissful coral
#

I mean

#

Yeah

#

Well no

#

It has to be a # or date

#

so

pale vessel
#

?

blissful coral
pale vessel
#

require("discord.js").Snowflake.deconstruct(snowflake); my man

blissful coral
#

oh wait I am dumb LMAO

#

First is a actual user ID the second is words

#

So if the binary is all 0s would that mean it isn't a snowflake Thonk

old cliff
#

Yes

blissful coral
#

Thought so

old cliff
#

Check for some real snowflake to see if it works

pale vessel
#

if (!Number(binary)) invalid ez

blissful coral
#

Yeah I got it now

old cliff
blissful coral
#

What?

#

Are you talking about valorant?

old cliff
#

Yes

blissful coral
#

I finished for the night

old cliff
#

Ok

blissful coral
#

Look good?

#

Coloring^

rustic nova
#

took me so long

old cliff
#

btw @blissful coral should I play my first ranked match now to get my rank rn ?

blissful coral
#

what is your rank from last season

old cliff
#

b2 act rank

blissful coral
#

actual rank?

old cliff
#

iron3

blissful coral
#

It wasn't a hard reset

#

You will be iron 3 then

old cliff
#

bruh

#

riot sus

#

it was giving -30 for loss and +19 for win

blissful coral
#

lul

edgy tapir
#
return client.commands
        .filter(cmd => cmd.category === category).map(cmd => `\`${cmd.name}\``).join(", ")
        .filter(cmd => cmd.category === "category name").map(cmd => map.delete(cmd.name));
``` is this the correct way to delete a category with a specific name from a map?
blissful coral
#

When doing member.roles.cache is there a way to put them in order of hierarchy?

pale vessel
#

sort by their position

keen folio
#

can anyone help how to start my bot if 'node .' and 'node main.js' doesn't work

blissful coral
#

you have to define "main" in your package.json

keen folio
blissful coral
#

npm init

keen folio
#

oh i did npm init already in command prompt

#

shall i do it again?

old cliff
#

Extreme you were correct... Riot does suck at comp experiece

opal plank
rustic nova
#

The discord ones? Nah

opal plank
#

hmmm pretty sure they do...

keen folio
#

can anyone help how to start my bot if 'node .' and 'node main.js' doesn't work?

opal plank
willow mirage
#

ehm . . .

#
            console.log(guildCache)
            //commands working
            (() => {
                const prefix = message.content.split(" ").shift().toLowerCase();
                console.log(prefix);
                if(guildCache.prefixes.includes(prefix)){
                    guildCache.prefix = prefix.toString();
                }
            })()
cinder patio
#

You are calling console.log(guildCache)

#

Put a semicolon after it

willow mirage
#

ok

cinder patio
#

What's the point of that iif though?

willow mirage
#

i wanna make a multi prefixes

#

but smth is not working

#

smh

copper cradle
#

that function creates its own scope

#

so that "prefix" variable will only exist inside if that scope

#

oh wait

#

that wasn't your problem

old cliff
#

Also why make instant functions ?

copper cradle
#

I didn't see the image above

old cliff
#

Dont make instant functions

#

When you dont need them

#

Then your code should work

copper cradle
#

the problem is bc of that self invoked function

cinder patio
#

The problem is that he hasn't put a semicolon after the first console.log call, and js thinks he's calling the return value of the console.log

old cliff
#

We said that

cinder patio
#

uh... no you did not but alright

old cliff
#

oh it was you

#

nvm

rocky hearth
#

it it possible for me to develop a new operator (or whatever it should be called) for js, that returns the factorial of a number if I try to do

const fact = 4!;
console.log(fact); // Should output: 24
cinder patio
#

nope

#

unless you create your own transpiler

#

Or maybe your own babel plugin or something

#

But what's the point

#

How often do you need the factorial of a number lol

pale vessel
#

this isn't an operator but it looks cool js function f([string]) { return Array(Number(string)).fill(1).map((_, index) => index + 1).reduce((acc, cur) => cur * acc, 1); } f`7`; // 5040

rocky hearth
#

what the heck??

#

how its a valid function?

cinder patio
#

string template functions

rocky hearth
#

does the variable, string has to be called that?

cinder patio
#

no

#
function a(text, vars) {
  console.log(text, vars);
}

a`Text ${1}, text ${2}`;
// ["Text ", ", text "] [1, 2]
#

p cool

rocky hearth
cinder patio
#

oh I guess the rest of the arguments are the expressions

#

And there's also a raw property at the end of the text array

rocky hearth
#

that raw has the same 3 strings

cinder patio
#

¯_(ツ)_/¯

#
const params = new URLSearchParams(req.url);
const formId = params.get("form") as string;
console.log(formId, req.url);

Am I going crazy y'all

#

Apparently it's an invalid URL

#

but why is ws giving me an invalid url

river panther
#
Promise { <pending> }
(node:47024) UnhandledPromiseRejectionWarning: FetchError: invalid json response body at http://ergast.com/api/f1/drivers.json/alonso reason: Unexpected token < in JSON at position 0
    at E:\smol bot\node_modules\node-fetch\lib\index.js:272:32
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:47024) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, orhout a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, usedled-rejections=strict the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:47024) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js 
terminate the Node.js process with a non-zero exit code.
#

can someone tell why i am getting this error

#

i am requesting data from an api

cinder patio
#

you need to await the promise and then parse

river panther
#

oh, ok, thank you

fathom frost
#

@cinder patio Help help

cinder patio
#

ask ask

river panther
# cinder patio ask ask

i did that

let data = await fetch(`http://ergast.com/api/f1/drivers.json/${driver}`);
            const  info = data.json().stringify()
#

still shows the same error

fathom frost
#

ok so

river panther
#

ples explain

fathom frost
#

Are you seeing the event thing

#

I told you yesterday

#

I already putted all commands on one event

cinder patio
fathom frost
#

But the message stills appearing

river panther
#

ooh

cinder patio
#

hmmm, mind sharing your code again @fathom frost

fathom frost
#

ok

stone quest
#

guys, kinda starting here but does anyone know how could I set my bot to use @ mention as its default prefix? I have no clue how to do it

fathom frost
#

Can i share on dms?...

cinder patio
#

no

river panther
#

@cinder patio still the same code

fathom frost
#

ok

river panther
#

error*

cinder patio
river panther
#

what do?

fathom frost
#

I cant create more commands :C

#

I am only using 2 events ig

river panther
#

=|

cinder patio
river panther
#

oh, ok

cinder patio
#

btw

river panther
#

mhm

cinder patio
#

you will most likely get an error for trying to call .stringify()

#

json can't have functions

river panther
#

oh, so do i do .parser()

#

or whatever it is

fathom frost
#

ok not appearing...

cinder patio
#

no you do JSON.stringify(...)

river panther
#

wait, how

#

please give an example

cinder patio
#

But why are you parsing and then stingifying? What is your goal

river panther
#

you only asked me to parse it

cinder patio
#

I didn't ask you anything

cinder patio
#

That was when you had to await the fetch

river panther
#

oh

cinder patio
#

It's just await data.json() to get the data

#

data.json() parses it from a json string to an actual object

river panther
#

oh, ok

earnest phoenix
#
              if (err !== null) return;  
            
              imghash
                .hash(body)
                .then(hash => {
                  let result = db[hash];
                  
                  if (result === undefined) {
                  message.channel.send("f");
                  }
                
                  message.channel.send( + result); ({ time: 10000 });```
                                                                                                                    ^^^^^^^^^^^^^^
#

timeout dont work

brave spoke
#

what

earnest phoenix
#

({ time: 10000 });

#

dont work

royal herald
#

are u want to add timeout for sending message?

earnest phoenix
#

yup

royal herald
#

can u wait a min

earnest phoenix
#

ohk

royal herald
#

hmm

#

you want timeout for only that command rigth?

#

oh sorry i have school

earnest phoenix
woven sundial
#

Hi, that code returns me undefined and not the variable string. Idk why. Can someone help me ?

let site;

          axios
          .get("https://api03.thehostingbot.xyz/netheberg.fr")
          .then((response) => {
            var data = response.data
            if(data.statusInfo.statusCode == 200){
              if(data.pingInfo.time<250){
                site = ":white_check_mark: | Site Web (" + data.pingInfo.time +"ms) [[Visiter le site]](https://netheberg.fr)";
              }else{
                site = ":chart_with_downwards_trend: | Site Web (" + data.pingInfo.time +"ms) [[Visiter le site]](https://netheberg.fr)";
              }  
            }else{
              site = ":x: | Site Web `"+`${data.statusInfo.statusCode} - ${data.statusInfo.error}`;
            }
          })
console.log(site)
boreal iron
#

Add catch() to check if your promise gets rejected for some reason.

slim heart
#

its an async issue not an error

#

@woven sundial put what you do with site in the .then

#

you can't use something that's defined after the fact before it's even defined

boreal iron
#

Oh yeah I see he didn’t await it

#

Nvm

woven sundial
#

Maybe should I just await it ?

slim heart
#

sure

woven sundial
#

bc I cant put my result in the axios get request

river panther
#

how do i get these objects?

slender thistle
#

Iterate over yourarray[0].DriverStandings

river panther
#

oh, ok

crystal wigeon
#

wtf suddenly i cant see offline peeps on my server

#

its happening only on 1 server

#

i can see on others

#

dafuq

river panther
slender thistle
#

Your object is in an array as the only element

#

so to get it you do yourarray[0]

boreal iron
#

Loop through DriverStandings

#

Thx auto corrections

slender thistle
#

since that gets you the object itself which contains DriverStandings, you access that and then probably do for loops over it or something

river panther
#

oh, ok

edgy tapir
#

i made an html table and i want to make like the squares in the table glow if the cursor is on it, help ?

dusky sundial
boreal iron
#

We all saw that cheap ad KEKW

dusky sundial
#

I apparently fat fingered my ctrl-c and pasted the wrong link, oops

quartz kindle
#

phat

boreal iron
#

Use hover for the whole line table tr:hover td or just for the cell you’re in with your mouse table td:hover

willow mirage
#

does running d.js on multi process is necessary ?

quartz kindle
#

depends on how big your bot is and how much cpu it is using

waxen snow
#

Ummmmm... How do I get custom Commands in my bot??

#

Halp

umbral zealot
#

write them. with code.

waxen snow
#

Ok what code?

umbral zealot
#

your bot's code.

waxen snow
#

discord.js?

umbral zealot
#

Step 1) learn programming
Step 2) choose a library
Step 3) write your bot
Step 4) ???
Step 5) Profit!

waxen snow
#

Ok

boreal iron
#

Step 5)

Damn capitalist!

willow mirage
#
const Guild = require("../../models/guilds");
module.exports = async function getGuild(client, id) {
    try{
        const guild = await Guild.findOne({ _id: id }).catch(e => require('../function/error')(e, undefined))
        if (!guild) {
            const guild = await require('./newGuild')(client, id);
            return guild
        }
        if(!guild.voice){
            guild.voice = {
                "enable": false, "_id": ""
            }
            await guild.save();
        }
        ------>> console.log(guild.voice) <<------------
        return guild;
    }catch(e){
        return require('../function/error')(e);
    }
    
}

Why is it console.log() nothing just a empty object ?

#
voice: {
        "enable": Boolean, "_id": String
    }
#

this is in my model

lament rock
#

The property is probably a getter/setter which voids the value assignation

lyric mountain
#

ah, wait

#

you defined it as a constant

lament rock
#

getter values won't appear in object logging

willow mirage
#

what

#

me?

lament rock
#

const is only for shallow reassignment. You're able to reassign the value of object properties of consts

lyric mountain
#

no, I mean

willow mirage
#

it is ok

#

when i defien as cosnt

willow mirage
#

u mean the value is too big?

#

to display it?

ember wave
#

hi

willow mirage
#

@lament rock i have done this before and it makes no problem, but now i dunno why it is not saving and it has an empty obj

lament rock
#

getters and setters are methods which pretend to be properties. A getter specifically returns a possibly private variable scope locked. Setters are properties which accept reassignment statements to change the value of a possibly private variable

onyx hare
#

would message.reply(embed) work as a ping before sending the embed?

willow mirage
#

:(((

lament rock
#

I am speaking human. Getter and setter properties do not show in logging/stringification of Objects

willow mirage
#

so how i can fix it?

#

cuz i can't find anything on google

earnest phoenix
#

Is it possible to document that a value of a function will be an object that has an unspecified property name, basically the property name can be anything in JavaScript using JSDoc? For example:

function deleteMany(...keys) {
  return keys.map(key => ({
    [key]: this.delete(key)
  }));
}```
crimson vapor
#

in ts its ts interface stuff { [key: string | number]: any }

lament rock
#

or keys to be Array<keyof object>

#

If you want it to be an instance of the class properties, you could do
@param {Array<keyof typeof Class>} keys

#

Idk if the this keyword works

#

or wait. Exclude the typeof Class. typeof Class is before it's constructed

#

just Class is when it's constructed

earnest phoenix
#

Hmm lemme see

lament rock
#

Oh wait

#

This is a Map extension, right?

#

keyof returns a type which shows all of the Object's properties as an OR

#

What are you trying to do

#

If you have the generic type for what you key your Map with, you can just pass that generic

#

I think this is how it's done

/**
 * @template K
 * @template V
 * @extends Map<K, V>
 */
class Thing extends Map {
   constructor() {
      super();
   }
   /** @param {Array<K>} keys */
   deleteMany(...keys) {...
outer perch
#
 DiscordAPIError: Unknown Message
2021-03-01T09:37:18.790588+00:00 app[worker.1]: at RequestHandler.execute (/app/node_modules/discord.js/src/rest/RequestHandler.js:154:13)
2021-03-01T09:37:18.790589+00:00 app[worker.1]: at runMicrotasks (<anonymous>)
2021-03-01T09:37:18.790590+00:00 app[worker.1]: at processTicksAndRejections (internal/process/task_queues.js:93:5)
2021-03-01T09:37:18.790590+00:00 app[worker.1]: at RequestHandler.push (/app/node_modules/discord.js/src/rest/RequestHandler.js:39:14)
2021-03-01T09:37:18.790591+00:00 app[worker.1]: at MessageManager.delete (/app/node_modules/discord.js/src/managers/MessageManager.js:126:5) {
2021-03-01T09:37:18.790592+00:00 app[worker.1]: method: 'delete',
2021-03-01T09:37:18.790593+00:00 app[worker.1]: path: '/channels/773263328017252372/messages/815880348768534558',
2021-03-01T09:37:18.790594+00:00 app[worker.1]: code: 10008,
2021-03-01T09:37:18.790594+00:00 app[worker.1]: httpStatus: 404
2021-03-01T09:37:18.790595+00:00 app[worker.1]: }
lament rock
#

When you try to fetch a message which doesn't exist/has been deleted

#

or try to do some other rest action on a message which doesn't exist/has been deleted

#

in your case, delete

lament rock
outer perch
#

@lament rock the problem is I can't find in the code where the problem is

#

maybe I used a message.delete(); incorrectly

lament rock
#

You need to check if a message has already been deleted or not and then try to delete it

outer perch
#

aight

earnest phoenix
lament rock
#

You can just cast it as K since it'll be the same as what the user defines it as

earnest phoenix
lament rock
#

WAIT A MINUTE

#

now I understand