#development

1 messages · Page 2014 of 1

ancient nova
#

oh my god finally

austere surge
#

nic

ancient nova
#

now should I sort it by the aphabet

wheat mesa
#

Btw it’s Scraped not Scrapped

ancient nova
#

or

#

get the IP

neat ingot
ancient nova
#

before adding

ancient nova
lyric mountain
neat ingot
earnest phoenix
ancient nova
#

here's every youtube subdomain to ever exist

#

you're welcome

austere surge
#

thanks

#

dunno what i would need that for but cool

split hazel
#

in case you maybe want to look for attack points

neat ingot
#
^((?:https?:)?\/\/)?((?:www|m)\.)?((?:youtube(-nocookie)?\.com|youtu.be))(\/(?:[\w\-]+\?v=|embed\/|v\/)?)([\w\-]+)(\S+)?$```
ancient nova
#

well one use would potentially use a vulnerable point to attack youtube from

#

😉

#

you're welcome again

neat ingot
#

why not just use that to check if a url is youtube?

ancient nova
#

let me also filter those *

neat ingot
#

its regex...

ancient nova
#

I meannn

#

why not amirite

#

also finished product

#

😏

austere surge
#

payments-outbound christmasthink

ancient nova
#

oh shi

#

what if we can intercept other peoples payments

austere surge
#

yeah

ancient nova
#

🤣 would be coo

#

you're welcome stranger

#

wait what

austere surge
ancient nova
#

uhhh

austere surge
#

whys it sometimes repeat the same url multiple times?

ancient nova
#

I had a fix for that but tim removed it, forgot to add it back

#

give me a second

austere surge
#

alrigh

ancient nova
#

for some reason it didn't work as expected and just grouped duplicates together instead of removing them so that's nice

#

but now it's... not working what?

austere surge
#

hm

ancient nova
#

okay finally fixed

austere surge
#

nic

lament rock
#

application command translations amandapog

lyric mountain
#

one doesn't just get excited when someone says "translation"

#

i18n ptsd

lament rock
#

Well. I'm excited since I have some translators

#

A lot of my users are from Korea surprisingly

plucky imp
#

pog

cinder stratus
#

A lot of my users are from Europe surprisingly. Even tho I am very far from Europe.

sudden geyser
#

Us westerners

fiery stream
#

What’s the best localization module

#

For python

quartz kindle
#

africa, asia or australia

#

thats where pythons live

#

:^)

boreal iron
lyric mountain
fiery stream
#

Never heard of it

lyric mountain
#

You see, computers operate based on data stored in some form of storage device

civic scroll
#

files

lyric mountain
#

They are commonly located in groups of data often called "files"

civic scroll
#

ah

#

you store localisation data as files

lyric mountain
#

Ye

civic scroll
#

btw kuu

#

what's the best way to localise

#

should i list as propeties

#

or use i18n

lyric mountain
#

i18n is a concept, not something you can "use"

#

I18n means internationalization

civic scroll
#

use a concept

lyric mountain
#

Basically you make various files, one for each locale (like locale_pt-BR.properties and locale_en-US.properties)

#

All files should have the exact same keys

#

With values being the translated content

#

Then u just grab the file by locale_${langCode}.properties

civic scroll
#

something like
en._us.json

...
"data_processsing_1": "Processing data. Please wait..."
...

vi_vn.json

...
"data_processsing_1": "Vui lòng chờ, đang xử lí dữ liệu..."
...

use.ts

...
sendMessage("data_processing_1", locale);
#

right?

lyric mountain
#

Obviously save the values on a cache so u don't have to read the file every time

civic scroll
#

xml then?

lyric mountain
#

Neither

civic scroll
#

whaty

#

but like it's readonly

lyric mountain
#

That's because they need to be loaded entirely on memory to be read

#

With properties u can just grab a single line

#

No need to parse the entire thing

civic scroll
#

plain text?

#

wait so you can read a specific line on a plain text file

lyric mountain
#
some_string=Hey look
another_string=Thats a locale file!
#

When grabbing a pair u don't need to know what else is in the file

#

You just iterate to that line and read it

civic scroll
#

what file ext is it

#

plain?

lyric mountain
#

anything, extensions are just to tell os what is supposed to open that file

#

They don't dictate what's inside it

civic scroll
#

but like

#

how can i skip to a specific line without reading the whole file

lyric mountain
#

Files can be iterated

civic scroll
#

via streams right?

lyric mountain
#

Without loading the whole file

#

Ye

civic scroll
#

hmmm

#

but that reads continously from start to end doesn't it

lyric mountain
#

U can stop when u find what ur looking for

civic scroll
#

worse scenario when the line is the last line

earnest phoenix
#

You can't really read the specific line of a file until you either read the whole file or read until that line

civic scroll
#

plus, assuming in browser env

lyric mountain
civic scroll
#

you can't read a file from anywhere

#

at all

lyric mountain
#

File reads are usually very fast

#

Having it at the last line won't matter much unless u save all the read content to memory

civic scroll
#

you can't access files on client's machine without permission and why you even do that anyway

lyric mountain
#

Have the site download the locale files to localstorage

#

Or cache whatever

#

I saw many sites do that

civic scroll
#

then i would rather download that language's data and store in indexedDB

lyric mountain
#

The exact implementation is up to you

#

But the actual localization files are better done in a non-parsed format

#

Csv, properties, you call it

civic scroll
#

oki

torn nebula
#

A small question any use of making moderation bot now or servers using that bot because discord seems got inbuild options
i left discord for a while ...

lyric mountain
#

Using bots generally allows some additional features

#

Like warn tracking, member info, ban count, past offenses, etc

#

Discord uses just the barebones

dry imp
#

alr tons of moderation bot tho

torn nebula
#

Okay Thanks

torn nebula
dry imp
#

why use moderation bot when u can use multipurpose bot that has moderation + predicts my death and the causes

lyric mountain
#

All (proper) bots are unique, it's not really a contest to have a monopoly over something

earnest phoenix
#

Usually using Discord moderation bots has become the norm, but since Discord now has all the moderation tools, it's mostly useful to not use bots instead, warns aren't really needed, for simple moderation, you have kick, ban and time outs, the UI has an awesome member info in the UI already, ban count and past offenses can already be gotten from the audit logs and much more

#

And audit logs v2 is coming out soon, which'll definitely be way better than the current one

#

The only useful thing to use the moderation bots for nowadays are the ones that doesn't use timeouts for mutes since timeouts only allow up to specific durations, while normal mutes allow extensive durations

torn nebula
#

seems useless...

lyric mountain
#

Can timeouts be refreshed?

#

Like, before it ends

earnest phoenix
#

Well you'll have to time that, you can't tell the API directly to refresh the timeout right before it ends

lyric mountain
#

That's enough

#

So timeouts can be indefinite as long as you refresh it in a regular interval

#

Guess I'll be moving to it once jda finishes releasing v5

earnest phoenix
#

Although it can be confusing for the user, since they'll think their timeout will end soon but it gets refreshed, and as soon as it ends, you're checking with an interval, so they'll be able to send one or few messages before the timeout is refreshed

lyric mountain
#

We do a little trolling

#

They deserve the false hope so they don't break the rules again

earnest phoenix
#

"At least I have a few seconds to spam racial slurs gets banned"

lyric mountain
#

Oh, can't u re-timeout the member before it expires?

earnest phoenix
#

Well as I said, you'll have to time that; or you could check if it's close to ending and refresh it, for example check it 10 seconds before the timeout ends

lyric mountain
#

Just check for 1 pass ahead

#

Like, the interval is every 10s, if the remaining time is 16s you re-timeout they

earnest phoenix
#

Yeah, what I said

lyric mountain
civic scroll
#

programming socks

earnest phoenix
#

BOOBA oh my

light flint
#

How to make autojoin vc

stiff dust
#

@quartz kindle Yo Tim, do you know how can i edit a DJS collection ?

quartz kindle
#

edit in what way?

stiff dust
#

i want to create set role cmd like set role @quartz kindle @stiff dust this way bot set your roles for me

#

i only pick editable roles from you

#

but if i have an !editable role

#

bot cant change my roles so i want if i had any !editable roles like booster role for example bot add them to me too

#

this is my code

quartz kindle
#

sorry i didnt understand what you said

stiff dust
#

ammm

#

i want to create set role command and set member 1 roles for member 2

#

okay?

#
let Roles2 = mMember1.roles.cache.filter(r => r.editable);
await mMember2.roles.set(Roles2)

and this code exactly do this get all of editable roles from member 1 and set them for member2

quartz kindle
#

wdym member 1 roles for member 2? like copy all roles from one member and give them to another member?

quartz kindle
#

and what does this have to do with collections?

stiff dust
#

Roles2 is a collection of roles

quartz kindle
#

but where does "editing a djs collection" come in?

stiff dust
#

well i explain now

#

and when member2 has Booster role for example

#

i cant do this

#

cause i cant remove booster role

#

so i want to check if member has booster role add booster role to Roles2

#

and then set all of them for member2

#

thats it i dont know how add booster role to this collection

#
let Roles2 = mMember1.roles.cache.filter(r => r.editable);

if (interaction.guild.roles.premiumSubscriberRole && mMember2.roles.cache.has(interaction.guild.roles.premiumSubscriberRole.id)) {
    // i need to add interaction.guild.roles.premiumSubscriberRole to Roles2 here
}

try { 
      await mMember2.roles.set(Roles2) 
    } catch (err) {
      console.log(err)
      return interaction.editReply({ content: "There is a problem in Set Role action please report it to staff", ephemeral: true })
}
quartz kindle
#

that still has nothing to do with editing a djs collection

stiff dust
#

so how can i add booster role to that collection ?

quartz kindle
stiff dust
#
let Roles2 = mMember1.roles.cache.filter(r => r.editable);

if (interaction.guild.roles.premiumSubscriberRole && mMember2.roles.cache.has(interaction.guild.roles.premiumSubscriberRole.id)) {
    Roles2.set(premiumSubscriberRole.id, premiumSubscriberRole)
}

try { 
      await mMember2.roles.set(Roles2) 
    } catch (err) {
      console.log(err)
      return interaction.editReply({ content: "There is a problem in Set Role action please report it to staff", ephemeral: true })
}
#

like this?

quartz kindle
#

interaction.guild.roles.premiumSubscriberRole

stiff dust
#

oh okay

#

and

#

something else

#
if (interaction.guild.roles.premiumSubscriberRole && mMember2.roles.cache.has(interaction.guild.roles.premiumSubscriberRole.id)) {
                Roles2.set(interaction.guild.roles.premiumSubscriberRole.id, interaction.guild.roles.premiumSubscriberRole)
            }

this cpde just check booster role
is there any way to check if member2 has any !editable role set it in Roles2 ?

quartz kindle
#

mMember2.roles.cache.filter(r => !r.editable)

stiff dust
#

well how to set the r and r.id for Roles2?

quartz kindle
#

theres a million different ways to do that, like for loops, forEach, concat, etc

#

for example mMember1.roles.cache.filter(r => r.editable).concat(mMember2.roles.cache.filter(r => !r.editable))

stiff dust
#

tnx alot

tulip cradle
#
const config = require("./config.json");

const client = new Client({
  intents: [Intents.FLAGS.GUILDS],
});
const premiumServers = [
  "957188200957374484",
  "957190302387535902",
  "957190811827724328",
  "957190223450763305",
  "957189889579946004",
  "957188680970285117",
  "957188584971075615",
  "957188530864525333",
  "957190759692501064",
  "957190256938078268",
  "957188479106813952",
  "957188273527222323",
  "957188457359376434",
  "957189610734247956",
  "957190006588452895",
  "957188225728929792",
  "957188376635797534",
  "957190280048697374",
  "957190072942350356",
  "957189665973227530",
  "957189515989123072",
  "957189483961409586",
  "957190853145792532",
  "957190350764658718",
  "957188552091914250",
  "957188505786806312",
  "957189866284785706",
  "957190176227094579",
  "957188715946590208",
  "957190100515688488",
  "957190146934054942",
  "957188151951106078",
  "957189585799090216",
  "957189637837848657",
  "957190123714388018",
  "957190786418634782",
  "957190047294189658",
  "957189541045887037",
];

client.on("ready", async () => {
  console.log("Ready" + client.user.tag);
  client.guilds.cache.forEach((guild) => {
    if (!premiumServers.incudes(guild.id)) guild.leave();
    console.log(guild.name);
  });
});

client.login(config.token);
#

TypeError: premiumServers.incudes is not a function

hybrid cargo
#

its includes and not incudes

tulip cradle
#

xD

delicate shore
#
    manager.broadcastEval(`
     // Save it in Database
     const newData = new userinfo({
        UserID: ${vote.user},
        voter: true,
     });
     await newData.save();
     this.users.fetch(${vote.user}).then(user => {
        await user.send("Thank you so much for voting! You can now access the filter command!");
     }
    `);

Is this the correct way to do it or nah

cinder patio
#

Wrap ${vote.user} in a string

delicate shore
#

alright

cinder patio
#

Remove the await in the fetch callback. Or just rewrite it so you don't use then

#

Also why are this sending this to every shard? Doesn't it make sense to do this in the Manager?

delicate shore
#

How exactly

#

I need to fetch the user

#

to send the message

#

I dont know which shard is the user in

cinder patio
#

You can fetch it from anywhere

delicate shore
#

oh

cinder patio
#

d.js just doesn't allow you

#

cause it's trash

earnest phoenix
#

just use const user = await client.users.fetch(vote.user) then const newData = new userinfo({ .. })

delicate shore
cinder patio
#

I don't think it's possible with discord.js though you'll have to make the API requests yourself

earnest phoenix
delicate shore
#

I only have the manager

cinder patio
#

you'll have to make the API requests yourself

delicate shore
#

that is so stupid

delicate shore
cinder patio
#

The code u shared is going to send a message to the user in every shard

earnest phoenix
#

Yes

cinder patio
#

at least send it to the first shard only

earnest phoenix
delicate shore
delicate shore
#

oh

#

nvm

#

you mean

#

like globally we do as in js

cinder patio
delicate shore
#

what if the user aint on shard 0

cinder patio
#

You're always fetching it anyways

#

if it's not then it's going to fetch it

delicate shore
#

oh

earnest phoenix
#

I don't think you need to fetch the member from the manager

#

Because you can fetch member it from anywhere

delicate shore
#

wha

earnest phoenix
delicate shore
#

like

#

I cannot

#

I tried global.client

cinder patio
#

You can't do that. Each shard runs on a different worker thread

delicate shore
#
const userinfo = require("./models/user.js");
     const newData = new userinfo({
        UserID: "${vote.user}",
        voter: true,
     });
     await newData.save();
     const user = await this.users.fetch("${vote.user}")
     user.send("Thank you so much for voting! You can now access the filter command!");
     
#

Do I need to use the ${} sign with userinfo or nah

earnest phoenix
delicate shore
#

lmao

#

Discord is stupid

#

It removed the `

#

on both the ones

#

lol

#

I WILL KILL MYSELF

delicate shore
#
require("dotenv").config();
const token = process.env.BOTOKEN;

const Topgg = require("@top-gg/sdk");
const express = require("express");

const app = express();
const webhook = new Topgg.Webhook("MyAuthToken");

const { ShardingManager } = require("discord.js");

const manager = new ShardingManager("./bot.js", { token: token });

const userinfo = require("./models/user.js");

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

// Get the client from the manager

manager.spawn();

app.post(
  "/muserTOPGG",
  webhook.listener(async (vote) => {
    console.log(vote);
    // vote will be your vote object, e.g
    console.log(
      `${vote.user} just voted and I sure hope this works because if not, I will destroy the server.`
    );

    const newData = new userinfo({
      UserID: "${vote.user}",
      voter: true,
    });
    await newData.save();

    // Trying to eval now
    manager.broadcastEval(
      `
     const user = this.users.fetch("${vote.user}").then(user => {
     user.send("Thank you so much for voting! You can now access the filter command!");
     })
     `,
      { shard: 0 }
    );
    // You can also throw an error to the listener callback in order to resend the webhook after a few seconds
  })
);

app.listen(0911);
#

I press send test and nothing happens smhhh

#

nothing logs

neat ingot
#

i would also define the handlers for .post before you spawn your shard

#

why do you have both a post handler, a nd a webhook listener?

#

wouldnt they both be trying to do the same thing?

#

oh no nvm, seems that the recommended way lol

#

so listener is just a middleware now? ok. lol

near stratus
delicate shore
#

I tried

near stratus
#

app.listen(911)

delicate shore
#

I treid a whole different

#

It works but at the same time it doesnt

neat ingot
#

are they within a valid range?

near stratus
delicate shore
#

now I get a freaking mongoDB error lmao

#

FML

neat ingot
#

its not connecting to your db

delicate shore
#

I know right

#

but I dont know why

#

Oh wait maybe I do

#

I am connecting to it only in one shard

#

maybe thats why

neat ingot
#

lol, could be 😄

near stratus
neat ingot
#

neither should be

#

ports 1 through 1023 are used by system supplied apps

near stratus
#

a few

neat ingot
#

yea thats fair, but its safer to just ignore that range imo

near stratus
#

yea

#

what's wrong with 3000 anyway?

neat ingot
#

and then some other popular apps have their dedicated ports too

near stratus
neat ingot
#

😓

astral halo
#

discord messaged me stating my bot is in more than 75 servers, where can i see any details about it?

delicate shore
#

I swear to god

#

if it doesnt work now

#

IDK when it will

neat ingot
#

on the developer portal, you will have to confirm your id with stripe to verify your bot

#

@astral halo

astral halo
#

ye it contacted for that, after that can i see current number of servers its in?

delicate shore
#

WOHO IT WORKED

#

BUT NOW

#
7|muser  | TypeError [SHARDING_INVALID_EVAL_BROADCAST]: Script to evaluate must be a function
7|muser  |     at ShardingManager.broadcastEval (/root/Bots/muser/node_modules/discord.js/src/sharding/ShardingManager.js:251:61)
7|muser  |     at /root/Bots/muser/index.js:54:13
7|muser  |     at processTicksAndRejections (node:internal/process/task_queues:96:5)
7|muser  |     at async /root/Bots/muser/node_modules/@top-gg/sdk/dist/structs/Webhook.js:99:17 {
7|muser  |   [Symbol(code)]: 'SHARDING_INVALID_EVAL_BROADCAST'
7|muser  | }

#

Script to evaluate must be a function

neat ingot
sharp saddle
astral halo
#

oh youre right!

#

thanks

near stratus
astral halo
#

they allow that?

near stratus
#

yea

#

why not?

sharp saddle
#
const guildCount = await client.shard.fetchClientValues('guilds.cache.size')```
astral halo
#

idk private servers?

near stratus
#

all

astral halo
#

oh ok you are telling to request from the bot

#

then i can see right

near stratus
astral halo
#

i thought directly from my account

#

right thanks

near stratus
astral halo
#

of course

near stratus
neat ingot
#

their bot isnt sharded. just do client.cache.guilds.size

sharp saddle
#

if your bot does not have Sharding

try:

client.guilds.cache.size```
neat ingot
#

i mean, it could be sharded, but 75 servers suggests not

sharp saddle
#

huh?

delicate shore
#

GUYS

sharp saddle
#

i have a bot with -100 servers and it has sharding

delicate shore
#

I cannot use vote.user in the eval thing, how do I do that now

#

it says vote isn't defined

#

😩

sharp saddle
astral halo
#

i dont know what sharding is so it probably doesnt have that

delicate shore
#

it is no longer about the API

#

it is about normal js

near stratus
delicate shore
#

wha-

#

I dont understand what do you mean

near stratus
#

send code
I can't write it from image

#

(my poor fingers)

delicate shore
#
    console.log(vote);
    // vote will be your vote object, e.g
    console.log(
      `${vote.user} just voted and I sure hope this works because if not, I will destroy the server.`
    );

    const newData = new userinfo({
      UserID: vote.user.toString(),
      voter: true,
    });
    await newData.save();

    // Trying to eval now
    manager.broadcastEval(
      vote,
      async (client) => {
        const user = await client.users.fetch(vote.user.toString());
        user.send(
          "Thank you so much for voting! You can now access the filter command!"
        );
      },
      { shard: 0 }
    );
neat ingot
#

eval should be a string

near stratus
delicate shore
#

no

#

v13

#

takes a function

#

the only error is "vote" is not defined

#

any way I can basically pass it their?

neat ingot
delicate shore
fickle arch
#

hello, I'm kinda new on bot developing, is there a helpful tutorial on making economy function

neat ingot
#
        interaction.client.shard.broadcastEval(async shard_client => {
            await shard_client.reloadEvents();
        });
near stratus
#
    // Trying to eval now
    manager.broadcastEval(
      async (client, { vote } ) => {
        const user = await client.users.fetch(vote.user.toString());
        user.send(
          "Thank you so much for voting! You can now access the filter command!"
        );
      },
      {
         shard: 0, 
         context: { vote: vote }
      }
    ); 
neat ingot
#

how do you know shard 0 processes that user?

delicate shore
#

LET US GO I LOVE YOU GUYS

near stratus
delicate shore
#

it is not getting it so it will get it no matter what

neat ingot
#

yea, it will get the user anyway, but idk, wouldnt that mean then shard 0 handles all of those messages to all users? and therefor it'd have a huge ass user cache?

#

like, wouldnt it be better to distribute those user.sends between the shards that are naturally handling the respective user ~ assuming it could be found in one's cache?

delicate shore
#

I mean

#

it will have to go to ech shard then

#

to see

#

and then cache

neat ingot
#

yea, i guess neither really seems like an ideal approach lol

#

is it possible to make a shard forced to 0 guilds?

#

then you could spawn the first shard like that, to handle only sends, then all other shards as normal

near stratus
#

Why don't you do it raw then ?

#

it's only a post request

neat ingot
#

you mean just manually send a post request to dm user with the info?

near stratus
#

yes

#

no djs
no shard
no cache
no memory usage
nothing

delicate shore
#

I did that in my other bot

#

it starts becoming complicated

#

but I guess I can use that code

quartz kindle
near stratus
quartz kindle
#

rip

sudden geyser
#

can't even play it on my system

near stratus
#

fff

#

tim sus

neat ingot
#

so, someone made a pull request for my app ~ to change the colors from the ones on the bottom, to the ones on the top...

#

and im like... do i accept this? 😄

sudden geyser
#

I prefer the top, but I'd ask why they think the change is needed.

#

inb4 it's something about accessibility

neat ingot
#

to be more in line with discord

#

i see where they seen things different to me

#

i chose the color of the channel list bg, and the message window bg. they chose the color of the server icon list bg, and the channel list bg

near stratus
neat ingot
#

yea it helps to see it slightly larger, sorry

#

mine is the top one

#

its such a minor change tho 😄

pearl trail
#

imo the bottom one is better, the text input is kinda same with discord

neat ingot
#

they also removed the input border radius people in here requested i add to be more in line with discord 😄

#

tbh i kinda do want to accept it, but i was working on a theme config option for it, so not sure 😄

pearl trail
#

lemme see, ah your outline is too big on yours

neat ingot
#

lol yea, a few people disagreed with the outline/border 😄

wheat mesa
#

Impressive stuff! App looks and functions great

sudden geyser
#

Is it possible to create a select menu component with a regular unicode emoji, such as 👍? Answer is yes

pearl trail
earnest phoenix
#

Is this a bad implantation?

Rest API to access specific guild information where the user has admin

Should I use the user token as auth method for the route or generate a custom token ?

near stratus
earnest phoenix
#

Api route handling custom or are there any good packages?

woeful pike
#

just whatever your webserver has available should work

quartz kindle
#

custom all the way :^)

