#development

1 messages ยท Page 1513 of 1

shy turret
#

i updated it

summer torrent
#

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

shy turret
#

and it crashed several times

zenith terrace
#

my phone kept constantly saying "connecting"

shy turret
#

thats fixed

#

update it

#

role names are dead thoguh

#

imma update discord again

#

for the i think 3rd time today

zenith terrace
shy turret
#

This message has been sent on andriod alpha.

#

Btw roles still dont load

#

At least user profiles do now

zenith terrace
#

ima wait till everything works again lol

shy turret
#

K

cerulean ingot
#

should i make a role unboxing bot or a ticket bot

earnest phoenix
#

android discord developers and competency really dont go hand in hand huh

mellow kelp
#

yea

#

they should just add some responsiveness to the website and make it a PWA smh

long marsh
#

Yeah, this makes the most sense

crimson vapor
#

is there a way to get data from a FormData node js

#
const data = new FormData();
data.append('json_payload', JSON.stringify({ content: 'test' }))``` I want to be able to get json_payload from this
pale vessel
#

There's data.getHeaders() or something

#

or data.toHeaders(), not sure

crimson vapor
#

I need the data tho

#

not the headers

pale vessel
#

yes

#

that's what formdata is

pale vessel
#

headers with boundaries

crimson vapor
#

so is there any way for me to get the json_payload back?

pale vessel
#

probably

crimson vapor
#

@quartz kindle do you know how I would go about doing this?

mellow kelp
#

it just occurred to me

#

should i store images in a mongodb database?

#

(probably a bad idea i think)

crimson vapor
#

there are pros and cons

#

like its easy and you can just export everything

#

but max is 16mb iirc and the bigger the db the slower requsts should be iirc

mellow kelp
#

hmm yeah

#

probably a bad idea for scaling

crimson vapor
#

a few people are proficient

mellow kelp
#

yeah just ask

crimson vapor
mellow kelp
#

thats poggers

crimson vapor
#

yea

#

until I introduce a bug into the code and like 1/2 of the files are 404

stuck pike
#

Best budget hosting

#

Like 3-5$?

misty sigil
#

i would say contabo if their reviews weren't shit

#

so i recommend galaxygate @stuck pike

earnest phoenix
#

go to their Discord Bot Hosting packages, starting from $1.75 to $4.00

crimson vapor
#

I use ovh lowest tier is about 3usd

solemn latch
earnest phoenix
#

Intel(R) Xeon(R) CPU E5-2630L v3 @ 1.80GHz

#

for my plan ^

crimson vapor
#

how many cores?

solemn latch
#

I would tell you but their website is a potato and is taking 30 seconds to load a page

crimson vapor
#

lmao

solemn latch
#

Oh man the cpu on those plans are literally going for a few dollars on ebay.

earnest phoenix
#

the bot hosting plans are meant to be cheap so idk

earnest phoenix
crimson vapor
#

oh

#

yikes

solemn latch
#

Oh yeah, its not a bad deal for an extremely cheap hosting plan assuming its not oversold.
Just not for me as I need some cpu power.

earnest phoenix
#

i dont need much cpu power, so it's good enough for me

distant cobalt
#

On discord.js how do you get the bot's uptime?

crimson vapor
earnest phoenix
#

<Client>.uptime

distant cobalt
distant cobalt
earnest phoenix
#

np

crimson vapor
#

I prefer process

solemn latch
#

Id suggest using the process up time if you dont have a specific reason for using bots uptime.

The bot might dc for a split second but not go down

crimson vapor
#

process.uptime? process.uptime()?

#

lemme check

earnest phoenix
#

second one

distant cobalt
#

lol

crimson vapor
#

process.uptime() is in seconds?

distant cobalt
#

I d k, lemme check

earnest phoenix
#

nope

distant cobalt
solemn latch
#

Looks like the number of seconds the bots been up KEKW

earnest phoenix
#

oh yeah might be

#

it returns the seconds

distant cobalt
# earnest phoenix

So do i add math.floor to the code or just keep it like that cuz it's been seconds?

solemn latch
#

Its generally cleaner to round it down like that

earnest phoenix
#

yeah

distant cobalt
#

Okay i will round it

crimson vapor
#

do process.uptime().toFixed(2)

#

it looks nicer

distant cobalt
#

okAy

solemn latch
#

Or converting it into minutes hours days weeks is better pogey

solemn leaf
#

how can I get author from guild member

earnest phoenix
#

you mean user?

solemn leaf
#

yeah jus to get displayavatar

earnest phoenix
#

isn't it literally GuildMember.user

solemn latch
#

think so

#

docs are amazing for that kind of stuff

earnest phoenix
#

true, searching that in the docs yourself would be faster than asking it here tbh, at least to me

solemn leaf
#
    let URL = user.displayAvatarURL({
        dynamic: true,
        size: 1024,
        format: 'png'
    }) || user.author.displayAvatarURL({
        dynamic: true,
        size: 1024,
        format: 'png'
    }), type = "png";
opal plank
#

wtf is that

#

user.author??

solemn leaf
#

wait nvm

earnest phoenix
#

eNgLisH

solemn leaf
#

dont ask

#

how do I get displayAvatarurl from member

solemn latch
#

hmm, ill go look at the docs for you.

solemn leaf
#

thanks

solemn leaf
#

ok

#

how do I get user from guild

#

bcs Im doing it write

#

right

solemn latch
#

what do you mean?

#

are you getting an error?

solemn leaf
#

idk at this point

#

user.displayAvatarURL

#

user was

#

message.mentions.first

solemn latch
#

message.mentions.first would give you undefined

#

so user is probably undefined

#

which im guessing what your error is?

crimson vapor
#

Woo do you know the top.gg api a bit?

solemn leaf
#

@solemn latch it was exapmle

#

I did

#

message.mentions.members.first()

solemn latch
#

so are you getting an error? or?

solemn leaf
#

TypeError: user.displayAvatarURL is not a function

solemn latch
#

log your user

#

oh wait

#

user is a member Thonk

solemn leaf
#

I asked how to

solemn latch
#

member.user

#

so in your case

#

user.user.displayAvatarURL()

#

since you named your member user

solemn leaf
#

Ill change it to member to make it more clear thanks

solemn latch
#

you could also just use message.mentions.users.first()

#

skip the member entirely

solemn leaf
#

??

solemn latch
#

well since your using only the user anyway, no need to use .members

solemn leaf
#
    let member = message.mentions.members.first() || message.guild.members.cache.get(args[0]) || message.guild.members.cache.find(c => c.displayName.toLowerCase() === args.join(" ").toLowerCase()) || message.member;
    if (!member) {
        return message.channel.send({ files: [message.author.displayAvatarURL({ dynamic: true })] });
    } else return message.channel.send({ files: [member.user.displayAvatarURL({ dynamic: true })] });

Tried this havent read what you sent after the ??

#

got it

#

thank

charred pumice
#

With ytdl-core is there a way to skip to a certain part of the video?

crimson vapor
#

did you check the readme for a seek method?

#

idk if there is

#

but I think that was it

#

as well as options for startat

#

idk its name

long marsh
#

Hey, guys! I have a question for someone if you're up for it ๐Ÿค”

#

Regarding singleton / cache principles

#

I have this in my cache.js:

const Keyv = require('keyv');

const Cache = new Keyv();
Object.freeze(Cache);

module.exports = {
  Cache
};

and this in my index.js:

const { ShardingManager } = require('discord.js');
const { Bot, TopGG } = require('./config');
const { App } = require('./server');

const manager = new ShardingManager('./bot.js', {
  totalShards: 'auto',
  token: Bot.token,
});

manager.on('shardCreate', (shard) => console.log(`Launched shard ${shard.id}`));
manager.spawn();

App.listen(TopGG.webHookPort);

Then this in my server.js:

const express = require('express');
const { User } = require('./classes/user');
const { TopGG } = require('./config');

const app = express();
const webhook = new Topgg.Webhook(TopGG.webHookAuth);

app.post('/dblwebhook', webhook.middleware(), (req) => {
  const { vote } = req;
  const user = new User(vote.user);
  user.voted('tgg', vote.isWeekend);
});

module.exports = {
  App: app,
};
#

What's weird is that when the Cache object is referenced from the user.voted() command in server.js, it's as if it creates a whole separate Cache object than the one that's reference from the discordjs module ๐Ÿค”

#

Even though, I thought cache.js froze the object?

#

In the same user.js file, I print out the Cache and it references two different objects (user.voted vs. user.getCoins ... which is supposed to reference the same require(./cache) ๐Ÿค”

solemn leaf
#

why does this still return uvu hello

"uvu hello".slice(3)
long marsh
#

It doesn't

#

It returns hello

solemn leaf
long marsh
#

I don't know what else is going on behind the scenes, but "uvu hello".slice(3) returns hello

solemn leaf
#

idk eithere

#

1 sec

#

I think I figured it out

long marsh
#

Something else is going on there ๐Ÿ˜ฌ

solemn leaf
#

ik

#

fixed

long marsh
#

๐Ÿ‘

solemn leaf
#

I dont understand your cache thing

#

but ill look

long marsh
#

Lol, no worries

#

@solemn latch -> I'm sssooo sorry for the ping. You mentioned to me earlier that you used some sort of protocol or something to communicate between your webhook server & discord bot?

solemn latch
#

ipc?

long marsh
#

That was ti!

solemn latch
#

it just means interprocess communication. its not really a protocol, its just saying the two programs talk to each other,

long marsh
#

How did you actually 'communicate' between the webhook server and your discord bot? I'm having a really oddball problem with my singleton Cache instance. For some reason, when running the discord bot + webhook from the same index.js ... it instantiates two Cache objects ... which is weird.

#

Legit, that's all I'm doing.

solemn latch
#

tim would spot the issue in 30 seconds

long marsh
#

I'm starting to think it spawns two different processes ๐Ÿค”

#

Which uses two different versions of 'Cache' object.

#

I appreciate your response, Woo!

lusty quest
#

did you start all 3 files with the same process?

solemn latch
#

just a guess(not worked with object freeze before) but you are creating a separate cache object, so its not frozen, because its its own new object.

#

cache 1 is created
cache 1 is frozen
cache 2 is created
cache 2 is frozen

long marsh
#

Technically, I have the index.js that calls the two files ๐Ÿ˜ฌ

#
const { ShardingManager } = require('discord.js');
const { Bot, TopGG } = require('./config');
const { App } = require('./server');

const manager = new ShardingManager('./bot.js', {
  totalShards: 2,
  token: Bot.token,
});

manager.on('shardCreate', (shard) => console.log(`Launched shard ${shard.id}`));
manager.spawn();

App.listen(TopGG.webHookPort);
lusty quest
#

i think Woo is right. you call the cache file from 2 points

long marsh
#

I think that's true as well; however, if that's the case, how do I just call it from one location and share it among all the files that consume it?

#

I require the Cache from multiple places.

lusty quest
#

if i get it right you want to share the cache between 2 processes?

long marsh
#

Correct ๐Ÿ‘

lusty quest
#

why not Redis? sure its not directly in memory but i guess managing it would be easyer

long marsh
#

I may end up switching to redis.

#

I'm already using docker anyways ... would be easy to spawn two containers ... one with the discord bot ... one with redis

lusty quest
#

yea

#

i probably switch to K8 in the next months, finnaly everything running in containers

long marsh
#

nice!

#

But, without Redis, is there a straight forward way to share the same Cache among two processes?

lusty quest
#

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

#

ask Tim, i guess at this point they should create a Channel and name it Ask Tim.

crimson vapor
#

@quartz kindle

#

summon activated

solemn latch
#

poor tim

crimson vapor
#

he signed up for this by being so good

valid temple
#

how can I console.log() an invite to every guild my bot is in on startup?

solemn leaf
#

why does this only allow me to use all commands not just ones in the owner category

solemn latch
#

the easiest way is to map all the guilds in the cache by their name @valid temple

solemn leaf
#
    let ownerCMDs = bot.categories.get('Owner');
    if (!ownerCMDs.toString().includes(cmd) && message.author.id !== "485987127809671168") return message.channel.send("Owner only command!");
solemn latch
solemn leaf
#

yeah

#

But I fixed it

#

didnt I ? @solemn latch

pale vessel
#

why toString()

#

what's bot.categories.get('Owner');

solemn leaf
#

tostring maybes the table a string

pale vessel
solemn leaf
#

well

#

[ 'eval', 'reload' ]

pale vessel
#

an array?

solemn leaf
#

yea

pale vessel
#

use ownerCMDs.includes(cmd) then

#

without ! and toString()

#

why are you negating the value

solemn leaf
#

?

pale vessel
#

that just made it "if command is non owner only and author isn't owner, return"

solemn leaf
#

oh

#

thanks

old cliff
#

is there a way to disable everyone and here in !say command ?

earnest phoenix
#

either escape that or disable the mention I suppose

old cliff
#

How to disable mentions ?

earnest phoenix
#

allowed mentions, idk what lib you're using, but rtfd ig.

old cliff
#

djs

earnest phoenix
#

take a look at allowedMentions parameter, it takes MessageMentionOptions ig

#

oh there's also disableMentions

solemn latch
#

honestly everyone and here should be disabled by default.

earnest phoenix
#

how can i host my bot 24/7 ?

#

run the code and leave it alone

#

lol

#

@earnest phoenix i suggest you to use heroku

#

heroku isnt 24/7 after 550 hrs

old cliff
#

allowedMentions: {parse: []} this property in message options works

#

to disable mentions

lusty quest
earnest phoenix
#

Um ok

neon heart
#

how to fix (process:6572): Pango-WARNING **: 13:40:18.814: couldn't load font "Noto Serif SC Heavy Not-Rotated 30px", falling back to "Sans Heavy Not-Rotated 30px", expect ugly output.

lusty quest
#

install the font

earnest phoenix
lusty quest
#

heroku doesnt offer free 24/7 you get 550 On Hours per month, if they are reached you go offline

earnest phoenix
#

^

neon heart
earnest phoenix
lusty quest
#

nope

earnest phoenix
#

Uh

#

But

#

What about if i usually update my bot rebooting it

#

There is still the hours limit?

#

Or that limit is for getting the bot 24/7 without any update?

lusty quest
#

the limit is till there

earnest phoenix
#

Uh

#

22 days

#

After that i have to wait until the next month, right?

lusty quest
#

yes

earnest phoenix
#

Now heroku sucks for me uh

#

Why is there a limit

lusty quest
#

no one will give you free hardware

#

well they give you free hardware there has to be a catch

stuck pike
#

I bought a hosting due to this

#

Crashed at the last moment of test

#

Thx to free hosting

rocky hearth
#

Which is more efficient?
In which case should I use which method?

class A {
  hello = 100;
  /* OR */
  get hello() {
    return 100;
  }
}
sudden geyser
#

Use get when you want the value computed every time

#

Use the latter if you don't want to recompute it every time.

rocky hearth
#

does using get, takes up memory?

sudden geyser
#

For example, if I did A.hello on get hello() {...} 100 times, it would run {...} 100 times. If I use hello = 100, that single value is returned every time.

#

It's not really a memory question. It's a, "Do I want to compute this every time?" because there are cases where you may want to recompute a property.

rocky hearth
#

So in this case, it is better to not use the getter. Right?

sudden geyser
#

If you don't need recomputation, yes.

earnest phoenix
sudden geyser
#

It's the embed title.

#

Use markdown [text](link)

rocky hearth
#

I dont need any computation, but what is the downside of still using a getter?

tight plinth
#

so i'm trying to do a dashboard for my bot, and i never did that before. I figured out how to get the code from OAuth, i just have two questions:
-How exactly do i use the code to get the user's info?
-How to use cookies/cache for the user to stay logged in?

lusty quest
#

how does your enviroment looks like?

#

did you use Express?

sudden geyser
#

@rocky hearth The body of the hello property is recomputed every time you access .hello. To visualize this, see this: ```js
class A {
get hello() {
console.log("Hi!");

return 500;

}
}

