#development

1 messages · Page 100 of 1

quartz kindle
#

which means

#

you tried doing undefined.defaultFontFamily = something

hushed robin
#
const chartJSNodeCanvas = new ChartJSNodeCanvas({ width, height, backgroundColour, chartCallback: (ChartJS) => { 
  ChartJS.global.defaultFontFamily = 'Inter';
}});```
so global is undefined?
lament rock
#

ChartJS.global is undefined

hushed robin
#

hm

#

ok

#

ah figured it out

#

👍

unborn basalt
#

how you doing battleless, you need any help with your projects?

#

ill try to be here and help ya out if ican

hushed robin
#

yes

#

what is this line that i highlighted called

#

i wanna delete it from my graph

unborn basalt
#

point of origin?

#

it depends on what you are measuring

#

but that looks like from the graph that is the start of the measure

#

it could also just be the first entry into your data set, in which you would delete the corresponding data

#

if you give me some more information about what you are measuring i could be of more help

solemn latch
#

Id just call it a line

hushed robin
#

well

#

i'm trying to figure out the actual term so i can remove it

unborn basalt
#

That could be true as well! if its the entire part that he highlighted, then it could be

hushed robin
#

cus it looks weird there

solemn latch
#

chartjs?

unborn basalt
#

Can you take a closer screenshot of what you are trying to remove

#

if youre talking about the vertical black line, i am not sure

hushed robin
hushed robin
#

thats what i highlighted

unborn basalt
#

yeah. Well if you want to learn to be a better communicator (not sure if thats a real word) its important to both learn the definitions of words, but also their "working" definition

hushed robin
#

what

unborn basalt
hushed robin
#

i didn't ask how to remove it

#

i asked what it's called

unborn basalt
#

well i was asking how to remove the message i just wrote which from your view is highlighted

#

that is the semantics part of understandign someone

hushed robin
#

what are you on about

lyric mountain
#

"what"

unborn basalt
#

i do not know the name of the black line that you highlighted in your data

#

but someone may be able to help you better remove it

hushed robin
#

ok

unborn basalt
#

I apologize if i made that more confusing

hushed robin
#

yes

#

you could have just said 'i don't know ☹️ '

#

time to do more searching

lyric mountain
#

Many came, many tried, none succeeded

#

You're pretty polite

unborn basalt
#

When we have questions, we should be sure to encourage giving as much information as possible as we are trying to be open

hushed robin
#

figured it out 👍

#

now graph looks pog

quartz kindle
#

is that the number of fucks you give over time?

#

so in july you will give 0 fucks

#

:^)

hushed robin
#

no

#

it's a random dataset i found on the chartjs website

#

btw guys how can i remove ExperimentalWarning's

harsh nova
#

check the docs of wherever that is included from

hushed robin
#

buffer.File is an experimental feature and might change at any time

#

is it ok to use it

hushed robin
harsh nova
#

then check the docs for that on node

#

or check whatever error message is included. Those normally tell you where/what you need to do to fix the issue

hushed robin
#

well it's not an error

#

it's a warning

spark flint
hushed robin
#

yes

#

😮‍💨

#

does anyone know something like https://www.npmjs.com/package/chartjs-plugin-datalabels that works with common.js

unborn basalt
#

its not a threat, its an admission that i enjoy the game

#

catch yall later

hushed robin
#

what

#

sour basin
unborn basalt
#

uh oh

#

better change your name in this server

#

if you want this

#

you can do it

#

:lutune:

boreal iron
#

Tf are this weird people today

#

not that this channel would be a place of sanity but still

spark flint
#

lol

hushed robin
#

looks pretty nice

spark flint
#

how are you making it look like that lol

hushed robin
#

i can send the code

#

if you want it

spark flint
#

please do uhh

hushed robin
#

sure

hushed robin
spark flint
#

rt

#

ty

hushed robin
#

👌

viral spade
#

Hello,
in my interactionCreate, interactionSuccess events, I only receive an object with id and nonce fields. How can i access the interaction`when it has been answered by a bot (and the response of a bot to that interaction?)

lyric mountain
#

nor can bots use yours

viral spade
hushed robin
#

message.content

#

message.embeds[0] i think

lyric mountain
#

messages can have up to 10 embeds

viral spade
#

thx!

crystal furnace
#

Hey after listening some people, I try to up my project to version 14 but I get this error when I running my bot

#

require('dotenv/config');
const { ShardingManager } = require('discord.js');

const Bot = require('./src/Structures/bot.js');
const client = new Bot();
client.start();

const manager = new ShardingManager('./src/Structures/bot.js', {
  token: process.env.BotToken,
  totalShards: 'auto',
});

manager.spawn();

manager.on('shardCreate', (shard) => {
  console.log(`Launched shard ${shard.id}`);
  shard.on('ready', () => console.log(`Shard ${shard.id} ready!`));
  shard.on('disconnect', () => console.log(`Shard ${shard.id} disconnected!`));
  shard.on('reconnecting', () => console.log(`Shard ${shard.id} reconnecting...`));
  shard.on('error', (error) => console.error(`Shard ${shard.id} encountered an error: ${error.message}`));
  shard.on('warn', (warning) => console.warn(`Shard ${shard.id} encountered a warning: ${warning.message}`));
});

My client.js file

#

require('dotenv/config');
const { Client, Collection, Partials } = require('discord.js');
const { GatewayIntentBits } = require('discord.js');
const { Channel, GuildMember, GuildScheduledEvent, Message, Reaction, ThreadMember, User } = Partials;
const { readdirSync } = require('fs');
const { BotToken, Prefix } = process.env;
const Util = require('./Utils');
const chalk = require('chalk');

class BOT extends Client {
  constructor() {
    super({
      ... //intent + partail, Discord limit don't allow me puthere
    });
    this.token = BotToken;
    this.config = require('./config.json');
    this.setMaxListeners(0);
    this.events = new Collection();
    this.legacyCommands = new Collection();
    this.aliases = new Collection();
    this.commands = new Collection();
    this.components = {
      buttons: new Collection(),
      modals: new Collection(),
      selectMenus: new Collection(),
    };
    this.cooldowns = {
      legacyCommands: new Collection(),
      buttons: new Collection(),
      commands: new Collection(),
      modals: new Collection(),
      selectMenus: new Collection(),
    };
    (this.commandArray = []), (this.developerArray = []);
    this.legacyArray = [];
    this.colors = {
      green: 0x22b14c,
    };
    this.rds = readdirSync;
    global.chalk = chalk;
    this.utils = new Util(this);
  }

  async start(token) {
    const functionFolders = this.rds(`./src/functions`);
    for (const folder of functionFolders) {
      const functionFiles = this.rds(`./src/functions/${folder}`).filter((file) => file.endsWith('.js'));
      for (const file of functionFiles) require(`../functions/${folder}/${file}`)(this);
    }
    this.handleEvents();
    this.login(token).then(async () => {
      await this.utils.logger();
      this.handleCommands();
      this.handleComponents();
      if (Prefix) this.handleLegacyCommands();
    });
  }
}