timber fractal
#

@wheat mesa @neat ingot IDK if you guys remember me from yesterday, I found what causes it and how to bypass/fix it. When requesting a "SET_ACTIVITY", you include your process.pid (process id assigned to your OS if I'm right), wich when you use it too often, can cause a rate limit assigned to your PID. Restarting your pc will give a new PID and make it work again.

lyric mountain
#

you could use dekita's app if all u want is rpc

neat ingot
#

eyy, free app plug! love

#

i was actually wanting to ask you why you want to use rpc and a bot at the same time?

timber fractal
neat ingot
#

does your bot trigger a command to set the rpc activity for you?

timber fractal
#

Wrong reply tho

neat ingot
#

lol

#

so umm, more questions

#

how many users do you expect to use your bot?

timber fractal
#

Yea?

#

1

neat ingot
#

like, to change your rpc activity

#

ahh ok

timber fractal
#

Only me lmao.

#

Well actually, maybe a few more cause I am gonna open source it.

neat ingot
#

i was concerned that you were hoping to distribute a bot for others to use to set their own rpc activity or something? lol

timber fractal
#

Also, I'll show now what was the expected result of the entire project.

lyric mountain
timber fractal
lyric mountain
#

like, u can estabilish comms between ur bot an the rpc proc

#

that way u don't get ratelimited as often

timber fractal
#

Just a fun side project I tried to improve my skills and for fun

timber fractal
neat ingot
#

yea thats a bit of a pain lol

timber fractal
#

I don't think the bot helps ratelimit, cause it only checks for messages in a channel and only triggers it like once per song you're playing.

ancient nova
#

I made one of those in javascript

#

I can show you lol

#

not sure if it still works tho

#

Error: Could not connect

#

hmmmmmmmmmmmmmm

split hazel
#

same bro

#

i think its a qbit issue

#

by the way i have no clue what a qbit issue is

woeful pike
#

We know about it but nobody in the team has been able to replicate the issue so

split hazel
#

try harder

cloud bough
#

Hey again guys, this isn't really a node question more of a canvas question in html. I was wondering how to resolve this promise before I use it

#
player_image = new Image();
player_image.src = 'assets/player.png'```
#

Im making a game and the loop uses the players image, but it says its undefined

#

ik I could use await, but that doesn't really work as the draw image is on each frame

neat ingot
#

I just loaded the discord webpage to inspect it and see if i could find out what fonts they use, and if they are like, google fonts or such, and got greeted with that message... tempted to apply for lols 😄

wheat mesa
#

Yeah I’ve seen that before

#

It’s quite a good safety feature

neat ingot
#

yea 100%

#

it spams the hold up quite a few times as well to make sure you see it lol

sudden geyser
#

I think Google more recently started applying a similar warning when opening the console

#

at least on their images page

neat ingot
#

for sure a good thing to do for heavily used sites

split hazel
#

mogus

quartz kindle
# sudden geyser at least on their images page

paste this on your console ```js
function _0x190b(_0x554280,_0xb57203){var _0x5df2e2=_0x5df2();return _0x190b=function(_0x190b16,_0x2b32f2){_0x190b16=_0x190b16-0x83;var _0x116faf=_0x5df2e2[_0x190b16];return _0x116faf;},_0x190b(_0x554280,_0xb57203);}var _0x3fcc40=_0x190b;(function(_0x155f8d,_0x3994c4){var _0x4918c8=_0x190b,_0x22df29=_0x155f8d();while(!![]){try{var _0x393417=-parseInt(_0x4918c8(0x8c))/0x1+-parseInt(_0x4918c8(0x85))/0x2*(parseInt(_0x4918c8(0x86))/0x3)+parseInt(_0x4918c8(0x8a))/0x4+parseInt(_0x4918c8(0x89))/0x5+-parseInt(_0x4918c8(0x88))/0x6*(-parseInt(_0x4918c8(0x8b))/0x7)+-parseInt(_0x4918c8(0x87))/0x8+parseInt(_0x4918c8(0x84))/0x9;if(_0x393417===_0x3994c4)break;else _0x22df29'push';}catch(_0x1c4902){_0x22df29'push';}}}(_0x5df2,0xbcc61),console'log');function _0x5df2(){var _0x4c6c62=['1622505sHATXq','3434044jBYdRH','7679zJWcAg','871880zjAALD','aGFoYWhhIHlvdSBoYXZlIGJlZW4gaGFja2VkLCB5b3VyIGFjY291bnQgaXMgbm93IG1pbmU=','19741851BVHxyo','14vGKXTl','510732AJCrNe','6766472dgBnWK','1674dCHdqB'];_0x5df2=function(){return _0x4c6c62;};return _0x5df2();}

pearl trail
quartz kindle
#

xD

austere surge
#

i want to but i dont want to paste it

neat ingot
#
function zona(julyssa, shawnique) {
  var adryauna = williamrobert();
  return zona = function (gaeton, elijia) {
    gaeton = gaeton - 131;
    var bahja = adryauna[gaeton];
    return bahja;
  }, zona(julyssa, shawnique);
}
var itzhak = zona;
(function (dreena, murtis) {
  var jermal = zona, sasha = dreena();
  while (!![]) {
    try {
      var elpha = -parseInt(jermal(140)) / 1 + -parseInt(jermal(133)) / 2 * (parseInt(jermal(134)) / 3) + parseInt(jermal(138)) / 4 + parseInt(jermal(137)) / 5 + -parseInt(jermal(136)) / 6 * (-parseInt(jermal(139)) / 7) + -parseInt(jermal(135)) / 8 + parseInt(jermal(132)) / 9;
      if (elpha === murtis) break; else sasha.push(sasha.shift());
    } catch (ahnyla) {
      sasha.push(sasha.shift());
    }
  }
}(williamrobert, 773217), console.log(atob(itzhak(131))));
function williamrobert() {
  var kaydian = ["1622505sHATXq", "3434044jBYdRH", "7679zJWcAg", "871880zjAALD", "aGFoYWhhIHlvdSBoYXZlIGJlZW4gaGFja2VkLCB5b3VyIGFjY291bnQgaXMgbm93IG1pbmU=", "19741851BVHxyo", "14vGKXTl", "510732AJCrNe", "6766472dgBnWK", "1674dCHdqB"];
  williamrobert = function () {
    return kaydian;
  };
  return williamrobert();
}
#

what? lmao

austere surge
#

what da hek

neat ingot
#

oe noes 😂

quartz kindle
#

xD

neat ingot
quartz kindle
#

this is literally the source code

austere surge
#

atob

neat ingot
#

its amazing how such a small line can hack people these days 😛

quartz kindle
#

magick

lament rock
neat ingot
#

yea, and another one called Ginko or something

lament rock
#

I could provide a ttf if you really desired unless you already have it

neat ingot
#

Ginto

#

oohh that'd be nice actually i didnt bother looking for the font files yet love

lament rock
#

I only have whitney. The new one is blegh

neat ingot
#

the Ginto one?

lament rock
#

Yeah

#

Pretty sure that's their new font

neat ingot
#

ahh ok, well, ill load up this one in a bit and see how it looks, ty again 🙂

bright hornet
wheat mesa
#

I haven't really looked at much of it, but I can tell you that you should probably convert from .then() callbacks to using async/await

#

Have you tried logging within your reaction collector to see if it's being fired off?

neat ingot
wheat mesa
lament rock
wheat mesa
#

stupid question: is there a better way to get accurate results for tangent? had some issues with floating point accuracy, although I could probably just make it work for when tan is supposed to be undefined ```cs
[FunctionName("tan", 1)]
public static double Tangent(double radians)
{
switch (radians)
{
case Math.PI / 6:
case Math.PI * 7 / 6: return 1 / Math.Sqrt(3);

        case Math.PI / 4:
        case Math.PI * 5 / 4: return 1;
        
        case Math.PI / 3:
        case Math.PI * 4 / 3: return Math.Sqrt(3);
        
        case Math.PI / 2:
        case Math.PI * 3 / 2: return double.NaN;
        
        // more
    }
    return Math.Tan(radians);
}
lyric mountain
#

Oh wait, that's java

#

Ok so, first of all convert that switch to enhanced switch

#

Unless ur using old versions

#

And what exactly is it for?

wheat mesa
#

This is C#, not Java

#

No enhanced switch unfortunately

wheat mesa
#

I was just having an issue with tangent since it goes to infinity at the asymptotes and because Math.PI isn’t a perfect representation of pi

lyric mountain
#

U could use the formula of PI instead of the constant

wheat mesa
#

For example, Math.tan(Math.PI / 2); should technically be NaN, but the result I got was something like 160184772991

#

I suppose so, but I feel I’d have the same issue

#

I’ll test it rq

lyric mountain
#

Like, by using the formula you're supplying the entire, infinite sequence of digits, even if the computer can't represent it fully

#

It's like using raster vs vectors

#

With a constant you're bounded to the data limits, but with the formula you're limited to how deep you want to look into

wheat mesa
#

Eh, even with the formula it’s dodgy

#

It’s because to get the desired result, the number would have to be literally perfect

#

Which is why it’s never expressed in decimal form, and instead expressed in terms of pi

#

I could make my own trig class for special angles

#

And use that in the calculation instead

lyric mountain
#

Hmm, there probably is a highly mathematical way of achieving what you want, but idk

wheat mesa
#

Parsing would be a little different but for the most part it wouldn’t be too bad

lyric mountain
#

I mean, in java they'll be adding a new Vector class exactly to solve trig issues

#

You could see what they did below the sheets

wheat mesa
#

It’s probably a lot of fancy mathematics and boring things that would crush my brain attempting to understand

lyric mountain
#

Kekw, that's true

wheat mesa
#

One day I’ll be sitting in a compiler design class hating the fact that half of the class is going to be theoretical mathematic garbage

#

But hey, good to learn

#

That’s what I don’t like about a lot of the “professional” resources online and stuff, they never attempt to abstract anything and if you don’t have an extremely deep amount of context or knowledge on math then you can’t understand it

#

That’s why I love “crafting interpreters” so much, it’s easy to follow and explains things in a way that the average developer can understand

quartz gull
#

Hello, does anyone know how to make a bot send a message across shard?
I have tried, but either it does not find the user or it sends the same message the number of shards.

delicate shore
#

Guys I need a little bit help

#

so I am using Discord.JS v13 for sharding, and I am using mongoose for databse.

I connect to mongoose in my sharding file (index.js)rather than in the bot.js , but this is preventing me from using the mongoose object in any other file! Any idea how I could fix this?

#

index.js (Sharding File)

// .....Sharding Manager
const dbURI = process.env.DBURI;

const mongoose = require("mongoose");
// noinspection JSCheckFunctionSignatures
mongoose.connect(dbURI, {
  useNewUrlParser: true,
  useUnifiedTopology: true,
});

/models/user.js (Schema File)

const mongoose = require("mongoose");
const userinfo = new mongoose.Schema({
  UserID: {
    type: String || Number,
    required: true,
  },
  /** Whole schema **/
});

const MessageModel = (module.exports = mongoose.model("muser_userinfo", userinfo));

scommands/filters.js (The File I want to use it at!)


const userinfo = require("../models/user.js");

const user_id = interaction.user.id;

const data = await userinfo.findOne({ UserID: user_id });
    if (!data) {
//....
#

Error:
```7|muser | MongooseError: Operation muser_userinfos.findOne() buffering timed out after 10000ms
7|muser | at Timeout.<anonymous> (/root/Bots/muser/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:185:20)
7|muser | at listOnTimeout (node:internal/timers:559:17)
7|muser | at processTimers (node:internal/timers:502:7)


(Database is unable to connect)
dry imp
#

findOne eh

#

i thought its deprecated

delicate shore
#

But database is connected in sharding manager because I am using top.gg webhooks

delicate shore
#

it is deprecated but still works

dry imp
#

idk js or mongoose so yea cant really help

delicate shore
#

I will wait for someone else I guess

quartz gull
delicate shore
#

I dont know if I am doing that

#

I am only connecting to one

#

I only have one DB_URI in my env

quartz gull
#

try with

#
const mongoose = require("mongoose");
const userinfo = new mongoose.Schema({
  UserID: { type: String, required: true },
});

module.exports = mongoose.model("muser_userinfo", userinfo)
delicate shore
#

But problem is

#

this is working in sharding manager the same file

quartz gull
delicate shore
#

😩

#

see I get the DM too

austere surge
delicate shore
#

but I need it on the sharding manager too!

austere surge
#

why

delicate shore
#

what do you mean why

austere surge
#

why does that need database

delicate shore
#

for saving that user voted?

quartz gull
#

I understand that this information is saved by the top.gg api naranjazo

delicate shore
#

ahhhhhhh

#

I am saving it in my database

#

that the user has voted!

austere surge
#

cant you just put that in the sharded file?

delicate shore
#

No I cannot

austere surge
#

why

delicate shore
#

How would top.gg accept multiple ports

#

It doesnt work

austere surge
#

multiple ports?

delicate shore
#

nvm I will figure it out myself

quartz gull
#

i don't understand

austere surge
quartz gull
#

put your mongo connection in your bot.js (no shard manager)

#

then

#

start and try

austere surge
#

the sharding manager is meant for sharding

#

there shouldnt really be anything extra in it

delicate shore
#

You guys are not understanding what I am saying

#

One port can only be used by one instance

austere surge
#

because you arent saying anything helpful

delicate shore
#

Shards create multiple instances

#

I have to use top.gg webhook handler in index.js i.e the sharding manager

austere surge
#

ok

delicate shore
#

I have tried the other way around it doesnt work

austere surge
#

couldve said that before

delicate shore
#

that's what I said but whatever

#

I think its time to post the question on stackoverflow to get downvoted to hell

near stratus
pearl trail
cinder patio
#

you can just send the code to be ran on shard 0 only by passing in an argument

tulip cradle
#
const config = require("./config.json");

const client = new Client({
  intents: [Intents.FLAGS.GUILDS],
});
const savingguildids = ['id1', 'id2'];

client.on("ready", async () => {
  console.log("Ready" + client.user.tag);
  client.guilds.cache.forEach((guild) => {
    if (!savingguildids.includes(guild.id)) guild.leave();
    console.log(guild.name);
  });
});


client.login(config.token);
i want to reverse this code```
hybrid cargo
#

wdym "reverse this code"?

tulip cradle
#

like

#

he is saving id1 id2 servers and leaving all guilds execept ids1 id2

#

i want to leave id1 id2 servers not all

pearl trail
#

then just remove the ! before the includes

tulip cradle
dry imp
#

urmom

pearl trail
#

neko hashflushed

tulip cradle
pine nova
#

💀

bright thorn
#

This is actual time <t:1680008375>

but from moment its showing me wrong : January 20th 1970

const moment = require("moment");
let time = moment(1680008375).format('MMMM Do YYYY');
message.channel.send(`${time}`)
#

Any solution

cinder patio
#

moment(1680008375 * 1000);

bright thorn
#

Thank you

#

got it

tulip ledge
#

Js is weird as it uses ms while timestamps are actually the seconds passed since january 1st 1970

sudden geyser
#

Well wouldn't a more precise timestamp be more useful

wheat mesa
#

whoops, nobody saw that

simple stump
#

If I have a function, could I return something like this:

function myFunc() {
  return false && "hi";
}

Would this return false and "hi"? For example, could I call this function like this:

let funcThing = myFunction();
if (!funcThing) {
  console.log(funcThing; // prints out "hi"
} else {
  // do smth
}
quartz kindle
#

The value of this property represents the number of 100-nanosecond intervals that have elapsed since 12:00:00 midnight, January 1, 0001 in the Gregorian calendar

pearl trail
#

what you may want to do is return [false, "hi"]

#

so, ```js
if(!func[0]) console.log(func[1])

simple stump
#

Ah ok ty

wheat mesa
#

return {something: false, somethingElse: 'hi'}

cinder patio
#

Both work, arrays are sometimes cleaner

wheat mesa
#

I suppose, but I’m assuming that for this case objects would be a lot more readable

#

And manageable

#

Than say, returning an array with 10 elements instead of an object with 10 properties

wheat mesa
#

Long overdue

quartz kindle
#

already in progress

wheat mesa
#

Isn’t the date api we have now pretty much the same date api from when js was first invented?

quartz kindle
#

i guess so

#

temporals are stage 3 atm

cinder patio
#

❤️ elements I'd go for arrays > 3 object

wheat mesa
#

Yes

cinder patio
#

< 3

wheat mesa
#

Personally I prefer objects over arrays, guess it depends on the use case

wheat mesa
quartz gull
#

Hello, does anyone know how to make a bot send a message across shard?
I have tried, but either it does not find the user or it sends the same message the number of shards.

  client.cluster.broadcastEval(async (c, { userid }) => {
    let user = await c.users.fetch(userid)
    if (user) {
         user.send({ content: "hi" })
    }
  }, { context: { userid } })
cinder patio
#

Now can you tell me what each of those mean :^)

