#development

1 messages ยท Page 2015 of 1

lyric mountain
#

Nothing more that

#

When u load ALL members into the cache you're effectively destroying your whole process by flooding it with data that'll only be used once

#

If you're up to sacrificing accuracy you can iterate over all guilds and get the memberCount value

#

But that's also slow depending on how many guilds you have

#

The fastest way would be to get rowcount if you use some kind of relational database

fickle arch
#

does getting overall members count from all guild is faster or

lyric mountain
#

That only if you use some kind of leveling or economy

lyric mountain
#

At the end of the day, is it really important to show member count?

fickle arch
#

well gonna use that option for now probably

lyric mountain
#

Like, nobody cares about member count, it's just a big value thay you cound make up and nobody would know

fickle arch
lyric mountain
#

"testing" yes, I saw that story a few months ago

#

But anyway, you do you

#

Just remember it's a somewhat costly operation

fickle arch
#

I see, sorry if I'm bothering you, I'm kinda new on bot developing.

quartz kindle
#

client.guilds.cache.reduce((a,b) => a + b.memberCount, 0)

#

its fine to use that, thats what i use too

#

its not 100% accurate, but it its 99% accurate most of the time

snow urchin
#

Anyone here work with NextJS at all, and would know how to workaround this issue?

lyric mountain
#

Sorry if it sounded too harsh

fickle arch
#

the more I learn

fickle arch
lament rock
#

if the members were sent to the client

#

ah nvm. memberCount is static guild prop

#

I wish they'd rename the property to approximate_member_count like they do with invites

fickle arch
#

also how do I make bot grab guild id, is it using fetch() ?

quartz kindle
#

what guild id?

#

of which guild?

fickle arch
#

like any ?

quartz kindle
#

a random guild?

#

client.guilds.cache.random().id lol

craggy pine
#

If it's the guild a command is ran in, it would be simply something like message.guild.id, anything else you can fetch.

fickle arch
#

I mean like, the bot is in A server and try to get the guild id without providing the id.

quartz kindle
#

it all depends on the context

craggy pine
quartz kindle
#

what is your starting point?

#

if is a voicestateUpdate then etc...

lyric mountain
#

They have it too easy tsk tsk

lament rock
#

Collection<K, V> is an arbitrary class extending Map<K, V>. It's up to the implementer to add helper functions like random. Map's prototype is relatively small

lyric mountain
#

Js has generics (the types I mean)?

lament rock
#

Yes and no

#

its a typescript concept, but it's a paradigm that applies to anything logic based

#

Map.get(key: K) where K is usually a string

#

it's arbitrary, but the concept is there

#

A Map can also have mixed keys which makes things complicated, but JS isn't type safe

fickle arch
snow vector
#

@lyric mountain i updated all my hrefs and it works thank you

fickle arch
#

do I need to specific ms time if I'm going to make giveaway command

dry imp
#

dont think so

bright hornet
arctic solar
#

hi how to change a github pages website?

fickle arch
#

created a giveaway message, but the winner is undefined when giveaway ended, how do I make the winner is random people that react to the message ?

slender thistle
#

Are you sure the message you're referring to has an embed

slender thistle
#

Try printing message.embeds, maybe even the message ID and verify that the message you're getting is the one you want

lament rock
#

Do you have the message content intent enabled

#

you won't see embeds without it

woeful pike
snow urchin
#

I aint

#

thats the funny part about it

woeful pike
#

uh what does your _middleware file look like

snow urchin
#

This is it now, but the main issue is I can no longer access session data, like verified, banned etc, the stuff we have stored on the user session https://i.callumdev.xyz/oz4sl.png

split hazel
#

btw that is a cool extension

#

says the bundle size

cinder patio
#

Why does cd folder not work in github workflows ๐Ÿค”

#

nvm figured it out

#

:/ that's so uncool next.js

slender thistle
#

I'm rather curious how you don't know what intents are

#

Google will help you better than my currently comfyblob self

#

Ah yes, my client object is client.event

#

No. Events happen BECAUSE OF intents

fickle arch
#

does each server has it's own db ?

#

I wanted to make a list giveaway command that list currently running giveaway on a server you in.

neat ingot
#

dang. apparently 4 russians have downloaded my rpc app. that it a missed opportunity for a node-ipc install ๐Ÿ˜„

signal lance
#

how do i get the presence of a guild member?

bright thorn
#

DiscordHTTPError: 401 Unauthorized on POST /api/v9/oauth2/token

#

?

surreal knoll
simple stump
#

Is it possible to interact with a .html file using NodeJS? Ex:

myDocument.js:

const htmlFile = require("index.html");

module.exports.myFunc = myFunc;

function myFunc() {
  // do smth
  return "hi!";
}

index.html:

<!DOCTYPE HTML>
<html>
  <body>
    <script>
      const myDocument = require("myDocument.js");
      let smth = myDocument.myFunc();
      </script>
    </body>
</html>
woeful pike
#

or you can use js modules which is probably a better idea

fickle arch
civic scroll
#

to identify the guild in which the message was sent

fickle arch
#

I try to make the bot find modlog channel to see the config of the bot in the server

civic scroll
#

then store the configs in a database

#

each server's config being stored with the server id as key and value being be config

fickle arch
#

using db.get ?

civic scroll
#

depends on the API

fickle arch
#

.addField('Mod Log Channel', `${db.get(`modlogchannel_${message.guild.id}`)}`)
tried this and it's said null

civic scroll
#

because you hhaven't saved it

sick agate
#

it doesnt exist in database soo add a fallback for it

fickle arch
sick agate
#

weird

#

add a fallback when it doesnt exist anyway

civic scroll
#
db.set(`modlogchannel_${message.guild.id}`);
#

also

fickle arch
#

also prefix is null despite I try change the prefix

civic scroll
#

if that db is stored in RAM

#

you are out of luck

#

you have nothing to store it persistently on disk

fickle arch
civic scroll
#

so when the bot process ends, all db data goes with it

civic scroll
#

so

fickle arch
#

sort off ?

civic scroll
#

but where do you store it on disk

#

how else is the bot gonna pick up the config when it boots up

#
define db: runtimeDatabase {
    when update {
        update data, this
        update data, storage
        return true unless exception: false
    }
}
define storage: persistentStorage
when bot boots up {
     copy storage -> db
}

define cmd {
    when set (args)
        bool status <- call db.set, args
    if (bool is true)
        send Message
    otherwise
}
civic scroll
stable eagle
#

Hello, I am trying to remove a field from all documents in my mongodb database. But, it doesnโ€™t do anything, all documents still have the reactionRoles field. Can someone help me? This is the current code I have.

const guildDatabase = require('../../database/guild')
guildDatabase.updateMany({}, { $unset: { "reactionRoles": ""}}).then(res => console.log(res))
fickle arch
civic scroll
#

what do you mean?

fickle arch
#

because I already do
db.set(`modlog_${message.guild.id}`)

#

was asking to do the same method for a guild/server

civic scroll
#

yeah

fickle arch
#

also what's message.guild do again is it getting the guild/server name or something ?

civic scroll
#

not just names

stable eagle
sick agate
#

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

#

which mongodb version

earnest phoenix
#

When adding data to MongoDB should I create a list if it's different data for the same guild with the same topic of using that collection? Or should I create different query's in the db?

wheat mesa
#

Create a new cluster for each guild :troll:

ancient nova
#

so guys

#

I'm using a cli

#

on nodejs

#

does anyone know how to possible center the text? :/

#

I mean I already found a way to center the text kinda, get the width of the window and divide it by half

#

but what if there's a text on both sides

cinder patio
#

uuuuuuuh... what are you talking about

#

text on the console?

#

html text?

sudden geyser
#