let alphabet = new A()

for (let i = 0; i < 100; i++) {
alphabet.hello
} // Prints "Hi!" 100 times.Now, seejs
class A {
hello = 100;
}

let alphabet = new A()

for (let i = 0; i < 100; i++) {
alphabet.hello
} // Prints nothing because I didn't tell it to, but if it could, it would only print "Hi!" once -- when the class was initialized.The downside is you're using cpu/power to do something you don't need to do. There are cases where getters are useful. See this,js
class Rectangle {
constructor(width, height) {
this.width = width;
this.height = height;
}

get area() {
return this.width * this.height;
}
}```
area gets recomputated every time it's accessed. This is important because if width or height change, area will still return the correct area of the rectangle.

#

oh a bit long

tight plinth
#

I use express and EJS, yes

lusty quest
#

ok use express-session for handling cookies, and i can recomend looking into passport and passport-discord

tight plinth
#

I'm trying to get the backend before doing the actual website

#

alr

#

i'll try that

rocky hearth
#

Oh man, so much appreciated and thanks for your time. But I'm aware of using members and getters, and how they work.
I just wanted to know, are there any downsides of using a getter that just returns a literal.

sudden geyser
#

The downside is very trivial, but pretty much the same: using cpu power to do something you don't need to do.

rocky hearth
#

hmm thanks again!

tight plinth
#

nvm figured out, i'm just being dum

lusty quest
#

ok then

#

it makes handling OAuth extremely easy

tight plinth
#

i have to put the uri in this

lusty quest
#

ye

#

you can also pass the Intends you want to use with it directly in a easy way.

#

i use it to get the member object of the User and the Guilds of the user

brazen hill
#

Can I see who voted for my bot?

sudden geyser
#

Yes, see top.gg's API documentation.

lusty quest
#

you want to add cooldowns to your commands?

#

i would recommend using Redis for such stuff, you can get a Free Database online. Redis is more or less designed to persistent store temporary data. You can set a TTL for each entry and if the TTL reaches 0 it fires an event you can listen to.

#

still would recommend redis. using a DB that is designed to store stuff persistant will get unnecessary read /writes with such stuff

#

you call the function to remove the cooldown inside an If statement i guess

#

and the delete time on finish i would set inside an event that is called when the bot starts -> starts a timeout for each cooldown stored in the database

#

also with your current way its possible that a guild get stuck in a infinite loop of repeating cooldowns

#

delete it

#

if you set it to 0 you still could set a timer since it exist

#

this is why i suggest redis, if you set a TTL you will have way less issues

#

if the TTL reaches 0 the data self destructs

#

and on each time the command is used just check if the Cooldown exist in Redis if yes return with an error if not execute command and then set a cooldown in redis

jolly hearth
#

anyone can help with bal cmds that is working

lusty quest
#

ok

#

would still recomend redis, the way you do it rn uses more CPU power, this can cause issues if you scale larger.

true ravine
#

I'm trying to send a get request using axios to my api which is currently running on the same machine, but every time I get "connection refused" and no requests logged on the api - what could I be doing wrong?

lusty quest
#

did you need to send a header?

#

also can you connect to the api with something like postman?

true ravine
#

Yeah I've got the header with my auth token and stuff, and the api will respond with a 403 if the authentication fails

#

Yeah postman works fine

lusty quest
#

how did you send the header?

true ravine
#

I threw all the request config including the header, body, request type etc into a config variable and then passed that to axios, since that's what postman suggests

lusty quest
#

maybe there is the issue, that you send something with the wrong attribute

true ravine
#

I'll have a look into it thanks

wide wharf
#

where's my question gone lmao

#

how do I redirect the user when it's done verifying (bot verification etc) to a specific link?

earnest phoenix
#

...what?

fierce ether
#

if req.session.guilds always returns undefined, what am i doing wrong?

rocky hearth
#

how do I know if two instances are of the same class?

lusty quest
fierce ether
#

yes

#

im logging in, and using guilds, identify scopes

#

so idk the problem

lusty quest
#

log what your oauth workflow returns, maybe its attached wrong

fierce ether
#

req.session.user

#

returns true

lusty quest
#

it should return a object or how did you check if it exist?

fierce ether
#

it returns the user

lusty quest
#

yes it should return the user object

fierce ether
#

yes

lusty quest
#

so it cant be a true or false

fierce ether
#

but idk why guilds is not returning an object

lusty quest
#

is it attached to the user object?

fierce ether
#

res.render('dashboard', { user: req.session.user, guilds: req.session.guilds, cli: client })

#

no

lusty quest
#

how did you access oAuth?

#

i use passport and the profile object returns the guilds together with the user object

fierce ether
#

ill show the auth file

lusty quest
#

gg you do it barebones.

fierce ether
#

i need to fetch the guilds correct?

lusty quest
#

yea i guess you need to use users/@me/guilds

#

but it is limited to 100 Guilds. i get the guilds of the User with oAuth

fierce ether
#
                    method: 'GET',
                    headers: {
                        authorization: `${response.token_type} ${response.access_token}`
                    }
                })```