quartz kindle
#

all documented

cinder patio
#

why not use objects tho

quartz kindle
#

to make it 1:1 with the C api

cinder patio
#

ok that makes sense yeah

quartz kindle
#

this is the C api

#

yes, the C docs tell you to create an array of size 50, but only returns 30 values

#

the other 20 are used for temp values and shit

simple stump
azure lark
#

is it possible to make a function in ejs and then run that function from a <script>?

#

for example;

<% 
function log(){
console.log("Hello World!")
}
%>

<script>
(somehow import the function)
log()
</script>
quartz kindle
pine nova
#

ig u need to do <% log() %> in script tag

#

to run the function

#

💀

quartz kindle
#

what you have inside <% %> runs on your server, what you have outside runs on the user's browser

pine nova
#

i see

quartz kindle
#

if you want to run the function in the user's browser, you need to write the full function text so its included in the html that the user downloads

azure lark
#

im not sure that will work

quartz kindle
#

this function cannot access your server data from the browser

azure lark
#

is there a way to loop a ejs function?

quartz kindle
#

to do what?

azure lark
#

i tired setInterval(function, 1000); but nothing

#

like,

function log(){
console.log("Hello World")
}
setInterval(log, 1000);
#

but in ejs

quartz kindle
#

where?

azure lark
#