probably means stylizing the terminal output

#

like rich for python or tui for rust

ancient nova
#

it's the cli app I sent before, I'm trying to fix some stuff in the GUI

#

hold on let me take a screenshot

#

I came up with something

#

I'm about to test it right now

#

hopefully it works

#

well almost?????????

#

I'll post my code, but beware, it's very very very very bad, and very bloated

#
    const usernameCenterResult =
    `${cyan(">")}` + 
    " ".repeat (15 - `Username: ${Username}`.length / 2) + 
    `Username: ${Username}` +
    " ".repeat (15 - `Username: ${Username}`.length / 2) + 
    `${cyan("<")}`
    const typeCenterResult =
    `${cyan(">")}` + 
    " ".repeat (15 - `Type: ${Username != "Zero" ? "Account" : "Admin"}`.length / 2) + 
    `Type: ${Username != "Zero" ? "Account" : "Admin"}` +
    " ".repeat (15 - `Type: ${Username != "Zero" ? "Account" : "Admin"}`.length / 2) + 
    `${cyan("<")}`
    const prefixCenterResult =
    `${cyan(">")}` + 
    " ".repeat (15 - `Prefix: ${Prefix}`.length / 2) + 
    `Prefix: ${Prefix}` +
    " ".repeat (15 - `Prefix: ${Prefix}`.length / 2) + 
    `${cyan("<")}`

    centerText += "\n" + centerAlignText(usernameCenterResult);
    centerText += "\n" + centerAlignText(typeCenterResult);
    centerText += "\n" + centerAlignText(prefixCenterResult);
#

please don't kill me I know it's bad

#

if anyone can fix it, I'd be really grateful to you

lyric mountain
#

tf is that tf

ancient nova
#

I'm aware...

#

anything else I try doesn't work though ๐Ÿ˜ฆ

lyric mountain
#

yk leftPad exists right?

ancient nova
#

what?

lyric mountain
#
List but aligned to the right
-----------------------------
                         Alan
              Alan but longer    
         You see, left padded
                          Yes

ancient nova
#

that still won't help me center it... no?

#

I want have the same amount of spaces before > and <

lyric mountain
#

you can use both leftPad and rightPad

ancient nova
#

I've never used that function

lyric mountain
#
const MAX_SIZE = 30;
let name = "Alan";
let padded = name.padStart(name.length + Math.floor((MAX_SIZE - name.length) / 2), ' ').padEnd(MAX_SIZE, ' ');
ancient nova
#

huh no way

sudden geyser
#

Pain.

lyric mountain
#

more than necessary I'd say

sudden geyser
#

less than necessary actually

lyric mountain
#

ah yes, js lacks isEven()

ancient nova
ancient nova
sudden geyser
#

bruh Java is huge and packages like apache commons and google guava exist

lyric mountain
#

give it a read when u can

#

like, delve in the docs

lyric mountain
sudden geyser
#

is it because it's by google?

#

but like, javascript is missing so much for what a language should have

#

everyone flairing their arms because javascript added .at so you can do negative indexing

#

woo hoo features and good progress

#

no man why

simple stump
#

I'm utilizing Express to host a web server, but I keep getting the error that there isn't any Access-Control-Allow-Origin header even though I set one. I've tried nearly everything, whether it be setting the header client side for axios, using other HTTP getters like got, http, and request-promise, using the CORS package for Express, etc. Nothing seems to work which really confuses me.

server.js:
https://sourceb.in/7E8aPSmaEe

index.html:
https://sourceb.in/UMWhsfenmO

bundle.js problem code:

axios.defaults.headers.post['Access-Control-Allow-Origin'] = '*';
const response = await axios.get(url);
split hazel
sudden geyser
#

big agree

lyric mountain
sudden geyser
#

plus it makes more sense than x % 2 === 0 given we work with simple stuff like that

lyric mountain
#

I still have Gson ptsd

sudden geyser
#

lol

lyric mountain
#

really, you wouldn't believe how complicated they managed to make a simple JSON construction

#

I was relieved when I discovered Moshi

sudden geyser
#

arr.at(-1) would return the last element in the array

#

arr.at(-2) the second to last

#

and so on

lyric mountain
#

what if the array is size 10 and u use arr.at(-10)?

sudden geyser
#

first element

ancient nova
#

@lyric mountain

#

you won't believe what just happened

#

I changed every variable to let in my script

#

and guess what

#

it broke

lyric mountain
#

at least u cant pass values lower than negative maximum

lyric mountain
ancient nova
#

so you can't use let like that

#

that's dumb

lyric mountain
#

that's actually a logic flaw

ancient nova
#

how are you gonna have passwords then

lyric mountain
#

variables are supposed to exist only within their scope

lyric mountain
ancient nova
#

var password
//further further further in their script
password = something

#

basically something like that

#

it's what broke my script

lyric mountain
#

...how about using global variables?

craggy pine
#

Bec ur using var

#

Stop using var

ancient nova
#

changing it to let is what broke it

#

breh

lyric mountain
craggy pine
#

Ah lol

ancient nova
lyric mountain
#

but now the code broke cuz they were using var's hoisting problem

ancient nova
#

because some it breaks

craggy pine
#

Disregard ๐Ÿ˜›

ancient nova
lyric mountain
#

or just put the variable on class scope

#

(if ur using classes)

ancient nova
#

your method didn't work @cinder patio

#
    const defaultSpace = 15;
    let usernameCenterResult = `Username: ${Username}`;
    let typeCenterResult = `Type: ${Username != "Zero" ? "Account" : "Admin"}`;
    let prefixCenterResult = `Prefix: ${Prefix}`;
    usernameCenterResult = usernameCenterResult.padStart(usernameCenterResult.length + Math.floor((defaultSpace - usernameCenterResult.length) / 2), ' ').padEnd(defaultSpace, ' ');
    typeCenterResult = typeCenterResult.padStart(typeCenterResult.length + Math.floor((defaultSpace - typeCenterResult.length) / 2), ' ').padEnd(defaultSpace, ' ');
    prefixCenterResult = prefixCenterResult.padStart(prefixCenterResult.length + Math.floor((defaultSpace - prefixCenterResult.length) / 2), ' ').padEnd(defaultSpace, ' ');

    centerText += centerAlignText(cyan(">") + usernameCenterResult + cyan("<"));
    centerText += centerAlignText(cyan(">") + typeCenterResult + cyan("<"));
    centerText += centerAlignText(cyan(">") + prefixCenterResult + cyan("<"));

    console.clear();
    console.log(white(`${centerText}`));
lyric mountain
#

feud?

ancient nova
#

wasn't he the one that suggested using padend and padstart

lyric mountain
#

it was me

ancient nova
#

oh sorry

#

my mind is deceased at this point so forgot

lyric mountain
#

ok, lemme see that

#

first of all, make a method to help centerPadding

wheat mesa
#

dirty string manipulation code hurts me

ancient nova
wheat mesa
#

I didnโ€™t say I had a better way, I just said that string manipulation code is yucky

lyric mountain
#
function padCenter(str, size) {
  return str.padStart(str.length + Math.floor((size - str.length) / 2), ' ').padEnd(size, ' ');
}
ancient nova
lyric mountain
#

then just use that for the lines

#

that way u don't get a messy code

ancient nova
#

thanks ๐Ÿ™‚

lyric mountain
#

and please use smaller variable names

#

like, they need to be descriptive, but not THAT descriptive

#

also I noticed ur not using \n

#

terminal support newline

#

or if u must, you need to calculate how many characters can fit in the terminal horizontally

#

else it won't break at the right spot

lyric mountain
#

the tricky part is that terminal is resizeable, so u can't use a fixed value

ancient nova
#

and then it automatically redos the function

#