module.exports = BOT;

My bot.js file

#
D:\CoronaChanV3\Discordjs-v14-Template\node_modules\discord.js\src\sharding\Shard.js:162
        reject(new Error(ErrorCodes.ShardingReadyDied, this.id));
               ^

Error [ShardingReadyDied]: Shard 0's process exited before its Client became ready.
#

This is my first time with discord.js-v14, anyone know why my shard always die?

My project is start normal if I'm not putting sharding

earnest phoenix
crystal furnace
earnest phoenix
#

You're supposed to instantiate the bot and login in the file you're passing to your sharding manager

#

For example:

// bot.js
import { Client, GatewayIntentBits } from 'discord.js';

const client = new Client({
  intents: [GatewayIntentBits.Guilds]
});

await client.login(process.env.botToken);
// index.js
import { ShardingManager } from 'discord.js';

const manager = new ShardingManager('./bot.js', {
  token: process.env.botToken
});

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

await manager.spawn();
crystal furnace
#

I will try this way again, I remember I tired it but fail

crystal furnace
unborn basalt
#

im not sure, but intents seems to be determining what data can go through a gateway

#

and by checking that data

crystal furnace
#

@earnest phoenix I think I will move const Bot .... Start(); into a new files, then create a connect from main files and start shard.js file, I think it should work

earnest phoenix
neon leaf
earnest phoenix
#

What if I create a set function

#

In the end it's a .replace and eval() kek

neon leaf
#

well then you do call set()

earnest phoenix
#

And what happens to the variable setting technique CS_pepehmm

neon leaf
#

its unaffected, you cant overwrite predefined functions

earnest phoenix
#

disappointed

neon leaf
earnest phoenix
#

Eventually parsing is a bit more "complex"

neon leaf
#

yeah, it isnt that hard

earnest phoenix
#

Would probably ditch the set function to set a variable

#

And go the ordinary way

dense flame
#

looks pretty nice

neon leaf
#

its called "best theme"

#

literally

earnest phoenix
#

LMAO

neon leaf
dense flame
#

great xD

rose warren
#

Slash command adoption for Feb 2023 was ~73% 👀

#

That means pretty much 3 out of 4 commands run were slash commands

earnest phoenix
#

What happened in December monkaS

rose warren
#

I think that's when slash commands stopped loading in everyone's clients? There was that Discord bug

earnest phoenix
#

Ah may have bene that time yeah

rose warren
#

Anyway, I implemented slash commands in Feb 2022 and 1 year later this is where we're at without me even promoting the use of them anywhere in my bot / Top.gg page.

#

So this is natural adoption

earnest phoenix
rose warren
#

It actually also equates for 75% of unique users

radiant kraken
earnest phoenix
jagged hornet
#

Tf smith's wrong with my clipboard

#

Imma fix it brb

radiant kraken
jagged hornet
#

So I was wondering. You can hypothetically get infinite queries on midjourney using different Accounts!, Now you can also make infinite (or many) bot account in discord developer portal, so if you were to somehow make it happen that "your bot" types "/imagine" then presses the pop up that shows that it's going to register that /imagine as a command and not a message, then type out what you provided then press enter/send then you can"

Exploit your bots for midjourney free queries and each time one runs out, you can just put your first bot's preset to your new bot and go on. Will that be possible?

#

Better

rose warren
#

Using rust

hushed robin
earnest phoenix
jagged hornet
earnest phoenix
#

Also iirc bots cannot execute slash commands

#

Yeah they can't

jagged hornet
#

F

radiant kraken
quartz kindle
hushed robin
#

bots cannot run slash commands

radiant kraken
rustic nova
#

Daily Aurel rent

#

Who the fuck invented leap years

#

I hope you continuously suffer in your grave

#

Like

#

Haha yes lets have funny month days numbers years numbers haha

earnest phoenix
#

it's caesar

rustic nova
#

Fuck that dude

earnest phoenix
#

Time savings is also a mess

rustic nova
#

Nobody cares about leap years, yet devs have to deal with it

#

Jesus

#

IM NOT GONNA GET STARTED ON TIMES YEAH

#

Hellno

quartz kindle
earnest phoenix
rustic nova
#

Fuck your leap seconds

#

I'll give you leap nano seconds

#

So done fr

earnest phoenix
#

Surprised daylight saving hasn't been abolished yet

#

Doesn't make any sense

quartz kindle
#

what about sidereal time, terrestrial time, ephemeris time, universal time, mean and apparent times

rustic nova
#

Tim

#

I'm glad i dont have to work on time

#

Only date

quartz kindle
#

also universal time (UT1) !== coordinated universal time (UTC)

rustic nova
#

🗿

#

Im done

quartz kindle
#

lmfao

#

ok im done

hushed robin
#

if I’m tracking multiple stats of games is it best to have a table for each

#

cus there’s going to be a lot of data

rustic nova
#

Like

#

Cant describe what im doing

#

But

#

My head

unborn basalt
#

looking at that data on /slash commands, is that good or bad in your opinion! I def see that it is changing!

unborn basalt
#

What sort of data are you looking at pulling? ive done it for a few games in the past, but just as smaller projects! if you want an example of a 3rd party using game stats, check out some applications like overwolf or fire for blizzard

hushed robin
#

☠️

quartz kindle
hushed robin
#

there’s going to be like 300k rows a day

hushed robin
#

I was going to organize it by adding a type column

quartz kindle
#

you have to think of different ways to organize tabular data, i dont know what exactly your data looks like, but for example:

table a+b
id, type, value
1, "a", 500
1, "b", 400
2, "a", 200
2, "b", 840
``` or ```js
table a
id, value
1, 500
2, 200

table b
id, value
1, 400
2, 840
#

there are many options

#

in general separated tables are faster to access (if accessing individual data) but consume more space

hushed robin
#

just wondering if it’ll be better to separate them because there will be quite a bit of data and I’ll need to access it regularly

unborn basalt
#

can you give me some contxt and i can help

hushed robin
#

the example he sent is what I’m doing right now except i have a time stamp column

unborn basalt
#

Ok let me look for a second

#

Sometimes you have to read the lyrics to make sense of the song - owo define

#

^^ignore that was just trying to help another bot^^^

hushed robin
#

☠️bro

neon leaf
#

Im doing alot of small side projects right now to just understand more concepts and currently im making a simple text compressor, I have this code. it does work - just not correctly since it makes the files 2x bigger, is my concept that this code uses generally even the right direction?
https://pastes.dev/iu02QpXQZn

#

my current Idea was just to assing each word a number, have all number: words at the bottom and just use the numbers for the actual text

lyric mountain
#

wont work

#

you see, with this method ur limited to 10 numbers, or 16 if ur using hex

neon leaf
lyric mountain
#

ah, you're using _ to separate characters

#

you could use unicode chars intead, which supports up to 65k different values

neon leaf
#