lusty quest
#

this will only give the you first 100 Guilds tho

fierce ether
#

i only want the guilds the bot and user are in

lusty quest
#

for the guilds for the bot i needed to use a Websocket connection to get all guilds

#

idk why you dont get the Guilds, i use Passport for handling the oAuth authentification and this gives me the stuff i send with the intends in a single variable i can deconstruct

fierce ether
#

idk never rlly used passport

lusty quest
#

its relatively easy

fierce ether
#

idk

cinder patio
#

oh nvm I misread the question

rocky hearth
cinder patio
#

yea I misread it

rocky hearth
#

ooh lol, np

cinder patio
#

A instanceof SomeClass && B instanceof SomeClass

#

should do it

rocky hearth
#

but idk the SomeClass

#

actually I've four childclasses of a static parent class

#

And I want to know if two instances are of same child class, on one of parent method

#

the other instance is passed as an arg
so I've this and childInstance on that method

cinder patio
rocky hearth
#

hmmm, ๐Ÿค”

true ravine
#

There's no place like 127.0.0.1

lusty quest
#

localhost is valid for me?

#

but only if you run it on your pc and access it over a browser on your pc

true ravine
#

For axios I mean

#

In postman localhost works

#

But axios doesn't like it

lusty quest
#

i do localhost with axios on my frontend?