and updates the gui

#

that's weird

#

the username bit is a bit off center

#

also why is the entire thing a bit of center

#

it couldn't be ansi codes could it?

wheat mesa
#

ANSI codes just affect color in your case

ancient nova
#

yep, however their pure form has a bunch more chars

#
    centerText += "\n" + centerAlignText(`${cyan(">")}${padCenter(`Username: ${Username}`, 15)}${cyan("<")}`);
    centerText += "\n" + centerAlignText(`${cyan(">")}${padCenter(`Type: ${Username != "Zero" ? "Account" : "Admin"}`, 15)}${cyan("<")}`);
    centerText += "\n" + centerAlignText(`${cyan(">")}${padCenter(`Prefix: ${Prefix}`, 15)}${cyan("<")}`);
lyric mountain
ancient nova
#

and since this is how I'm putting the code do you think it affects?

lyric mountain
#

you see, even doesn't have a center

#

1 2 3 4 5 -> the center is 3
1 2 3 4 5 6 -> the center is either 3 or 4

#

so you need to adjust the > < based on how many chars there are

ancient nova
#

that's fine, I'll just increase the number a bit it so it won't be as noticable

lyric mountain
#

why don't u put them 1 char away from the text?

#

the way it is currently is a bit "stiff"

ancient nova
#
centerText += "\n          " + centerAlignText(`${cyan(">")}${padCenter(`Username: ${Username}`, 20)}${cyan("<")}`);
centerText += "\n          " + centerAlignText(`${cyan(">")}${padCenter(`Type: ${Username != "Zero" ? "Account" : "Admin"}`, 20)}${cyan("<")}`);
centerText += "\n          " + centerAlignText(`${cyan(">")}${padCenter(`Prefix: ${Prefix}`, 20)}${cyan("<")}`);
ancient nova
lyric mountain
#
> Username:  Zero <
  > Type: Admin <
   > Prefix: - <
ancient nova
#

that's how I had it before

#

it doesn't look good

#

wait you mean to add one more char to the width between username and zero?

#

what if I add a text that is gonna make it even

lyric mountain
#

padStart the username

#

so it's always within a fixed size

ancient nova
#

so you want the username to be 16 and rest be 15?

#

won't that increase it a bit?

lyric mountain
#

hmm not really what I meant

#

> Username: __________ <

#

like, reserve a fixed size

#

and fit the username there

ancient nova
#

ohhhhh

#

I'd still have to calculate the size of the text to fill it up with spaces later, no?

#

also what if the text is too big

#

actually what IF it is even if the code you gave me

#

it might break

lyric mountain
#

btw just a little nitpick, but console commands are supposed to be -h and --help

#

single for single, double for multi

ancient nova
#

it's fine I'm not trying to make it accurate

#

I know I'm asking for too much, but

#

is it possible to make everything line up with "username"

lyric mountain
#

wdym?

ancient nova
#

be like

#
                          >   Username: Zero   <
                          >   Type: Admin      <
                          >   Prefix: -        <
#

instead

lyric mountain
#

just add a padEnd to the entire line

#

padCenter(text.padEnd(usrName.length, ' '), 50)

simple stump
lyric mountain
#

that way instead of Type: Admin you have Type: Admin

ancient nova
lyric mountain
#

cuz like, cors blocks on the server not on the client

ancient nova
#

since it moves to the very left

simple stump
ancient nova
#

so not really line up with username

#

I still want some spaces be on left

lyric mountain
wheat mesa
lyric mountain
#

Char pos is an integer ๐Ÿ‘๏ธ

simple stump
wheat mesa
pearl trail
astral heron
#

is there anyone who knows why my bot dosnt play music, its on v13 discord.js and yesterday works fine but today donst work idk why

lyric mountain
#

because doing music is nothing but a headache

#

did you check if your ip wasn't banned from yt?

astral heron
#

its playing live stream radio station

lyric mountain
#

any error on the console?

#

like, you need to give us something, we can't just guess what's the issue

astral heron
#

no error

wheat mesa
#

no code, no error, no solution!

astral heron
#

code:

const { joinVoiceChannel, createAudioPlayer, createAudioResource } = require("@discordjs/voice");
const connection = joinVoiceChannel({
            channelId: interaction.member.voice.channelId,
            guildId: interaction.guildId,
            adapterCreator: interaction.guild.voiceAdapterCreator,
        })

        const player = createAudioPlayer()
        connection.subscribe(player)

        const resource = createAudioResource(`stream link`)
        player.play(resource)
#

bot joins vc but it dosnt play stream

wheat mesa
#

I've never seen functions like that before, no idea what lib you're using or if those are custom functions or anything

astral heron
#

discord.js

wheat mesa
#

@discordjs/voice?

astral heron
#

yes

wheat mesa
#

I don't think you can create an audio resource from a stream link

#

from looking at these docs

astral heron
#

yesterday it work fine..

#

idk

wheat mesa
#

No idea, never used djs voice before

astral heron
#

ugh

austere surge
#

in v13 the djs voice is horrible

astral heron
#

true

austere surge
#

v12 was more straightforward

pulsar bone
lyric mountain
#

you're trying to call strip on something

#

the most important part you omitted (the last lines)

pulsar bone
lyric mountain
#

look, "working <insert timeframe here>" isn't really a valid justification

#

it isn't working now, that's all that matters

lyric mountain
pulsar bone
#

Yes

lyric mountain
#

you're aware that it's a dead library right?

dry imp
#

not anymore

#

but yeah should be dead

lyric mountain
#

they resumed updates?

dry imp
#

yea

#

for some reason

lyric mountain
#

under different team I imagine

#

or same dude?

dry imp
#

same dude, idk if he has a team now tho

pulsar bone
#

Wasn't strip the name of software used to take identity proofs by discord?

dry imp
#

its stripe

#

smh

lyric mountain
#

tf after that huge memo I imagined he'd leave forever library maintenance

dry imp
#

yea

#

its just weird when there is another fork wanting to continue his legacy but somehow he came back which make d.py community bit awkward

lyric mountain
#

show the last lines of your print, THAT'S where the relevant info is

dry imp
#

i dont think there is any pressure since there is a lot of other popular forks replacing d.py

lyric mountain
#

but there's always the "stayers" that refuse to migrate code

dry imp
#

yea

pulsar bone
lyric mountain
#

?

#

also is that a json db I see there?

pulsar bone
lyric mountain
#

I mean the actual error but near the last line shown in the print

dry imp
lyric mountain
#

well, the only thing I can think is that token is undefined or null

#

that means this is returning nothing

pulsar bone
lyric mountain
#

that's...erm...well, idk how that solved it but ok

dry imp
#

yea cuz u dont need dot env

pulsar bone
#

And does anyone know how to automate Google form response.

lyric mountain
#

wdym?

fickle arch
#

how do I fix mongo bad auth

lyric mountain
#

either wrong login or wrong password

pulsar bone
# lyric mountain wdym?

Google form response automation so that I don't have to open the link everyday and fill my attendance ๐Ÿ˜…

earnest phoenix
lyric mountain
#

and maybe impossible since google uses reCaptcha for everything

wheat mesa
lyric mountain
#

classes are important

wheat mesa
#

^^

#

your education is probably one of the most valuable things you will receive for free (depending on what you define as "free"), take advantage of it while you can

lyric mountain
#

also a big part of one's social life KEKW

wheat mesa
#

It might not make you rich, but it definitely makes your chances of success much higher

wheat mesa
#

you won't be able to get that kind of social interaction once you're out of school

pulsar bone
wheat mesa
#

Then fill it out

#

I donโ€™t think itโ€™s too difficult to fill out an attendance form :p

fickle arch
#

uh is it possible to make footer text bold ?

#