can I somehow turn a simple number to unicode in js?

#

or do I have to manually do that?

lyric mountain
#

you don't convert to unicode

#

I mean, in js ig u need to since it doesn't have char data type

#

see if there's a parseChar or smth

#

regardless, your method is quite similar to deflate compression method

#

although less efficient

neon leaf
#

mh

neon leaf
#

why does it accept 4 inputs?

lyric mountain
#

that's a surrogate quartet

#

actually, nvm, that's just individual char codes

neon leaf
#

oh

lyric mountain
#

surrogate pairs/triplets/quartets would be different

neon leaf
#

what would I do if I go over 65k?

lyric mountain
#

overflow

#

it supports up to 0xFFFF

#

so going over that will result in 0x0000

neon leaf
#

wouldnt that break the files content?

#

since im mapping a code unit to a word

lyric mountain
#

you wont be reading the content itself, you'll read the bytes

#

compressed files aren't supposed to be humanly readable

neon leaf
#

yes but I mean when decompressing if I go over 65k I would go back to the first word, right? and then it would show wrong words

lyric mountain
#

yes it'll break

#

but that's because you're using an inefficient method

#

as I said, you're doing what deflate already does

neon leaf
#

yeah, I also thought about checking if a word gets used over X times and only then map it

lyric mountain
#

that's not the issue

#

the issue is that you're using words

neon leaf
#

right

lyric mountain
#

in a compression algo you don't care about words at all, you need to focus on bytes

#

deflate counts repeated sequences of bytes and map them into pairs of bytes (0xFFFF)

#

you can also simply ditch chars altogether and use 4 bytes (0xFFFFFFFF), which will allow up to 4 billion words

#

note that the more bytes you use, the bigger the output will be

neon leaf
#

hm, Id just want it to compress with only changing text for now, no bytes since I havent done anything with bytes, really

lyric mountain
#

up to you, but it'll expand most content instead of compressing

neon leaf
#

how would using bytes change that though? isnt it the same in the end?

lyric mountain
#

this for example: _555__82__556__557__554__71__152_ = 33 chars
in bytes becomes: ȫRȬȭȪG˜ = 7 chars

neon leaf
#

🧐

lyric mountain
#

those are char representation of the bytes

neon leaf
#

numbers are just bytes though arent they

lyric mountain
#

only inside memory

#

inside files they are chars

#

so 555 isn't the number 555, but the character 5 repeated 3 times

neon leaf
#

ooh

#

how exactly did you turn those 33 chars into 7 chars?

#

ah no nvm

lyric mountain
#

I simply used the char representation instead of the readable number

neon leaf
#

yeah, I noticed a bit late

#

but for example with 1 it doesnt output anything

lyric mountain
#

?

#

yes, because chars below 40 or so are mostly control characters

#

but they are there

#

a quick example I wrote, based on ur algo + what I said

#

I added an offset of 60 to have visible chars at all

#

the text has a poor compression because it's separated by whitespace, this is what I mean when I said yours wont compress as much

neon leaf
#

its def progress though, from compressed being 100kb bigger to only 6kb bigger, still bigger though

#

what should I seperate by then?

lyric mountain
#

nothing

neon leaf
#

now we getting to bytes again aint we

lyric mountain
#

if u use 2 bytes (1 char) for every value you know for sure it'll be 1 value every 2 bytes

#

you don't need any separator, because every char will be the value itself

#

an example splitting by 2 chars

neon leaf
#

oh

#

lemme try

lyric mountain
#

it ended up being bigget than split by spaces

neon leaf
#

now its 30kb bigger, did I do something wrong?

lyric mountain
#

if it's bigger u probably did something wrong

spark flint
neon leaf
# lyric mountain if it's bigger u probably did something wrong
export function compressFile(file: string): string {
  let newContent = ''
  const content = fs.readFileSync(path.resolve(file), 'utf8')
  const lines = content.split('\n')

  for (const line of lines) {
    const words = line.match(/.{1,3}/g)
    if (!words) continue

    for (const word of words) {
      if (compressContext.cached.has(word)) newContent += String.fromCharCode(compressContext.cached.get(word) + 60)
      else {
        compressContext.cached.set(word, compressContext.cached.size + 1)
        newContent += String.fromCharCode(compressContext.cached.get(word) + 60)
      }
    }

    newContent += '##'
  }

  newContent += '\n'
  for (const [key, value] of compressContext.cached) {
    newContent += `${key}#${value}-#`
  }

  return newContent
}```
lyric mountain
#

1.0.0.1

spark flint
#

yeah goes to 1.0.0.1

#

get good

lyric mountain
#

apparently, splitting by a fixed number of chars has poor repetition, you'll need a more intricate way of splitting

neon leaf
#

wow, I fixed my regex and the file is 10kb smaller

#

well stll alot of room for improvement

lyric mountain
#

oh, btw

#

if ur gonna split by fixed amount of chars use /(?<=\G.{number})/

#

else it'll split only the first match

#

and remember to use (?<=) block else you'll delete the splitted part

#

last but not least, you can separate your dictionary in a separate file

#

cuz u only require it when decompressing

#

however this will also mean you need to transfer the two files when sharing it

neon leaf
#

technically I could treat that file as a "key" then, right?

lyric mountain
#

basically

#

the encoded file is virtually useless without the dict

rocky dagger
#

whats the best way to make global functions that i can use in every command?

lyric mountain
#

use a helper file

rocky dagger
#

Ok

crystal furnace
hushed robin
#

pixxie

#

there would be no way to get that data on every bot

earnest phoenix
#

Would be nice to see such data from Discord though

hushed robin
#

how can i attach an image to an embed

deft wolf
#

.setImage()?

spark flint
#

an example

#

the name in attachment:// must match that of the attached image

spark flint
#

SickBro no problemo

crystal furnace
#

I see I can put shard: auto like some people doing in the bot main file and it work, but this sharding can only set auto and I feel something is different from traditional way.

#

Apart from ShardingManager, discord.js also supports a sharding mode known as Internal sharding. Internal sharding creates multiple websocket connections from the same process, and does not require major code changes. To enable it, simply pass shards: 'auto' as ClientOptions to the Client constructor. However, internal sharding is not ideal for bigger bots due to high memory usage of the single main process and will not be further discussed in this guide.

#

Oh, that is explaining why I am feel strange ://

lament rock
#

the ideal way of sharding is cluster based which means the bot is spread out among multiple VPS' and each cluster manages a couple shards (however many can fit into the VPS without destroying the RAM and CPU)

boreal iron
#

The question is if that is more cost efficient than a stronger dedicated server

#

Load balancing of course makes the most sense especially on multiple machines also to prevent the entire thing from being down once one server is down

#

I Wonder how many servers a bot has to be in to reach the limit of a common dedicated server using an optimized way of handling and caching requests and data

lament rock
#

My bot is TINY and adding more guilds doesn't really increase memory usage. 6.7k guilds can fit into 100MB

crystal furnace
#

Internal sharding working alright

#

It increase only some%

#

Not a very big number if your bot not like Dyno, Probot, ...

#

But this way sharding working better.

#

as discord.js said they will not provide any more information about this, so I am asking here :))

lament rock
#

because it's a not recommended sharding method

#

for public bots

#

even for private bots, you're unlikely to reach any shards other than shard 0

quartz kindle
#

in my experience, internal sharding works fine for at least 16 shards

#

it can probably handle up to 30 something without much issue, depending on your intents and stuff

#

the main thing that destroys your bot is presence events, so leave them disabled if you can, and the initial guild creates especially wjen you have big bot sharding

tired panther
# quartz kindle in my experience, internal sharding works fine for at least 16 shards

Internal Sharding works fine with up to 30k Guilds. The way djs handles shards .... they keep disconnecting and the initial connecting phase takes pretty long. @boreal iron I had to start syncing the ratelimits upon 100k Guilds. You actually dont need no cache, proper ratelimit syncing will allow a cold cache. For the sake implicity you cache guilds & roles.

tired panther
earnest phoenix
#

hi ,url video (youtube) stopping before the song is over ?

#

average distube user

eternal osprey
#

in java, does obj1.equals(obj2) return true if both objects are the same class and if both objects have the same values for the fields?

#

cuz i have only used .equals on strings, and i know there it will check for each character and the type of the passed parameter. So it might be the same?

earnest phoenix
#

Neither

#

It compares the memory address

#

You can always override it in your object though

lyric mountain
lyric mountain
wheat mesa
#

Usually most objects have an overridden equals method

#

But yeah if the method isn’t overridden then it will compare memory addresses of the objects

manic crane
#

ho

severe linden
#

Hello everyone!

hushed robin
#

what’s the best way to round something in canvas I tried but couldn’t get it lined up right

neon leaf
#

this should work fine, right? generally

earnest phoenix
neon leaf
#

Im talking about the interface, how would I try it and see that

quartz kindle
#

compile it with ts, and see if it compiles :^)

crystal furnace
#

And log internal shard events like normal right?

spark flint
#

get the message reference id

#

and fetch the message

#

yes

#

thats what i said

#

get the message reference from message

#
if (message.reference) {
  const msg = await message.channel.messages.fetch(message.reference.messageId)
  content = `<@${msg.author.id}>`
}```
#