fierce ether
#

am i doing something wrong

#

<a class="btn2" href="./guild/config?id=<%= guild.id %>" >Manage</a>

#

router.get("/guild/config?:guildID", checkAuth, async (req, res) => {

#

app.use("/guild", require("./routes/server"));

lusty quest
#

it looks like the path should be /guild/guild/config?guildid

fierce ether
#

which one?

lusty quest
#

the last one is in your main file pointing to your routes/server where i guess the 2nd one is the path you want to access right?

fierce ether
#

yes

#

app.use("/guild/config?:guildID", require("./routes/server")); so that?

lusty quest
#

then you either use in the 2nd one /config?:guildid or change it in your first one to ./guild/guild/config?id=

fierce ether
#

and keep the app as app.use("/guild")?

lusty quest
#

yes

#

idk but it looks like you dont really know how express works

rocky hearth
#

@cinder patio If I do instance.constructor, on any parent method, will it always return the name of the child class?

fierce ether
#

yeh first time using it

lusty quest
#

i suggest reading the docs

fierce ether
#

what docs

lusty quest
#

the one for Express

fierce ether
#

<a class="btn2" href="./guild/guild/config?id=<%= guild.id %>" >Manage</a> well i changed that and still same error

#

so idk

cinder patio
eternal osprey
#

hey could somebody help me out a bit

#

after running my bot on my vps it shows this icon

#

and the filter !bassgboost is extremely distorted

#

but on heroku everything works fine?

#

i use the npm package discord-player.

fierce ether
#

@lusty quest i read the docs and figured it out thx

fierce ether
#
if (client.guilds.cache.get(req.query.id).members.cache.get(req.session.user.id).hasPermission('ADMINISTRATOR')) return res.redirect('/server/config?id=' + req.query.id)
  res.render('server/config', { user: req.session.user, guild: req.query.id, djsclient: client })
})