trying to make an embed but wondering if it possible to make the text bold at footer part.

austere surge
#

no

fickle arch
#

so you can't ? alright then, thanks for the info.

austere surge
#

i believe the footer and title are the 2 places that dont accept markdown

fickle arch
#

so what's possible for the embed for the bold text

#

I mean the embed part, like description and field ?

lament rock
#

description and field values. Field names cannot use md afaik

fickle arch
#

Uh it said null reading 'user'

.addField('**โ€ข Owner:**', `${message.guild.owner.user.tag}`, true)```
this is what I use
earnest phoenix
# fickle arch Uh it said null reading 'user' ``` .addField('**โ€ข Owner:**', `${message.guild.o...

The guild owner isn't always cached, fetch them using
https://discord.js.org/#/docs/discord.js/stable/class/Guild?scrollTo=fetchOwner

lament rock
#

Alternatively, use mentions

#

if you can get away with not caching something, the better

#

Discord says they never send official DMs from a user or bot account, but jokes on them; The system account is a bot

User {
  client: [Client],
  partial: false,
  username: 'Discord',
  discriminator: '0000',
  bot: true,
  id: '643945264868098049',
  avatar: 'd9fa72d57744dea056b12e2b34a87173',
  flags: 4096,
  system: true
}```
#

This is also hilarious

fickle arch
#

how do I make bot grab random post from reddit

lament rock
#

read reddit's api docs

near stratus
fickle arch
#

I use

const Rads = Reds[Math.floor(Math.random() * Reds.length)];

        const res = await Fetch(`https://www.reddit.com/r/${Rads}/random/.json`);

        const json = await res.json();

        if (!json[0]) return message.channel.send(`Your Life Lmfao`);

        const data = json[0].data.children[0].data;
#

Reds I put all the subreddit

#
            "memes",
            "me_irl",
            "dankmemes",
            "comedyheaven",
            "cursedcomments",
            "wholesomememes",
            "cursedmemes",
        ];
dry imp
#

cool

hoary apex
bright thorn
#
const DiscordOauth2 = require("discord-oauth2");
const oauth = new DiscordOauth2({
  version: "v9",
  clientId: settings.websitebot_client_id,
  clientSecret: settings.website.bot_client_secret,
  redirectUri: settings.website.callback,
});
let data = await oauth.tokenRequest({
    code: req.query.code,
    scope: "identify guilds email",
    grantType: "authorization_code",
    redirectUri: url,
  });
console.log(data)

DiscordHTTPError: 401 Unauthorized on POST /api/v9/oauth2/token

#

any one can help me

#

for this error

timber fractal
#

Why does this string: luckie@luckiecrab.nl
not match this pattern? js /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/

lament rock
#

The regex is really hard to read

#

Maybe look at email regexes made by other people verified to work

timber fractal
fickle arch
#

tried to experiment my bot run using heroku before hosting it on my vps but this things comes up, I already npm rebuild, npm install those 2 package but seems stuck on this.

earnest phoenix
#

Change your node version

fickle arch
#

on the package json ?

#

I set the engine to >16.x

earnest phoenix
#

I fixed mine by using the version 16.13.1 of nodeJs and node is not in your package.json

fickle arch
#

you mean the one from heroku ?

earnest phoenix
#

Your using the version 17 that's probably why. Downgrade to 16.13.1 to see if it works

earnest phoenix
#

I haven't use heroku for a while and I forgot how to use it properly

#

But I'm sure that you'll find the answer on the internet

fickle arch
#

alright thanks, I'll look for it

earnest phoenix
#

No worries

stiff lynx
#

I don't get why I get err on 'commands' that is undefined

await client.guilds.cache
                .get('846752749555286027')
                .commands.set(arrayOfSlashCommands)```
fickle arch
# earnest phoenix No worries

I tried changing the version on the package, push it to github, when I run the console the version dropped to 8.5.0

#

"engines": {
"node": "16.x"
},

snow urchin
lyric mountain
#

what u did could be simplified to /^[\w.]+@[\w.]+\.\w{2,3}$/

timber fractal
#

I didn't make it lol

atomic kindle
snow urchin
atomic kindle
#

Have you tried removing the last backslash from the root directive?

#

It might be creating an issue where the file it's looking for becomes dir//file.

#

@snow urchin.

snow urchin
#

mhmm

#

yup

atomic kindle
snow urchin
#

Tried; fixed, guess it was cache ๐Ÿ˜ญ

snow urchin
stiff lynx
#

and it worked

snow urchin
#

It worked? So, what's the issue?

stiff lynx
#

lmao

fickle arch
#

how do I set a node version for heroku, looks like if I do >=16.x on package.json it bring me to 17.8 version.

fickle arch
#

yeh still the same

wheat mesa
#

This is actually a great visual representation of this

neat ingot
#

100%

#

gonna share that with the nubs in my class ๐Ÿ˜„

wheat mesa
#

That would definitely make things a lot easier to distinguish

neat ingot
#

lol yea. my lecturer person was trying to explain it to them last week and I could tell everyone was insanely lost. but she was using reference examples which should have been done by value, and that really wasnt helping matters imo ๐Ÿ˜„

wheat mesa
#

What language was it in?

#

C++?

neat ingot
#

tell me input radius shouldnt return an int, i dare you! ๐Ÿ˜„

wheat mesa
#

Ah okay C#

#

Yeah thatโ€™s a bad practice tbh

#

Thatโ€™s a poor example

neat ingot
#

for sure!

cinder patio
#

This concept is hard to teach in languages where every non-primitive is passed by reference by default

neat ingot
#

she shold just made a tiny class and passed that around

#

or some instance of a default class

wheat mesa
neat ingot
#

references and pointers blew my tiny mind when i first learned of them ~ really tricky concept for a nubie

wheat mesa
#

Our teacher just explained it as โ€œA reference is a memory address that points to an object, so when you access methods on that memory address, you can change the object associated with itโ€ or something similar

#

Granted, my class is Java so we donโ€™t have to worry about the ref keyword

neat ingot
#

thats how i tried to explain it to the class people who were still confuzed

#

not sure if i helped them or not ๐Ÿ˜‚

wheat mesa
#

Yeah

rose lance
#

how do I call the concept of loading html code after the real site has already loaded?
the image below shows the basic layout of my page and I want to load the green area and have a js request to get the red part
lazy loading seems to be somewhat what I need but looking that up online only shows images
tho I want it to load actual html code (without an iframe)
https://cdn.discordapp.com/attachments/607849386461888512/956245858490384434/IMG_0104.png

lyric mountain
earnest phoenix
#

How do I get the mongo DB object ID ONLY in python?

lyric mountain
#

get the document by id?

earnest phoenix
#

oh okay

lyric mountain
#

...that was a question actually

earnest phoenix
#

Oh, yeah. Then that's what I meant

lyric mountain
#

use find

earnest phoenix
#

Okay

rose lance
# lyric mountain lazy loading regardless of what ur loading

how would I do it?
I tried js async function fetch_list(el) { const response = await fetch('/api/getlist'); const html_text = await response.text(); document.getElementById(el).innerHTML = html_text; }
but someone told me it's not secure because of xss

lyric mountain
#

well, it isn't secure because of html injection

feral aspen
#

Can I do something like this with an if statement?

const hasMysteryboxUpgrade = Object.keys(inventory.inventory).includes('mysterybox');

if (!hasMysteryboxUpgrade) inventory.inventory['upgrades'] = 1;
else inventory.inventory['upgrades']++;
lyric mountain
#

while you can, you really need to rethink ur variable names

cinder patio
#

looks fine to me

lyric mountain
#

inventory.inventory

rose lance
feral aspen
feral aspen
lyric mountain
cinder patio
#

use textContent

#

instead of innerHTML

rose lance
#

this is what I'm loading

{% for entry in list %}
<div>
    {{ entry }}
</div>
{% endfor %}```
lyric mountain
#