thats the code i use for tags and fetching replied to users

spark flint
#

idk then

hushed robin
#
lyric mountain
#

Explained in the first 6 words of the description

hushed robin
#

different backend?

#

which is better

lyric mountain
#

🗑️

hushed robin
#

thats a garbage can emoji

spark flint
#

I use this

#

So it’s the same across devices

harsh nova
spark flint
#

Mobile it shows as iPhone one

#

Same on mac

harsh nova
#

Thonk that's weird

hushed robin
solemn latch
#

I probably would avoid the pre-release one

hushed robin
#

ok

hushed robin
#

how do I check if a number is negative

wheat mesa
#

...

#

if(number < 0)

cinder void
wheat mesa
#

that does not work without parenthesis 99% sure

lament rock
#

the ! coerces the number to a boolean. 0 = false. everything else = true.
then the > symbol coerces it back to a number (0 or 1)

cinder void
#

ahh i see

topaz terrace
#

I'm stuck on the delete warn command. The issue is that when I do .warn @user#6969 reason and when i go ahead and delete it. it says that my case number is not correct. https://sourceb.in/rIglmdVdSv

earnest phoenix
topaz terrace
#

hmm

#

ok

#

hmm what the hell

topaz terrace
#

i tried splitting it

#

and it gave me an error saying that element.case.split is not an function

#

when i log c

#

it shows me an number

#

what is that number?

earnest phoenix
#

Then it's the case number, you don't know what you're putting into your database?

topaz terrace
hushed robin
earnest phoenix
topaz terrace
earnest phoenix
# topaz terrace

That's not how %Array.prototype.findIndex()% works, did you even look at the examples and documentation?

topaz terrace
#

wait

#

i put 1 equal instead of 3

earnest phoenix
#

That still wouldn't work because you're not returning anything to the function you're passing to the findIndex() method

#

It can be (c) => c.case === ... or (c) => { return c.case === ...; }

topaz terrace
#

oh

topaz terrace
#

what does it return

#

undefined?

#

or -1?

wheat mesa
#

@lyric mountain I don't know if you would know about this or not, but is the drawImage method on Graphics2D objects super super slow normally?

earnest phoenix
topaz terrace
#

oh

wheat mesa
#

roughly 90% of my CPU time is spent on drawing images, and my application gets REALLY laggy after I cross about 20 or so "bullet" entities in my swing application

#

Which either this method is slow as fuck or I'm using it poorly

#

And I'm thinking that I'm using it super poorly somehow

cinder void
#

finally made a bot that im proud of

#

only took me 2 years

earnest phoenix
wheat mesa
#

well

#

there's a lot

#

but I'll try to showcase the important parts

#

So, I have a system in my ECS that looks like this:

public class RenderSystem extends ECSSystem {
    public void update(Graphics window) {
        for(int entity : entities) {
            TransformComponent comp = world.getComponent(entity, TransformComponent.class);
            SpriteRenderComponent s = world.getComponent(entity, SpriteRenderComponent.class);
            Vec2f drawPos = comp.position.add(s.position);
            window.drawImage(s.sprite, (int)drawPos.x, (int)drawPos.y, s.width, s.height, null);
        }
    }
}
``` which is where all of the images actually get drawn. Super basic.
```java
public class Canvas extends JPanel {
    private final RenderSystem renderSystem;

    public Canvas(RenderSystem system) {
        renderSystem = system;
    }

    @Override
    public void paintComponent(Graphics window) {
        super.paintComponent(window);

        Graphics2D graph = (Graphics2D) window;

        BufferedImage back = (BufferedImage) (createImage(getWidth(), getHeight()));

        Graphics graphToBack = back.createGraphics();

        renderSystem.update(graphToBack);

        graph.drawImage(back, null, 0, 0);
    }
}
``` this is the JPanel for the entire application. Basically just a raw canvas with double buffering.
sudden geyser
#

🚪🚶‍♂️ Swing

rustic nova
#

Have been there, do not wish to be there again

wheat mesa
#

Here's my bullet class, which is basically just a sprite that moves a little: ```java
public class Bullet extends GameObject {
private static BufferedImage image;
static {
try {
File file = new File("src/com/waffle/test/images/projectile.png");
image = ImageIO.read(file);
} catch(Exception e) {
System.out.println("ERROR: " + e.getMessage());
}
}
private TransformComponent transform;
private SpriteRenderComponent sprite;
private int speed;

public Bullet(int speed, float x, float y) {
    this.speed = speed;
    sprite = new SpriteRenderComponent(new Vec2f(), image, 50, 50);
    transform = new TransformComponent(new Vec2f(x, y));
}

public void update(float dt) {
    transform.position.addY(speed * dt);
}

@Override
public void start() {

}

}