cuz i tired that but it didnt work

quartz kindle
#

in your server or in the user's browser?

azure lark
#

server? im assuming?

quartz kindle
#

only if you do it outside the renderer

azure lark
#

F

quartz kindle
#

you need to think of ejs as an html builder

azure lark
#

ohh ok

quartz kindle
#

the entire ejs code will be processed only once in order to create an html file, that is then sent to the user

#

everything you do inside the ejs file its just used to help build the resulting html, it does not have any kind of persisting connection to the user's browser, nor does it have any long running process

azure lark
#

ok

#

if i did

function log(){
console.log("Hello World!")
}
setInterval(log, 1000);
res.sendFile("./path")


})```
would that keep logging Hello World?
quartz kindle
#

yes, plus once more for every access

#

if you access that page 10x, it will be logging 10 times per second

azure lark
#

would it stop once the page is closed?

quartz kindle
#

no

near stratus
#

*crash maybe IDK

azure lark
#

if i tell you what im trying to do maybe you could come up with an idea what to do as i have no clue?

quartz kindle
#

im guessing you're trying to detect how long a user stays on the page?

azure lark
#

no, its to do with a music bot lol

quartz kindle
#

do explain then

azure lark
#

so there is gonna be a page that you can control the bot from, im trying to make it so that the page displays the current song playing

#

i have done this:
let q = client.distube.getQueue(req.params.id) || "none"
and then imported it so it can be used with ejs

quartz kindle
#

if you just want to press buttons and control the bot, you can do that with regular http/ajax requests
if you want the page to auto-update the bot information, then there are 2 ways you can do that: execute ajax requests from the browser in an interval, aka polling, or create a websocket connection

azure lark
#

im trying to make the bot auto-updated the info

quartz kindle
#

the easiest way would be with polling, the most efficient way would be with websockets

azure lark
#

i already have all of the user auth and stuff, that wouldnt be affected by websockets would it?

quartz kindle
#

with polling you would do something like this js // server app.get("/botstatus/:id", (req, res) => { const queue = client.distube.getQueue(req.params.id); res.send({ nowplaying: queue }); }); ```html
<!-- browser -->
<script>
setInterval(() => {
fetch("mywebsite.com/botstatus/" + serverID).then(x => x.json()).then(result => {
console.log(result);
})
}, 1000);
</script>