can't u do that on the page?

#

like, pass the values and let the site fill it

rose lance
#

not sure how I would do that tbh

lyric mountain
#

like all apis do

#

return a json array

#

then with js you can easily insert elements on the page

rose lance
#

but wouldn't that be a buttload of extra work?

lyric mountain
#

define "extra work"

rose lance
#

I have to write something that uses the json data instead of just already having it the way it's supposed to be

lyric mountain
#

I mean, you're the one that defines what "the way it's supposed to be" is

#

you asked how to prevent xss

#

retrieve the data and fill on-site instead of retrieving an entire html

rose lance
#

aight

#

but if someone could interfere into the html code I'm sending they could do the same with the json I'm sending, right?

lyric mountain
#

not really, at most you'll get a parsing error

lyric mountain
#

like, if the payload is a html, the middle man could insert malicious runnable code

rose lance
lyric mountain
#

with a data-only json payload, he'll be able to at most insert curses or plain malicious links (not clickable unless put inside <a>)

#

and of course, in both cases he'd be able to steal the transferred data (that's why u don't transfer sensitive data unencripted)

rose lance
#

so lets say I am gonna make it json instead, so my api returns the response below, how would I use that to get html code?
{'list': [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]}

lyric mountain
#

first of all you'd not have 'list'

#

[1, 2, 3, 4, 5, 6, 7, 8, 9, 0] is enough, it's a valid json

#

after u retrieve that data, parse it into an array and use js to insert the elements (on raw html)

#

or use the appropriate approach depending on your front-end framework

rose lance
#

ok I've rewrote it to create the html within the function, this is ok?

async function fetch_list(el) {
    const response = await fetch('/api/getlist').then((response) => response.json());
    const base_container = document.getElementById(el);
    response.map(value => {
        var container = document.createElement("div");
        container.textContent = value;
        base_container.appendChild(container);
    }
    )
}```
lyric mountain
#

are u keeping IE (read: not edge) compatibility?

simple stump
#

How do I convert a torrent into a readable stream in the browser? I'm using NodeJS, Express (for a web server), and Browserify (for WebTorrent), but since WebTorrent only works for WebRTC I can't use WebTorrent. Sorry, ik this isn't technically related to DJS but I've been asking around and haven't been able to get an answer haha

lyric mountain
#

if not, replace those vars with let

lyric mountain
rose lance
lyric mountain
#

IE support is bound to die this year

#

var causes some weird issues, I'd advise for u to replace it

rose lance
#

aight, to let it is

lyric mountain
#

2 months remaining

rose lance
#

damn, people really do be hating IE lmao

lyric mountain
#

it's not hate, but supporting it is like dragging a dead weight

#

it WAS a good browser, when sites were no more than a few KBs in size

#

nowadays it can barely enter youtube

lyric mountain
#

map is only when u want to modify the output of a stream chain

rose lance
#

someone just told me to use const instead of let in my case

lyric mountain
#

yeah it'd be more fitting

surreal knoll
#

Having an existential crisis on enmap database here
When anyone creates a new join-to-create setup, it sets in the database
The thing is it doesn't push the database to the host because the code's hosted in Heroku from GitHub
It doesn't auto-update the enmap database files from my initial code
Not sure if I should go back to self-hosting though as it may provide major downtimes for my discord bot.
This is still a major issue as you have to setup the join-to-create again every few days which is frustrating and very unprofessional

rose lance
lyric mountain
surreal knoll
#

I realised

lyric mountain
#

if u must, setup a way to save the database externally

surreal knoll
#

But how?

lyric mountain
#

or just use some service-based database

surreal knoll
#

I'm not familiar with mongodb and such

lyric mountain
lyric mountain
#

obviously, encrypt the database before uploading

#

then every time you start your bot just download it

#

there's a catch tho

#

you'd need to upload on a regular basis because heroku has random micro-restarts

#

that also means sometimes losing unsaved data

surreal knoll
#

Guess I have to go back to self-hosting

lyric mountain
#

you could use replit or hosts that have a free plan

#

or pay for a vps, they aren't expensive

feral aspen
#
PS C:\Users\HamoodiHajjiri\Desktop\Typescript> tsc
tsc : File C:\Users\HamoodiHajjiri\AppData\Roaming\npm\tsc.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ tsc
+ ~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

I don't understand, yet, what's causing this issue?

sick agate
lyric mountain
#

powershell has "safety" measures that most of the time only get in the way

sick agate
#

yes

wheat mesa
#

I remember fixing this somehow, canโ€™t remember what I did though

sick agate
feral aspen
#

Should I perform Set-ExecutionPolicy RemoteSigned?

lyric mountain
#

I mean, if someone gained access to ur pc why tf would they use pshell instead of cmd?

wheat mesa
#

No, thereโ€™s a way to use a different command

lyric mountain
#

if anything, just call cmd prompt from pshell

#

it's like making a heavy and fortified gate without having a fence

feral aspen
#

Problem: Getting โ€œcannot be loaded because running scripts is disabled on this systemโ€ error! On trying to run a PowerShell script from the PowerShell console, received this error message: โ€œFile C:\temp\GenerateRpt.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https...

#

I mean...

wheat mesa
#

Use tsc.cmd instead of tsc

lyric mountain
wheat mesa
#

Thatโ€™s what I did and worked for me on my system

feral aspen
#

What does that do, and when do we use it?

wheat mesa
#

Instead of using tsc, just type tsc.cmd instead

#

I donโ€™t know why, but it works

#

Just the same

feral aspen
#

I'm aware, but what does it do?

wheat mesa
#

The same thing as tsc

sudden geyser
lyric mountain
wheat mesa
#

True!

feral aspen
#

Why does typescript compile to ES3 and not ES6, supposedly.

cinder patio
#

because that's what you've set in your tsconfig

#

set it to ES6

feral aspen
#

What's the property in the object, called?

#

Also, does tsconfig.json have a default object?

cinder patio
#

answers all your questions

simple stump
feral aspen
#
interface User {
    name: string;
    age?: number;
};

What do you call the ?.

#

Is there a name of it in typescript?

#

Also, why is it not seperated with a , but a ;?

lyric mountain
surreal knoll
lyric mountain
#

if u used commas, it'd be like ```java
public class User {
String name, age;
}

lyric mountain
feral aspen
#

I can still use something like:

interface User {
    name: string,
    age?: number,
};
lyric mountain
surreal knoll
# lyric mountain why?

You need node 16+ to use djs v13, but replit only supports v12 or v14
I can't remember

lyric mountain
surreal knoll
#

Nothing ever worked for me
I'll just self-host anyway

snow vector
#

just made a chat room for staff only

lyric mountain
#

socket io?

snow vector
#

nope

#

dosnt lag either surprisingly

lyric mountain
#

direct socket then?

#

or plain http requests?

snow vector
#

pain request i think i made the css and the hta access while my friend worked on the index

lyric mountain
#

why don't u use a socket network?

#

that way u get the message sent instantly to clients

snow vector
#

idk we both beginners it sounds confusing lol

lyric mountain
#

that's how I did the chat for my pixel game

snow vector
lyric mountain
#

it's kinda easy, I'd say easier than setting a rest server

snow vector
#

ill look into it then

snow vector
lyric mountain
#

what lang did u use?

snow vector
#

php

lyric mountain
#

...

#

plain html + js + php then?

snow vector
lyric mountain
#

that's a yes then

snow vector
#

ok thank you

lyric mountain
#

you'd have a backend somewhere to handle the requests tho

#

that's where the previous node article comes in