#

All of this is put together in a Game class that has an update method called by a ScheduledExecutorService every 16ms (roughly 60fps)

#

Within that game class, this is basically what that looks like: ```java
@Override
public void run() {
if(window != null) {
this.update(UPDATE_DELAY_MS / 1000.0f);
}
}

public void update(float dt) {
    // Update other systems here
    physicsSystem.update(dt);
    world.update(dt);
    window.repaint();
}
#

I'm thinking MAYBE it's something to do with window.repaint(), but that should be just fine because it's (afaik) just calling the paintComponent method again, aka updating my render system

#

Oh and world is the ECS, world.update(dt) just calls the update method of every GameObject in the ECS

#

However I have confirmed that only 4% of the program execution time is spent on this Game.update(float dt) method, and the majority of the time is spent in renderSystem.update(graphToBack) because of the Graphics2D.drawImage() method

#

So yeah

#

that's my problem

#

lol

earnest phoenix
wheat mesa
#

It's a HashSet of integers given from the ECS

#

Basically just a set of IDs that point to entities with certain components that the System can use

#

Not really important for the scope of the issue

earnest phoenix
#

I feel like it's set is getting much bigger than expected so it's causing the operations in the loop to be called way too many times, making it much slower but that might not be the case

wheat mesa
#

It shouldn't be, I can debug it real quick to confirm though

#

yeah it's accurate

earnest phoenix
#

Hmm, maybe try running the update() method of the Game class (or whatever it's called) with a longer delay to see what happens?

wheat mesa
#

I mean that would decrease the framerate, but I can do that

#

It'll still encounter the same issue after I get too many entities

earnest phoenix
#

It's for testing purposes anyway

wheat mesa
#

Yeah doubling the delay still encounters the same issue after I rack up about 30-40 bullet entities

earnest phoenix
wheat mesa
#

createImage is just a method from JPanel

#

I would profile more to see which method in particular is causing the biggest use of time, but unfortunately about 85% of it tracks back to a native dll that I cannot profile methods of

earnest phoenix
#

Oh wait you're updating it's graphics content with the render system update() method, I see

wheat mesa
#

Yeah

earnest phoenix
#

Unfortunately I don't see what could be causing that

But you can at least profile every method you've declared in all of those classes to see which one is causing the slowness

#

That can definitely give you a hint

wheat mesa
#

unfortunately it all boils down to a dll here

#

that's where the profiling ends

#

Might just have to take a break for the night

#

@earnest phoenix I think I may have figured it out

#

The image I was using is like 1300x1300

#

and I'm resizing it to 50x50

#

I think that maybe a compression/resizing algorithm was taking a lot of time up

#

When I swapped to using a very small res image of like 200x175 I'm getting no lag with 1721 entities on screen

earnest phoenix
#

Very nice, I guess Java Swing struggles a lot to handle high resolution images

#

Maybe you should try SWT

quartz kindle
#

frequent image resizing in any graphics engine is a big no-no

#

thats why games usually have all textures and images in all supported resolutions already resized and available

#

or at least resize once and store the resized version in memory for reuse

lyric mountain
#

But u can speed it up by disabling some things, if u don't mind poorer graphics

#

G2d comes by default configured to "balanced" mode, you can set it to "performance"

#

Also, if you're using swing it's better to use createCompatibleImage

#

And yes, don't resize images in the render flow

hushed robin
#

just check if it includes https:// 🤨

deft wolf
#

Oh

hushed robin
#

so

#

😁

craggy pine
#

You asked in a public discord text channel which anyone can reply in so. 🙂

hushed robin
#

it’s fine he’s just grumpy cus he got something against me

#

😂

lyric mountain
#

(?! ...)

#

Hm, nvm then

#

What u trying to do?

#

Oh, btw

#

U added an space behind https

#

I added it in the example to keep it readable

#

But u shouldn't since it'll attempt to match an space

lyric mountain
#

What ur using it for?

#

Yes, but what context?

#

Can't u just replace the link matches with nothing?

#

Still, can't u just replace?

#

Regex is best for matches, not inverse matches

craggy pine
#

That could be rather difficult to match due to how many options there are out there.

#

.com, .net, .xyz ect

earnest phoenix
#

The global URL class will throw an error on any invalid input provided, so you can use that approach

earnest phoenix
quartz kindle
#

OwO?

earnest phoenix
#

Good catgirl

earnest phoenix
#

That would pretty much be impossible to do with just regex, mainly because some parts of a URL is optional and declaring that will cause the regex to also match certain parts of the URL when you don't want it to

#

You would need an actual URL parser to do that

hushed robin
#

guys

#

how do I get every other row in sql

#

then every third row

#

and fourth

#

and fifth

#

etc etc

solemn latch
#

oh, interesting.
I have no idea

hushed robin
#

ok Ty

#

will look into this

#

what that guy is doing is exactly what I’m doing too lol

#

need it for a line chart

surreal sage
#

Maths question

#

I want to get the opposite of a number

#

E.g 360 = 0
0 = 360
180 = 180
90 = 270

#

How do I.

#

E.g in JavaScript

rustic nova
#

What are you referring to with "opposite of a number"

surreal sage
#

Seems like 360 - x

#

ChatGPT says (360 - x) % 360

rustic nova
#

chatgpt sucks

#

what are you referring to with opposite of a number

wheat mesa
#

You mean the complimentary angle to add up to 360?

surreal sage
#

There's a minimum and a maximum

#

The max in my case is 85

wheat mesa
#

Just 360 - x

surreal sage
#

Yeah

#

Lemme see

#

Yeah seems to be it.

#

Thanks.

surreal sage
#

Minus minus x = Plus x

#

And zero is not my minimum, it's -45

#

Ig I can increase with 45 and decrease with 45 later

lyric mountain
#

always normalize your ranges

quartz kindle
#

(angle % 360 + 360) % 360
this will put any number, positive or negative, in the range 0-360
then you can further add another ( + 180) % 360

neon leaf
#

so lets say I have an interface like this:

interface TestIdk {
  type: 'ok' | 'ok2'
  message?: string
  error?: string
}```
how would I make typescript know that message is always defined when type is ok & error is always defined when type is ok2?
solemn latch
#

Tim knows the answer, I'm just going to guess for the fun of it.

a typeguard? 🤷

quartz kindle
solemn latch
#

oh neat

neon leaf
#

oooh

#

interesting

#

how would I make a class thats an eventemitter with typed events?

quartz kindle
#

you can try implementing an interface that overrides the on method

surreal sage
#

Hey hey another shitty math question

#

So

#

I have my screen height

#

I convert that into a percentage

#

I then have 360 (degrees) / 100

#

Aka 3.6 degrees per 1%

#

But now

#

I don't have 3.6 exactly

#

Here comes the tricky part

#

The degrees' minimum is -45 and maximum 85

#

And uhhh

#

😨

#

I don't know.