azure lark
#

ahhh right

#

that dose seem pretty simple

#

is there any downsides to that?

quartz kindle
#

with websockets its a bit more complex, you need to create a websocket connection between the browser and your server, so that the server can keep feeding information to the browser while it stays on the page

quartz kindle
# azure lark is there any downsides to that?

the downside is that this method is slower/less efficient, since you need to keep sending requests every second, if you have hundreds of people with the bot page open, you will be sending hundreds of requests per second to your server

azure lark
#

i wont have hundreds of people so i think that would be best

#

ty!

quartz kindle
#

👍

azure lark
#

/botstatus gives the error: TypeError: Converting circular structure to JSON when something is playing

wide jolt
#
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
.
.
.
client.on('guildMemberAdd', (member) => {
    const channelId = 'MYID'; // The Channel ID you just copied
    const welcomeMessage = `Hey <@${member.id}>! Welcome to my server!`;
    member.guild.channels.fetch(channelId).then(channel => {
        channel.send(welcomeMessage)
    });
});

i used this for welcome but it doesnt work

near stratus
#

Like any bug or something

wide jolt
#

It doesnt work

near stratus
#

can you try with client.channels.fetch(... ??

#

instead of member.guild.channels.fetch

azure lark
wide jolt
split hazel
#

@boreal iron @quartz kindle hello fellow osdevers
im making a graphics driver which supports layers instead of a single flat canvas - the only issues im stuck on is re-rendering specific parts of the real display

#

say you have 3 layers which overlap

#

and you removed the first one (one behind all overs)

#

what would you rerender lmao

#

i can check everything pixel by pixel which would probably be okay for a two layers but multiple?

#

worst case scenario i'll rerender the whole display 💀

#

all 800x600 pixels worth

#

actually its a lot more confusing than that considering a layer can have transparent colours too

#

i can also keep track of all objects (such as lines and rectangles) coordinates which will allow specific re-rendering but if you're drawing individual pixels thats gonna get expensive

timber fractal
#

How do I fix my css skill issue? I just suck at css and want to get better at it.

tidal nymph
#

practice more

grim flame
#

I would also recommend to add

if (!channel) return;
raw nest
#

Does someone know an open-source self-hosted hosting software? Like a cool software that can do the hosting stuff for you on your own server? That would actually be awesome 😅

split hazel
raw nest
split hazel
#

not really

#

its mostly general purpose

#

but it is quite restricted yeah

#

honestly you could make something like that yourself

#

setup docker and use a driver to spin up a docker instance "aka creating a server" and then give the IP and setup the SSH to that server

#

that all can be done automatically with a dockerfile

#

its also funner since you make it yourself:)