#

unless ur fine having only a 1 <-> 1 communication

snow vector
#

ill try it out!

simple stump
#

How do I check if a port exists already? Basically I am doing this:

function createServer() {
  let randomPort = functions.createPort(); // generates a random number from 1-9999 for the port
  functions.createServer(randomPort); // creates an http server. so the website will now be http://localhost:1234 or something.
}

But sometimes a server may exist already. Is there a way to check if a server is busy or smth?

sick agate
#

??

simple stump
#

idk why i didnt think of that earlier omg. mb ty

lyric mountain
#

kekw, it's weird but probably the most convenient solution is to try-catch stuff

#

regarding port stuff it's always a headache and the closes way to check would involve a lot of low-level shit

#

oh btw, remember to enable reuseAddr

#

else u might get a ghost port

cinder patio
simple stump
#

yea i change d it haha

#

mb

simple stump
lyric mountain
#

The Character Generator Protocol (CHARGEN) is a service of the Internet Protocol Suite defined in RFC 864 in 1983 by Jon Postel. It is intended for testing, debugging, and measurement purposes. The protocol is rarely used, as its design flaws allow ready misuse.A host may connect to a server that supports the Character Generator Protocol on eith...

timber fractal
#

Why do I keep getting this error when trying to send an E-mail using nodemail? Error: Connection timeout at SMTPConnection._formatError (/home/runner/DAVM/node_modules/nodemailer/lib/smtp-connection/index.js:784:19) at SMTPConnection._onError (/home/runner/DAVM/node_modules/nodemailer/lib/smtp-connection/index.js:770:20) at Timeout.<anonymous> (/home/runner/DAVM/node_modules/nodemailer/lib/smtp-connection/index.js:229:22) at listOnTimeout (node:internal/timers:557:17) { code: 'ETIMEDOUT', command: 'CONN' }

sick agate
#

smtp server error

timber fractal
sick agate
#

you cant

timber fractal
#

oh

#

But then I just can't use nodemail???

#

or can I prevent the error somehow?

lyric mountain
#

you can catch it

#

topggFacepalm what did I just say?

#

ask the question, don't ask for help

earnest phoenix
#

If it's a command block you want, we can't help you

lyric mountain
#

basically a command that creates a private channel that only you and the mods can see?

#

what library are you using?

#

I know

#

are you using discord.js?

earnest phoenix
#

Use translate

lyric mountain
#

so you don't have a bot at all yet?

earnest phoenix
#

Are you talking about probot?

lyric mountain
#

you should ask on their support server then

#

we can't really help regarding other bots

earnest phoenix
#

Then we can't help you

#

It would make more sense to ask the support server of the bot you said

heavy marsh
#

In d.js v13
How to have choices instead of an option

split hazel
timber fractal
sudden geyser
split hazel
simple stump
#

Using NodeJS, how would I create a Blob and parse it into a playable format for the <video> tag?

const { Blob } = require("buffer"); // What I found online, but the type is different compared to the browser.
let filePath = URL.createObjectURL(new Blob([torrent], { type: 'application/x-bittorrent' }));

I'm using WebTorrent as a package, but the original code only allows me to get a torrent's blob URL if the source code is in the browser (which makes sense). I'm trying to do the same thing except for NodeJS. This is the code that WebTorrent uses:

  get torrentFileBlobURL () {
    if (typeof window === 'undefined') throw new Error('browser-only property')
    if (!this.torrentFile) return null
    return URL.createObjectURL(
      new Blob([this.torrentFile], { type: 'application/x-bittorrent' })
    )
  }
neat ingot
#

I made some changes to the ui of my rpc app. currently reworking everything to properly support theme options. I've been writing personal websites for years and only just learned about css variables ๐Ÿ˜‚

#

wondering if anyone has any more suggestions for improvements to the gui ๐Ÿ™‚

onyx socket
#

How to disable global error handler from processing the error if the error is handled by the local error handler.

split hazel
#

if the error is handled locally it should not become global

#

unless you're in the web

onyx socket
# split hazel context?

i have a command that can raise two errors. Error 1 is specific to that command Error 2 is missing arguments which is more common error. Now i have added a local handler for this command that only handles the error thats specific to it and not the missing arguemnt error which, is handled by global error handler as its required for apprx. every command.

#

THis specific error is just missing arguments error but with more explanation. For Example : ?cmd <parameter1> <parameter2> will raise missing arguments error when any argument is missing.
Accourding to that, will want to send a message explaining why that parameter is required and what to add as paramter. This explanation is specific for each command and thus can't be managed in global handler. But there are some commands taht don't require any explanation. Those should be handled by global handler saying argument is missing.

#
```will raise error like this : 
``` param 2 is a required parameter because its needed for <reason> and you have to enter <details> there.
```whereas 
`?cmd3 __`
doesn't require explanation so the missing arguments error will be handled by global handler like this 

Looks like you forgot to pass a parameter

onyx socket
sudden geyser
#

What exactly are you using as a command handler? It sounds like you just need to scope errors

hexed garnet
#

bot.topggpy = topgg.DBLClient(bot, dbl_token)
TypeError: init() takes 2 positional arguments but 3 were given

lyric mountain
#

I believe the error is self-explaining

hexed garnet
#

i have been migraating to slash commands

#

and nth work

#

s

#

just tell me

lyric mountain
#

did you read the second line?

hexed garnet
#

yea

lyric mountain
#

what does it say?

hexed garnet
#

TypeError: init() takes 2 positional arguments but 3 were given

lyric mountain
#

yes, so how many arguments does init() expect?

hexed garnet
#

topgg.DBLClient(bot, dbl_token)

#

where is the third?

lyric mountain
#

that's not where init is

#

show the whole stacktrace

hexed garnet
#

witch init?

lyric mountain
#

just show the error stacktrace

#

the big verbose error

hexed garnet
#

Traceback (most recent call last):
File "/home/container/main.py", line 74, in <module>
bot.topggpy = topgg.DBLClient(bot, dbl_token)
TypeError: init() takes 2 positional arguments but 3 were given

lyric mountain
#

the next lines

hexed garnet
#

container@pterodactyl~ Server marked as offline...
[Pterodactyl Daemon]: ---------- Detected server process in a crashed state! ----------
[Pterodactyl Daemon]: Exit code: 1
[Pterodactyl Daemon]: Out of memory: false
[Pterodactyl Daemon]: Aborting automatic restart, last crash occurred less than 60 seconds ago.

#

that dosnt help.

lyric mountain
#

there should've been more to that error

hexed garnet
#

yea i agree

#

would removing help_command=PrettyHelp(),

#

cause it?

lyric mountain
#

not really

#

is your code like this?

hexed garnet
#

kinda

#

class Echo(commands.AutoShardedBot):
def init(self):

    super().__init__(
        command_prefix={","},
        owner_ids={775030123749441536},
        intents=discord.Intents.all(),
        case_insensitive=True,
        start_time=datetime.utcnow(),
    )
lyric mountain
#

one of those inits are expecting 2 arguments but receiving 3

#

search in your code anywhere there's init written

hexed garnet
#

all have 2 things

#

def init(self, bot):
self.bot = bot

#

def init(self, max_size: int = 128):

#

class Echo(commands.AutoShardedBot):
def init(self):

    super().__init__(
        command_prefix={","},
#

so idk

#

only one is this

#

def init(
self,
prefix: str = "", suffix: str = "",
max_size: int = 2000,
scale_to_size: int = 2000,
max_lines: t.Optional[int] = None,
) -> None:

#
        self,
        prefix: str = "```",
        suffix: str = "```",
        max_size: int = 2000,
        scale_to_size: int = 2000,
        max_lines: t.Optional[int] = None,
    ) -> None:````