quartz kindle
#

so you want to make like a pie slice fit fullscreen?

surreal sage
#

Lol no

#

So basically

#

(This is Roblox stuff)

#

I have an arm

#

The arm has a tool

#

The arm should move up and down based on the mouse's Y position

#

Now I don't want the arm to be able to do a looping

#

So I want limits

#

Being -45 and 85

#

I'm just stuck on how to do this

quartz kindle
#

so 0 would be horizontal center

#

-45 would be down swing

#

and 85 up swing?

rustic nova
#

Didnt glitch ban these?

#

Against their tos iirc

lyric mountain
#
    @Override
    public void fillOval(int x, int y, int width, int height) {
        GL2 gl = buffer.getGL().getGL2();

        float[] xy = {
                (2f * x + 1) / WIDTH - 1, (2f * y + 1) / HEIGHT - 1,
                (2f * width + 1) / WIDTH - 1, (2f * height + 1) / HEIGHT - 1
        };

        System.out.println(Arrays.toString(xy));

        float detail = 45;
        gl.glBegin(GL_POLYGON);
        {
            double step = Math.toRadians(360 / detail);
            for (double i = 0; i < 360; i += step) {
                gl.glVertex2d(xy[0] + xy[2] * (1 + Math.cos(i)), xy[1] + xy[3] * (1 + Math.sin(i)));
            }
        }
        gl.glEnd();

        gl.glFlush();
    }
#

So, regardless what I put in glVertex2d() it doesn't move the circle

#

Ex kept if I change the multiplication, then it makes it bigger

#

I actually stopped midway when trying to debug, which is why the sout is there

#

gl.glVertex2d(xy[2] * Math.cos(i), xy[3] * Math.sin(i))

#

This will put the circle in the middle of the canvas

#

As soon as I get to the pc I'll run the code to show what it's outputting

#

Think I'll change the scale to allow me to use pixel coordinates, instead of the weird ogl mid-pixel percent coords

wheat mesa
#

Yeah usually you use a projection matrix for that

lyric mountain
#

heh, simply fixing the coordinate matrix solved it

#

(x: 0, y: 0) | (w: 250, h: 250)

#

(x: 250, y: 250) | (w: 100, h: 100)

#

and I no longer need to do big conversions to get the correct coord

wheat mesa
#

niceee

#

I now have an fps counter in my engine

#