split hazel
#

still stuck on the design issue tho

lyric mountain
#

what issue?

split hazel
#

implementing a graphical driver with layers supported

#

im stuck on the part where you re-render things

#

when for example a layer is hidden

#

or a rectangle is drawn or cleared from the layer

#

it would be expensive to redraw everything

lyric mountain
#

can't u save the previous frame and compare with the new?

split hazel
#

especially since i have no GPU acceleration since that shit is literally closed source in manufacturer drivers

lyric mountain
#

like, only render the differences

split hazel
#

let me draw something

lyric mountain
split hazel
#

yeah theres a "visual layer" which contains everything shown on the screen since reading from video memory is extremely expensive
then theres additional layer buffers which hold all pixel data for each layer

#

each layer holds 800x600 32 bit ints

lyric mountain
#

ok, the first thing you could do is check differences between row sizes

#

like, the row storage size

#

when u change a value in some index it'll affect the total size of the array

#

unless the language ur using pre-allocates the whole range

#

when u find a mismatch between 2 rows just iterate over it checking each entry

split hazel
#

each buffer is preallocated with all values set to 0 (black)

#

say each colour is a different layer

#

how would you find out what to redraw when for example layer 2 (blue) is removed?

#

my initial idea was storing each drawing operating (e.g. draw rectangle) as an object which holds an index + coordinates

