#development

1 messages Ā· Page 2053 of 1

earnest phoenix
#

what's wrong duh

quartz kindle
#

are you using djs v13?

earnest phoenix
#

BLURPLE is not a valid button style

earnest phoenix
quartz kindle
#

see voltrex's answer

earnest phoenix
#

new MessageButton()
.setCustomId('1')
.setLabel('šŸ˜‚')
.setStyle('PRIMARY '),
new MessageButton()
.setCustomId('2')
.setLabel('šŸ˜€')
.setStyle('PRIMARY '),
new MessageButton()
.setCustomId('3')
.setLabel('āš’ļø')
.setStyle('PRIMARY'),
new MessageButton()
.setLabel('Invite me !')
.setStyle('URL')
.setURL("https://dsc.gg/zylem")

#

this ?

#

.setStyle('PRIMARY')

#

PRIMARY is for the blurple coloring, which I suppose is what you're looking for so yes

lyric mountain
#

last one will fail

earnest phoenix
#

For links, it's LINK not URL

earnest phoenix
spark flint
earnest phoenix
#

I don't think that's where the error occurs, what's the permissions variable's value?

spark flint
quartz kindle
#

what is guild.permissions?

spark flint
#

returns the bitfield

earnest phoenix
#

The Permissions constructor only accepts bigints now, not numbers

spark flint
#

what permission the user logging in has in that guild

#

37080768 for example

earnest phoenix
#

BigInt(guild.permissions)

spark flint
#

ah alr lemme try rq

#

awesome that worked

lyric mountain
spark flint
#

thats what Discord returned

lyric mountain
#

yes, because integers are always base 10

spark flint
#

Gonna store guilds in a database and insert ID into db when it joins and remove when it leaves etc

#

so people can't ratelimit the bot

lyric mountain
#

you need to convert it to base 2 if u want to view what's toggle on/off

earnest phoenix
#

Working with large numbers is problematic with regular 32-bit numbers in JavaScript, as bitfields can be a pretty large precision number, so bigints are preferred

quartz kindle
#

except that they waste a lot more memory

#

and are slow af

#

i even made a lib to avoid using bigints lol

earnest phoenix
#

Especially with bitwise operations and exponentiations

lyric mountain
quartz kindle
#

not yet

lyric mountain
#

damn

quartz kindle
#

bigint bitwise is literally 50x slower than regular numbers

earnest phoenix
#

Time to write a lib to turn Tim into a catgirl

lyric mountain
#

bigint is to numbers what HDD is to SSD

quartz kindle
#

meow

lyric mountain
#

it's big, like, real big, but slow

#

iirc biginteger doesn't even have a limit, depends on how much ram u have

spark flint
#

anyone know the url for the fallback Discord avatar?

#

/ the default one

#

its like 1.png

solemn latch
#

there's a handful of them, and they depend on the tag of the user

quartz kindle
#

remember when people were hating on the new discord logo?

#

pepperige farm remembers

solemn latch
#

It was a good change for users on mobile

solemn latch
spark flint
#

oh btw

#

for av.dbl.tf, i recommend adding a random string on the end to clear cache

#

my fix was using the timestamp thing as a query so cache was cleared

solemn latch
#

yeah, I can put the timestamp

#

yeah

#

I just was mostly worried about destroying the api with requests, getting over 1.5k a day now.
Turns out most people disable the user icon anyway though.

spark flint
#

it caches internally

#

with userids

#

stores the buffer in cache (terrible solution I know but it works) for 15 mins

solemn latch
#

why not cache at the webserver level and ignore query params.

spark flint
#

i only suggested query params because Discord cache

solemn latch
#

probably can be a bit more efficient that way.

spark flint
#

I ignore query params anyways

#

discordā„¢ļø

solemn latch
#

so I used prisma on v2...
that was a mistake

spark flint
#

lol

solemn latch
#

I've spent whole days on single errors that have no solution(talked to a contributor).

quartz kindle
#

i've seen lots of issues with prisma as well

solemn latch
#

I'm too far in now to back out though.
Ive made workarounds but they are so ugly. It hurts because I've done such an amazing job imo everywhere else.

earnest phoenix
#

A

thin oracle
#

If you playing don’t texts him

quartz kindle
#

nice scam bro

thin oracle
#

It’s not

#

Dm him right now

quartz kindle
#

nice scam

thin oracle
#

It’s not I am tell you

quartz kindle
#

if its not then why dont you dm him and make the 3k yourself

wheat mesa
#

Check and mate

spark flint
#

@solemn latch

#

omg claim the monies!!

solemn latch
#

@thin oracle no ads

spark flint
#

but its not ads woo, its legit 3k monies!!

wheat mesa
#

free shekels

spark flint
#

source: trust me bro

raw nest
#

Can I use FontAwesome's free plan for my software which maybe gets commercially used or something?? I don't find something clear I just find the Pro Version license

boreal iron
#

Nobody gives a fuck about it as nobody has a way to check if you’re licensed or not

raw nest
#

hm well I found something more safe I guess

boreal iron
#

Im using it for ages now on every project and site no matter it’s private or business site

raw nest
#

for private stuff I instantly take FontAwesome no question but for professional stuff I'm more into checking all the stuff about license and copyright etc.

boreal iron
#

But it’s up to you of course

sick agate
#

Yea

sick agate
boreal iron
#

Yeah like I said the pro files don’t come with a license file or anything you could check if your site has a license or not

#

Also you can bind the license to natural person not a domain which makes it also impossible for somebody else to check if your license is valid

#

If you get closer into their tos they also don’t sell a license but more like a subscription to use their pro icons

#

Which is less "violentlyā€œ if you decide to grant somebody else access to your downloaded icons

#

But like I said it’s up to you

split hazel
#

how should i implement encryption in traffic between my database and the client (pure tcp btw)

#

im thinking just using asymmetric encryption

#

like each side generates a public and private key and they both exchange the public keys and encrypt the payloads with it

quartz kindle
#

you cant use tls/openssl?

split hazel
#

cant lie i have no idea how any of them work underneath

#

but doing it from scratch sounds more interesting anyways

#

should i just generate one public key and use it across all clients or create a unique public key for all clients

#