pretty basic (also don't worry about the rocket ships I was stress testing a little)

#

for some reason though I'm not able to use ScheduledExecutorService to get accurate frametime, I'm measuring 64-65 fps when in theory it should be running at a max of 60

#

I would understand if it was less than 60fps, but greater than 60fps would require the service to be executing early which doesn't make much sense to me

#

@lyric mountain you have any idea why this might be happening?

hushed robin
#

how do i use clip twice in canvas ☹️

wheat mesa
#

timer is the ScheduledExecutorService btw

lyric mountain
#

converting fps to nanos might generate some precision issues

#

especially since ur fpsCap is float

#

u can simply use millis for update rate, don't think you'd ever use a cap of 1000

wheat mesa
#

I suppose I could come to a compromise on frame precision and use microseconds so I can still get in-between ms values

#

ehh

lyric mountain
#

also, instead of an sched service u could use an infinite loop + sleep

wheat mesa
#

By using millis only I can't get good precision

lyric mountain
#

I mean, yeah, but the difference would be minimal

wheat mesa
lyric mountain
#

java sleep only pauses the current thread, it doesn't work like c++ or alikes where it freezes the whole thing

wheat mesa
lyric mountain
#

ah

wheat mesa
#

I'll try using sleep rq and see if I run into any issues

lyric mountain
#

just make sure you create a new background thread

#

u can use extends Thread on your game to have itself be a thread

wheat mesa
#

Alright so using sleep seems to get a little more precise on the delay

lyric mountain
#

sleep is much more precise than sched because it tells the cpu to pause that thread

#

while sched works with queues

wheat mesa
#

ugh I hate how sleep doesn't allow you to use nanos or micros

#

requires millis + nanos

#

so annoying

#

might just make a helper method rq to fix that

lyric mountain
#

u can make a somewhat gambiarra function to get even higher precision

wheat mesa
#

I always forget, does casting truncate decimals or round them?

#

truncates right?

lyric mountain
#

truncates

wheat mesa
#

ok

lyric mountain
#

always down

quartz kindle
#

love me some gambiarra functions

wheat mesa
#

ok so now I'm realizing why I originally didn't use sleep

lyric mountain
#
long pause = ...;
long end = System.nanoTime() + pause;
do {
  Thread.onSpinWait();
} while (System.nanotime() < end);
wheat mesa
#

doesn't that burn cpu cycles really badly

#

or is it fine to use

lyric mountain
#

if ur waiting for a very small period of time it doesn't matter much

#

also onSpinWait() tells the cpu that loop will be going for a while

wheat mesa
#

I also need to think about the math here

#

Since I need to sleep a different amount of time depending on how much time the last frame took to execute

lyric mountain
#

did u manage to antialias with opengl?

wheat mesa
#

no lmao

#

I did not get that far

lyric mountain
#

flag disabled

#

flag enabled

wheat mesa
#

I left off trying to use Nuklear to make basic UIs

lyric mountain
#

all it does is get a bit thicker

wheat mesa
#

and that was too painful

lyric mountain
#

actually, I found out why it wasn't smooth

#

I was (again) using degrees instead of radians

#

now it's one sexy circle

#

and now I have this issue 😔

hushed robin
quartz kindle
hushed robin
#

ok

lyric mountain
#

managed to fix it by using GL_ONE instead of GL_ONE_MINUS_SRC_ALPHA for blending type

hushed robin
#

yay it worked

#

w

wheat mesa
lyric mountain
#

really?

#

what's the difference between both btw

wheat mesa
craggy pine
#

For javascript w/ html css. What's the difference between getElementById and GetElementByClassName? Why does only byId let you do <element>.style while className does not

lyric mountain
#

only one element can have a specific id

#

but many elements can have the same class

craggy pine
#

Gotcha

#

I just found it weird you can css both Id's and Class' however.....

#

in JS you can't edit the style with class'

lyric mountain
#

it's cuz getElementsByClassName returns more than one element

craggy pine
#

I see

#

so its an array and I'd have to chose the specific one

lyric mountain
#

yep

craggy pine
#

Makes sense.

#

Finally deciding to try to get better with web design basics and that kinda tripped me up

lyric mountain
#

that's why ids are generally better if ur going to access a certain element many times

craggy pine
#

ya makes sense.

quartz kindle
#

also, they both do different document transversal

#

byID is faster because html ids are kind of put in a fast access table

#

byClassName requires a document scan to find them

craggy pine
#

Interesting.

#

Ty for the info 🙂

quartz kindle
#

stuff like document.getElementByID(...).getElementsByClassName() can be used for optimization purposes, to narrow down the area that is scanned

hushed robin
#

how much cpu does canvas use ⁉️

lyric mountain
#

but then idk how to fix the circle strike issue, it's probably because it's trying to blend with the background

#

hm, maybe if I increase the line width

hushed robin
#

why won't these load

#

actually it's just the bottom one

#

the top one loads

quartz kindle
#

instead you should use the weigth and style optinos

#
registerFont("...", { family: "Manrope", weight: "SemiBold" })
registerFont("...", { family: "Manrope", weight: "ExtraBold" })
hushed robin
#

ah ok

#

also

#

does node-canvas support emojis?

#

like the colored ones

quartz kindle
#

no idea, never tested

#

but in theory it should support anything that the font file supports

#

i've used it with custom fonts and custom font files with custom symbols

hushed robin
#

well with the other canvas emojis seemed to work by default

#

with this one they’re the weird black ones

lyric mountain
#

Emoji is dependant on the font itself

hushed robin
#

this is the same font

#

with napi-rs/canvas the emojis had color

#

with node-canvas they don't

#

which is a little disappointing but seeing how horrific napi-rs/canvas does with memory it's ok 👍

radiant kraken
#

@earnest phoenix

#

i love github so much

rustic nova
#

Oh shit yeah, the code viewer beta

#

Useful asf

earnest phoenix
#

Bit buggy sometimes, quite often actually

rustic nova
#

Not experienced yet

earnest phoenix
#

Doesn't find references etc.

#

So I rather use the web ide and search there kek

rustic nova
#

It is able to find references from the same repo

#

Ofc not the ones that are for example included in a package and not directly in the repo

earnest phoenix
#

Well that's obvious kek

radiant kraken
earnest phoenix
lyric mountain
#

nice, now I can also draw arcs

quartz kindle
#

pizza

pearl mantle
#

.

lyric mountain
#

how should I approach shapes like this? (green is the desired shape, red is the actual shape)

#

both have the exact same coordinates

#

the issue of the red shape I imagine is because the poly area is calculated from the point of origin (top left)

#

the obvious fix would be starting from the middle in this case, but there's probably a mathematical way of finding the correct initial point

#
GL2 gl = canvas.getGL().getGL2();

gl.glBegin(GL_POLYGON);
{
    for (int i = 0; i < nPoints; i++) {
        gl.glVertex2i(xPoints[i], yPoints[i]);
    }
}
gl.glEnd();

gl.glFlush();
``` current code, just in case
#

hm, maybe calculate the bounding box's center and grabbing the nearest point?

noble python
#

hey

#

am getting this error but idk what's wrong with the package

#

._. and its needed for database thing

quartz kindle
#

libraries that use native code must be recompiled when the node version changes

#

you can do that by uninstalling and reinstalling the library

noble python
#

i guess v17 would be good?

quartz kindle
#

how did you reinstall it?

noble python
quartz kindle
#

deleted how?

noble python
#

shall i try npm rebuild?

noble python
quartz kindle
#

run npm uninstall

#

npm uninstall better-sqlite3

noble python
#

ok

noble python
quartz kindle
#

npm install better-sqlite3

noble python
noble python
#

uhm its giving error

#

@quartz kindle ?

quartz kindle
noble python
quartz kindle
#

show

noble python
#

@quartz kindle

quartz kindle
#

v8 normally installed and v7 installed by the package enmap

#

the one that is giving the error is the v7 one used by enmap

#

if you really need enmap, check if there is an update that uses the newer version

#

otherwise try removing it and see if the newer version of bettersqlite works

radiant kraken
#

@quartz kindle @earnest phoenix do you guys think this is safe from race conditions? ```c
// a global bool
bool gInitiated = false;

void someCleanupFn() {
if (gInitiated) {
gInitiated = false;
// ... code ...
}
}

// someCleanupFn is added to several close event handlers - that may be called from different threads

#

or should i use a Mutex instead

#

[and also @wheat mesa]

quartz kindle
#

generally it is safe yes, although it depends what exactly it is cleaning up and how it affects other threads

#

also the cleanup function itself might need a race condition protection if there is a possibility a new gInitiated is created while the cleanup function is not done cleaning the old one yet

wheat mesa
#

Personally I would use a lock just to be safe

#

But I don’t do multithreading often

earnest phoenix
wheat mesa
#

The general advice is whenever you have data that can be read and modified by more than one thread at a time you want to use a lock

#

Also is a lock the same thing as a mutex

#

Only reason I ask being that my CS class generally uses the term lock for these situations

quartz kindle
#

when the OS uses files for mutex purposes its also called lockfile

earnest phoenix
#

Depends on what you refer to as a "lock", it's not the same terminology used for only these situations, it could also be used to keep track of lock files

wheat mesa
#

Just looked it up, mutex is just a type of lock

#

“Mutual exclusion lock”

quartz kindle
#

also, back to the original question, usually multithreaded languages and systems have functions that only modify something if the current value of something matches the expected value

#

atomic operations are usually done that way, something like modifyVariable(new value, expected value) // only executes if the varuable's current value matches the expected value

#

and it executes the value change in an guaranteed atomic manner

wheat mesa
#

I’m assuming this is C or C++ from looking at the syntax, and I’ve only really done multithreading in Java so I can’t really help too much

quartz kindle
#

im also mostly basing myself from how JS does it with sharedArrayBuffer

#

but its probably better and safer to use a higher level C++ mutex than low level instructions like these

lyric mountain
#

trynna do in-place array rotation, but I can't figure out how to do it with O(n) complexity

#

like, I always lose some indexes based on the jump size

#

for example, with jump size of 1 I lose the value of the leftmost index

#

with jump size 2 I lose the leftmost 2

#

this is what I have currently, I have no idea how to achieve that without resorting to a second array or O(nx) complexity

quartz kindle
#

cant you use a simple variable to hold the missing value, then re-place it at the end of the loop?

lyric mountain
#

issue is the missing value is "values" for jump > 1

#

guess I'll just go with O(n+x) for now, wost case it'll be O(2n)

#

which is creating a new array with size equal to jump size

quartz kindle
#

but no matter how many jumps you do, you are always reading+writing one element at a time, so you will need at most one temporary element

lyric mountain
#

no, I mean, it'll always iterate array.length times

#

I'm not using recursion to prevent falling into O(nx)

#

like, an array with 5 elements and jump size of 3 would be shifted 3 times, so 15 operations (3 read/writes per entry)

quartz kindle
#

hm

quartz kindle
#

it claims to be o(n) speed with o(1) storage, but its still creating temporary values

lyric mountain
#

not the best way, but it does pass all tests

lyric mountain
#

but with one less loop and inverse iteration

quartz kindle
#

its really interesting tho, im reading more in depth now trying to understand it

#

it doesnt iterate through the whole array

#

i mean it does, but not in a loop form

lyric mountain
#

now I can return to the original issue lul, spent 3 hours finding out how to rotate an array

#

such an apparently trivial question but never stopped to think on how to do it in-place

quartz kindle
#

the second answer from here explains better the GCD concept

lyric mountain
#

saw that answer

quartz kindle
#

i guess you cant get faster that that

#

each element is only read/written once

#

unless creating a new array is somehow faster

#

but i doubt it

lyric mountain
#

I couldn't undestand that specific answer

slender wagon
#

? Would you like to use experimental app/ directory with this project? » No / Yes

#

noticed this while installing nextjs

#

what's it about

lyric mountain
#

yay, it worked

earnest phoenix
#

too much java out here

lyric mountain
#

made an algo to calculate boundaries and center, then rotated the coordinate arrays to leave the nearest point as first index

#

now I can draw relatively complex shapes

#

as long as lines don't intersect tho, but that's something for another day

#

it gets funky when lines intersect

quartz kindle
#

xD

#

doesnt your lib have functions for path filling tho?

#

or do you have to reinvent even that

lyric mountain
#

I'm using opengl so...well

#

just found out opengl has a thing called GLU that tesselates irregular polygons

quartz kindle
#

isnt GL_POLYGON supposed to support filling?

lyric mountain
#

it does

#

but it works the same way as GL_TRIANGLE_FAN

#

basically connects all vertices to the first vertex

#

which is why that's happening

quartz kindle
#

i see

hushed robin
#

why isn't the font applying was working earlier ☹️

lyric mountain
#

Are u supposed quote it?

hushed robin
#

no

lyric mountain
#

Then unquote

#

When in doubt search google how to define canvas font

hushed robin
#

they quote it in the examples

#

i'm not sure if it's something obvious but it was working earlier 😵‍💫

wheat mesa
#

“It was working earlier” is literally the most common thing we see in this channel. You have to have changed something since then otherwise it would still be working

hushed robin
#

well

#

idk

#

this is how i'm registering it

#

and uh it just doesn't work

wheat mesa
hushed robin
#

same thang

lyric mountain
#

Try without px

#

Also try downloading the font again

hushed robin
wheat mesa
#

Are you registering the font before creating the canvas?

hushed robin
#

that is not the issue

#

the sizing is fine

wheat mesa
hushed robin
#

yeah

wheat mesa
#

Is ExtraBold even a real weight? That doesn’t make much sense

hushed robin
wheat mesa
#

I know but I’m pretty sure that’s not a thing

hushed robin
#

what's not a thing?

wheat mesa
#

Just because you “register” it as ExtraBold doesn’t mean that ExtraBold exists

hushed robin
#

how

wheat mesa
#

Weight should be a number or something like "bold"

#

Look at this

hushed robin
wheat mesa
#

You haven’t shown your other font

#

I’m not a wizard

hushed robin
wheat mesa
#

These should be your only options in terms of weight

#

And a number ofc

hushed robin
#

hm

#

how was it working earlier then

wheat mesa
#

I don’t know

#

It probably had a default

#

It doesn’t matter how it was working because it’s still wrong

hushed robin
#

buttttttttt

#

if it was wrong how was it working

wheat mesa
#

My man

#

I’m not going to argue with you over this because you’re going to drag it on for an hour

hushed robin
#

well I'm just asking your saying it's wrong yet it was working with setting the font weights as I was right now earlier

quartz kindle
#

what did you change between the "it was working and now its not"?

hushed robin
#

idk tbh

lyric mountain
#

The only weights I know are bold, bolder, boldest and black

#

And the thin variants

#

Tho never checked if js has them too

obtuse hinge
#

Hi, I am trying to make a bots site, but I don't know how to make a system to avoid the dm all by the bots. I am using python and flask

wheat mesa
#

Huh?

obtuse hinge
#

I mean when I add the bots to the server, is there any way to prevent the bots from doing dm all in case they are scam bots?

wheat mesa
#

You can prevent bots from DMing a ton of members in your server by not adding them to your public server in the first place

#

That’s why you test bots in a private server

#

Also it’s a bad idea to add a ton of bots to one server anyways, top.gg learned the hard way on that one

obtuse hinge
obtuse hinge
hushed robin
#

then just don't add it there's no way to stop a bot from dming people

#

unless they disable their dms

wheat mesa
quartz kindle
prime herald
hushed robin
#

is it a good idea to put everything in a try catch

wheat mesa
#

Depends on what you’re doing

quartz kindle
#

it doesnt make much difference today, but a few yeats ago try catch would make your code slower

sudden geyser
#

applying java logic, you should let exceptions float up the call stack until some code which is appropriately fitted to handle it catches it

#

so if you do catch try only catching what matters

sudden geyser
#

putting your main call in a try catch is probably not useful in of itself

radiant kraken
#

@quartz kindle @earnest phoenix how is this valid

sudden geyser
#

see this meme as a demonstration

hushed robin
#

why object promise

solemn latch
#

Await, or .then the promise

hushed robin
#

i do await ☹️

hushed robin
wheat mesa
#

Like, a .map?

hushed robin
#

yes

wheat mesa
#

Yeah no don’t do that

hushed robin
#

bruh

wheat mesa
#

You are not meant to use async functions in map operations like that

hushed robin
#

um

#

then what am i suppose to do

wheat mesa
#

Just loop through and push the result to a new array?

#

@quartz kindle could probably elaborate better than me on the async thing

hushed robin
#

sounds like extra effort

#

☹️

quartz kindle
#

if you want to concurrently resolve multiple promises, you can combine .map with Promise.all()

hushed robin
#

idk what a Promise.all() is

quartz kindle
#

a built in function to resolve multile promises at once

hushed robin
#

bot said no

quartz kindle
#

because it itself is also a promise

lyric mountain
#

"bruh"

quartz kindle
#
const result = await Promise.all([promise1, promise2, ...])
result.join(...)
hushed robin
#

ok

#

let me see

#

it says .join is not a function

#

👁️👄👁️

#

i think waffles suggestion is easier than this even tho it's extra effort

quartz kindle
#

then yoi did something wrong, but yeah you can also await in a for loop

#

althougj awaiting in a for loop is sequential and not concurrent

wheat mesa
#

He probably did await Promise.all(…).join(…)

quartz kindle
#

probably

lyric mountain
#

Btw waffle, did u ever work with stencil?

#

Like, glStencil

wheat mesa
#

Nope

#

My opengl work was very limited so far

#

I plan to return to it later on to learn it more

#

Either with jogl or C++

lyric mountain
#

Meh, I need to add arbitrary shape support to the lib

#

But glScissors only allows rectangles

wheat mesa
#

Can you not just define vertices and use glDraw(GL_TRIANGLES, …)?

lyric mountain
#

Ah, I mean arbitrary shapes for clip

#

Not for drawing

wheat mesa
#

Ahhhh

#

I see

lyric mountain
#

The one abt making polys will be solved with tesselation

#

If I undestood glStencil correctly it can be done through bitmasking, but there's probably a more efficient way other than iterating over a shape's area

hushed robin
wheat mesa
#

🤦‍♂️

hushed robin
#

what's wrong

quartz kindle