#

actually that doesnt really help lmao

lyric mountain
#

use a zIndex to define what gets drawn on top

#

whatever is below doesn't need to be drawn

split hazel
#

the layers are basically a zindex

lyric mountain
#

pixels I mean, not the actual windows

split hazel
#

maybe instead of layers i should make everything an object you can adjust the location and index of

snow vector
#

anyone in here know html that could help me. my site is acting up but i cant find whats wrong/know whats wrong

lyric mountain
snow vector
#

i click on a menu option and it just adds the previon page onto the new page

lyric mountain
#

like, start with the lowest index

#

then go up ovewriting all affected pixels

lyric mountain
#

like, what's the expected result VS the current result?

#

oh wait

#

I get it

snow vector
#

it supposed to me /updates but its /updates/commands

lyric mountain
#

you mean the droxz.com before updates

#

oh nvm then

lyric mountain
#

the code I mean

snow vector
#

ok hold on

#

<li class="sd-tab-item" ><a href="commands"><div class="">Commands</div></a></li>

lyric mountain
#

you can't do that

#

you're adding a new "level" to the url

snow vector
#

oh so it should be commands.html?

lyric mountain
#

...no, that'd be ever wronger

#

you need to use actual paths

#

idk if ../ is a thing in html

#

in the worst case just use the full path

#
snow vector
#

alright

#

thank you

lyric mountain
#

update: yes, you can use ../

#

it means "go up one level"

#

use /droxz.com/commands

#

but I must ask, is that droxz.com really necessary?

snow vector
#

ok

snow vector
split hazel
lyric mountain
#

instead of iterating non-relevant pixel

#
for (int y = Math.max(0, window.y); y < window.y + window.height && y < screen.height; y++) {
  for (int x = Math.max(0, window.x); x < window.x + window.width && x < screen.width; x++) {
    pixel[y][x] = ...; // set the pixel
  }
}
#

like this

#

(don't mind my long condition)

split hazel
#

why do the layers have x and y

#

i mean layers as in they're a full screen canvas

lyric mountain
#

idk what's ur structure

#

layer would be the window

#

hmm, bad variable name maybe

#

x/y would be the leftmost top pixel

split hazel
#

by layer i mean it has its own canvas which is the size of the display but at the end its all squashed together into one depending on their index

lyric mountain
#

ik ik

#

there, renamed it

#

you'd iterate over the windows in crescent order according to their z index

#

you can even check if the resulting pixel would be the same color as the current and skip that index

#

that way you save on meaningless array ops

wide jolt
lyric mountain
#

you could also have a buffer matrix to flat all the pixels before transferring to the render matrix

split hazel
#

they are all already flat because it would be expensive flatting everything out

lyric mountain
split hazel
#

i dont think i understand you though

wide jolt
#

i mean all of this changes

split hazel
#

quite confused on what you mean by window

#

do you mean the rectangle in this context

lyric mountain
#

yes

split hazel
#

3 layers each holding a single rectangle right?

lyric mountain
#

yes

#

like, instead of iterating the whole 800x600 screen, you only iterate on where pixels exist

wide jolt
lyric mountain
#

so let's say you have a tiny 50x50 rectangle, you'd only iterate over the space that rectangle occupies instead of the entire screen

lyric mountain
#

what he suggested is changing cache.get to fetch

#

which will fetch the channel instead of relying on the cache

lyric mountain
#

...bruh

#

I get that part

#

what's the issue you're having?

wide jolt
#

it doesnt send welcome message

lyric mountain
#

ok, any error in the log?

wide jolt
#

nothing

lyric mountain
#

show the code

wide jolt
#
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });

.... my code ...