(ones faster than the other i'll let you guess which one)

#

encryption will only be used if the client requests to use it, or unless the server makes it mandatory

#

the handshake is not encrypted so its an easy way to exchange keys

lofty cedar
#

Hi.
If I'm making a virtual host on ubuntu with apache and my server is running on flask, what should the DocumentRoot be?

lyric mountain
#

errr....

#

index?

lofty cedar
lyric mountain
#

ah wait, it should be the root folder, like, where ur site starts no?

radiant kraken
boreal iron
#

The paths are always absolute paths, keep that in mind

ancient nova
#

how do I replace the token out of the eval command?

#

I tried everything

#

client.token by itself seems to work nicely, but doing message.channel.send(client.token); somehow doesn't 😭

wheat mesa
#

Pro tip: don’t make your eval command public!

#

You will not be able to secure it easily

#

Just make it dev-only

#

Unless you really know what you’re doing

ancient nova
#

reason I didn't even make it available for me is because I really don't trust myself

#

that's why I'm asking if anyone knows how to do it properly

quartz kindle
#

just use string replace

#

message.channel.send(evaled.replace(client.token, "bot token"))

ancient nova
ancient nova
#

any many other variations

radiant kraken
#

.replaceAll

ancient nova
#

it works if I just eval client.token by itself but if I try doing it using <channel>.send it shows

ancient nova
quartz kindle
#

you cant

radiant kraken
#

then just don't send your token

quartz kindle
#

evaling gives you full execution rights, its impossible to protect against every possible attack vector

radiant kraken
#

plus there's a feature to regen it

ancient nova
#

I just want to hide the token tho

#

no need for anything else

ancient nova
radiant kraken
#

in the dev portal

wheat mesa
#

You can regenerate your token in the dev portal

radiant kraken
#

^

ancient nova
#

yeah that's rather obvious

#

but if I'm not available and somehow someone grabs the token I'd rather not take chances

quartz kindle
#

best you can do is using the string replace method for finding tokens in the evaled string, and also use stirng replace to remove any occurence of .token for example, but its impossible to protect against every possible way to get the token

wheat mesa
#

Eval commands are inherently dangerous, there is nothing you can do to stop them from being used maliciously

ancient nova
quartz kindle
#

for example you could still do client["token"] or even client[["t","o","k","e","n"].join("")]

wheat mesa
radiant kraken
#

you can make the eval responses in DMs instead of public

wheat mesa
#

eval just runs your code

ancient nova
quartz kindle
#

you are executing another command inside a command

wheat mesa
ancient nova
quartz kindle
#

the first command cannot see the token string inside the second command

ancient nova
#

I edited discord.js package a lot

wheat mesa
#

And that’s not an 'endpoint'

#

The client token is used quite literally everywhere

ancient nova
#

that's just a term I use to refer to it

radiant kraken
#

client.token is not a getter-only property?

ancient nova
#

how?

quartz kindle
wheat mesa
#

Rest

radiant kraken
#

Sending requests to the discord API

#

like sending messages

#

lol

ancient nova
#

well that's a problem

wheat mesa
#

That’s probably your best option if you don’t trust yourself

ancient nova
#

you'd think discord.js caches the token after initialization instead of fetching it everytime

wheat mesa
#

Granted you would still be able to instruct the bot to send the message

radiant kraken
#

yes, it's cached in client.token

proven lantern
#

is it possible to send an ephemeral message that isn't a response to an interaction?

ancient nova
ancient nova
#
evaled = evalec.replaceAll(client.token, "[REDACTED]");
proven lantern
radiant kraken
vivid fulcrum
#

you cannot fetch the token anyways, the token endpoint is a regen-only and a user-only endpoint, the vulnerability is in the environment where the token string is used

wheat mesa
#

The only bots that have public eval commands that would be immune to some sort of malicious behavior is those that either use a sandboxed environment to run code (still kinda dangerous) or use an API of some sort

ancient nova
radiant kraken
#

make it send in DMs

radiant kraken
#

why would you want to do message.channel.send every time you eval something

ancient nova
#

I'm not quite sure but as long as it's not emulated it should be safe

quartz kindle
vivid fulcrum
#

replacing won't work, i can insert random characters in-between every character in the string which nullifies the replace

wheat mesa
#

There is an infinite amount of ways to get your token from an eval command, either accept it and move on, go through a complex process to run it, or don’t have an eval command

ancient nova
radiant kraken
#

the problem is why would you want to send your token to the public

quartz kindle
wheat mesa
#

There’s still ways to get it

quartz kindle
wheat mesa
#

If you’re really going to leak your token like that then you’ve probably already leaked your token a thousand other ways

#

Just use it in a private server or in DMs

radiant kraken
ancient nova
boreal iron
# ancient nova can you break a VPS?

Ofc especially since 99% of the customers have literally no network knowledge including how to secure their servers and configure their apps/services/firewalls.

wheat mesa
quartz kindle
vivid fulcrum
#

imo the absolutely safe way to run evals is to containerize it in another process, you effectively remove all djs methods though so you'd have to implement some sort of an interpreter and hand pick which methods to parse and call in your main process

wheat mesa
#

Like what MODiX uses for the C# server, and what Geordi uses for C++

ancient nova
vivid fulcrum
#

yup

vivid fulcrum
#

it is

boreal iron
#

Challenge time

wheat mesa
quartz kindle
ancient nova
#
    if (message.author.id !== process.env.OWNER) return;
wheat mesa
#

There’s a reason eval commands are meant to be restricted to only trusted people

wheat mesa
#

Because you’re running unknown 3rd party code on your machine

boreal iron
#

No risk no fun gentlemen

ancient nova
#

I doubt anyone would be evil enough to brick a VPS

boreal iron
#

Just to say

wheat mesa
#

log4j would like to hire you

boreal iron
#

lol

vivid fulcrum
#

especially on platforms like discord

wheat mesa
#

No such thing as morals on discord lmao

quartz kindle
#

speaking of running 3rd party code, my api parses user input into a linux grep command, will this be enough to sanitize it?
query.replace(/[&`\\"|*~<>^()[\]{}$\n\r]/g, "")

radiant kraken
#

me when client["nekot".split("").reverse().join("")]

wheat mesa
#

Lol

#

Is .reverse a real thing in js?

radiant kraken
#

yes

quartz kindle
#

yes

wheat mesa
#

Never seen that before

#

Interesting

ancient nova
wheat mesa
#

Seen rust’s .rev()

#

But not that

quartz kindle
#

also, array.push()*n + array.reverse() is faster than array.unshift()*n

ancient nova
#

wait a second

#

wtf

#

can bots create guilds?

quartz kindle
#

yes

ancient nova
#

WHAT

#

HOW DOES THAT EVEN WORK

vivid fulcrum
#

yes, as long as they're in under 10 guilds

ancient nova
boreal iron
ancient nova
#

can someone explain how does bot creating a guild even work?

wheat mesa
#

It creates a guild.

ancient nova
#

would it be the owner?

wheat mesa
#

Yes

ancient nova
#

so many questions

vivid fulcrum
#

the same way a user does

#

a bot is a user

wheat mesa
#

Under 10 guilds it’s allowed

ancient nova
#

can you transfer the owner to a user after creation?

wheat mesa
#

There’s a reason it’s not allowed above that though lol

ancient nova
#

that can be super super super abused

quartz kindle
wheat mesa
#

Not really

ancient nova
# wheat mesa Not really

wdym you can log into someone's account and then create like 50 guilds then transfer ownership to the logged person

wheat mesa
#

You cannot do that

boreal iron
ancient nova
#

it sounds like you can from what you're telling me

vivid fulcrum
#

any exploit you can think of has measures to prevent said exploits

wheat mesa
vivid fulcrum
#

otherwise we wouldn't be talking about this

ancient nova
#

it's still quite a lot

wheat mesa
#

Discord has had an API for a long time, you’re not the first one to think of these things, they have measures to prevent abuse of their api

vivid fulcrum
#

that doesn't make it any different from just creating the guilds yourself as a user though lol

ancient nova
vivid fulcrum
#

if you're at the guild limit as a user, transferring the ownership to you will fail

ancient nova
#

a person I know got a virus on their discord once

wheat mesa
#

That’s not a virus, I’ve seen that bug before

ancient nova
#

the application kept changing colors from white mode to black mode

wheat mesa
#

Oh you mean not from discord but got into discord

boreal iron
wheat mesa
#

I was thinking of the emoji that triggers windows defender

ancient nova
ancient nova
boreal iron
#

And creating a guild isn’t dangerous

vivid fulcrum
#

cracked

#

lol

radiant kraken
#

cracked sdForgor

wheat mesa
#

Cracked version of a free service moment

ancient nova
#

😭 what

radiant kraken
#

cracked nitro perhaps?

ancient nova
#

like modded ok

#

just a term

ancient nova
#

like modded xml files

wheat mesa
#

BetterDiscord is like the only thing I would trust

ancient nova
wheat mesa
#

Since it’s open source and widely used

#

I’m aware, they don’t ban BD users unless they have malicious plugins or do something harmful though

vivid fulcrum
#

staff don't care if you have a modded client unless you use it to abuse the api or bother people, confirmed many times in dapi

wheat mesa
#

Most people just use it for custom themes

ancient nova
#

I wasn't aware of that

wheat mesa
#

Yes

radiant kraken
#

It's very obvious

ancient nova
#

how do they do it?

radiant kraken
#

From the screenshots

wheat mesa
#

Lol

ancient nova
#

well that's not what I meant...

vivid fulcrum
#

quietly by checking file sizes/checksums and api behaviour

boreal iron
vivid fulcrum
#

every single api request in the client is logged

ancient nova
#

can they detect if you messed with the html of the web client?

radiant kraken
#

/api/science moment

wheat mesa
#

I used BD at one point because I wanted a nicer theme, then it just became more of a hassle and I didn’t care about the theme anymore

ancient nova
#

that would be an overkill tho

vivid fulcrum
#

thanks to that discord has an automatic system to prevent dm bots

vivid fulcrum
#

just by checking the behavior of your api calls

wheat mesa
#

That would just be a client side modification, but messing with the HTML would not be able to change the behavior of the client itself

ancient nova
vivid fulcrum
#

and the fact that discord is barely made in html 🄲 most of the DOM in discord is virtual

ancient nova
#

is changing the HTML only against TOS?

radiant kraken
#

no

wheat mesa
boreal iron
vivid fulcrum
#

oh god i remember that

ancient nova
#

that's great, I could make the script into an extension

radiant kraken
#

LMAO

vivid fulcrum
#

they were absolutely mental

boreal iron
#

Yeah but still funny somehow

#

At least a bit

#

If he 100% refuses to accept the reality

wheat mesa
ancient nova
#

by the way is it possible to bulkDelete a messages from certain users?

vivid fulcrum
#

yes, by filtering out the messages in your code

wheat mesa
#

The bulkDelete endpoint takes an array of message IDs, filter out the messages by user

vivid fulcrum
#

the bulk deletion endpoint doesn't care about anything but the ids of the messages you want to delete

ancient nova
#
await message.channel.bulkDelete(...).filter(...)
``` ?
wheat mesa
#

What

ancient nova
#

would something like this work?

wheat mesa
#

No

#

Fetch messages, filter by user, then bulk delete

vivid fulcrum
#

why can't people think in a logical flow 😭

wheat mesa
#

Can’t just randomly throw a .filter on something and expect it to work lol

vivid fulcrum
#

yeah

boreal iron
vivid fulcrum
#

this channel suffers from so many people trying to be developers when it isn't meant for them, talking generally here, didn't mean to target anyone

wheat mesa
#

I think there’s a certain level of intuition that goes along with it. Logical thinking can certainly be learned but it helps a lot to just have a logically oriented mind

quartz kindle
#

all of the above problems are more likely caused by not knowing enough how the language works

wheat mesa
#

I know some people that will panic on tests because they look at a question and have no idea what to do, but when I help them later and break it down into parts they find that they can do it really easily

boreal iron
#

Dogs do, people not

ancient nova
#

I have one idea of how I could do that but I'm not sure if it's the best

quartz kindle
#

its not exactly a lack of logical thinking if you dont know what is a promise, what is an array, and what is what in a given piece of code

wheat mesa
#

Sometimes it helps to think like you’re writing pseudo code too lol

quartz kindle
#

its just lack of knowledge

boreal iron
#

Also true

radiant kraken
#

i remember learning JavaScript just for making discord bots, worst decision in my life

boreal iron
#

Missing the fundamental knowledge is a pain to do something

ancient nova
#

I could check the 2nd argument for mention then do the purge command with it and if there was not a mention I could bulkDelete insstead

wheat mesa
#

My first ever programming project was a bot in djs

radiant kraken
#

it feels so hard to understand the language in a very complex environment

wheat mesa
#

If you check my message history and go back to my oldest messages, I was a complete js clown

radiant kraken
quartz kindle
#

:^)

ancient nova
#

is that good enough? :]

vivid fulcrum
quartz kindle
#

i basically also learned js from making a bot

#

i had a bit of previous experience, but it was very limited and mostly browser js

wheat mesa
#

My only previous experience was a summer school thing I did when I was 9 lmao

radiant kraken
#

My first time programming was from some random youtube recommendation in late 2019

wheat mesa
#

Remembered a whopping nothing (probably because it wasn’t very in depth at all)

#

I started programming in like September or August of 2020 I believe

vivid fulcrum
#

started out with minecraft plugins and then developed deep hate for java gang

#

i associate java with my childhood trauma

radiant kraken
#

java is okay, it just needs to be more optimized

boreal iron
#

I did get into it too after moving the php bot to js but years of experience with an actual Programm language helped a lot

vivid fulcrum
#

far from okay

quartz kindle
#

i never tried java, but i always hated it because of the annoying jdk shit that i had to keep installing every time a new update was out because banking plugins required it (and minecraft)

ancient nova
#

can anyone give me a link to the messages.fetch function documentation?

#

I can't find it

vivid fulcrum
#

the desing extremely messy and there's tons of patterns that the language can't seem to decide which one to make a standard, i.e. the stream api

ancient nova
#

I'm not sure how to format that

vivid fulcrum
#

design*

ancient nova
#

do I just put fetch({author: id})?

quartz kindle
ancient nova
#

or is it more complicated?

quartz kindle
wheat mesa
#

Ok I just confirmed my first ever real programming project was a discord bot on august 25th 2020

radiant kraken
#

fetch messages -> filter by user ID -> get message IDs by corresponding user ID -> bulk delete

wheat mesa
#

(Also make sure that you’re filtering out any messages greater than 14 days old)

boreal iron
#

Or more probably

#

Oh and pawno of course

wheat mesa
#

I believe bulkDelete will not work (?) if you try to delete any message more than 14d old

vivid fulcrum
ancient nova
#
            let messagesToDlete = await message.channel.messages.fetch({limit: messagesToDelete, });
            messagesToDlete = messagesToDlete.filter(message => message.author.id === mentionedUser.user.id);
``` alright so I got something like this
#

now do I loop through them or what?

radiant kraken
boreal iron
#

yikes

wheat mesa
#

Same

boreal iron
#

I faked my parents sign under the contract to the rent servers back in time when I was 14

#

lmao

quartz kindle
radiant kraken
#

And of course it's multipurpose sdTroll

ancient nova
#

then what is limit for?

#

from what I read it does exactly what you say it doesn't

vivid fulcrum
#

i used to selfhost on a notebook that was meant for office work. let me tell you, wifi and an old laptop processor sure make a great team for extremely fast response times!

quartz kindle
ancient nova
#

oh

quartz kindle
#

if in those 50 messages, only 10 were from that user, thats the number of deleted messages

ancient nova
#

that does make sense

boreal iron
#

If it would actually have WiFi

quartz kindle
#

back in 2010 i downloaded visual basic and said "im gonna try to program something"
spent a couple hours on it, didnt understand shit, uninstalled

vivid fulcrum
#

i remember when wifi was on the rise, the pop out antennas 😭

radiant kraken
#

I regret learning Visual basic

#

basically microsoft PHP

ancient nova
#

@quartz kindle ```js
const messagesToDlete = await message.channel.messages.fetch({limit: 100});
const filteredMessages = messagesToDlete.filter(msg => msg.author.id === mentionedUser.user.id);

        for (i = 0; i > filteredMessages; i++) {
            if (i >= messagesToDelete) break;
            filteredMessages[i].delete();
        }
#

will this do the trick?

radiant kraken
#

nooo

#

that's api abuse lol

quartz kindle
boreal iron
ancient nova
radiant kraken
#

that's where bulkDelete comes in

vivid fulcrum
wheat mesa
#

me when someone forgets the initialization keyword of the variable in the for loop

boreal iron
#

If I ever have the time to play of course

ancient nova
radiant kraken
#

map the message IDs and call the bulkDelete func

quartz kindle
#

bulkDelete(array of message ids)

#

or array of messages works too

#

so basically you dont even need to remap

#

bulkDelete(filteredMessages)

radiant kraken
#

oh right i forgot we're working with a wrapper here

ancient nova
#
        if (mentionedUser !== undefined) {
            const messagesToDlete = await message.channel.messages.fetch({limit: 100});
            const filteredMessages = messagesToDlete.filter(msg => msg.author.id === mentionedUser.user.id).map(msg => msg);
            
            await message.channel.bulkDelete(filteredMessages + 1).then(messages => {
                message.channel.send(`Successfully purged ${messages.size - 1} out of ${messagesToDelete} messages from the chat.`);
            });
        } else {
            await message.channel.bulkDelete(messagesToDelete + 1).then(messages => {
                message.channel.send(`Successfully purged ${messages.size - 1} out of ${messagesToDelete} messages from the chat.`);
            });
        }
#

so

#

does that work?

#

whoops

boreal iron
#

My gosh I remember the times when you couldn’t just ask how to do things
When there was a forum people needed days to reply if were lucky
A time you had to test and try things an entire day to get it working or give up

quartz kindle
#

why + 1

ancient nova
#

the command

radiant kraken
#

bruh

ancient nova
#

ĀÆ_(惄)_/ĀÆ

quartz kindle
#

you are deleting messages by id

#

not by number

ancient nova
#

yeah I noticed

wheat mesa
#

Also you can’t fetch more than 100 messages at a time, right?

ancient nova
wheat mesa
#

Oh just saw that

vivid fulcrum
#

doesn't djs batch requests if the argument is higher than 100 regardless?

quartz kindle
#

no

#

dpy does that

vivid fulcrum
#

bad lib

quartz kindle
#

but djs doesnt

#

bed lib

radiant kraken
#

i miss dpy

quartz kindle
#

then go back to it

#

its alive again isnt it?

boreal iron
#

Dynamic, expects no argument and can live with a wrong one

radiant kraken
#

it still is?

quartz kindle
#

didnt danny come back?

ancient nova
#
        if (mentionedUser !== undefined) {
            const messagesToDlete = await message.channel.messages.fetch({limit: 100});
            const filteredMessages = messagesToDlete.filter((msg, index) => msg.author.id === mentionedUser.user.id && index >= messagesToDelete).map(msg => msg);
            
            await message.channel.bulkDelete(filteredMessages).then(messages => {
                message.channel.send(`Successfully purged ${messages.size} out of ${messagesToDelete} messages from the chat.`);
            });
        } else {
            await message.channel.bulkDelete(messagesToDelete + 1).then(messages => {
                message.channel.send(`Successfully purged ${messages.size - 1} out of ${messagesToDelete} messages from the chat.`);
            });
        }
``` forgot to limit
#

is index a thing in the filter func?

boreal iron
quartz kindle
#

seems very active

radiant kraken
#

wait what bruh

#

but the damage is already done

ancient nova
#

wat

wheat mesa
#

Probably got harassed too much for leaving KEKW

radiant kraken
#

bruh sdForgor

boreal iron
#

After running so much people’s work

wheat mesa
#

ā€œRuiningā€

#

Doubt

#

People will cry over anything when they have to update code

ancient nova
#

um guys

wheat mesa
#

So many people still use v12 because ā€œv13 is too much workā€ to update to

ancient nova
#

I don't think

#

that worked

#

Successfully purged 42 out of 3 messages from Anonymous Hater#2437.

boreal iron
wheat mesa
#

Lol

radiant kraken
#

you know the host freerealestate

wheat mesa
#

Devs are lazy, it’s their job

ancient nova
#

😐 can I get help or not

wheat mesa
#

Automate the tasks that we’re too lazy to do by hand

vivid fulcrum
#

"i watched a youtube tutorial and i have no idea how my programming environment works" trope

wheat mesa
ancient nova
#

I'm using .then to get the message size

wheat mesa
#

You don’t need to do that

#

Use async await

#

It’s the same thing but a lot easier to read

vivid fulcrum
#

also, look at the variables you're using in the string very carefully

wheat mesa
#

^

wheat mesa
#

messagesToDelete is not a number

#

It’s a Collection

boreal iron
ancient nova
#

no messagesToDelete is a number

#

I just noticed I named two variables the same thing

wheat mesa
#

Oh nevermind you just have bad naming KEKW

boreal iron
#

And if people grow up using that trash instead of learning things how you would expect it

ancient nova
#
            const messagesToDeleteFiltered = await message.channel.messages.fetch({limit: 100});
            const filteredMessages = messagesToDeleteFiltered
                  .filter((msg, index) => msg.author.id === mentionedUser.user.id && index <= messagesToDelete)
                  // We are mapping to make the message IDs readable to the bulkDelete() func.
                  .map(msg => msg);

            await message.channel.bulkDelete(filteredMessages).then(messages => {
                message.channel.send(`Successfully purged ${messages.size} out of ${messagesToDelete} messages from ${mentionedUser.user.username}.`);
            });
``` I know ![KEKW](https://cdn.discordapp.com/emojis/727825308404940800.webp?size=128 "KEKW")
#

is that better readable

#

I moved the index to the map func cause I know map has the index property

#

will that fix it?

vivid fulcrum
#
.map(msg => msg)
ancient nova
wheat mesa
#

You don’t need to map

ancient nova
#

so you told me lies

boreal iron
#

const a = a smirk

wheat mesa
#

That’s why you’re able to chain them like that

ancient nova
#

yeah but index doesn't work in filter

wheat mesa
#

Not sure what else it would even be able to return

ancient nova
#

so how do I check for the amount of messages to be deleted

wheat mesa
#

Huh?

ancient nova
#
.filter((msg, index) => msg.author.id === mentionedUser.user.id && index <= messagesToDelete)
``` notice what I'm even tring to do
#

index <= messagesToDelete

wheat mesa
#

Why do you even need that

ancient nova
#

to delete only the messages that I want to delete

vivid fulcrum
#

you're thinking way too much into it

ancient nova
#

I put -clear 3 I want to delete 3 messages not 1000

wheat mesa
#

You don’t need that

ancient nova
#

then

#

how

#

my brain hurts

wheat mesa
#

Why not just fetch however many messages the user specifies

ancient nova
#

because it's gonna fetch messages from other users too

wheat mesa
#

Math.min(userInput, 100)

#

You’re already fetching messages from other users

ancient nova
#

yeah then I want to filter them to only be the ones of my user

wheat mesa
#

Then filter it after you fetch

vivid fulcrum
#

waffle was right about writing pseudo, you should first outline your problem and solution by writing pseudo then actually translating it into code... you're getting confused because you keep getting lost in your thought process, writing it down will help

wheat mesa
#

You don’t need the index if you only filter however many messages your user tells it to fetch

ancient nova
#

well

#

I'm confused

wheat mesa
#

And if it’s over 100, then just fetch 100

ancient nova
#

???

#

what am I supposed to do

wheat mesa
#

Think about your problem instead of piling more code on to a solution that is already going the wrong direction

#

Just take a second and think about what you need to do

ancient nova
#
            const messagesToDeleteFiltered = await message.channel.messages.fetch({limit: 100});
            const filteredMessages = messagesToDeleteFiltered
                  .filter((msg, index) => msg.author.id === mentionedUser.user.id && index <= messagesToDelete)
``` trying to fetch 100 messages, filtering those messages by user ID and filtering the ones that aren't in the range
#

what's wrong with that?

wheat mesa
#

And write it down in a comment if it helps you

ancient nova
boreal iron
#

If you necessarily need to limit the filtered result then slice the array by the user input

ancient nova
#
            const filteredMessages = messagesToDeleteFiltered
                  .filter(msg => msg.author.id === mentionedUser.user.id)
                  .slice(0, messagesToDelete);
#

better?

vivid fulcrum
#

your naming is so confusing 😭

boreal iron
#

Idk about the order fetch returns

ancient nova
#

oh my god

boreal iron
#

So read the docs or test it out

ancient nova
#

this code had an error

#

5 days uptime over

vivid fulcrum
#

why not name fetched messages just messages and the ones you filter out filteredMessages, your variables don't have to be verbose, that's what comments are for

wheat mesa
#
Your user has given the number to delete, let's call it ARGS
Your user has given the Member object to delete from, let's call it MEMBER

In order, you need to:
  fetchedMessages = Fetch 100 messages
  filtered = Filter those messages to include only those of MEMBER.id
  bulkDelete filtered.slice(0, ARGS - 1)
  Send a message like "You have deleted `filtered.size` messages from `MEMBER.username`"
ancient nova
#
    try {
        if (mentionedUser !== undefined) {
            const messagesToDeleteFiltered = await message.channel.messages.fetch({limit: 100});
            const filteredMessages = messagesToDeleteFiltered
                  .filter(msg => msg.author.id === mentionedUser.user.id)
                  .slice(0, messagesToDelete);

            await message.channel.bulkDelete(filteredMessages).then(messages => {
                message.channel.send(`Successfully purged ${messages.size} out of ${messagesToDelete} messages from ${mentionedUser.user.username}.`);
            });
        } else {
            await message.channel.bulkDelete(messagesToDelete + 1).then(messages => {
                message.channel.send(`Successfully purged ${messages.size - 1} out of ${messagesToDelete} messages from the chat.`);
            });
        }
    } catch {
        return message.channel.send(`Couldn't purge because the messages are more than 14 days old.`);
    }
#

here is the entire thing

wheat mesa
vivid fulcrum
#

wait till we get to the 14 day problem

ancient nova
wheat mesa
#

Don't worry about the 14 day quite yet, that's easy to filter out after you get the other part working

ancient nova
#

..or that won't help?

vivid fulcrum
#

that's like putting a band aid on a deep wound

wheat mesa
#

You can either try catch and let the entire bulkDelete fail, or you can filter them out beforehand and just delete those under 14 days old

#

The second approach is more intuitive for your user

fervent moss
#

How do I get first result

ancient nova
vivid fulcrum
#

it's a 2d array, ^

ancient nova
#

cause it will fetch the amount of messages

#

so it will fetch 3 messages

#

2 of those aren't send my me

#

and if I remove the 3 messages

vivid fulcrum
#

delete what you wrote and start fresh, now following what waffle wrote

wheat mesa
#

You know that's a fair point I didn't think of

ancient nova
#

only 1 gets deleted

#

exactly

wheat mesa
#

I was thinking about something else

ancient nova
#

well then what else could I do?

ancient nova
wheat mesa
#

There

#

I updated it

#

I'll resend it so you don't have to scroll up

#
Your user has given the number to delete, let's call it ARGS
Your user has given the Member object to delete from, let's call it MEMBER

In order, you need to:
  fetchedMessages = Fetch 100 messages
  filtered = Filter those messages to include only those of MEMBER.id
  bulkDelete filtered.slice(0, ARGS - 1)
  Send a message like "You have deleted `Math.min(filtered.size, ARGS)` messages from `MEMBER.username`"
#

(Does slice throw if the second value is too high? Not sure, if it does, just use Math.min)

#

Ok no it doesn't throw, that should be fine

ancient nova
#
            const messagesToDeleteFiltered = await message.channel.messages.fetch({limit: 100});
            let filteredMessages = messagesToDeleteFiltered
                  .filter(msg => msg.author.id === mentionedUser.user.id)
            filteredMessages = JSON.Stringify(filteredMessages).slice(0, messagesToDelete);

            const resultMessage = await message.channel.bulkDelete(filteredMessages).then(messages => {
            return message.channel.send(`Successfully purged ${resultMessage.size} out of ${messagesToDelete} messages from ${mentionedUser.user.username}.`);
``` <--- this is what I wrote before reading your message
wheat mesa
#

What on earth is that JSON.Stringify doing there

ancient nova
wheat mesa
#

Read my message and write it from that pseudo

ancient nova
#

okay give me a sec

#
        if (mentionedUser !== undefined) {
            const messagesToDeleteFiltered = await message.channel.messages.fetch({limit: 100});
            let filteredMessages = messagesToDeleteFiltered
                  .filter(msg => msg.author.id === mentionedUser.user.id)

            const resultMessage = await message.channel.bulkDelete(filteredMessages.slice(0, messagesToDelete - 1)).then(messages => {
            return message.channel.send(`Successfully purged ${Math.min(resultMessage.size, messagesToDelete)} out of ${messagesToDelete} messages from ${mentionedUser.user.username}.`);
        }
#

there

wheat mesa
#

And does that work?

ancient nova
#

let me test

wheat mesa
#

(Not counting the 14 day issue yet)

ancient nova
#

I have to restart my bot 😭

#

almost 6 days uptime

wheat mesa
#

Use a beta bot

vivid fulcrum
#

why are you testing in prod

#

lol

wheat mesa
#

I wouldn't be testing in prod lol

#

Day 15 of silently breaking prod

ancient nova
wheat mesa
#

Still don't understand what that has to do with testing on production though

ancient nova
#

cause I don't have a beta bot

wheat mesa
#

Make one, it's easy

boreal iron
wheat mesa
#

lol

ancient nova
#

} else {
^
SyntaxError: missing ) after argument list

wheat mesa
#

syntax error

#

I'm sure you can debug that one yourself

ancient nova
#

nvm

#

lmao

#
            const resultMessage = await message.channel.bulkDelete(filteredMessages.slice(0, messagesToDelete - 1)).then(messages => {
#

I forgot to remove the .then part

#

update: doesn't work

wheat mesa
#

What doesn't work about it

ancient nova
#

filteredMessages.slice is not a function

#

that's the error

wheat mesa
#

Oh it's a collection isn't it

#

Hold on

ancient nova
#

alr

boreal iron
wheat mesa
#

You'll need to do give it the array of messages

boreal iron
#

Can’t you just use the collection keys which should be the message IDs?

ancient nova
#
        if (mentionedUser !== undefined) {
            const messagesToDeleteFiltered = await message.channel.messages.fetch({limit: 100});
            const filteredMessages = messagesToDeleteFiltered
                  .filter(msg => msg.author.id === mentionedUser.user.id)
                  .map(msg => msg)
                  .slice(0, messagesToDelete + 1);
            
            const resultMessage = await message.channel.bulkDelete(filteredMessages);
            return message.channel.send(`Successfully purged ${resultMessage.size - 1} out of ${messagesToDelete} messages from ${mentionedUser.user.username}.`);
        } else {
            const resultMessage = await message.channel.bulkDelete(messagesToDelete + 1);
            return message.channel.send(`Successfully purged ${resultMessage.size - 1} out of ${messagesToDelete} messages from the chat.`);
        }
``` this fixed it
wheat mesa
#

Or that yeah

ancient nova
#

it works now

boreal iron
#

Map the keys or is there even a collection method to return the keys in an array

#

Maybe

wheat mesa
#

Yeah that looks fine

ancient nova
#

how about that 14 days error issue?

radiant kraken
#

That's the limit

ancient nova
#

yeah you guys said a catch statement wasn't enough

wheat mesa
ancient nova
#

I know how to do it but it would require me to also alter the below bulkDeleting with I'm honestly too lazy to do

#

a try catch it is

wheat mesa
#

Ah yes, spend more than an hour on one problem and still refuse to do it the right way because too lazy mmLol

vivid fulcrum
#

you're wasting a request

radiant kraken
vivid fulcrum
#

i.e. you're intentionally putting yourself in a situation where you can get rate limited

ancient nova
vivid fulcrum
#

no

ancient nova
#

I am limiting the messages by 100 anyway?

vivid fulcrum
#

think outside of the box

#

it's the fact that you can prevent the request failure in the first place if it's trying to delete messages that are older than 14 days

#

if you send a bulk deletion request with a message id older than 14 days the whole request will fail

radiant kraken
#

ratelimiting is when you send too much requests to the discord API

vivid fulcrum
#

ergo you wasted an api request and contributed to the rate limit

wheat mesa
#

My implementation of a clean command in detritus (without the user part) was as follows: ```ts
async run(payload: Command.Context, args: CommandArgs): Promise<any> {
if (args.messagesToDelete) {
let messagesToDelete = args.messagesToDelete + 1;
const messages = await payload.rest.fetchMessages(payload.channelId, { limit: messagesToDelete });
const messageArray: Array<string> = [];
for (let [k, v] of messages) {
if (Date.now() - v.createdAtUnix < 14 * 24 * 60 * 60 * 1e3) {
messageArray.push(v.id);
}
}
if (messageArray.length > 1) {
await payload.channel?.bulkDelete(messageArray);
} else {
const embed = createUserEmbed(payload.user);
embed.setColor(Colors.DEFAULT);
embed.setDescription('I cannot delete messages greater than 14 days old.');
return editOrReply(payload, { embed });
}
}
}

radiant kraken
#

detritus sdForgor

wheat mesa
#

Granted I wrote this a while back, so it's probably not my best work

ancient nova
#

I'm not quite sure how to actually check for the time?

                  .filter(msg => msg.author.id === mentionedUser.user.id && message.createdTimestamp - Date.now() >= )
#

how do I actually check if it's longer than 14 days?

radiant kraken
#

Date.now() returns the Unix timestamp in seconds iirc

radiant kraken
#

No because it's in TypeScript

#

but yeah you can

wheat mesa
#

I mean I posted it, probably not the best way to do it, but go ahead and convert it if you want

ancient nova
#

I could conert it pretty sure

vivid fulcrum
#

the code gets even more complicated when you get to batching the bulk requests if you want to delete more than 100 messages in one go mmLol

ancient nova
wheat mesa
#

bulkDeleting more than 100 messages is getting to sketchy ratelimit territory

#

lots of things to worry about when batching requests like that

radiant kraken
#

Why would you want to delete that many messages anyway

vivid fulcrum
#

spam bots etc.

ancient nova
#

lol I just noticed

radiant kraken
#

Ban exists

vivid fulcrum
#

true

wheat mesa
#

ban purges all messages up to a specified time

radiant kraken
#

Still

ancient nova
#
                  .filter(msg => msg.author.id === mentionedUser.user.id && Date.now() - msg.createdAtUnix < 14 * 24 * 60 * 60 * 1e3))
``` what does `createdAtUnix` even do?
wheat mesa
#

0-7d iirc

ancient nova
#

I never heard of it?

wheat mesa
#

gets the message's created timestamp in unix form

radiant kraken
#

Less painful than bulk-deleting

wheat mesa
#

it's not djs

vivid fulcrum
#

popular mod bots have the feature regardless but have hardcoded limit, i.e. 500 or so

ancient nova
wheat mesa
#

idk, check djs docs

#

probably

ancient nova
#

it returns time in ms

#

I think...

radiant kraken
#

it uses the detritus lib

#

idk the similarities

quartz kindle
#

detroit us

wheat mesa
#

detritus has .createdAt and .createdAtUnix, I don't remember the difference

#

I just know that createdAtUnix works for me

radiant kraken
#

.createdAt probably returns some object/wrapper

quartz kindle
#

probably the same as .createdAt and .createdTimestamp in djs

ancient nova
#

didn't work

#

well

radiant kraken
#

have you tried .createdTimestamp

wheat mesa
ancient nova
#

I misspelled it

quartz kindle
#

you missed the take

ancient nova
#

the code is actually clean

#

ngl

ancient nova
quartz kindle
#

now you missed the joke

wheat mesa
quartz kindle
#

haha im so funny /s

#

im gonna make an account on oracle and slap it with a minecraft server

ancient nova
#

kill me

wheat mesa
#

I already have an oracle account

ancient nova
#

I wonder why

wheat mesa
#

I'm just too lazy to log back into it and do linux server shit for 5 hours

#

Fuck it, I'm gonna go buy some ice cream at the store, brb

ancient nova
#

I have an important question

#

is TS better than JS, if you think so, why?

vivid fulcrum
#

for me it's the fact that you can catch type errors at compile time instead of struggling to debug it during runtime

#

main reason why i fell in love with it

#

early ecma features & proposals are a bonus

ancient nova
#

that sounds kinda cool

#

should I give it a try?

#

I always thought it was just a copy other than slightly different syntax

radiant kraken
boreal iron
radiant kraken
#

^

#

no matter what you do, you will always end up debugging by console.logging in the end ia_lul_haha

boreal iron
#

Mostly yeah and modern editors aim to help people a lot to debug issues

#

Excl people who aren’t willing to switch to one and still use npp

quartz kindle
#

vsc actually does have a js type checker, which basically does the same as typescript, but uses jsdoc instead, so its fully compatible with regular js

#

its disabled by default

radiant kraken
#

i've been using notepad++ for over 3 years

quartz kindle
#

i started with npp

#

then moved to sublime

#

then to vsc

boreal iron
solemn latch
quartz kindle
#

i just dont like the compilation part of ts, i like my code running as i write it, not compiled to got knows what

boreal iron
#

People complain so much about the default behavior that adjusting the app until I like is a long process I’ve got no time for

#

And you know, once you’re old and tired you don’t wanna change the running system or learn new tricks

quartz kindle
#

i am old and tired, i dont want to change my bot to slash commands

boreal iron
#

Or release your api

#

Or finish anything else

#

@.@

#

im sorry that had to be said

quartz kindle
#

@_@

wheat mesa
#

It's also really really nice for things like react where you can make types for functional components really easily

radiant kraken
boreal iron
#

Alr have a good one, just have 4h left until a 1000km trip for an useless meeting

#

šŸ¤¦ā€ā™‚ļø

wheat mesa
#

rip

boreal iron
#

Yeah fuck natural resources

radiant kraken
#

also @wheat mesa thanks for merging my pull request

wheat mesa
#

Thanks for submitting one poggythumbsup

#

My next rust project is implementing jlox

#

But that's a job for 1 week in the future me to figure out

#

Also I've been really enjoying looking at the compiled (unoptimized) code for basic c++ programs, really fun to look at the assembly

radiant kraken
terse hound
#

hey i was asking about the pokemeow bot and it not having permission that i had given to it and got sent here. is confused.

wheat mesa
#

You're going to want to look at their discord support, this is a channel for making bots

terse hound
#

see that's kinda what i figured. but the response i got referenced me to here

slow terrace
#

I am using discord-player package

Disconnected from log stream. There may be events happening that you do not see here! Attempting to reconnect...
2022-06-13T21:38:47.375648+00:00 app[Worker.1]:     },
2022-06-13T21:38:47.375648+00:00 app[Worker.1]:     playbackDuration: 939040,
2022-06-13T21:38:47.375648+00:00 app[Worker.1]:     started: true,
2022-06-13T21:38:47.375649+00:00 app[Worker.1]:     silencePaddingFrames: 5,
2022-06-13T21:38:47.375649+00:00 app[Worker.1]:     silenceRemaining: -1
2022-06-13T21:38:47.375649+00:00 app[Worker.1]:   }
2022-06-13T21:38:47.375649+00:00 app[Worker.1]: }
2022-06-13T21:38:47.382557+00:00 app[Worker.1]: (node:4) Warning: [DiscordPlayerWarning] Unhandled "connectionError" event! Events "error", "connectionError" must have event listeners!

why?
it logs

[Wolves] Error emitted from the queue: aborted
[Wolves] Error emitted from the connection: aborted
lyric mountain
#

Add an error listener and try to reproduce it

#

All that error is saying is that you're not properly treating your errors

simple stump
#

Nvm .split exists

slow terrace
#

The last logged error in the block is from the error event

slow terrace
earnest phoenix
#

How to make a no-prefix command which works without a prefix.

#

<@&817055174613794826>

earnest phoenix
#

Ah okay

sharp saddle
#

how do 2 different websites on the same IP?

#

I've been searching but haven't found anything about it

cinder patio
#

they just have to be on different ports

spark flint
lyric mountain
earnest phoenix
lyric mountain
#

then add a condition to check for those specific IDs

sharp saddle
lyric mountain
#

you can have up to 65k+ sites on a single ip

feral aspen
#

pepeWave Haii, alright, so I'm trying to understanding a bit of a complex topic that I need opinions on before I can start my course: Oooh

- We have NGINX and we have APACHE, what's significantly better? I mean, based on what I've seen by most YouTubers (especially developers), I've heard that NGINX, overall, is a better web server which could also be used as a reverse proxy.
- How does the process work, like do you also need to use a Virtual Private Server in order to fully install NGINX using CLI?
- What's the relation between NGINX and CloudFlare, as I've heard that though using cloudflare makes NGINX have no real advantage unlike APACHE since Cloudflare could already do load balance (which I'm not entirely sure what it is) and proxy for you.

reef quarry
#
TopGGAPIError: 401 Unauthorized (You need a token for this endpoint)
    at Api._request (C:\Users\wpuser18\Desktop\UrakoBeta\node_modules\@top-gg\sdk\dist\structs\Api.js:76:19)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Api.postStats (C:\Users\wpuser18\Desktop\UrakoBeta\node_modules\@top-gg\sdk\dist\structs\Api.js:99:9) {
  response: Response {
    size: 0,
    timeout: 0,
    [Symbol(Body internals)]: { body: [PassThrough], disturbed: true, error: null },
    [Symbol(Response internals)]: {
      url: 'https://top.gg/api/bots/stats',
      status: 401,
      statusText: 'Unauthorized',
      headers: [Headers],
      counter: 0
    }
  }
}
#

how to fix ?

lyric mountain
# feral aspen <a:pepeWave:587383614153424980> Haii, alright, so I'm trying to understanding a ...

We have NGINX and we have APACHE, what's significantly better?
neither, both have their pros and cons, I personally prefer nginx because it's simpler to deal with and I hate xml

How does the process work, like do you also need to use a Virtual Private Server in order to fully install NGINX using CLI?
nginx/apache are just normal programs that you leave running indefinitely, anywhere you can install programs AND handle ports can have either installed

What's the relation between NGINX and CloudFlare
none

feral aspen
#

I believe the last, how does it know I own the domain?

lyric mountain
lyric mountain
feral aspen
#

How do you connect your domain, then?

lyric mountain
#

all nginx/apache does is redirecting incoming requests to the proper files

reef quarry
lyric mountain
#

when you buy a domain you get to choose where it'll point to

#

the only thing you do regarding your domain on serverside is setting up the ssl

feral aspen
#

Fair enough, however, I have a domain registered with namecheap, so would it work even though I have a VPS somewhere else?

lyric mountain
#

domain doesn't care where you point it to

feral aspen
#

I'm willing to follow a course (or let's say a documentation) but I'm hoping not to get lost.

lyric mountain
#

you could point to google and it'd work

#

domain is just an ip alias (kinda)

feral aspen
#

Wait, so it just leads you to the IP? And not act as the website domain for the website?

lyric mountain
#

ye

#

domain is just a name, nothing else

#

it cant host anything

#

that's why you usually use cloudflare, to mask your server's real ip

feral aspen
#

Oh, so even though I enter wergnhp0.com, I'll go to wergnhp0.com and not the IP of the server.

feral aspen
lyric mountain
feral aspen
#

Fair enough.

#

Any course you recommend based on your personal experience? (A website or so).

lyric mountain
#

not really, just a bunch of scattered google searches

feral aspen
#

Alright, many thanks on this. šŸ‘

quartz kindle
#

do you know what dns is?

feral aspen
#

I'll be managing that through CloudFlare, correct?

quartz kindle
#

no

feral aspen
#

Or from NameCheap? (the place I'll buy the domain from)

quartz kindle
#

DNS means Domain Name System, its what controls where domains go everywhere in the world

#

there are thousands of DNS servers out there

feral aspen
#

Indeed.

quartz kindle
#

when you buy a domain, you can do two things: configure its DNS server and configure its IP address

#

the domain IP address, is used to know which server that domain should go to, for example your VPS's IP address

feral aspen
quartz kindle
#

the DNS server is used to know which server the domain should use as its "authority", meaning where this domain name is "based at" if that makes sense, which for example, cloudflare asks you to change you domain to their DNS servers in order to give them the authority over your domain, prove that you own it, and make all connections go through it

#

so when a person types "yourdomain.com" on the address bar, the browser first searches for the DNS server that "owns" the domain, then the DNS server will tell the browser which IP it should go to

feral aspen
#

Alright, particularly, which IP it should go it, yes.

quartz kindle
#

afterwards the browser attempts to connect to the final IP address, and thats where your webserver receives the request, but your webserver can still see what domain is being requested

#

so you can run multiple websites on the same server

feral aspen
#

Ohh, alright, alright. I get it, so I believe my prerequisites, at my particular case, to host just a simple static website via NGINX, is: 1. An Ubuntu (or any distribution) VPS. 2. Cloudflare. 3. A Domain?

#

Do I need anything other than that?

quartz kindle
#

cloudflare is optional

#

all domain sellers have their own DNS server by default

feral aspen
#

Fair enough.

#

Quick question, does each domain have an IP or a domain is just a domain.

quartz kindle
#

each domain has an ip, unless that domain is inactive

#

subdomains also have their own ips

feral aspen
#

Indeed, however, we're inputting the ip of the domain when going to the website, however, when do we use the IP of the VPS, itself?

quartz kindle
#

there are many types of DNS Records that you can create and configure

#

for example A record is for an ipv4, AAAA record is for an ipv6

#

a domain can have both

#

and they can both be different servers

feral aspen
#

Yup, however, when does the VPS IP come in handy.

quartz kindle
#

a CNAME record is a domain alias to another domain

#

MX records are for emails

#

etc

lyric mountain
quartz kindle
feral aspen
#

However, do you think I should manage so from NameCheap or do I just convert everything to be CloudFlare used.
In addition, to be using CloudFlare as my DNS, let's say "authority", I should rewrite each DNS Configured on my default DNS Manager and write them again on the CloudFlare one, correct?

eternal osprey
#

not really a coding question, but does installing windows 11 remove all your apps, games etc again lmao?

quartz kindle
#

only if you format and install from scratch

lyric mountain
quartz kindle
feral aspen
#

Yup, that is understandable, but when it comes, generally, using CloudFlare as your DNS, you have to rewrite all the records to your CloudFlare, right?

quartz kindle
#

cloudflare also works as a domain registrar these days

lyric mountain
#

really?

quartz kindle
#

so you could also completely transfer your domain to cloudflare and remove it from namecheap

#

but that requires renewing the domain

feral aspen
quartz kindle
#

you dont need to write A records to cloudflare

#

when you go to the domain options in namecheap there should be two different things: "name server" and "dns settings"

#

name server is where you add cloudflare

#

dns settings is where you add your vps

feral aspen
#

I mean, DNS Settings is all I see.

quartz kindle
#

did you buy namecheap hosting?

feral aspen
#

No, I'm just using Plesk as an example to understand what you mean by "name servers".

quartz kindle
#

go to dns settings

feral aspen
#

Done, then?

quartz kindle
#

what does it show?

#

i dont use namecheap

feral aspen
#

I see a list of records, 29 in total, for my particular attitudebot.com domain.

quartz kindle
#

a list of records or a list of domains?

#

records as in A AAAA CNAME MX etc

feral aspen
quartz kindle
#

what about the dashboard? is there a "nameservers" option in the dashboard?

#

this is what i get from google images

feral aspen
#

Oh, I found it.

#

Alright, so a couple of questions I need to clear off my head, if I want to use CloudFlare as my DNS "authority", I have to just change the name servers, and what else, go to the A Records of who (NameCheap or CloudFlare) to add the VPS. Also, why are we not recreating all of the records in the NameCheap at the CloudFlare?

quartz kindle
#

A records on namecheap

#

you dont need to create DNS records on cloudflare because the DNS records will use the name servers to propagate

#

DNS propagation is the process of sending the new DNS records to all DNS servers in the world

#

every time you change your DNS records, the update will be slowly propagated to the world, which is why it may take some time for your ip addresses to update

feral aspen
#

So what's the advantage of CloudFlare if I'm managing my records through NameCheap and not CloudFlare?

quartz kindle
#

cloudflare is not a record manager, cloudflare does a lot of other shit like ddos protection, security, caching, etc

feral aspen
#

Oh, so if you would want to use CloudFlare, it's never a record manager?

quartz kindle
#

it can be one, but its not required

feral aspen
#

Fair enough.

#

I'll let you know how it goes in like a few hours. šŸ‘ (as I'll be starting later)

quartz kindle
#

this is how the cloudflare page looks like (or it looked like, idk with their new UI)

#

so you can also manage it from cloudflare

#

but it doesnt really matter, both cloudflare and namecheap's dns records will always be copies of each other

feral aspen
#

Lastly, I heard using CloudFlare will disallow you being able to use sub-domains.

#

So how does that work?

quartz kindle
#

never heard of that

feral aspen
#

Wait, so CloudFlare uses the DNS records of NameCheap, correct, since I'm using their nameservers?

quartz kindle
#

the dns records belong to the domain itself, it doesnt matter if its on cloudflare or namecheap

#

the domain registrar will always have access to them

#

and you can give access to another system by using their nameservers

feral aspen
#

Alrighty. pepe_yay

#

Many thanks on this.

lyric mountain
#

they finally gave up on using top navigator

spark flint
#

yup

lyric mountain
#

about time

ancient nova
#

what is this error?

#

happens when someone adds my bot to their server

#

my whole bot crashes

near stratus
#

and as the error says at <something>.cache something is undefined

ancient nova
#

not from my code

near stratus
#

like the full error

#

also are you using djs12 or 13 ?

quartz kindle
ancient nova
ancient nova
#

guess without evaling, will this be true or false?

!!null===null==false;
lyric mountain
#

true

ancient nova
#

correct

lyric mountain
#

why tho?

ancient nova
#

I'm just bored

lyric mountain
#

unbore

ancient nova
#

making up weird js snippets

ancient nova
#

how about this KEKW

(true??null===null==false)?true===true:false;
#

no evaling

split hazel
#

i thought windows had a terrible c api

#

but after i saw openssl

#

was this shit even written by a human

radiant kraken
#

lmao

#

windows' c api isn't even that bad

split hazel
#

im trying to generate an rsa public and private key pair but idk how šŸ’€

radiant kraken
#

i feel your pain sdForgor

split hazel
#

i did something idk wtf this is

#

i dont do cryptography

#

i just want to convert it into a string 😭

#

so i can send it to a node server

ancient nova
#

ok guess this one

#
(false??null===null==false)?true===true:[undefined]==0??Number()?parseInt(null,24)===23?+false?true:false:true:true;
#

I don't even know what I did here

slow terrace
#

I am using discord-player package to play songs in discord by my bot.

If the music duration was to long(like 15mins or more) after this time the bots stops the music and logs this error

Disconnected from log stream. There may be events happening that you do not see here! Attempting to reconnect...
2022-06-13T21:38:47.375648+00:00 app[Worker.1]:     },
2022-06-13T21:38:47.375648+00:00 app[Worker.1]:     playbackDuration: 939040,
2022-06-13T21:38:47.375648+00:00 app[Worker.1]:     started: true,
2022-06-13T21:38:47.375649+00:00 app[Worker.1]:     silencePaddingFrames: 5,
2022-06-13T21:38:47.375649+00:00 app[Worker.1]:     silenceRemaining: -1
2022-06-13T21:38:47.375649+00:00 app[Worker.1]:   }
2022-06-13T21:38:47.375649+00:00 app[Worker.1]: }
2022-06-13T21:38:47.382557+00:00 app[Worker.1]: (node:4) Warning: [DiscordPlayerWarning] Unhandled "connectionError" event! Events "error", "connectionError" must have event listeners!