router.post('/config', async (req, res) => {``` why does this send 404 everytime
lament rock
#

Idk if you're able to reference the class which supersedes the instance's unless you have a method in the class which returns the keyword super

crystal wigeon
#

hey guys

#

anyone know how to cache data between two node processes?

lusty quest
#

i would use redis

crystal wigeon
#

other than that

lusty quest
#

sure not as fast as direct in memory but its easy

crystal wigeon
#

i tried memcached but its not setting anything

lusty quest
#

memcached is like redis just works a bit different

crystal wigeon
#

yeah

#

but the thing is its not setting any value

lusty quest
#

never used memcached.

pure lion
#
#[tokio::main]
async fn main() {
    let (sender, receiver) = std::sync::mpsc::channel();
    let mut users: std::collections::HashMap<String, User> = std::collections::HashMap::new();
    let mut channels: std::collections::HashMap<String, Channel> = std::collections::HashMap::new();
    let server = TcpListener::bind("127.0.0.1:9001").expect("Unable to start server");
    for connection in server.incoming() {
        let sender = sender.clone();
        tokio::spawn(async move {
            let mut ws = accept(connection.unwrap()).unwrap();
            ws.write_message("You connected".into()).unwrap();
            loop {
                let msg = ws.read_message().unwrap();
                let msg_json: WSMessage = from_str(&msg.to_text().unwrap()).unwrap();
                let close_opts: CloseFrame = CloseFrame {code: coding::CloseCode::Normal, reason: std::borrow::Cow::default()};
                match msg_json.opcode {
                    Opcodes::Connect => {
                        if msg_json.data["login_pkg"] == Value::Null {
                            ws.write_message(Message::Binary("{\"error\":\"missing login data\"}".into())).unwrap();
                            ws.close(Option::from(close_opts)).unwrap();
                        } else {
                            let token = gen_token();
                            sender.send(token.to_owned()).unwrap();
                            ws.write_message(Message::Binary(format!("{{\"connection\": {{\"token\":\"{}\"}}}}", token.to_owned()).into())).unwrap();
                        }
                    }
                }
            }
        });
    }
    println!("{}", receiver.recv().unwrap());
}
```I have a websocket server that handles connections in a blocking loop, and i want to have data sent between threads so they can be set onto the `users` and `channels` hashmaps. The issue is that the loop is blocking the sender from sending the data, so how can i have it send data to the receiver?
crystal wigeon
#

how do i write to memory?

#

in nodejs

pure lion
#

use a map

#

or dont use anything

crystal wigeon
#

wat

lusty quest
#

he means barebones

pure lion
#

ah

crystal wigeon
#

like i want to access that stored data from 2 node js processes

pure lion
#

yeah sounds like a bad idea ngl

#

how could you ensure safely sending the data

stuck pike
#

Decent hosting for under 5$?

lusty quest
#

i guess Tim or PapiOphidian maybe know a solution

crystal wigeon
#

tf?

#

how do i share data between 2 node processes

stuck pike
crystal wigeon
#

is my question

lusty quest
stuck pike
#

Ok

lusty quest
sacred aurora
#

anyone know how to turn on safe search in dogpile website?

pure lion
lusty quest
#

i dont think memory will be aviable bcs in how it works

pure lion
#

i guess this is a thing

lusty quest
#

wait there is something to make pointers nice

pure lion
#

my question is why not use a lower level language anyway

stuck pike
#

What's the difference dif

pure lion
#

one has a big ip

lusty quest
#

read

warm marsh
#

the price?

lusty quest
#

they have different amount of Ram, with this the price scales

pure lion
#

tiny amount of ram

pure lion
lusty quest
#

512MB can be enough if you have a small bot that dont use much ram

stuck pike
crystal wigeon
#

im trying to store an object with methods

#

i cant use redis for that

lusty quest
#

why?

crystal wigeon
#

i need to share this object with 2 node processes

lusty quest
#

i store also objects in redis without any issues

pure lion
#

you've mentioned

crystal wigeon
#

clustering things

#

objects with methods

#

something like

#

message

lusty quest
#

ohh well

pure lion
#

just set up a ws connection xdxdxdxd

stuck pike
#

Decent bot

crystal wigeon
#

message.send() will not working if its coming from redis

#

i thought of ws

lusty quest
pure lion
crystal wigeon
#

the message object

pure lion
#

message.send isn't a method

lusty quest
#

maybe you could look into breaking down your bot into microservices

crystal wigeon
#

i know

#

thats what im trying to do

#

i have 2 node processes that need to look in a memory to get an object with methods

lusty quest
#

there is an outdated github repo of an node bot that is made in microprocesses

pure lion
#

pylint or flake8?

fierce ether
#

can someone explain why post dosent happen? ```js
router.get('/config', async (req, res) => {
if (!req.session.user) return res.redirect('/')
if (!client.guilds.cache.has(req.query.id)) return res.redirect('/')
if (client.guilds.cache.get(req.query.id).members.cache.get(req.session.user.id).hasPermission('ADMINISTRATOR')) return res.redirect('/server/config?id=' + req.query.id)
res.render('server/config', { user: req.session.user, guild: req.query.id, djsclient: client })
})

router.post('/config', async (req, res) => {```

pure lion
#

does it 404?

fierce ether
#

yes

#

it redirects to /server/config?id='id' but then says 404

pure lion
#

where is server/config?

fierce ether
#

from the routes?

#

../views/server/config.ejs

pure lion
#

not the ejs

fierce ether
pure lion
#

no, show me the routes in your js file

fierce ether
#

or these?

pure lion
#

server/config anywhere?

fierce ether
#

no its views

#

i changed it over

#

but still same thing

earnest phoenix
#

Has the bot verification been stopped or is it false news?

trim saddle
sand condor
#

it's closed for the holiday break

trim saddle
#

oh lol

sand condor
#

will comeback tomorrow so

#

or tuesday

earnest phoenix
#

:(

trim saddle
#

even discord staff have family they wanna celebrate the holidays with

earnest phoenix
#

or this witch one is better ?

trim saddle
#

bottom tbh

earnest phoenix
#

@trim saddle and with this ?

trim saddle
#

i don't like backgrounds so 2nd

earnest phoenix
#

I ended up with this one

trim saddle
#

@crimson vapor every time i try to append data to formdata, i get TypeError: source.on is not a function

quartz kindle
#

what are you adding?

trim saddle
#
body.file ? 
        data.append("file", body.file.buffer, {
            filename: body.file.filename,
            contentType: 'application/octet-stream'
}) : {}
#

buffer being a buffer ofc

fierce ether
#

<% user.guilds.cache.forEach((guild) => { %> returns undefined, user is req.session.user

trim saddle
#

uh

#

that looks wrong

#

you can't fetch all guilds for a user

fierce ether
#

why?

trim saddle
#

unless your bots in every guild said user is in there's no way you'd have them cached

fierce ether
#

i want all the users guilds

#

if the bot is in change to configure if it isnt its invite

trim saddle
#

don't think you can get them.

delicate shore
#
 let model = await nsfwjs.load()

let optionsboi = ["Neutral"]
let probboi = 0

    if(msg.attachments.size > 0){
        msg.attachments.forEach(async(Attachment) => {
            async function fn() {
                const pic = await axios.get(Attachment.url, {
                  responseType: 'arraybuffer',
                })
                const image = await tf.node.decodeImage(pic.data,3)
                const predictions = await model.classify(image)
                image.dispose()
                console.log(predictions)
                let i = null
                for (i = 0; i < predictions.length; i++) { 
                    console.log("Works First")
            if(optionsboi.includes(predictions.className)){
                console.log("Works Second")

             if(predictions.probability > probboi){
                console.log("Works Third")

                Attachment.delete()
             }
            }
                } 
              }
              fn()


        })
    }
#

It works till - console.log("Works First")

#

But doesn't work any further

trim saddle
delicate shore
#

predictions.className is an array

fierce ether
#

yes

trim saddle
#

where there's no guild key for members/users

#

you can't get user guilds

fierce ether
#

loads of dashboard do it? there has to be a way

delicate shore
#

you can get it only using Oauth

trim saddle
#

that's not d.js

#

that's oauth

#

you can't build a dashboard with d.js

fierce ether
#

yeh im using that aswell

delicate shore
#

^^

fierce ether
#
 [
                fetch('https://discordapp.com/api/users/@me', {
                    method: 'GET',
                    headers: {
                        authorization: `${response.token_type} ${response.access_token}`
                    },
                }),
                fetch('https://discordapp.com/api/users/@me/guilds', {
                    method: 'GET',
                    headers: {
                        authorization: `${response.token_type} ${response.access_token}`
                    }
               })
            ]```
#

im only getting the users and bot guilds?

trim saddle
#

if that isn't returning guilds your temporary user token is wrong or something

#

actually wait

fierce ether
#

its returning the user just not there guilds

trim saddle
#

are you permissions correct?

fierce ether
#

wdym

trim saddle
#

you need permissions when you sign in to get certain data

fierce ether
#

scopes?

trim saddle
#

scopes yes

fierce ether
#

indenitfy, guilds

#

is what im using

trim saddle
#

hm.

fierce ether
#

so what is the problem?

#

res.render('servers', { user: req.session.user, guilds: req.session.guilds, cli: client })

#

using this

trim saddle
#

i'm not 100% sure then

lament rock
# crystal wigeon like i want to access that stored data from 2 node js processes

Just read chat history. If you use the built in worker_threads module, multi-threaded processes share the same memory space which means you can share global variables. Threads can also share locally scoped references by sending messages to each other which you can just pass the reference since the data isn't being duplicated across two different memory spaces.

#

If they absolutely have to be multiple processes, you have to use something such as redis. I don't know of another database which allows for unstructured and fast K,V storage

#

You could write your own proprietary Map based cache worker and hook that over a REST api but Node has a bit of overhead which isn't worth it

trim saddle
#

@lament rock guess whaaaat

lament rock
#

What, cutie?

trim saddle
#

i'm still having a problem with things

lament rock
#

What's the problem

trim saddle
#

file sending

lament rock
#

Hoh boy. Still multipart requests

trim saddle
#

eeeeyup

earnest phoenix
#

Guys is it possible to code a website on iOS?

trim saddle
#

glitch

lament rock
#

There are IDEs for iOS but it's not very efficient since not many of them are mature

trim saddle
#

although it's recommended you code on a computer

earnest phoenix
#

If I had one I would happily do that

#

Lol

#

Hm glitch?

#

Will the website be online 24/7?

#

for a website you can use literally any platform that supports webview

trim saddle
#

they don't garantee 100% uptime

#

but it's good enough

earnest phoenix
#

Oh, so hm is there something else?

trim saddle
#

idk

earnest phoenix
#

it depends on which kind of website you want

#

Just like dyno

#

yikes

#

Why uh...

#

it requires full stack development knowledge and a proper vps

lusty quest
#

^

earnest phoenix
#

So what ya guys recommend me?

#

to get a pc

#

you can't really do this on mobile

lusty quest
#

lol fullstack coded on Mobile, if you pull this off you either Insane or get insane

earnest phoenix
#

especially on ios lmfao

#

Lol

#

android, okay, fine, android can be unlocked and pushed to its fullest potential

#

but ios is a literal cage, good luck doing anything without jailbreaking

lament rock
#

There is a vscode online

earnest phoenix
#

@lament rock visual studio code?

lament rock
#

I haven't tested on iOS, but 02shrug

earnest phoenix
#

you need code-server running somewhere

#

no?

#

So, uh ima be honest visual studio code can be installed on iOS

lament rock
#

I don't believe so. I was able to run a sandboxed version with just vs liveshare

earnest phoenix
#

I mean in the website

#

Oh @lament rock and btw is visual studio code better than repl.it?

lament rock
#

By every stretch, yes

earnest phoenix
#

Ima try to get it

cinder patio
#

visual studio code is just an editor

#

repl.it is an editor which automatically runs your code afterwards and hosts it

trim saddle
#

@lament rock now as i was saying, i was trying to use the form data package

body.file ? 
data.append("file", JSON.stringify(body.file.buffer), {
    filename: body.file.filename,
    contentType: 'application/octet-stream'
}) : {}
data.append("payload_json", JSON.stringify(body))

i get silence when i try to send data like this

delicate shore
#

Please help me

delicate shore
umbral zealot
umbral zealot
#

well the code disagrees

#

you think it's true, but you're wrong

delicate shore
#

Code is very bad then

umbral zealot
#

Probably, if you wrote it.

#

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

ornate otter
#

Does anyone think they could help me make the bot check if the user they are trying to ban/kick is above the user who ran the command

umbral zealot
delicate shore
#

@umbral zealot so what should I do

ornate otter
#

thanks

umbral zealot
delicate shore
#

It had a property Neutral

#

How ?

#

What's wrong in the code

#

May I send the logs ?

umbral zealot
#

Start by console logging your values maybe

#

You made the assumption that those conditions could return true. They're not. That assumption is false, so verify the data

delicate shore
#

Hmmm

#

Let me

#

See

#

Cya in 12 hrs

#

Good night

umbral zealot
#

console.log(optionsboi) and console.log(predictions.className) and see why one doesn't include the other. And then console.log(preductions.probability) and console.log(probboi) and check why THAT isn't working.

ornate otter
#

if(msg.member.highestRole.comparePositionTo(BanUser.highestRole) <= 0)

#

returns the error TypeError: Cannot read property 'comparePositionTo' of undefined

#

now i just woke up so im probably being really dumb rn

trim saddle
#

is highestRole the correct variable?

ornate otter
#

idk i just woke up

trim saddle
#

maybe read the docs

#

of whatever lib you're using

#

@ornate otter are you using d.js?

ornate otter
#

yeah its .roles.highest

#

thank youuu

trim saddle
#

mhm.

ornate otter
#

and yes

marble juniper
#
Traceback (most recent call last):
  File "C:/Users/Link/Documents/Programming/Expirements/Game-Bot-50d61accd6850640ef71cb832fcfd95c2f19b64b/train.py", line 34, in <module>
    main()
  File "C:/Users/Link/Documents/Programming/Expirements/Game-Bot-50d61accd6850640ef71cb832fcfd95c2f19b64b/train.py", line 29, in main
    model = train_model(model, X, X_test, Y, Y_test)
  File "C:/Users/Link/Documents/Programming/Expirements/Game-Bot-50d61accd6850640ef71cb832fcfd95c2f19b64b/train.py", line 20, in train_model
    model.fit(X, Y, batch_size=batch_size, epochs=epochs, validation_data=(X_test, Y_test), shuffle=True, callbacks=checkpoints)
  File "C:\Users\Link\Documents\Programming\Expirements\Game-Bot-50d61accd6850640ef71cb832fcfd95c2f19b64b\venv\lib\site-packages\keras\engine\training.py", line 952, in fit
    batch_size=batch_size)
  File "C:\Users\Link\Documents\Programming\Expirements\Game-Bot-50d61accd6850640ef71cb832fcfd95c2f19b64b\venv\lib\site-packages\keras\engine\training.py", line 789, in _standardize_user_data
    exception_prefix='target')
  File "C:\Users\Link\Documents\Programming\Expirements\Game-Bot-50d61accd6850640ef71cb832fcfd95c2f19b64b\venv\lib\site-packages\keras\engine\training_utils.py", line 138, in standardize_input_data
    str(data_shape))
ValueError: Error when checking target: expected activation_6 to have shape (4,) but got array with shape (36,)
#

anyone know how to fix

#
def train_model(model, X, X_test, Y, Y_test):
    print(X, X_test, Y, Y_test)
    checkpoints = []
    if not os.path.exists('Data/Checkpoints/'):
        os.makedirs('Data/Checkpoints/')

    checkpoints.append(ModelCheckpoint('Data/Checkpoints/best_weights.h5', monitor='val_loss', verbose=0, save_best_only=True, save_weights_only=True, mode='auto', period=1))
    checkpoints.append(TensorBoard(log_dir='Data/Checkpoints/./logs', histogram_freq=0, write_graph=True, write_images=False, embeddings_freq=0, embeddings_layer_names=None, embeddings_metadata=None))

    model.fit(X, Y, batch_size=batch_size, epochs=epochs, validation_data=(X_test, Y_test), shuffle=True, callbacks=checkpoints)

    return model
#

this is my code

#

it errors out on the model.fit line

#

ValueError: Error when checking target: expected activation_6 to have shape (4,) but got array with shape (36,)

tulip ledge
#
    if (!webhook) webhook = await channel.createWebhook(name, {
      avatar: avatar
    });

Anyone knows why my code just gets stuck here?

#

no errors

#

nothing in console

#

It just stops there

#

it also doesn't create a webhook

#

it used to

#

but the last few tries it doesn't anymore

lusty quest
#

code looks valid, maybe the if check blocks it from getting executed

lament rock
trim saddle
#

hm.

lament rock
#
const formData = new FormData();
formData.append("file", data.file.file, { filename: data.file.name });
formData.append("payload_json", JSON.stringify(data));
return req({
    url: endpoint,
    "POST",
    data: formData,
    headers: {"Content-Type": `multipart/form-data; boundary=${formData.getBoundary()}`}
});
sacred trout
#

hey

#
    async def open_account(self, user):
        users = await get_bank_data()
        with open("mainbank.json", "r")as f:
            users = json.load(f)
        return users

        if str(user.id) in users:
            return False
        else:
            users[str(user.id)] = {}
            users[str(user.id)]["wallet"] = 0
            users[str(user.id)]["bank"] = 0

        with open("mainbank.json", "w")as f:
            json.dump(users, f)

        return True

    async def get_bank_data(self):
        with open("mainbank.json", "r")as f:
            users = json.load(f)
        return users

    @commands.command()
    async def balance(self, ctx, open_account):
        user = ctx.author
        open_account = open_account
        await open_account(user)

        users = await get_bank_data()

        wallet_amt = users[str(user.id)]["wallet"] = 0
        bank_amt = users[str(user.id)]["bank"] = 0

        embed = discord.Embed(
            title=f"{ctx.author}'s balance.", color=discord.Colour.blue())
        embed.add_field(name="Wallet Ballance โฃ",
                        value=wallet_amt, inline=False)
        embed.add_field(name="Bank Ballanceโฃ", value=bank_amt, inline=False)
        await ctx.send(embed=embed)
#

discord.ext.commands.errors.MissingRequiredArgument: open_account is a required argument that is missing.

#

error

sudden geyser
#

The user didn't give a open_account argument.

sacred trout
#

what????/

#

oh

sudden geyser
#

If I ran !balance it'll error.

#

If you want it to be optional default it to None

#

Aka open_account=None

sacred trout
#

but i want the account to open whenevr this command is executed

#

it worked fine without the cogs

#

but with cogs it is giving error

earnest phoenix
#

Because open_account isn't defined

sudden geyser
#

I don't even know why you're giving it the same name as the function

earnest phoenix
#

It's a method, so you need to refer to it with self

sacred trout
#

async def balance(self, ctx, open_account):

tulip ledge
earnest phoenix
#

CogName.open_account(self, user) is equal to self.open_account(user)

sacred trout
#

do i add that in the param or under async def

earnest phoenix
#

Bruh, making a discord bot in python without knowing how python works is pain

sacred trout
#

lmao

trim saddle
#

why are you listening for argument errors

earnest phoenix
#

What

sacred trout
#

??

earnest phoenix
#

It's raised by default anyway unless you silent it

sacred trout
#

@earnest phoenix i am sorry for asking stupid questions i just suck at coding i just started it

lusty quest
#

everyone has to start somewhere

earnest phoenix
#

Bad idea to start off with discord bot, but nothing is stopping you

umbral zealot
#

Except rule 8.a

sacred trout
#

i started with like a game you wanna see?

earnest phoenix
#

Nah

sacred trout
#

btw are you a pentester?

#

@earnest phoenix

earnest phoenix
#

What is a pentester

sacred trout
#

nvm

lusty quest
#

someone who is specalized to attack software/websites

sacred trout
#

nop3

lusty quest
#

to check if there are vulnerabilities

earnest phoenix
#

Oh, pen refers to penetration?

lusty quest
#

yea

sacred trout
#

Yes

earnest phoenix
#

No

sacred trout
trim saddle
sacred trout
#

@lusty quest are you one?

lusty quest
#

no but i know a few

sacred trout
#

Umm do you exploit open ports

trim saddle
#

wdym

lusty quest
#

im not out for attacking others, i have no intention to do so

safe agate
#

hello :)
I have a Question
How do I know the names of the servers my bot is joining?
I think they added my bot to the fake servers
Because it has become a member of 60 servers in three weeks

lusty quest
#

also it can get you into trouble

sacred trout
#

Nvm

safe agate
lusty quest
#

if you use js you can just run a loop over the guild manager and then get the name from each guild

safe agate
#

tnx , I'm not worried anymore

lusty quest
#

i would be worried if it would be way more

safe agate
lusty quest
#

not really

dense saddle
#

Sidekick or hero

#

You know where this is going

lusty quest
#

?

#

wrong channel i guess

dense saddle
#

Yeah, wrong channel

#

Sry

marble juniper
lusty quest
#

looks like Tensorflow on py. but there ends my knowledge

marble juniper
#

yeah

#

it uses tensorflow

lusty quest
#

i dont know py

marble juniper
#

k

#

sad

lusty quest
#

and only did some small research on tensorflow

marble juniper
#

I only know its some sort of problem with the layers

#

need to convert it somehow

#

idk how

lusty quest
#

the only machine learning stuff ive did for now where in ML.net

marble juniper
#

sadly google didn't really help me either

#

guess I will have to ask in the python discord

lament rock
solemn leaf
#

@lament rock hii

trim saddle
#

i don't think my form is sending at all

lament rock
solemn leaf
#

no nice pfp

lament rock
trim saddle
#

i'm trying to see

gloomy yew
#

how can I host a webhook locally using Flask?

trim saddle
#

do you know the flask basics?

gloomy yew
#

yea

trim saddle
#

good

#

basically you make all your routes POST

simple pulsar
#

J

gloomy yew
#

yea I setup a basic flask server last night but the webhook on Topgg never reached it, I had the correct port open as well

near stratus
near stratus
trim saddle
#

there's a test vote feature

gloomy yew
#

yea I used that to test

#

and it never reached my server for some reason

#

I set the webhook url on Top.gg to: http://mypublicip:5000

near stratus
gloomy yew
#

and then on my flask server

trim saddle
#

so it's listening on the / route

gloomy yew
#

oh sorry I meant

#

http://mypublicip:5000/upvote

near stratus
#

then

trim saddle
#

so it's listening there?

gloomy yew
#

I then tried to run my flask server in different ways, one on localhost and one on 0.0.0.0

near stratus
#

did you try curl from any other device ?

#

like making a fake request and testing if it's reachable

#

or postman

trim saddle
#

yeah if it's not working, your device isn't port fowarded and can't receive non local requests

gloomy yew
#

yea I think thats the problem, the port isn't open

#

for some reason

#

yea its not working on other devices on my network

#

something is wrong

lusty quest
#

then use the IP of your local machine to access it from other devices on the network

solemn leaf
#

@gloomy yew

#

open the port on your pc

#

you can open ports with netsh interface portproxy add v4tov4 listenaddress=127.0.0.1 and then append listenport=9000 to set a port to listen on
connectaddress=the IP connectport=whatever port as a connection to the proxy

near stratus
#

see this

gloomy yew
#

thank you I'll check it out

tulip ledge
#

did anyone know that unity uses JS? o.O

#

Game development with JS? pog?

lusty quest
#

unity uses it for some backend stuff

near stratus
lusty quest
#

its common that software use Mutiple languages

tulip ledge
#

idk my friend and I were discussing if Cpp or Cs was better

#

(he wants to start coding)

#

and wants to do game dev

near stratus
lusty quest
#

both are good

#

C# is easyer for front end stuff i guess

tulip ledge
#

I thought Cs since it's easier then Cpp

#

and Cpp needs memory management

near stratus
near stratus
tulip ledge
#

I thought Cs was easier then Cpp

lusty quest
#

if you know already a language is easyer to pick up

tulip ledge
#

thats the thing

#

he doesnt

near stratus
tulip ledge
#

thats why I told him to do js or something like that to at least get an easy language toi start with

#

but he wants to do game dev

lusty quest
#

people are starting with C++ or C# its not an issue but its harder to pickup as js, py or lua

near stratus
#

imagine starting with Java

lusty quest
#

i know 2

tulip ledge
#

ahum minecraft devs

near stratus
true ravine
#

I have an API that I am using for my bot, and I can get data to it easy enough through the appropriate requests, but I also need the API to send stuff to the bot which I plan to use webhooks for. How would I structure my code in order to allow my bot to do certain things based on the request sent to my webhook?

solemn latch
#

you can just use your bots stuff inside the webhook event

feral aspen
#

Yo

#

It's guildMemberAdd and what was the other one again?

#

Remove or delete?

solemn latch
#

should be delete? it would be in the docs.

feral aspen
#

It doesn't work.

true ravine
#

But how would I get it there because at the moment I have the actual express app in a separate file, which has it's export set to the express instance

true ravine
feral aspen
#

Thank you! ๐Ÿ™‚

solemn latch
#

its easiest to look at the docs yourself to find it.

true ravine
#

True

solemn latch
#

in cases where i need data from the initializing file*

smoky herald
#

Hi, I'm saving fetched user object in my db as JSON so I don't have to fetch it every single time someone uses the command.

The problem is if I call avatarURL() on the user object from database it throws an error (is not a function I think), is the issue that discordjs uses collection and the avatarURL() can't be called on object? I'm not really sure how collections work because of the fact js doesn't even have any right?

How do I get avatarURL() from preserved JSON user object?

solemn latch
#

best bet, log the json user object to find it.

#

or, rather than saving the whole user, save only the parts you need.

smoky herald
#

the first one is original fetch, the other one is the preserved db object, couldn't find any difference ๐Ÿ˜ฆ

solemn latch
#

oh duh, yeah youll have to construct the url yourself.

#

from the avatar property.

smoky herald
#

the problem is avatarURL() throws error on the second one while working on the first one even tho they're the same

solemn latch
#

the first one is the class user, so it gets all the methods from that.

#

which wont be saved.

#

constructing the url isnt hard at all.
https://cdn.discordapp.com/avatars/136583532972605440/0292de8c83b3e8e3558e9be9886b02cb.png?size=128
^ my url
https://cdn.discordapp.com/avatars/userid/avatar.png?size=128

#

can drop the size.

pale vessel
#

user.saveAvatar = user.displayAvatarURL(); JSON.stringify(user) if you're lazy

smoky herald
#

I seee, thanks a lot ๐Ÿ’–

solemn leaf
#

flaze

dawn summit
#

Does someone use node.js?

pale vessel
#

Nope

blazing portal
#

What kind of question is that... ofcourse someone uses it ๐Ÿ˜„

mellow kelp
#

yea

dawn summit
#

But who?

blazing portal
#

would you like a list?

solemn latch
#

lol

blazing portal
#

Just ask your question about node.js xD

dawn summit
#

Okay

mellow kelp
#

yea just ask the question

#

don't ask to ask

dawn summit
#
    "platform": "discord",
    "url": "[webhook link]"
}```
How do I put that configuration on the app?
mellow kelp
#

what do you mean

#

do you want to send a webhook?

dawn summit
#

No

#

How do I put that configuration on the app?

solemn latch
#

trying to make an object?

dawn summit
#

No

#

It's the configuration of a webhook

mellow kelp
#

(you shouldn't share webhook URLs either, regenerate it rn)

dawn summit
#

But IDK how to type that

solemn leaf
#

dfiscored?

solemn latch
#

your trying to run it in a command?

mellow kelp
#

what exactly what do you want to do

dawn summit
solemn latch
#

maybe a startup configuration?

dawn summit
solemn latch
#

i think nodejs has flags n stuff

dawn summit
#

I just want help on how to type that!!!!!!!!

solemn latch
#

well, theres lots of ways to

#

and you said no to the two most common

#

looking to make a config file?

mellow kelp
#

the article says you have to do a config.json file

solemn latch
#

store it in a variable?

dawn summit
#

Is there a way to type like exactly this?

    "platform": "discord",
    "url": "[webhook link]"
}```
mellow kelp
#

yeah put it in a config.json file as the article says

solemn latch
#

i mean, in a json yes.

dawn summit
#

I can't paste that text on the app

mellow kelp
#

not on the app

#

on a json file

#

do you know what json is?

dawn summit
#

But I need the app to open that file

solemn latch
#

if you want to do it through the app, you might be able to use flags.

pale vessel
#

jason.db

mellow kelp
#

you can't escape jason.db

solemn latch
#

it wont be exactly that, but it would serve the same purpose.

dawn summit
#

What program do I use to open .json files?

mellow kelp
#

the article doesn't say anything about flags tho

solemn latch
#

nodejs can

mellow kelp
#

use any text editor

#

its a text file

solemn latch
#

sure, but im answering the question he asked, not what the article says to do :p

dawn summit
#

So I can't put the config on the file

solemn latch
#

well, generally nodejs isnt a text editor. If you want to use it as a text editor, youd have to write some code. just saying .config.json wont do it.

dawn summit
#

Can I write the code on Notepad++?

solemn latch
#

thats a text editor, so yes?

dawn summit
#

ok

#

I wrote the code and with what extension should I save it?

#

?

solemn leaf
#

how can I convert a buffer to an array

fierce ether
#

how can one page look like this, and the other like that

#

same location file, exact same code

dawn summit
#

@solemn latch ?

solemn latch
dawn summit
solemn leaf
#

@fierce ether css

#

how do I convert a buffer to hex bytes

fierce ether
#

its the exact same code in each file

solemn leaf
#

css might not have loaded

fierce ether
#

that can happen?

solemn leaf
#

yea

#

check console

fierce ether
#

check console for what though?

solemn leaf
#

errors

#

you nimwit

gilded olive
#

Hard refresh cache

fierce ether
#

none

gilded olive
#

ctrl r

fierce ether
#

i reset browsing cache aswell

#

yeh that didnt work

solemn leaf
#

look at the style

#

in f12

#

is it there?

gilded olive
#

Are you linking the page first of all GWjiangOmegaLUL

fierce ether
#

i had to reset again and it worked, but now this happens

solemn leaf
#

ghoal

fierce ether
#

<link rel="icon" type="image/png" href="../assets/imgs/Untitled-1.png" />

solemn leaf
#

ow do I convert a buffer to hex bytes

#

what

fierce ether
#

it dosent load it, yet its there

gilded olive
solemn leaf
#

jsd

gilded olive
#

I dont know js

solemn leaf
#

re

#

do you know how to tho

earnest phoenix
#

isn't a buffer already hex bytes

gilded olive
#

(This is a stack overflow kind of question)

crystal wigeon
#

hey @solemn latch

#

do you have any idea how i can serialize an object with methods and maps and functions?

cinder patio
#

you can't really serialize functions, not a good idea

solemn latch
#

well, you can, youll just have to eval them to run them

#

guess, still not a good idea

crystal wigeon
#

so how would i share an object with 2 node processes?

#

serializing is one way ig

cinder patio
#

you only serialize the needed data

#

the function can be created on both processes and ran with the serialized data

#

no point to serialize functions

crystal wigeon
#

yeah, i mean i do need the methods to send back data and do other stuff with it

#

so

#

for example the message object that djs gives

#

im actually trying to share this message object with 2 node processes

#

the weird thing is i have a good vm of 7gb ram and 2 cpus and its still not able to handle 50 users concurrently and lags

earnest phoenix
#

don't use node if you're targeting performance

cinder patio
#

Serialize only the important data you need like channelId, guildId, content, id, etc. Then on the process that receives the message you'd do something like this:

const {Message} = require("discord.js");
const receivedMessage = new Message(client, messageData, client.channels.get(messageData.channelId));
receivedMessage.delete();
crystal wigeon
#

ah

#

AHH