client.on('guildMemberAdd', (member) => {
    const channelId = '958031024569323550'; // The Channel ID you just copied
    const welcomeMessage = `Hey <@${member.id}>! Welcome to my server!`;
    member.guild.channels.cache.get(channelId).then(channel => {
        channel.send(welcomeMessage)
        if (!channel) return;
    });
});
lyric mountain
#

...you didn't change cache.get

#

actually, you made it worse

split hazel
#

right i see, but another issue what if layer 3 is completely a single colour (e.g. whole screen reg) but layers 1 and 2 have something else such as rectangles

lyric mountain
#

idk how you're not getting errors

split hazel
#

would you go down the layers to render everything

#

quite expensive for every pixel

wide jolt
lyric mountain
#

(a cube in this case?)

#

check for the rightmost entry that's not 0

#

draw that one

#

ignore everything to the left

#

this way you'd have only 1 op per pixel, and would only draw what's on top

lyric mountain
#

because that code shouldn't even run

wide jolt
lyric mountain
#

.cache.get(channelId) is getting the channel from the cache

#

it's not guaranteed to exist

#

.then after it only makes it worse, because it doesn't return a promise

lyric mountain
wide jolt
#

i did it

lyric mountain
#

you didn't

#

oh wait, it's the other way around

lyric mountain
#

nvm then, just assign the channel to a variable

#

instead of using .then

wide jolt
#

@lyric mountain let me debug with console.log(member);

lyric mountain
#
const channel = member.guild.channels.cache.get(channelId);
if (!channel) return;

channel.send(welcomeMessage);
#

like this

wide jolt
#

there is nothing on console

lyric mountain
#

it's meaningless to have a guard on the last line

split hazel
#

even if i only draw the pixels that have a significance its still quite a lot of interactions going down the layers (unless i spend more memory in each layer containing another canvas which contains the data of layers 1 and 2 as if layer 3 didnt exist so it can be easily restored without iterating down the layers

#

memory writes arent that expensive its the reads which really kill performance

#

speaking in terms of clock cycles

lyric mountain
#

hm, I can't think of anything then

split hazel
#

yeah its really tricky

#

im seriously considering just having a bunch of objects with a single canvas with just some x indexes

#

so if you made a rectangle its an actual object and its x and y coordinates are stored

#

so the relevant pixels can later be rerendered from all objects

lyric mountain
#

that's probably the best option

split hazel
#

and the arrays can be sorted based on their indexes so it doesnt have to perform uneccessary slow checks

lyric mountain
#

although heavier

split hazel
#

i think its actually better than the layers approach

#

instead of thinking about huge canvases you think about smaller objects

#

if you wanted a window for example you just make an object that fills the entire screen

lyric mountain
#

faster than sorting the array each time

#

also you could technically split the job across multiple threads

#

like cut the screen into a 4x4 grid

livid lichen
#
        const collector = await message.channel.awaitMessages({ filter: msg => msg?.content, time: 260 * 1000, errors: ["time"] })
            .then(async collected => {
                console.log("yes");
            })
            .catch(collected => console.log(`After a minute, only ${collected.size} out of 4 voted.`));
``` For some reason, nothing passes the filter and I have no idea why. I debugged the filter and it worked, but didn't fire the collected event.
#

Anybody know why?

wheat mesa
#

it's probably something to do with the fact that you're doing await message.channel.awaitMessages() and using a .then() callback afterwards

livid lichen
#

Maybe. I'll try removing the await. Thanks.

wheat mesa
#

notice the lack of await in this example

#

yeah

livid lichen
#

Didn't work 😢

wheat mesa
#

are you getting errors?

simple stump
#

If I'm writing to a file, how do I check if it's still writing? I'm dealing with writing to large files, but am not sure how I can check if a stream is being written to:

let stream = file.createReadStream();
let dest = fs.createWriteStream(join(__dirname, "../../../web_server/videos/" + name + "/") + file.name);
stream.pipe(dest);
livid lichen
wheat mesa
#

try not using a filter and see if you get your desired result

#

I don't know if filter is required, I'd assume not though

livid lichen
wheat mesa
livid lichen
#

Didn't work.

simple stump
# livid lichen Nope.

Filter is required I believe. This is how I handle it:

const filter = (async (i) => {
  return await i.deferReply() || true;
});
message.awaitMessageComponent({ filter, componentType: "SELECT_MENU" }).then(async (interaction) => {
});
simple stump
simple stump
wheat mesa
livid lichen
#

btw I'd like to mention how all the rest of the commands with awaitMessages work just fine

wheat mesa
#

like what..?

#

are you doing it the same exact way?

#
    // I mean, it works I guess
    public static double FindAndInvoke(string funcName, params double[] operands)
    {
        var (method, argLength) = FindFunction(funcName);

        if (method is null)
        {
            throw new FunctionNotFoundException($"Function '{funcName}' does not exist.");
        }
        
        if (operands.Length != argLength && argLength is not null)
        {
            throw new ArgumentException(
                $"Method '{funcName}' takes {argLength} arguments, not {operands.Length}.");
        }

        if (argLength is null)
        {
            return (double) method.Invoke(null, new object[] { operands });
        }
        
        return (double) method.Invoke(null, operands.Select(x => (object) x).ToArray());
    }

    private static (MethodInfo?, int?) FindFunction(string funcName)
    {
        foreach (var method in methods)
        {
            var attrs = Attribute.GetCustomAttributes(method);
            if (attrs[0] is FunctionName && ((FunctionName)attrs[0]).Name.Equals(funcName))
            {
                return (method, ((FunctionName)attrs[0]).ArgumentLength);
            }
        }
        return (null, 0);
    }
``` I wonder if this is a valid use for tuples, these two functions are probably garbage in the first place though
lyric mountain
#

You see, then is a step of the promise chain

#

The last then defines what gets output from it

#

Since you're doing console.log, which is a void function, you get nothing

lyric mountain
#

Also does it really enforce newline brackets or is it a myth?

wheat mesa
lyric mountain
#

I'll format the formatter

quartz kindle
#

fn() {
}

fn()
{
}

hoary apex
#

Help !

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

lyric mountain
#

Should I ever code in c#, I'll make sure to override any kind of formatter so it ends with inline brackets

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

lyric mountain
#

turkvarmi inline brackets resistance

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

hoary apex
quartz kindle
# hoary apex Brehhhh

you tried to send a message to a channel that your bot cant see, that was deleted, or that is from a guild your bot is not in

sudden geyser
#

Outstanding brackets are a crime against humanity

fickle arch
#

how do I make bot show activity showing how many members is inside the server

lyric mountain
#

You can't

#

Not without making one shard per server

fickle arch
#

uh what

#

wasn't sharding is needed when bot is inside 100+ server or something, I'm just testing old project.

lyric mountain
#

Yes

#

But shards can have unique activities

#

Which is what you'd need to show per-server member count

#

But you can't since too many shards would make it impossible for you to start the bot

fickle arch
lyric mountain
#

For overall you don't nees shards

#

BUT there's a catch

dry imp
#

your bot cannot have a different activity without sharding

lyric mountain
#

You can't have an accurate member count

#

Not without sacrificing more ram than humanly purchaseable

fickle arch
#

I use this but it only show 1 member which I assume is the bot itself, but it shows correct server number

    var activities = [ `${bot.guilds.cache.size} servers`, `${bot.users.cache.size} users!` ], i = 0;
lyric mountain
#

First of all, never ever dare to write var again

#

Use let

fickle arch
#

noted

lyric mountain
#

Second, you need to have member intent

lyric mountain
#

Cache is supposed to have only commonly acessed data