this is the code from the index.js

const Discord = require('discord.js')
const { Client, Intents, Collection } = require('discord.js')

const client = new Client({
     partials: ['MESSAGE', 'CHANNEL', 'REACTION'],
     intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.DIRECT_MESSAGES, Intents.FLAGS.GUILD_MESSAGE_REACTIONS, Intents.FLAGS.GUILD_PRESENCES, Intents.FLAGS.GUILD_BANS, Intents.FLAGS.GUILD_VOICE_STATES, Intents.FLAGS.GUILD_BANS],
     allowedMentions: { parse: ['users', 'roles'], repliedUser: true }
    });

const { Player } = require("discord-player")

const { registerPlayerEvents } = require('./MusicEvents');

client.player = new Player(client, {
    ytdlOptions: {
        quality: "highestaudio",
        highWaterMark: 1 << 25,
        dlChunkSize: 0
    }
});

#

This is the MusicEvents.js folder:

module.exports.registerPlayerEvents = (player) => {

    player.on("error", (queue, error) => {
        console.log(`[${queue.guild.name}] Error emitted from the queue: ${error.message}`);
        queue.metadata.channel.send(`[${queue.guild.name}] Error emitted from the queue: ${error.message}`);
    });

    player.on("connectionError", (queue, error) => {
        console.log(`[${queue.guild.name}] Error emitted from the connection: ${error.message}`);
        queue.metadata.channel.send(`[${queue.guild.name}] Error emitted from the connection: ${error.message}`);
    });

    player.on("trackStart", (queue, track) => {
        queue.metadata.channel.send(`šŸŽ¶ | Started playing: **${track.title}** in **${queue.connection.channel.name}**!`);
    });

    player.on("trackAdd", (queue, track) => {
        queue.metadata.channel.send(`šŸŽ¶ | Track **${track.title}** queued!`);
    });

    player.on("botDisconnect", (queue) => {
        queue.metadata.channel.send("\\āŒ **clearing queue,** I was manually disconnected from the voice channel!");
    });

    player.on("channelEmpty", (queue) => {
        queue.metadata.channel.send("\\āŒ **leaving,** Nobody is in the voice channel!");
    });

    player.on("queueEnd", (queue) => {
        queue.metadata.channel.send("![Verify](https://cdn.discordapp.com/emojis/841711383191879690.webp?size=128 "Verify") Queue finished!");
    });

};
#