#

..

lyric mountain
#

try ctrl + clicking DBLClient to see its internals

#

I can't find that lib's source code

hexed garnet
#

it works locallyt

#

not on a server

lyric mountain
#

the same code?

hexed garnet
#

yep

lyric mountain
#

did you remember so save it?

hexed garnet
#

dude i can git pull to a new folder

#

and it works locally

lyric mountain
#

is the lib updated?

hexed garnet
#

i dont know

#

it on the newest ver

hexed garnet
lyric mountain
#

I'll need to wait someone more experienced with either pterodactyl or that lib to see where's the issue

simple stump
#

How would I convert a NodeJS buffer into a playable format that normal JavaScript can play using the <video> tag?

quartz kindle
#

stream it

#

make an new path/endpoint in your server/router that sends the buffer

#

and give the <video> tag the url to it

neat ingot
#

~ watching my lecturer copy/paste with mouse...

#

c# lecturer* ๐Ÿ˜‚

wheat mesa
#

Lmao

#

I wish we had a c# course

#

Iโ€™m chilling in my Java class rn

neat ingot
#

ooohh, after our two week holiday we get to learn about while loops!

#

#excite

simple stump
neat ingot
onyx socket
#

Let me share the code

civic scroll
#

i'm confused

simple stump
neat ingot
#

idk what the pipe call is when using the http lib, but using express it'd be something like this: ```js
const express = require('express')
const app = express()
const origin = 'https://example.com'

app.get('/*', async (req, res) => {
const proxy = await fetch(${origin}${req.path})
res.writeHead(proxy.res.statusCode)
proxy.res.pipe(res)
})

app.listen(process.env.PORT)```

#

actually, what is it your trying to do? why do you need two servers?

simple stump
neat ingot
#

like, if your just wanting to stream data from your server to the client, thats only one server, no?

simple stump
# neat ingot like, if your just wanting to stream data from your server to the client, thats ...

Essentially I'm utilizing the library WebTorrent which creates an HTTP server with the link to the original file. I can scrape that link, but it leads to no where. So I devised the idea of getting the buffer of the torrent and then streaming it by creating a new HTTP server. I can't use WebTorrent in the browser because WebRTC doesn't work, so I have to do all this work in the backend.

neat ingot
#

so your basically creating a server to act as a proxy between torrents? ๐Ÿ‘€

simple stump
#
axios({ method: 'post', url: "http://localhost:3000/api/users", data: { title: links[0].text, magnet: links[0].url }} ).then(async(res) => {
  let port = res.data.id;
  let server = torrent.createServer();
  server.listen(port, async() => {
    const http = require("http");
    http.createServer(function(request, response) {
    }).listen(port);
  });

There's a bit more to it, but that's the general idea.

simple stump
#

maybe? ๐Ÿ‘€ dw abt it ๐Ÿ‘

neat ingot
#

lmao

#

no worries SnorlaxDab

simple stump
#

mostly just doin this for fun haha. dumbest idea ive come up with tbh

neat ingot
#

lol, dumb ideas usually are fun ๐Ÿ˜„

simple stump
#

frfr

civic scroll
simple stump
civic scroll
#

you don't wanna import every time you request the thing

neat ingot
#

doesnt really matter

#

require is cache'd

#

it is good practice tho

civic scroll
#

also

#
http.createServer(() => {}).listen(port);
civic scroll
neat ingot
#

yea thats fair

simple stump
simple stump
#

also the fetch part is sending an http request to the localhost server or wherever the buffer is stored? sorry not sure if i interpreted that correctly or not

#

wait nvm i saw the link you sent mb.

#

dang thats unfortunate. nvm imma use express then

neat ingot
#

express isn't bad ๐Ÿ™‚

#

almost all my sites/api's use it

#

really nice optional url parameters and such

simple stump
#

haha. thats true ive used it a bit. im just having a bit of issue cause every time a new torrent is requested i create a new port

#

which prob isnt a good idea but express can only listen to 1 port i believe

#

i tried having it listen to all ports but that didnt seem to work haha

neat ingot
#

you could umm

#

might make things large than you anticipated

#

but you could use something like docker to spin up containers (instances of your torrent server)

#

thats likely way more work though ๐Ÿ˜„

simple stump
#

haha ty i will look into that ๐Ÿ‘

rose lance
#

would yall say commands like avatar, serverinfo and userinfo are general commands or utility commands?

split hazel
#

and depends what you mean by general

#

something quick you'd usually group it as utility

rose lance
#

aight

#

general is stuff like ping, help, info

onyx socket
# onyx socket Let me share the code

Sorry for being late but this is the code first image shows the global error handler and second one shows the local error handler of the smogon command.

fickle arch
#

uh, so I have economy system on my bot, how do I keep the data from not getting wipe on every bot restart

#

I was testing it on heroku so want to make sure it work fine before deploying it to vps

rose lance
quartz kindle
fickle arch
near stratus
#

psql

near stratus
fickle arch
near stratus
#

saw that coming

fickle arch
#

yeh I'm still new on coding.

quartz kindle
#

heroku uses an ephemeral file system, they are the ones deleting your data, if you move to a vps it wont be deleted

fickle arch
#

planning to move into vps, after testing it with heroku.

near stratus
#

If you're testing then having the data on heroku for 24 hours should be good enough for testing/ building

fickle arch
#

Alright then, thanks for the info.

fickle arch
quartz kindle
#

if you want my suggestion, just move to a vps right away

#

the sooner the better

#

dont waste time on heroku

onyx socket
quartz kindle
#

you dont the problem?

ancient nova
#

@quartz kindle I don't have the error atm because right now it's apparently working however it probably won't in the near future

#

it just says "Value" is undefined pretty much

quartz kindle
#

show the full code then

ancient nova
# quartz kindle show the full code then
                const response =
                let result = response.map(value => value.name_value.split("\n").filter(x => !x.startsWith("*"))).flat();
                result = result.filter(function (item, pos, self) {
                    return self.indexOf(item) == pos;
                })
quartz kindle
#

and where is if (response.statusCode !== 200) { or if (arrayLength === 0) {?

ancient nova
#

below this piece of code

quartz kindle
#

why?

ancient nova
#

I can't get them before getting the json first, no?

quartz kindle
#

you can check statuscode before json, and you can check length before map

feral aspen
#
const redeem = new MessageEmbed()
.setColor(black)
.setDescription('Please enter your code by sending it to the chat.')

const n = await ButtonInteraction.update({ embeds: [redeem], components: [] });

const nFilter = (nInt) => nInt.message.id === n.id && nInt.member.id === n.id;
const nCollector = new MessageCollector(interaction.channel, { nFilter, max: 1, time: 10000 });
#

In the nFilter function, how can I check if the nInt member id is equal to the member id in n?

ancient nova
#

even so how would that help in solving the value error?

quartz kindle
#

you cant trust the api to always give you what they are supposed to

ancient nova
#

agreed that's why I also decided to try scrapping the body of the webpage (not the api) and then use regex to turn it into a json

#

however it gives me the same issue

#

it sometimes works and sometimes doesn't

quartz kindle
#

not n

#

also that filter will not work

#

nFilter is not a valid collector option

ancient nova
#

just a thought, couldn't it possibly be a sort of rate limit / IP barrier that prevents my program from accessing the website?

#

thinking about it makes me think no, because if I just take the url and put it on chrome it suddenly works again

quartz kindle
ancient nova
#

hmm

earnest phoenix
ancient nova
#

should I just try catch that and give an error of API being unavailable if I ever get that error?

quartz kindle
#
let response;
try {
  response = await fetch(`https://crt.sh/json?q=${_domain}`).then(response => response.json());
} catch(e) {
  console.log(e);
  return;
}
if(!Array.isArray(response)) {
  console.log("not an array");
  return;
}
let result = response.map(value => value?.name_value?.split("\n").filter(x => !x.startsWith("*")) || []).flat();
``` these are a few checks you can add for example
ancient nova
#

how does it work again?

#

also can I just get rid of the try catch since I have a handler, it will give me the error anyway

quartz kindle
#

a?.b is the same as a ? a.b : undefined

ancient nova
#

should I else if that?

quartz kindle
#

you dont need else if you return inside the if

ancient nova
quartz kindle
#

its decent if it looks right

feral aspen
#

Hmm.. so why is this error?

const redeem = new MessageEmbed()
.setColor(black)
.setDescription('Please enter your code by sending it to the chat.')

const n = await ButtonInteraction.update({ embeds: [redeem], components: [] });

const nFilter = (nInt) => nInt.message.id === n.id && nInt.user.id === interaction.member.id;
const nCollector = new MessageCollector(interaction.channel, { filter: nFilter, max: 1, time: 10000 });
TypeError: Cannot read properties of undefined (reading 'id')
    at MessageCollector.nFilter [as filter] (C:\Users\HamoodiHajjiri\Desktop\Rewrite\src\slashcommands\utility\subscription.js:79:72)

It's saying n.id is undefined.

quartz kindle
#

having both return and else for no reason is not decent

ancient nova
quartz kindle
feral aspen
#

What, where?

quartz kindle
#

.update({embeds, components, fetchReply:true})

feral aspen
#

Still, same error?

ancient nova
quartz kindle
#

it doesnt matter

ancient nova
#

but it will look better

feral aspen
#

Slower, though, I think.

ancient nova
#

switch cases are actually faster

quartz kindle
feral aspen
ancient nova
#

also I would leave the default to be the rest of the code

#

so if it doesn't stop somewhere in the switch it will just run the code

#

that's pretty smart ngl

quartz kindle
#

show code

feral aspen
#

Yes.

#
const redeem = new MessageEmbed()
.setColor(black)
.setDescription('Please enter your code by sending it to the chat.')

const n = await ButtonInteraction.update({ embeds: [redeem], components: [], fetchReply: true });

const nFilter = (nInt) => nInt.message.id === n.id && nInt.user.id === interaction.member.id;
const nCollector = new MessageCollector(interaction.channel, { filter: nFilter, max: 1, time: 10000 });

nCollector.on('collect', (aCode) => ctr = aCode.content);

nCollector.on('end', async (collected) => {
    if (!collected.size) {
        embedError.setDescription('โŒ The **15 seconds** time limit has reached.');
        return await interaction.channel.send({ embeds: [embedError] });
    } else {
        collected = collected.first();
        interaction.channel.messages.fetch(collected.id).then(msg => msg.delete());
        resolve(null);
    };
});
quartz kindle
#

idk then

#

but like

#

why do you need that id again?

ancient nova
#

the code is pretty neat I like it

feral aspen
#

Isn't it the job of filters?

quartz kindle
#

dont you want to filter for the channel id and the member id?

ancient nova
#

I'd just put the redeem embed into a global variable so it doesn't made the code look bad

earnest phoenix
quartz kindle
#

why not just use awaitMessageComponent()?

#

or awaitMessages()

earnest phoenix
#

Message component collects the message interaction components, not the message which I suppose is what they want, but yeah the awaitMessages() method is also a good option

feral aspen
#

I'm collecting a message, only, and applying filters.

ancient nova
quartz kindle
#
const n = await ButtonInteraction.update({ embeds: [redeem], components: [], fetchReply: true });

const collected = await interaction.channel.awaitMessages({ filter: m => m.author.id === interaction.member.id, max: 1, time: 10000 });

    if (!collected.size) {
        embedError.setDescription('โŒ The **10 seconds** time limit has reached.');
        return await interaction.channel.send({ embeds: [embedError] });
    } else {
        collected = collected.first();
        interaction.channel.messages.fetch(collected.id).then(msg => msg.delete());
        resolve(null);
    };
kind thicket
#

Heya, for some reason command returns as undefined when I console.log it but I cant figure out why that is
Hope someone can help me

module.exports = {
    name: "interactionCreate",
    run: async (client, interaction) => {
        if (!interaction.isCommand()) return;

        const command = client.commands.get(interaction.commandName);
        if (!command) return;

        try {
            await command.execute(interaction);
        } catch (error) {
            console.log(error)
        };
    }
};```
feral aspen
#

