#development
1 messages · Page 2035 of 1
in my school not really
they teach you about old architectures of the CPU
like really old
back when cpus only had one general purpose register
it teaches you about how we got where we are today 🙂
and how utterly hopeless we all are
and how one major disaster means back to stone age because nobody actually knows how anything actually works
The usual activity of uninformed people casually scaring other people of a "world ending" scenario while nothing is actually going to happen, or at least nothing so bad
It's actually annoying when people talk about stuff they have no idea about
hey tell that to mr putin :^)
Putthatout
Tim’s dream, somebody finally pressing the red button
And he wouldn’t need to finish his API anymore
As well as the 5000 unfinished projects

meanwhile the guy developing API for the red switch

lmao
idk
here's a simple count app ```js
<script>
let count = 1;
// the `$:` means 're-run whenever these values change'
$: doubled = count * 2;
$: quadrupled = doubled * 2;
function handleClick() {
count += 1;
}
</script>
<button on:click={handleClick}>
Count: {count}
</button>
<p>{count} * 2 = {doubled}</p>
<p>{doubled} * 2 = {quadrupled}</p>```
no useHook nonsense
this is insanity I hate it
so much compiler magic involved you don't even know what the code is doing at this point
rather have that than a virtual dom nonsense
i'm still pretty new to it, but it's nice so far
using labels for variables seems like madness, why do we need this level of abstraction I don't understand
I don't want things to feel like I'm incrementing a variable if that's not what's going on under the hood. Vue is guilty of this too imo
i feel the same way whenever i look at react code
svelte doesn't allow you to write a function that returns a component which is weird at first
but react is just regular js that is built on top of a few rendering rules
my ideal js framework is no framework but the way browsers work by default leaves so much to be desired idk
react has a shit ton of modules and functions and classes that do things for you, so you have to learn how to write web pages almost from scratch
with svelte besides some minor differences, i still feel like im writing actual html+css
you cant write a function that returns components. that a big different there
the label magic is kind of a deal-breaker to me
it feels like a js program that somehow creates html for you
I mean in a way that's what it is yes
what do you mean by labels for variables? the count is defined at the top like a normal variable let count = 1;
yes but anything else you want re-computed needs a label for it. Normally it does nothing but svelte's compiler looks for a magic $ to rewrite code under the hood to make that reactivity happen and I don't like things being that far abstracted from me
you like writing the useState and useHooks stuff better?
I feel like a simple function call would suffice, tbh.
onChange(() => {
// Code here...
}, [variable1, variable2]);
allows to be more explicit, too.
I like that I understand exactly what it does and it doesn't generate code for me
The compiler would still remove it
also I like react's philosophy of no-mutations a lot more
that is a good philosophy
but that has its own bag of issues that come with it
wait what does the actor model have to do with that
mutations
actors don't share mutable state with other actors
actor is purely functional until it changes state(mutates) for the next message
also I don't think the idea of an actor specifically says anything about mutation. Elixir is built on that idea and doesn't allow mutable state but ponylang does
think about the back account example
the balance mutates after a deposit message
they dont create another actor with a new balance
yeah but that behavior is opaque to the person sending the deposit message. You can implement it that way and the caller wouldn't know or care
yep, the message gets sent to an address and all you get is the ACK
then the actor does pure function stuff based off it's current state and then mutates its state for the next message
mhm
it's probably the best way to handle mutation
const DIG = require("discord-image-generation");
const Discord = require("discord.js");
module.exports = {
config: {
name: 'rip',
description: 'RIP!',
aliases: ["rip"],
usage: '',
group: 'fun',
},
run: async (bot, message, args) => {
// const m = bot.findMember(message, args, true);
let user = await message.mentions.members.first() || message.guild.members.cache.get(args[0]) || message.guild.members.cache.find(r => r.user.username.toLowerCase() === args.join(' ').toLocaleLowerCase()) || message.guild.members.cache.find(r => r.displayName.toLowerCase() === args.join(' ').toLocaleLowerCase()) || message.member;
let m = await message.channel.send("**Please Wait...**");
let avatar = user.user.displayAvatarURL({
dynamic: true,
format: "png",
});
let img = await new DIG.Rip().getImage(avatar);
let attach = new Discord.MessageAttachment(img, "rip.png");
m.delete({ timeout: 5000 });
message.channel.send({ embeds: [ attach ] });
},
};```
your message needs a description too
but where?
on this let attach = new Discord.MessageAttachment(img, "rip.png");
attach.description = "things"
and message attachment probably isn't an embed
so js Discord.MessageAttachment(img, "rip.png"0: attach.description = "things"?
make a new MessageEmbed() and perhaps there is an setAttachment method
here's a full example
https://discordjs.guide/popular-topics/embeds.html#using-the-messageembed-builder
so remove img, "rip.png"?
const { MessageAttachment, MessageEmbed } = require('discord.js');
// ...
const file = new MessageAttachment('../assets/discordjs.png');
const exampleEmbed = new MessageEmbed()
.setTitle('Some title')
.setImage('attachment://discordjs.png');
channel.send({ embeds: [exampleEmbed], files: [file] });```
like this?
yep
this doc will show you exactly what you need to do
https://discordjs.guide/popular-topics/embeds.html#attaching-images
i did it wrong i think
ok what do i do to fix it?
read the link Ben posted
i am
i am confused
…
Usual developer that lacks the ability to read

no you didnt get it
Sometimes I wonder how clear one must be in this channel for someone to understand things
what did i do wrong?
read this ^ carefully
you need BOTH MessageAttachment AND MessageEmbed
I don’t understand where this extra parenthesis is coming from
what line?
you're just blindly trying out random things instead of reading and understanding lol
Take a closer look
line 31 im guessing
Chance you find it is 1 out of 8
lmao

The ); in line 28 is unnecessary, I'm getting the feeling that you don't know JavaScript fundamentals
i do understand
And to dumb it down for you in literal steps instead of reading and understanding, you also need to use the attachment:// as a prefix in the setImage() method for it to consider using the attachment you've just attached to the message
also, you didnt add the actual image data to the attamcjment
you just added a name
And the timeout option in the <Message>.delete() method was removed in discord.js v13, use setTimeout() instead
Well yeah using the right path would also help a lot
There's a button called Delete in your bot's Top.gg page
Thanks
@quartz kindle i really dont like the C and C++ api for reading/writing to files
so i might just write my own
after all great ideas spark from problems
C++ ones is slow and overly complicated
C ones is buggy as hell
tho if i have to deal with shit like sectors and paging i'll pass
i need a suggestion
say my api takes in an array of object ids, and returns data for said object ids
if an object id is invalid, would it be better to remove it from the return value and put it in some kind of errors array, or keep it in the return value but replace it with some kind of error indicator
like
input => [a,b,c,d,e]
result => { result: [a,b,c,error,e] } or { errors: [d], result: [a,b,c,e] }
tricky
dont like the "error instead of object" thing
usually youd just make it fail alltogether or ignore the failed ones
former
@_@
'='
my old api returns an object instead of an array, like this: { a: result, b: result: c: result, d: error, e: result }
but somehow i dont really like it because it makes it harder for the end user to iterate over it
which is what they will want to do 90% of the time
but i guess they can iterate using the array they sent in the first place and just map the ids
Why not something simpler like null for invalid id and false for no result people can read in your documentation
because there are different types of errors
its complicated
lmao
some specific configurations or invalid options invalidate the entire request and return 400
other configurations should invalidate only specific object ids
for example id is not valid, or id cannot be calculated using those specific options or id cannot be calculated for that specific date
I see but since you’re returning the exact same order like the input I would not return the error as separate key
Inputting 5 items and getting 4 back and an error under a different object key is confusing
i can replace the errored one with something like { error: error message }
since all items return an object
Oh all items are an object?
basically yeah
I would still prefer the first version
so basically
You gotta be consistent
[a,b,c,d] => [{id: "a", a:1, b:2}, {id: "b", a:99, b:55}, {id: "c", error:"abc"}, {id: "d", a:500, b:200}]
lmao
We don’t work well together tonight sir

Yeah you changed to what i was writing actually
Keep the key, c in that case with its data as null and add an extra key error with the message as value
replacing with null i already do in a different scenario lmao
if only parts of the object are possible to calculate
the parts that are not possilble are nulled
anyway i g2g
kthxbb
be back later to change more answers while you type
thats what my roblox friends used to tell me when they were hopping off
You got friends?

alright fake

sorry i am currently using a premium web framework
It's okay fake doesn't have friends either
best thing about the english language
you can say "fuck the fucking fucker" and its both gramatically and semantically correct and makes sense
I think the word fuck is about right in any possible form within the American English
I, you, he/she/it fuck(er/ing/s/…)
You know


get a bigger screen
i'll just paste it as text
objectTypes: "PACHLMTSX", // planets, asteroids, comets, hypotheticals, parts, moons, sats, stars, points
extendedObjectTypes: ["PA", "PP", "PN", "PS", "PF", "AA", "AP", "AN", "AS", "AF", "LD", "LN", "L!", "S@", "S!", "H!"],
lmao
And where’s the mess?
im trying to organize all the possible object types into categories, but it gets a bit complicated
all object ids start with a letter, or 2 letters, followed by a number or any information about it
for example P5 would be planet 5, A30 would be asteroid 30, etc
but then some of them are extended or combined, like PA5 would be the aphelion of planet 5
but now i need to add another type
that is basically a midpoint between any 2 existing types
and idk what kind of syntax i wanna use
Poor Tim, needs to categorize the entire verse
something like[P5, A5]
or $P5+A5
idk
$[P5+A5]
but
the type L! already does this, but with 3 objects, for example L!P5,A5,X5
but the calculation used in L is different, so i need to add a new one anyway
lmao
About 20 message above my brain stopped understanding anything
lmao
1000 bucks and im yours
lmao
Totally okay for me as long as you keep your clothes on your body
:D

lmao
member.user.presence.status
Cannot read properties of undefined (reading 'status')
what did they change it to?
I'm creating my first bot after like 3 years so ion know anything bout the new api
an users presence requires a privileged intent
iirc
As well as the gateway intent
In your case means that the property presence is undefined
I think I got it enabled, or is it verified bots only? I created a new bot cause I can't change the name of my verfied one
if not then most likely I enabled it
Check if you also have the gateway intent
either way what do I change it to if I want to fix it?
Hi, if anyone has some context around GitHub actions & you're available, I need some help with this: https://github.com/mkdocs/mkdocs/issues/2839
thanks in advance for any help
yeah all 3 intents are checked
are you using discord.js v13?
yep
did you also add them to the intents option in your client?
new Client({ intents: [your intents here] })
intents: [ Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.DIRECT_MESSAGES ],
hold on
what are all the intents I need called again?
GUILD_PRESENCES
still doesn't work
I have no idea what that is supposed to mean
lol now I see it, too
....
member.user.presence lol
ohhhhhh
my bad
@quartz kindle so it does work when I use it on myself but it doesn't when I mention
why?
the data is not cached
presences only get cached when the member is active, for example when they send messages, etc
you have to fetch the member to get them if they are not cached
there is only one way to fetch presences
await guild.members.fetch({ user: ['66564597481480192'], withPresences: true })
yes and no
sure you can
great
nevermind that didn't work for some reason
thought if I had a || it would ignore the error
what error?
i personally do member.presence?.status
why is this giving me a fucking error
because \ is an escape character
meaning, "treat the next character as a literal string no matter what"
so it makes the second ' become part of the string, and not the closing of the string
then how else am I supposed to write a path?
ah I didn't think it would work because __dirname returns a path with \ if I'm correct
windows is smart enough to know how to handle both \ and /
even when mixed together
but linux for example only uses / and does not support \
so using / is also better for compatibility
I wonder why people dont use path.sep more often
😔
not many use cases for it?
i never needed to split a path into an array of path names
wait wut
path.sep is the separator for windows and linux
depending on the platform it either uses / or \
oh, I use path.sep when I am looking up files that can be on linux or windows
ye
I've had cases where using __dirname bugged out for some reason so I had to do the full path myself
lel weird
@quartz kindle did they change statuses as well?
TypeError: Cannot read properties of undefined (reading 'clientStatus')
client.users.cache.get(message.mentions.users.first().id).presence.clientStatus
Users don't have presences, guild members do
so again just chening message.mentions.members will work?
It should, and just use the user/member returned instead of getting it from the cache again
why are you getting from cache something that you already have
what do you mean?
message.mentions.users.first() and client.users.cache.get(id) both give you exactly the same thing, it makes no sense to use one to get the other, its the same as using something to get itself again for no reason
oh I got you now
wait really?... I think I mixed that up with c#......
but yea I figured it out
actually if it doesn't why did my intellisense show the function as if it was a real thing
no way it mixed up the languages
Cannot read properties of undefined (reading 'Util')
let parsed = Discord.Util.parseEmoji(emoji);
What is Discord
this is Discord
@ripe prairie
why does this return null?
I'm not aware of what discord changed in the API but this should return the first message
after takes a snowflake, not a number
what is a snowflake?
an ID
huh?
they must've changed that because it did work on previous discord.js version
is a Snowflake
well, 1 could be considered a Snowflake, but it would be the earliest message ever
ReferenceError: result is not defined
idk
that is quite weird
The after option in the <TextChannel>.messages.fetch() method takes the ID of the message you want to fetch after
{ limit: 1, after: 1 } does work for me
(which is a nice little trick to get the first message in a channel, i havent thought of doing that before)
you are once again doing the exact same thing twice
using a message you already have to get the exact same message again for no reason
plus you're doing the second one wrong, thats why you're getting that error
Can’t even find limit or after in the base fetch options documentation lol
While I can find limit as option in one code example
Why I get this err?
const roles = await member.roles
.fetch()
.sort((a, b) => b.position - a.position)
.map((role) => role.toString())
.slice(0, -1)```
```console
TypeError: member.roles.fetch is not a function```
interaction.member or message.member
const member = await interaction.guild.members.fetch(target.id)
<GuildMemberRoleManager>.fetch() method does not exist
https://discord.js.org/#/docs/discord.js/stable/class/GuildMemberRoleManager
I have a navbar which sits on top of everything with a fixed position, but elements under it ignore it and go over/under the navbar and not after it, any fixes?
do I have to apply a margin offset or something?
Yeah by creating a wrapper around the other content and using padding-top (navbar height) not margin
Also make sure to assign a z-index to the navbar to make sure it’s in front (always)
i still dont know the difference between padding and margin
padding inside margin outside
@quartz kindle @dry imp @earnest phoenix i learnt codingg!!
Les goo
i learnt html and css basics
i'm pretty good at css
not MASTER 
show me your website
Some browsers especially on mobile ignore margin on specific elements, that’s why I suggested padding instead
Yes
awesome
setting up an adfs environment for testing a feature in my bot but windows is giving me grief, what?
okay
just send a link here
yeah wait
@earnest phoenix
There you go
@dry imp
@earnest phoenix
this link takes you to https://www.youtube.com/watch?v=G3e-cpL7ofc
In this full course, we learn how to build websites with HTML and CSS, and get started as a software engineer.
Exercise solutions: https://supersimple.dev/courses/html-css-course#exercises
Copy of the code: https://supersimple.dev/courses/html-css-course#code
HTML and CSS reference: https://supersimple.dev/html
Lessons:
0:00 Intro
1:02 1. HTML ...
?
I see only plain text on that screenshot
really?
no its not
ohhh
But uh
i just credited you
also @earnest phoenix i am busy so i did that in 20 mins 💀 l
Excuse me. Plain text, bold text and an anchor 
cmon fake he doesnt copy any youtube videos thats an improvement
my pyscript website also looks like that
True but I expected a little bit more after reading this:
i'm pretty good at css
ouch thats mean
eh mine would also looks like that if bootstrap wasnt applied
tailwind cringe
i might actually use it later down the line
I DID THAT IN 20 MINS
I HAVE TO GO
use bootstrap, tailwind or some sort to make it look better
whats that?
tell me the element for that
i did not learn that yet
i know to make shadows
hover
active
and stuff
like .<class>:hover
hm
okay
butt
idk how to put images..
my website without bootstrap
<img> tag
.img tag
thats it?
And then we write the styles
right?
idk that
I dk boosttrap
and stuff
i mean
bootstrap
or you could start by looking through other website
WAIT I HAVE TO DOWNLOAD THAT??
mann i am getting confused
i mean tbh i use templates aswell
okay i'll give you an example
okay
you use replit right
no..
i use vs code
I did this
when u hover on the cursor it shows this
like animation and stuff
These frameworks like bootstrap just give you an huge amount of prebuilt styles you can use and customize, not more or less
ofc u can lmao
idk maybe? i never tried
I know the codes
and the <body> and <head> stuff
and the ccs stuff
elements
void elements
apparently the link to the example is dead
thats unfortunate
Knowing “all” of them is just the first step
i dont even know all of them
The combinations and how things work together (or not) are endless
i skipped the first step
That’s the sort of experience you need to gather in order to create fancy stuff, how the kids would say nowadays
Well not only the tags are important, the attributes are important, too
i wrote it on a paper and pinned it on my pin board ( irl )
you dont need to remember all of it
?
Collecting experience takes a lot of time, that’s how it is
You know i have a printer?
Except if you’re just damn talented
try searching for websites templates on google and modify a little things
My printer is
Eww why…
eh thats what i used to do on my early days
then i edit the structure
then i add some feature
my current website used to be a online template lol
but i've modify them so much from what it used to be
just copied this website
i had the files of the template
You should be careful with using trademark logos without permission
i did it by hand without using inspect elements ( exept the color codes )
thats not a trademark
yes
in the video they told me to do
it used to be the same folder and the same projects
Boomer
🥷🏻
three times three makes four,
widdle widdle wid,
and three makes nine
I'm making the world,
widdle widdle wid,
how i like it
I’m sorry
But …
Yeah
how do you send embeds messages
That’s no embed
It's > a quote
Stop throwing around words old people don’t know
That's how quotes are displayed
oh...
its >>> actually
magic embed self botting
asd
Selfbot confirmed, ban incoming, bye
Good job
you understand markdown now
For some reason quotes got abandoned
_enough of that weird discussion _

FakE’s gonna enjoying the sun now
And pissing of car drivers
Did somebody do a complicated dashboard with vuejs or similar?
- for example
I have a dropdown, should I fetch data from the parent and pass to dropdown component or should I fetch inside the dropdown component for choices.
Not planning to use ssr
This if is never true...
const ruolo = await interaction.guild.roles.fetch("973168091154493460");
if (interaction.member.roles.cache.has(ruolo)) {```
.has accepts a role ID, not the role object
can't u just check if the member has given role id?
instead of retrieving the role
wdym?
if (interaction.member.roles.cache.has("973168091154493460")) {
whats up with people doing redundant stuff lately
const userGuilds = await axios.get(DISCORD_API_URL + '/users/@me/guilds', {
headers: { Authorization: `Bearer ${req.user.accessToken}` }
});
anyone know how to solve this error ?
u supplied an invalid token for that scope
thanks buddy
@lyric mountain Hi I want to make my bot page in dark mode. I am going to design in dark mode and light mode both but when it turns to light mode top.gg text color automatically converts to black. Can I change that text color too ? If so then how
The ping was unnecessary tbh
You need to change the theme color instead of the text color, since toggling between light and dark applies the theme on top of any styles
@lyric mountainI want to change this thing and sorry for ping
Did u read my last comment?
how ?
Google time
I'm not up to date with top.gg styling names, you'll need to either find someone who is or find out yourself
All I know is that top.gg uses variables for each theme, and u need to change those instead of the direct component
I asked for text color in support channel and one of your team member said that its possible and ask for help in development channel
Not "my" support members, I'm just a bot dev
ya I mean topgg
As I said, either find someone who actively uses top.gg styling or find out yourself
I stopped doing styles in top.gg a long time ago
can I ping mac for this ?
oh
Ideally you shouldn't ping anyone
Just as here and wait for someone to answer
It might take a minute or an hour, be patient
k sure and thanks for help
You can actually detect the current theme of topgg using CSS
Look at both messages as reference
I explained how it works
ok lemme see
Ok well I see the second link was a different story
But the first one is accurate
regarding the user's theme selection (and the site (text) colors) you can choose to pick a darker or lighter background for example
To ensure a readability without trying to change the general site style like text, colors etc.
Thanks for your assistance 🥂
👍
Sorry for disturbing, I want to submission my project, what can I do now?
Yes, I've already submited
it was already approved no?
But I've seen a line tell me to test bot's func in this server, I dont know if I understood it right
Thank you for your guides, have a good day sir!
By the way
Excuse me, if my bot get verified, will it be faster?
@quartz kindle btw our talk abt bitfields the other day helped a lot regarding my cards lul
impressive how I managed to reduce 5 variables to 1 by packing everything inside a single int
and still have unused bits left
maybe I could pack it even further by using only the first 2 bytes for those 0-1 values
ye, way better
that's a nice looking comment block
whenever I work with bitfields I try to draw what each field is holding
What are you trying to make?
for the sake of sanity
remaking, I'm rewriting my bot
Card game?
ye, yugioh-like
this part is for card states
before I had many variables that could be merged into a single bitfield
the longest disable a card can suffer lasts 10 turns (petrification), I don't think I'll be adding anything longer than that
Is it stunne dif it's anywhere between 0-15?
that's the duration
draw those for me
holy
my database is doing gods work
password=YOUR_PASSWORD
heretic, it should be passwd=YOUR_PASSWORD
💀
Is there any way to bypass hotlinking protection (or whatever the term is)?
Trying to do this:
<img src="img_link_here">
But the site uses hotlinking protection or something cause I get a 403 forbidden error in console.
are there ways? yes
should you do it? probably not
Dang.
hotlink protection exists for a reason
you're using their server to host your images, basically stealing resources from them
just download the images, upload them to your server, and link them from there
Ah okay. That makes sense. Just wondering cause it's so much easier to just use the direct link then having to do another step
Not only that, I’m checking in my graphs generation script if the remote addr is the local addr to ensure that people not put my image in a forum etc. since it’s being regenerated on every hit
Which ends up being the same reason you mentioned basically
lol
:^)
const config = require('./config.json')
const fs = require('fs')
function SAVE() {
fs.writeFile("./config.json", JSON.stringify(config), (err) => {
if (err) console.log(err)
})
}
if(config[responses] == 'A'){
config[responses] = 'B';
await SAVE()
}
else if(config[responses] == 'B'){
config[responses] = 'C';
await SAVE()
}
else if(config[responses] == 'C'){
config[responses] = 'A';
await SAVE()
}```
when I make a change it deletes everything in the config
because you're writing to a file
you're re-writing the file with new data every time
The problem is that it does not rewrite
Could it be due to a lack of time, for example?
because it is a loop according to what I write in the console?
doing async writes concurrently on the same file = disaster
jasondb
json db 
<ref *1> BaseStore(1) [Map] {
'957867801119449113' => GuildChannel {
client: BaseClient {
_events: [Object: null prototype],
_eventsCount: 4,
_maxListeners: undefined,
ws: [WebsocketShardManager],
token: 'asdasdasd',
_intents: [Array],
_presence: [Object],
options: [Object],
rest: [RestManager],
channels: [Circular *1],
guilds: [BaseStore [Map]],
[Symbol(kCapture)]: false
},
id: '957867801119449113',
type: 2,
guild: Guild {
client: [BaseClient],
channels: [BaseStore [Map]],
id: '957867801119449109'
},
guildId: '957867801119449109'
}
}
When caching a channel to the client cache should I make it a GuildChannel which has the bare minimum, just the id, type guild and guildId or should I cache them depending on their type like VoiceChannel, TextChannel, etc
how do you check how many voice connections the bot has?
I am thinking for this I am just going to keep all channels as basic guild channels for now, and if you need further information on it you can just fetch with the id provided
Classic example of race condition + how files work
A file can only be opened in 3 modes:
R = read-only mode, cannot edit
W = write-only mode, cannot read
W+ = read-wrife mode, you detain full control over the file
And write ops can only come in 2 modes:
Append = add content to the tail of the file
Overwrite = clear the file and replace with content
In your case, you're doing a W+ overwrite op on more than one "thread" (quotes intentional), and they don't acknowledge each other in any way (each execute in their own context)
As such, if all tasks start at the same time, the last to finish will null the result of every preceding task, because they don't know what the file looks like after the previous tasks finished
Now, "but why is it clearing the file?" you may ask, well, imagine you have two travelers A and B, both share a single book of countries visited, they go on their way to visit wherever they want to
A visits the entire europe and asia, filling the book with many seals and photos, wonderful memories
B however gets stuck at an australian airport and gets his wallet stolen, preventing further traveling, also delaying his arrival at the encounter location
When A finally meets B, he notices the book no longer has all the places he visited, only australia is there.
That's called race condition, when many tasks start at the same time, sharing the same reference, but each end with their own version of it
you can also append
I forgor if you can read stream a file multiple times at the same time
Ye, it's right after I I talk abt W+
does read stream lock
Don't think so, read holds no lock at all
interesting
It's only when it comes to writing that the issue begins
Channel {
client: <ref *1> BaseClient {
_events: [Object: null prototype] {
debug: [Function: log],
ready: [Function (anonymous)],
messageCreate: [AsyncFunction (anonymous)],
channelUpdate: [Function: log]
},
_eventsCount: 4,
_maxListeners: undefined,
ws: WebsocketShardManager {
_events: [Object: null prototype] {},
_eventsCount: 0,
_maxListeners: undefined,
shards: [BaseStore [Map]],
presence: [Object],
client: [Circular *1],
totalShards: 1,
socketStack: [SocketStack],
[Symbol(kCapture)]: false
},
token: 'asdad',
_intents: [ 512, 1 ],
_presence: { status: 'dnd', activities: [Array] },
options: { intents: [Array], presence: [Object], cache: [Object] },
rest: RestManager { client: [Circular *1] },
channels: BaseStore(5) [Map] {
'957867801119449113' => [GuildChannel],
'972334766399582218' => [GuildChannel],
'972342210685206569' => [GuildChannel],
'972974453367652362' => [GuildChannel],
'972975386549968936' => [GuildChannel]
},
guilds: BaseStore(1) [Map] { '957867801119449109' => [Guild] },
[Symbol(kCapture)]: false
},
id: '961530915799060500',
type: 4
}
Okay so I like that client is there, but I don't like that it is all thrown out like that, anyway I can make it collapse when logging (I doubt there is but it is a hope)
That's why sqlite allows N reads but only 1 write at a time
Make your Discord caching system file based 
store the raw jsons in their own files under their own folders based on an arbitrary indexing system
sounds like a good idea
Go a level higher, store in the filename
go a step higher and store all the data in an image metadata
Wdym by "collapse"?
that texture atlas will be huge
So that way client only shows client: BaseClient (or whatever it will show if it is collapsed) and not all that info about the client
Mmmm, I don't think I really wanna go that route tbh
I wrote my own cursed JSON.stringify that supports circular references
It's logging, no need to get too fancy
I wouldn't mind the client being logged like that if it didn't have info that is relatively useless to some people
I'm afraid to ask, but who "some people"?
pretty sure there's a special Symbol property for when an Object is inspected
Aren't only u seeing the logs?
People who are noobs and couldn't care how many events are attached to the client
Well no, it occurs when you log the response of say message.channel or message.channel.guild
a client is attached to just about every structure
delete obj["client"]; Console.log(obj)
Well no I don't wanna delete the client entirely from the response
just want to limit the result
Mmm well again wouldn't that delete the client entirely from the response?
Only from the copy
But the copy is what is being shown to the user
so like again not what I want at all
Then show the original to the user
I don't really know what exactly ur trying
Why is the user seeing debug logs?
It isn't a debug log
it is the common response discord gives back when logging smth like a channel or guild
But why is the user seeing it?
🤦♂️
User should be abstracted of anything internal
Discord.js does exactly this
if you log message.channel you get the channel object back right ?
Right
But that's my question, WHY is the user seeing the message.channel being logged?
THEY aren't unless THEY do console log it
right now I am testing my lib and seeing the responses back
They both are and arent?
as if im a user
...for context, is the user a discord user or a lib user?
What does that even mean
Who is "user"?
They'd have to be a user of the lib if they are going to be interacting with the lib to console log message.channel
I feel like this is going entirely in the wrong direction
So it isn't a user in the sense of a random person on discord, it's a developer that's using your library
Right?
Yes
That makes more sense then
I was thinking you had a bot and the user was just a rando
No
This is my own lib that I am making and am trying to make the responses back as clean as possible and not so junky
You can make you own wrapper and override the toString function
I was thinking of just making my own logger that people can use to control the depth of what gets logged, but then again that probably wont end up ever getting used so I see no point
the logger that had a massive exploit ye
One of the other reasons I can't really be bothered
Just make a wrapper, ez pz
I might just say fuck it and leave it how it is at this point if someone cares enough they can just fork my lib and implement smth
Like, just a class to enclose the response
Or just a function to parse into more readable string
Ye, but at this point I just can't spend my time on it anymore
I have other things to work on
you can set it to non-enumerable
works for util.inspect too
But doesn't that basically just remove the entire thing from the response?
I see
and stuff thats not supposed to be seen/used by the user
I will work on that kind of stuff at a later point tho tbh
I am more worried about the rest api integration and making the gateway client better as well
right now if you were to leave the session going and smth happens you don't know why it just says request failed or smth
Well so far I have Text, Voice and Category Channel data support
But I feel like I am doing this a bit wrong when converting the raw data to the proper channel data
if (client.options.cache.channels) {
for (const rawChannel of data.channels.values()) {
switch (rawChannel.type) {
case ChannelTypes.GUILD_TEXT: {
const textChannel = new GuildTextChannel(this.client, rawChannel as GuildTextChannel, this);
this.channels.set(textChannel.id, textChannel);
break;
}
case ChannelTypes.GUILD_VOICE: {
const voiceChannel = new GuildVoiceChannel(this.client, rawChannel as GuildVoiceChannel, this);
this.channels.set(voiceChannel.id, voiceChannel);
}
case ChannelTypes.GUILD_CATEGORY: {
}
}
}
}
Actually I haven't really started the caching of category channels but the class is ready to be used.
This is how I currently do it
Seems to
Actually arrays do have .values
Tho tbh there really is no reason to use .values I don't even remember why I had it
But I am still questioning on whether converting the data to the proper type of channel like that is the best and most efficient way to do so
huh why do arrays have .values lol
no idea but it exists
especially since arrays are iteratorable
and plus arrays don't really have any keys so what is the point of getting the 'values' as a new array when the array already has the values
Should I do something if it sends the heartbeat but receives no ack after a long period of time?
hi
what does this mean FetchError: request to https://discord.com/api/v9/channels/963056926906789888/messages failed, reason: read ECONNRESET
rate limit?
connection died
"ECONNRESET" means the other side of the TCP conversation abruptly closed its end of the connection.
trying to figure out why it would happen in the first place?
maybe if there are too many requests?
@quartz kindle can you help with div element and CSS display property
And place holder
umm is there a way i can use node-canvas to use ctx.drawImage() asynchronously ?
i understand drawing on canvas is synchronous, but its causing event loop blocks
so what's the optimal solution then?
bop
if you could it would get very buggy
also how do i create canvas in rust? any links would help
two things drawing at the same time aint exactly great
i see. so how do i avoid event loop blocks
hmm
its actually being laggy for me
by blocking the event loop you mean nothing else can be done?
all my images are completing in less than 500ms but because there are lot of calls. its causing event loop blocks
yeah
until canvas finishes everything else is stuck
you can actually wrap your drawing function in a promise and i believe it will be executed on another thread eliminating a blocked event loop
an example:
i mean, that's what im currently doing
im still seeing weird behavior
let me send code snippet
function drawSomethingExpensive(ctx) {
return new Promise((resolve, reject) => {
ctx.drawImage();
ctx.drawRect();
resolve();
});
}
something like this?
card: Pick<
CharacterCanvasProps,
"filepath" | "difficultyIcon" | "type" | "isSkin" | "rank"
>,
isNotStar: boolean
) => Promise<Canvas | undefined> = async function (card, isNotStar = false) {
try {
const ns2ms = 1000000;
const startTime = process.hrtime();
const ctx = canvas.getContext("2d");
ctx.save();
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.restore();
ctx.fillStyle = "#000000";
ctx.fillRect(0, 0, canvas.width, canvas.height);
const startImageTime = process.hrtime();
const image = await loadImage(card.filepath);
const endImageTime = process.hrtime(startImageTime);
loggers.timerify(
"Info canvas image load path: ",
card.filepath,
"took:" + endImageTime[0] + "s " + `${endImageTime[1] / ns2ms}ms`
);
const border = await loadImage("./assets/images/border.png");
const borderCtx = borderCanvas.getContext("2d");
borderCtx.save();
borderCtx.setTransform(1, 0, 0, 1, 0, 0);
borderCtx.clearRect(0, 0, borderCanvas.width, borderCanvas.height);
borderCtx.restore();
// borderCtx.clearRect(0, 0, borderCanvas.width, borderCanvas.height);
borderCtx.drawImage(border, 0, 0, borderCanvas.width, borderCanvas.height);
borderCtx.globalCompositeOperation = "source-in";
borderCtx.fillStyle = elementTypeColors[card.type];
borderCtx.fillRect(0, 0, borderCanvas.width, borderCanvas.height);
const starPath = "./assets/images/star.png";
const star = await loadImage(starPath);
const starCtx = starCanvas.getContext("2d");
starCtx.drawImage(star, 0, 0, starCanvas.width, starCanvas.height);
// starCtx = desaturate(starCtx, starCanvas);
// starCtx = colorize(starCtx, starCanvas, starlen[card.rank].color);
ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
ctx.drawImage(borderCanvas, 0, 0, canvas.width, canvas.height);
const num = 48,
multiplier = 20;
if (!isNotStar) {
for (let i = 0; i < ranksMeta[card.rank].size; i++) {
ctx.drawImage(
starCanvas,
i * num +
canvas.width / 2 -
multiplier * (ranksMeta[card.rank].size + 1),
canvas.height - 150,
num,
num
);
}
}
const endTime = process.hrtime(startTime);
loggers.timerify(
"Info canvas completion took: ",
endTime[0] + "s " + `${endTime[1] / ns2ms}ms`
);
return canvas;
} catch (err) {
loggers.error(
"helpers.canvas.createSingleCanvas(): something went wrong",
err
);
return;
}
};```
oh
im doing something like this
haha
bit of a "hacky" solution but it should solve your issue of the event loop blocking
gotcha,
what would be the right way?
if i were to do this right
create workers ?
there is no right way i dont think
that's kinda slow tho.
hmm
also how do i reuse the same canvas to draw a new image, i tried ctx.clearRect(0, 0, canvas.w, canvas.h) but somehow it manages to persist older image and kinda shows that as well
you dont even need to make it an external function either you could do something like:
... your code
await (new Promise((resolve, reject) => {
// do your canvas work
resolve();
}));
yeah i need to load image using await loadimage() as well
i dont know too much about canvas since i havent used it in a while but that should work
that's not working actually.
its either showing old image
or doing some weird overwrites
can you show before and after?
are you using the same canvas across multiple users?
yeah
createCanvas() is at the top of the file
that's what re-using canvas means right
its just doing weird mix n match. sometimes even the entire canvas height is screwed
you mean the context?
yeah
if so you need to make it local to the function otherwise you'll run into weird bugs
if you're using the same canvas across multiple users they will overwrite each other
this the full file code
createCanvas is on top of file
then the context is inside local func
yeah the create canvas calls need to be inside of the function
then what's the use case for reusing canvas
you're probably running into race conditions
indeed
not many creating a canvas does not have a massive overhead so its fine to create it when you need it
also a general question: should I use recaptcha v3 (invisible) or v2 (im not a robot button) for a registration/login form?
yeah i was thinking v3
I mean how it functions behind the scenes
does v3 start a manual v2 captcha if you make too many requests?
v3 also has that but it only appears when it thinks you're a bot
v3 is a little more privacy invasive because it tracks your mouse movements and actions
yh
@fossil spear #commands
and try not to ghost ping people
(@supple spruce you were ghost pinged by @fossil spear)
damn @supple spruce , your jammin website is actually cool lmao
Go on, explaining your issue
thanks for the heads up lol, not sure why they'd wanna ping me lol
thanks lol
lmao
nope you cant do that
how big is your canvas? the resolution i mean
2250 x 2000
canvas scales with image size, abmnd it scales horribly
yeah i made sure all my image sizes are less than 100kb
lemme send you a screen shot
is it for a discord bot?
image size as in resolution
file size doesnt matter
yeah image reso is 750x1000, thats why my canvas width is 750 * 3 and height is 1000 * 2
canvas operates on pixel-by-pixel
yeah
so yiure using big images for nothing
if i try any other reso, the image is distorted or looks weird
then youre doing something wrong
you should pick a maximum size and resize everything to fit it
dont just add up images without resizing them
so im guessing 1000 height is the max size
yeah iam resizing my images
original image reso is 750x1000
kurumi 4 stars only wtf
so when i draw on canvas the canvas reso is also 750x1000 if there's only 1 image
but like you said for 3 x 3 images, its down sized so no point in me drawing 750x1000 image on canvas 2250 x 2000
size it down more
by how much tho, that's the point