And this is the play code

const { SlashCommandBuilder } = require('@discordjs/builders');
const discord = require('discord.js');
const { MessageActionRow, MessageButton, MessageEmbed } = require('discord.js');
const { QueryType } = require("discord-player")
const playdl = require("play-dl");

        const guild = client.guilds.cache.get(interaction.guild.id);
        const channel = guild.channels.cache.get(interaction.channel.id);
        const queue = await client.player.createQueue(interaction.guild, {
            metadata: {
                channel: channel
            },
        })

        try {
            if (!queue.connection) await queue.connect(interaction.member.voice.channel);
        } catch {
            queue.destroy();
            return await interaction.reply({ content: "![error](https://cdn.discordapp.com/emojis/888264104081522698.webp?size=128 "error")  Could not join your voice channel!", ephemeral: true });
        }

if (interaction.options.getSubcommand() === "search") {
            let url = interaction.options.getString("name")
            const result = await client.player.search(url, {
                requestedBy: interaction.user,
                searchEngine: QueryType.AUTO
            })

            if (result.tracks.length === 0)
                return interaction.editReply("![error](https://cdn.discordapp.com/emojis/888264104081522698.webp?size=128 "error") No results found for this song name!")
            
            const song = result.tracks[0]
            await queue.addTrack(song)
            embed
            .setAuthor({ name: interaction.user.tag, iconURL: interaction.user.displayAvatarURL({ dynamic: true }) })
            .setDescription(`**[${song.title}](${song.url})** has been added to the Queue`)
            .setThumbnail(song.thumbnail)
            .setFooter({ text: `Duration: ${song.duration}`, iconURL: client.user.displayAvatarURL({ dynamic: true })})
        }
        if (!queue.playing) await queue.play()
        await interaction.editReply({
            embeds: [embed]
        })

#

It logs this in the console

[Wolves] Error emitted from the queue: aborted
[Wolves] Error emitted from the connection: aborted
#

Does anyone have an idea how to solve this?

lyric mountain
#

but well, to convert it to string use base64

split hazel
split hazel
lyric mountain
split hazel
#

yeah but i have no idea how to do that

#

crypto++ looks more sane but i really dont want additional dependencies

lyric mountain
split hazel
#

i wish

#

c++