This works?

const redeem = new MessageEmbed()
.setColor(black)
.setDescription('Please enter your code by sending it to the chat.')

await ButtonInteraction.update({ embeds: [redeem], components: [], fetchReply: true });

const nFilter = (nInt) => nInt.member.id === interaction.member.id;
const nCollector = new MessageCollector(interaction.channel, { filter: nFilter, max: 1, time: 10000 });
nCollector.on('collect', (aCode) => ctr = aCode.content);
ancient nova
#

I need a project idea

kind thicket
#

I've tried that, it returns ping (which is the command)

quartz kindle
#

log client.commands

kind thicket
#

is what it returns when I do that

quartz kindle
#

check your command loading code

earnest phoenix
#

undefined as entry name/key

quartz kindle
#

you are storing the command with undefined as a key

kind thicket
#

I never saw that undefined before, idk how

quartz kindle
#

show where you do client.commands.set()

earnest phoenix
#

I suppose you're setting command.name in your loader rather than comnand.data.name

#

I've made that mistake before as well

kind thicket
#

This is what I use

    const commandFiles = await globPromise(`${__dirname}/commands/**/*.js`);
    commandFiles.map(res => {
        const file = require(res);
        client.commands.set(file.name, file);
        client.categories.add(file.category);
    });```
earnest phoenix
#

Knew it

quartz kindle
#

do all your commands use { data: { name: "" } }?

kind thicket
#

thanks! it worked

#

i changed file.name to file.data.name

quartz kindle
#

just make sure all commands are using the same format

kind thicket
#

Yeah, I was going to do that

quartz kindle
#

๐Ÿ‘

simple stump
#

How do I play mkv files in the browser? I understand standard JavaScript can only play mp4, ogg, and webm files, but the files I currently have are only mkv files.

quartz kindle
#

you can try playing it with type="video/mp4"

#

if it doesnt work, then you need to convert your files

simple stump
quartz kindle
#

not afaik

plucky imp
#

okay so

#

i'm working on a lockdown command but whenever i run it it won't lockdown and i think it's cause of how i'm getting my role?

#

this is where i update the channel tho

#
 const ok = await interaction.channel.permissionOverwrites.create(role, { SEND_MESSAGES: true })
        .catch(() => null);

      if (ok === null) return;
#

and this is what the role identifier is

#
const { role } = await client.db.updateGuild(interaction.guild.id);
#

@solemn latch pls halp BunPoke

#

nvm i fixed it

earnest phoenix
#

I'm getting Protocol error, got "A" as reply type byte redis while using redis-server or redis-cli command

#

How can I do big indents instead of doing <hr> many times for html?

boreal iron
#

Using padding/margin for your element

#

And <hr /> is an horizontal line (break), it has nothing to do with indentation

earnest phoenix
#

Okay

#

Thanks

boreal iron
#

For example
<span style="margin-left: 20px;">text first tab</span>

#

You may wanna define some CSS rules for it

earnest phoenix
#

Okay, thanks. And yeah. I'm working on the css for this as well

split hazel
#

does anyone know how to prevent TCP from clamping two packets together?

#

i looked online but the only answer i got was "TCP is a streaming protocol bro" ok cool now tell me how to solve the problem

sharp saddle
#

how i can fix this?

lyric mountain
sharp saddle
#

hmmmm?