#development
1 messages ยท Page 2036 of 1
well 750x1000 seems good enough?
I draw my stuff in HD because people can "Open original image" it
you make the biggest side that much, then you scale the smallest size to fit it
and keep the aspect ratio
still 2k is too much, especially when working with canvas
so i keep the original reso, and resize the image to a smaller size before drawing on canvas yea?
make it like 720p or 1080p max
gotcha
I mean, in my case we're talking abt keeping 10px text readable
any idea what max size discord scales it down to?
it depends on device i assume? cause images are smaller on mobile
also there is a HUGE difference with drawing full images on canvas, and only drawing text and shapes
yep
i got your point, i'll try stuff ig
is there an alternative to canvas tho, i wanna avoid this completely xD
because canvas works pixel by pixel, it scales linearly with the number of pixels it needs to draw
for image compositing you can try a library like sharp or imagemagick
since you dont need the graphical drawing features tjat canvas has, you just need image compositing
also, back to the async question
the only way to draw on a separate thread is to use worker thread or child process
yeah makes sense, i tried that before but it was kinda slow. didnt have much optimizations at the time tho
using async doesnt magically make the code run in parallel
it atleast wont cause event loop block right
it will
using new Promise() to draw the canvas
that's all i need for now
i'll try the resizing thing. need to figure out the magic numbers
\/ why I need high res
2250x2000 isnt gonna work (lesson)
damn son
async still blocks the event loop if you use sync code inside it
it doesn't redraw the whole thing everytime tho
nice
just your imagination
yeah there are many games who use canvas
nah nah cant fool me
they can draw at 60fps just fine
so do you know the magic number
69?
because they use multiple small canvases and/or draw small images separately and never redraw the whole thing
somewhere around 750
since my image gets downscalled to that unless I open original
is there a way i can check to what reso its being downsized to?
dev tools
ah you on the web
no need, the tab name will show it
u can download the image and check its details
thats who i ran into 750x1000
if you open original? but the it show original size, not discord scaled size
nono, if u open the image in a new tab
yea
ah
if you open in new tab it'll show the original full image
opening in a new tab will show the downscalled image, opening original will show the original image
ah
this is only possible in desktop tho
im supposed to do this on chrome no?
ye
alr lemme give that a shot
another thing you can do
dont create a new canvas every time
keep one canvas of that specific size always loaded
and when a command is run, draw the images in it and send
doesn't that hold resources hostage?
yes but its faster
typical use more ram to make it faster
yeah actually i've tried this
i tried using clearRect() to redraw the image
but it kept loading old images some times
cause multiple users
and end up showing wrong images
with that method you need to consume the image imediately, ie convert it to buffer
not gonna work cause i need to change the height of the canvas accordingly
before anything else can draw on it
oh im doing canvas.createJPEGStream()
yeah if you use streams you cant do that
buffers will be garbage collected like everything else
so ike if there are multiple calls coming in and the current canvas is still yet to be converted to buffer it will still persist old image no?
gotcha
so its gonna wait until the entire func finishes?
damn
its gonna block stuff cause like imagine 1k calls coming in
buffer takes 500ms. its gonna bubble up no
if you have that many calls, you def need to multiprocess
draw each canvas on a different process
500ms holy
not multiprocess the same canvas
less than 500ms ofc, worst case would be 500ms
yea, thats what i meant. back to workers here in that case
aren't u just overlaying images?
im not drawing shapes, im doing context.drawImage
composition then
it doesnt actually, but worst case i saw was 500ms+
yep. just the star and border are different
which are drawn in the func
but they finish in 1ms
are u using the gpu to draw it?
depending in the situation, i would use an external program to do that, like imagemagick, then the OS will take case of resource management for you
gpu on a vps? we not rich
mine is contabo and has a gpu
not anything fancy, but it has one
for graphic-related stuff gpu is faster than cpu
nah cpu, cpu is enough for me
yea
mines not too intensive, i just need to optimize it correctly
and im getting there i hope
you said you also use sharp, what do you use it for?
to resize it, its kinda 1 time thing when i upload an image i resize the image to the reso i need which is 750x1000 in current case
here's a tip, if your image is big try breaking it into smaller chunks, modifying them then re-attaching the parts
you know sharp can also do compositing right?
yeah
yoi dont need canvas at all, you can do everything on sharp
hmm
and it should be faster
they said stars and frames are procedural
wait, they aren't?
yes sharp can do compositing from what i remember reading their docs
i never used it tho since i draw shapes not images
also try not to upscale images
have the source asset at the right size before starting
upscalling is an expensive operation since it needs to calculate pixels for every pixel in the image
if you want absolute max performance, store 3 versions for your images
one version with the size of showing 1 image
another version of the same image for when the bot shows 2-4 imahes
another version for when the bot shows 5-6
all it their respective final sizes
so you dont need to resize anything when compositing
yeah this what im currently doing
youre using one version for everyhitng, thats why you made the canvas bigger
tho i have 2 different extensions, webp and jpeg to show on the web.
yeah this will change now that i know more
thanks 
np
another thing you can do is offer a resize option to your command
is it better than 1660
thats what i do
gotcha
well i assume discord is down scaling to its maximum, so thats all the info i need
my default size is 800x800 but if the user wants to, they can use a --size option to go up to 4000x4000
its slow as fuck, but almost nobody uses it
so my bot still runs smooht even on 9k servers
also if sharp supports compositing like canvas does with drawing 1 image on top of another, i'll try out sharp
damn nice
i used to allow up to 8000x8000 long ago
that was a disaster lmao
would randomly crash the bot
took like 5 seconds to draw
Go bigger!
im trying to run a onclick function in html but the problem is my mouse double clicks a lot which makes the function run 2 times, i tried making a isrunning variable and set it value to true and before running the function check if its value is true, but that did not worked at all its still running the function 2 times
show the code you tried and didnt work
==
let isRunning = false;
Let's pretend you never posted that screenshot
๐
u can also do if (!(isRunning = !isRunning)) return; 
ae
mutation!!!
any react expert know how to pause a form submit, do some processing then submit it?
what do you mean by pause
I have an invisible recaptcha and I need to get a token and apply it to the body before the form can submit but the problem is the form doesnt wait for the onSubmit to finish (promise) and just continues
so you need to hit submit twice since by then the token will be applied
dont know if this is intentional behaviour
yeah i could but that would defeat the point of the framework im using
what framework?

Does remix.js use a <form> under the hood to make the request? Are you sure there isn't a onBeforeRequest or a similar prop
react's major gig is controlled inputs, there must be something the framework exposes
i could probably ask on their github they have an active community
i tried using a prevent default at first but dont really know how to emit the submit event properly again, i tried once but the page just refreshes
or i can always fallback and stick to the v2 captcha "im not a robot" button if it doesnt work out
i guess attach a listener and use https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault if the captcha hasn't been loaded?
i did try using prevent default but I dont think react/remix supports stopping propagation then starting it again programatically
okay
turns out I was right all along with the prevent default
but remixjs has a special hook called useSubmit which you can use to submit it properly
the people in the github answer fast
Is there a native JS function that can loop an array of objects with a dynamic amount of nested objects inside?
seems rather specific so probably not
you can do it yourself though? I don't understand the question
Well I have a dynamic amount of nested arrays (with objects as items) I wanna loop
mu unnest command does that js const unnestCommand = options => !options?.options || (!options.options[0]?.options && options.options[0]?.type !== 1) ? options : unnestCommand(options.options[0]); module.exports = unnestCommand;
recursion is what you want
yeah the question still remains if JS has prebuilt functions for this
(spoiler PHP has)

I mean you could use .flat to flatten the arrays
why?
You have the right to have your own opinion 
That's an objective fact but this is a discussion we're not ready to have AND not for this server ๐
recursion is part of the language too
flat seems to be appropriate here if the depth doesn't matter to them
Oh even better... I see flatMap exists
nah flat doesn't work here
gonna give you an example
const arr1 =
[
{
search: 5,
volume: "abc",
options:
[
{
search: 4,
volume: "bcd",
options:
[
{
search: 3,
volume: "cdf",
options:
[
{
search: 2,
volume: "dfg",
options: null
}
]
}
]
}
]
}
];
the amount of nests is dynamic
options can contain another nest but doesn't have to
I have to loop each possible nest to compare search and volume to my input
looks a lot like the data discord sends
well you mean application options, aren't you?
unfortunately not no, it's the structure I have to deal with
better don't ask why
const unnest = (arr1) => arr1.reduce((acc, opt) => acc.concat(...[{search: opt.search, volume: opt.volume}, opt.options ? unnest(opt.options) : opt]), []);
hmm I see
I need to change it a little bit
instead of concating the object if options is null it should be ignored
but that seem to do it's job
this will get rid of the last duplicate js const unnest = (arr1) => arr1.reduce((acc, opt) => acc.concat(...[{search: opt.search, volume: opt.volume}, opt.options ? unnest(opt.options) : undefined].filter(a=>a)), []);
not the most efficient thing
well not the "best" structure I could get
but it's how it is
like I said
better don't ask why
Using a for loop sounds faster
The amount of arrays you're creating in that in that function
no mutations though
There's nothing wrong with mutations as long as they're limited
yep, as limited as possible
I'd say in this case it's acceptable
You're mutating it to initialize it so does that even count
you can freeze it afterwards
good idea
mutation is changing something after it has been initialized
but assignment is also bad
Cross posted from http://channel9.msdn.com/Shows/Going+Deep/Hewitt-Meijer-and-Szyperski-The-Actor-Model-everything-you-wanted-to-know-but-were-afraid-to-ask.
At Lang.NEXT 2012, several conversations happened in the "social room", which was right next to the room where sessions took place. Our dear friend, Erik Meijer, led many interesting conve...
yeah but the array is technically initialized, just not with the data you want. Is it really mutation to put the data in it ๐ค
const arr = []; // Technically already initialized...
for (const item of things) {
arr.push(do something with item idk);
}
return Object.freeze(arr);
push isn't pure
What I'm saying is, IMO this shouldn't count as truly mutating the array since you're still filling it with the data you want it to contain. While you're doing this nothing else can mutate it
last time i checked array.concat was slow af
Array.prototype.concat(): https://chromium.googlesource.com/v8/v8.git/+/refs/heads/main/src/builtins/array-concat.tq
Array.prototype.push(): https://chromium.googlesource.com/v8/v8.git/+/refs/heads/main/src/builtins/builtins-array-gen.cc#338

concat code looks so pure
whats the difference between concat and spread operator? also pls explain, dont just post code nobody understands
Tim I'm gonna decompile you to LLVM MLIR
mjolnir?
Halo

IS THERE ONE DAY WITHOUT A BENCHMARK IN YOUR LIFE
no

well concat and push are doing different things
concat creates a new array
push doesn't
ye
you could level it out by creating a new array in the second snippet and pushing to it instead
The concatenation methods are usually only available for specific primitive types and targets, and tend to initialize a new copy instead of modifying an existing one, while the spread operator (...) is available for multiple primitive types at once and is a direct call rather than a function call
:^)
Spread operator is usually more readable if you know what it does, although methods are usually for more functionally or verbosity, or both at once
Extended functionality/verbosity -> functions/methods
Performance -> operators
pls dont take concat away from me
no concat
let unnest = arr => arr.reduce((acc, opt) => opt.options ? [...acc, {search: opt.search, volume: opt.volume}, ...unnest(opt.options)] : [...acc, {search: opt.search, volume: opt.volume}], []);
hmm, good job
not really a fan of one liners but yeah... preferences are different
gonna rewrite that
Good job npm for killing my entire workflow for your stupid 2fa
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbm
i swear web dev frameworks are always like this
they make a lot of shit easy but sometimes you get stuck on something for hours that you would setup in minutes in js
like what
LIKE SUBMITTING A FORM PROGRAMATICALLY
i am going insane
the solution the guy gave me works but doesnt work with async
That's pretty easy and framework-independent
yeah it is easy
but my framework has a custom form
so its not as easy as prevent default and emit event
deserved
wtf windows is forcing me to use USB for the security key
omg
who thought of this bullshit
Well u gotta *put sunglasses* insert the key
bitlocker?
nah the npm site asks windows to download a key securely and the only option they're giving me is via USB
what
wtf
yeah 2fa is now mandatory unless you want to enter your password to login every single damn time
i have 2fa on npm but it never asked anything about a usb key
To get a security key
๐ฉ I don't think it even asked me if I wanted to use that
F
what the hell? GotoIf(TaggedIsSmi(arg), &default_label); goto macros?? oh god
what's a FastJSArray? packed smi elements?
GotoIf(IsElementsKindGreaterThan(kind, HOLEY_SMI_ELEMENTS),
&object_push_pre);
oh I guess so
this is crazy tho I can't believe v8 people abstracted the concept of gotos into classes and macros. Sounds like it'd be a nightmare but it's almost neatly organized
Why does the app command object (https://discord.com/developers/docs/interactions/application-commands#application-command-object) has option as optional property?
In which case can it be missing?
The V8 working group also implemented a programming language that can only be used inside the V8 engine which is Torgue, C++ + JavaScript to minimize effort and make things easier, anything to make things as easy and optimized as possible
Jfokus VM Tech Summit 2020 https://www.jfokus.se/vmtech #jfokus #V8 #javascript
When implementing a language VM, there are a number of choices on how to implement the runtime and standard library. For the V8 JavaScript engine, we have tried many different approaches over the years: handwritten assembly, C++, self-hosted (i.e., using JavaScript)...
it must really be worth it
to be maintaining another language to minimize effort lol
everything in v8 seems crazy overengineered
but seeing it runs like half the javascript in the world or something so
yeah but it is really fast
commands don't need to have options. For instance /cat where the return value can be "static"
well the thing is, when the command has no options why does the API then send options as property with an empty array as value
<ref *2> ApplicationCommand {
id: '973061310646476820',
...
options: [],
...
}```
You can take a look at https://github.com/AmandaDiscord/DiscordTypings for some good type defs
according to the API docs that would be inconsistent
The Discord API documentation marks properties as optional for input mostly, for output those are not really considered
oh
For example there's no icon hash returned for guilds that don't have actual custom icons, returned as null instead though
lol I missunderstood that then
Well I see I'm stupid
I mixed the djs output with the raw API response
djs this.options ??= [];
while the API would returns null
my bad
I feel stupid today
(async () => { await checkSomething().catch(() => process.exit(1)); })();
initClient();
Why is initClient() being called before checkSomething() is awaited?
checkSomething() returns a promise ofc
It returns a promise to the global scope, or whatever scope you're in, but it's not resolved
If it's not resolved it'll just continue the code execution
It gets rejected in my test
await checkSomething().catch(...);
initClient();
or
checkSomething()
.then(() => initClient())
.catch(...);
(and yes the scope is global)
If you want TLA (Top-Level Await), I'd recommend using ESM (I recommend using ESM over CJS anyway)
Well the second one as I showed
nah to keep the checkup in the self executing function
Or
(async () => {
await checkSomething().catch(...);
initClient();
})();
Why not just use ESM though?
It shouldn't really take much time, it's just replacing the usage of the global require() function with the import statements (import ... from ...) or dynamic imports (import()), and changing exports from module.exports.foo = ... to export ... and module.exports = ... to export default ...
hmm haven't used it so far
but I like the top level await
do functions still need to be async when awaiting something or is the entire code async?
the async keyword is function scoped
async function() {
function() {
await x // invalid syntax
}
}
should work the same with top-level await
yeah I know it has been a stupid question

ok one last question
try
{
code1
code2
log
}
catch...
Would log be called if let's say code1 would already throw an error?
nop
๐
did you desecrate the one liner?
U can use finally if u want log to run regardless of errors
module default import/export is the worst thing to happen to js
which is why I stick to cjs
How so?
import thing from "module"
thing.something(); // cannot read property something of undefined
I have to use the require statement a lot in my code because of default imports
import just screwing me over
won't import * as thing work tho?
you make a good point i was just wondering if that'd work
add a flag to totally disabled attempting to import default
in fact, add a flag to remove module.default
or just remove it entirely
I don't get it, that imports the default export and in this case if it doesn't contain the method called something, that error would occur, if you haven't exported it in the default export, you would have to do import { something } from '...'
What exactly is the concern here?
I do not export default in that mod, but the import statement tries to read module.default.something
So, say I am making a method for a class and the method will return basically the data of the class, so instead of doing
public async edit(): Promise<Message>
// Could I do
public async edit(): Promise<this>
It doesn't matter how you do it really I am just wondering if it is possible
Mmm, is there areason why it would be better?
in case you rename classes or people extend your class
Mmm, very true
It shouldn't if you just import the thing you need, for example
In this case I'm exporting the something() method in an object
// foo.js
function something() {}
export default { something };
And here I'm importing the default, which should be available
// bar.js
import baz from 'foo.js';
baz.something(); // works
But your concern seems to be headed towards this:
// foo.js
export function something() {}
// Or
function something() {}
export { something };
And import the function without importing the default export, as we didn't define a default export
// bar.js
import { something } from 'foo.js';
something(); // works
Mmm, so I am noticing an issue off whenever I do something like
message.channel.send(...).then(msg => {
// use one of the props on the Message class
})
msg is no longer an instance of Message it becomes an object
so therefor it cries that the method that does exist on the Message class is not a function
msg.edit({ content: 'Fuck off' });
^
TypeError: msg.edit is not a function
That's extra chars I don't wanna write
also, I cannot destructure a lot of my modules for hot reload purposes
Iโm aware about that, but nice tip tho but in the example I wrote log after code1 and code2 is debug message meaning the try/catch clause was successful
If code1 or code2 would throw an error, the success log (inside try) will not be called while finally would always call log if I would use it in there
ew .then
Err not yet but later the day since I had to go to work back when we were chatting about it
Fun fact: delphi cannot have try-catches with more than one of either except or finally
It's so fckin awful that you can't even concat non-string with strings
Also string-related arrays start at 1, while every other a array starts at 0
And for-loops are inclusive
That was my daily rant about this shitty language I'm stuck with at job
wow that sounds god awful
The IDE freezes if you press ctrl + space
In fact, you also cannot receive bugfixes or update it unless you pay a monthly fee
Also sometimes the debugger gets high and start considering code from unrelated projects into your current project
Or even worse, it forgets what code is in each line
Did I say you also don't get DB components unless you purchase the second most expensive plan?
Ye, because small startups clearly don't need to use databases
lol
I wish I was joking, but the scenario is just sad
Aye they can still use a pen and a piece of paper
I see
instead of a database
Btw don't look up delphi prices
i tried to reverse engineer a delphi program once and failed miserably
The bloat that's added during asm compilation is insane
Still have no idea when when using .then on the send method it then becomes an object instead of staying as a Message instance
public async edit(options: MessageEditOptions): Promise<this> {
return this.client.rest.patch(`/channels/${this.channelId}/messages/${this.id}`, options);
}
thats the problem
What is the problem
Mmm, yea I thought that was the issue to which is why I tried making the data be typed as what is going on with the request but that didn't work it remained as an object
typings dont do anything
Mmm
they only affect intellisense, not the actual code
Yea true
you need to take the response object, update the props for the message and then return this
public async edit(options: MessageEditOptions): Promise<this> {
const response = await this.client.rest.patch(`/channels/${this.channelId}/messages/${this.id}`, options);
this.content = response.content;
this.etc = response.etc...
return this;
}
thats why djs has ._patch() methods
which is called on class instantiation, on edit call, on send call, etc
bot have the send message perm
but its not working
why?
if i give permission to client role then it will be work
channel permissions maybe do something
why is the npm registry full of literal garbage and so many packages depend on it
I kinda wonder the same, it's littered with the most easy to make and unnecessary NPM packages that shouldn't exist, but there are no limits to what you can make so ยฏ\_(ใ)_/ยฏ
Especially packages like https://npmjs.com/package/true
8 years ago damn
bro?
wait until I add my package >:)
what shall be the webhook url for listening votes via replit
using @ancient bloomgg/sdk
Itโs your endpoint topgg will send the (vote) requests to
Your hostname/IP (and port) and path
i love the issues and pull requests in it
everyone so serious
Created using https://github.com/parzh/create-package-typescript. Latest version: 0.0.1, last published: 2 years ago. Start using - in your project by running
npm i -. There are 198 other projects in the npm registry using -.
dis is the best package
stfu your package is way more useful
people
i asked the same question to my packages too so 
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = null;
nice package indeed
I got a question via an email on a package I made years ago and deleted from my github and it was shit so I think you'll be fine
lmao
@quartz kindle what's the name of the functions that use module in JS?
for example something like this
Function: function() { }
wdym?
i still dont know what you mean
basically using module you can only request the library and use multiple functions
module.exports = {
FunctionName: function (variable) { },
FunctionName2: function (variable) { }
}
``` do you know the name of this syntax?
pls help me
it's a cool way to do it because it also works with variables themselves and all you do to call it is a simple require("name").FunctionName()
thats just exporting an object
yea, you export an object, ie: module.exports = {}
you can put whatever you want inside the object
okay that's good to know then
I prefer doing that with classes
import { functionName } from "./name";
...
functionName()
I prefer putting all your code in one file
๐ฅต
wait I just realized something terrible
if you have 2 obfuscated Js files
calling a function from an obfuscated file is impossible because it's all scrambled, right?
why'd you wanna do that anyways
well no but how would that work? even if I obfuscate both of them at the same time after finishing it still wouldn't work right?
The obfuscator has the context it needs to detect what you're importing and sync the obfuscated names
unless you're obfuscating the files separately... which is something you shouldn't do
obfuscate
open file
look for the exported names
change your import code to those names
???
profit
so profitable
Since you mentioned yesterday my would look like something the Discord API would return, I was actually thinking about to improve my command handler, too
And yeah for this specific use case (command handler) I don't even need to rewrite the function
Looks like that now:
let flat = (array) => array.reduce((previous, current) => (current.options) ? [...previous, { name: current.name, description: current.description, description_localizations: current.description_localizations }, ...flat(current.options)] : [...previous, { name: current.name, description: current.description, description_localizations: current.description_localizations }], []);
if(JSON.stringify(flat(fetched_command.options)) !== JSON.stringify(flat(local_command.options ?? []))) // command update
Stringifying the entire array (of objects) actually seems to be more effiently than looping through it and comparing each item
Even if that wasn't the intented use case, it's still a nice addition to the command handler
lmao
you forgot space after if
no
shut up java user
unacceptable
can i benchmark that
:^)
You forgot to slap your java user friend today
NOOOOOOOOOOOOOOOOO PLEASE NOT, I DONT WANNA UPDATE IT AGAIN, NOOOOOOOOOOOO
xDDDD
Tim benchmark it and send the results with a ping to FakE
become his worst nightmare
leaving topgg discord server
Quiet!
:)
(regarding the fact the actual command limit is 200 anyway, not 999999)
added description_localizations
no hes gonna write a parser from scratch which converts it to binary and a whole interpreter for it
makes sense
tim while you're at it can you find me an easy to use and optimized/fast json parser for my database
im using nlohmann json but its not the fastest :c
use bson
what did you do!
calling the accumulator previous?
it also uses std::string for strings which for performance is ๐
Hey @quartz kindle why tf is the description_localization property missing when it's undefined?
console.log(JSON.stringify(flat($command.options)), JSON.stringify(flat(command.options ?? [])));
[] [{"name":"enforce","description":"Force updating all global and guild commands"}]
when flat is pushing it to the array
[...previous, { name: current.name, description: current.description, description_localizations: current.description_localizations }
json doesnt support undefined
shouldn't even undefined as current.description_localizations be psuhed to?
Ahh lol
lmao didn't even think about that
well the result will always be wrong then
It needs to be [...previous, { name: current.name, description: current.description, description_localizations: current.description_localizations ?? null } then
As the name and description are of course required anyways but description_localizations not
damn... it's actually good we're talking about it, I wouldn't have noticed yet
xD
But I feel like I'm running straight into the next issue, lemme check
oh no I'm about right
0|Real | Response: Internal Server Error
0|Real | at RequestHandler.execute (/home/ubuntu/Real/node_modules/discord.js/src/rest/RequestHandler.js:357:15)
0|Real | at runMicrotasks (<anonymous>)
0|Real | at processTicksAndRejections (node:internal/process/task_queues:96:5)
0|Real | at async RequestHandler.push (/home/ubuntu/Real/node_modules/discord.js/src/rest/RequestHandler.js:51:14)
0|Real | at async TextChannel.send (/home/ubuntu/Real/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:175:15) {
0|Real | code: 500,
0|Real | method: 'post',
0|Real | path: '/channels/963796432727461929/messages',
0|Real | requestData: {
0|Real | json: {
0|Real | content: undefined,
0|Real | tts: false,
0|Real | nonce: undefined,
0|Real | embeds: [Array],
0|Real | components: [Array],
0|Real | username: undefined,
0|Real | avatar_url: undefined,
0|Real | allowed_mentions: undefined,
0|Real | flags: undefined,
0|Real | message_reference: undefined,
0|Real | attachments: undefined,
0|Real | sticker_ids: undefined
0|Real | },
0|Real | files: []
0|Real | }
0|Real | }
What is this error
i got first time
Something went wrong internally
mean
did i do anything wrong?
djs doesn't return the raw API command object, fuck
options: [
{
type: 5,
name: 'enforce',
nameLocalizations: undefined,
nameLocalized: undefined,
description: 'evil text here',
descriptionLocalizations: undefined,
descriptionLocalized: undefined,
required: true,
autocomplete: undefined,
choices: undefined,
options: undefined,
channelTypes: undefined,
minValue: undefined,
maxValue: undefined
}
]
descriptionLocalizations and description_localizations aren't the same keys ffs
AAAAAAAARRRRRRRRRRRRGGGGGGGGG
And I hate them
likewise
It means the server had an issue processing your request.
lemme see if I can actually fetch the raw API object
oh there's no fetch option to return the raw API object
any soultion
you have to use client.rest
Try again and hope it works ig
500 errors aren't typically things you can solve yourself unless you're just doing something so wrong that even discord can't respond with nothing else but 500
yeah which requires to change some other code, too (again, the 4th time?!)
I feel like you
At least you are becoming more efficient
I guarantee if tim benchmarked my incomplete lib rn he'd find so many problems
:^)
with speedydb it couldnt be easier
await client.api.applications(id).guilds(id).commands(id).get()
:c
Speedy can I ask your opinion on smth
i have a USP you can iterate a data set backwards
ys
The thing is you would need to check if the properties (name, description, ...) for c1 and c2 exist as both arrays can be completly different (the amount of nested options), means it would throw an unknown property of undefined error
Alright so with this lib I am wondering what would be best, to be user friendly or more efficient/performant
welp rip
I mean you would simply need to return true if c1 or c2 is undefined in that case
so yeah, yours is faster
But yeah GoogleFeud mentioned yesterday already a for loop would be faster anyway but hmm... doesn't really matter in that case tbh
how about this
well tbh I actually prefer reduce here
even if it performs worse
I mean look at the amount of code and lines
not that I'm lazy but in this case I prefer the compressed style
the above method is even faster
omg... why are you like this
lmao
speaking of findMany, im using a lib that has a get and a getMany method
and for some reason
their getMany method is like 20x slower
than running get multiple times
go figure
speaking of which, @earnest phoenix explain the v8 fast call api, from what i understand it cannot be used to return data to js? only to run cpp code from js that doesnt return anything? or am i understanding it wrong?
man... editing the flat function now the 5th time
adding djs stupid camel case key names instead of the API ones
my gosh
smh
wow now that I'm thinking of...
I have to expand the function with a few more properties
required, autocomplete, choices are a thing to I need to compare
once there's a command using it
fetching the application commands on a startup to register/update/delete them to the API if anything has changed
I don't like putting them manually
๐คช Detritus does this by default
wow... now we're back to detritus
I mean they're actually doing the same like I do
fetching comamnds and comparing them to the loaded commands
yes but it does it for you
it's not that much of work tbh but I need to consider to THINK of each possible case
Idk I think you've wasted at least an hour in this channel for a solution to problems caused by this so I'm just saying
yeah true but don't get me wrong, even if I use djs as framework I still like to do things myself
since I'm not earning my money with coding, wasting time let's say as hobby is acceptable
to gather some experience
i put all my command registering stuff in a separate script that i run manually when i edit it lol
well and I like to create a handler for doing it
might be non-sense as I'm the only one updating commands but hmm
but yeah changed the object keys to djs stupid camel case now and changed undefined properties to null (as json doesn't support them) and it should be okay now
let flat = (array) => array.reduce((previous, current) => (current.options) ? [...previous, { name: current.name, description: current.description, descriptionLocalizations: current.description_localizations ?? null, required: current.required ?? null, autocomplete: current.autocomplete ?? null, choices: current.choices ?? null }, ...flat(current.options)] : [...previous, { name: current.name, description: current.description, descriptionLocalizations: current.description_localizations ?? null, required: current.required ?? null, autocomplete: current.autocomplete ?? null, choices: current.choices ?? null }], []);
just takes 3 lines on a 4K display, my gosh
good thing I don't even need to be consistent to add the properties other than name and description to my command modules
as they get null if they don't exist
which is exactly what the API returns if they don't exist
let's say I can live with that, even if it's not the most effient thing
have fun benchmarking it

literally unreadable
In Discord, yes, not so in the code editor

xD
just for u
let flat = function(array)
{
return array.reduce((previous, current) =>
{
if(current.options)
{
[
...previous,
{
name: current.name,
description: current.description,
descriptionLocalizations: current.description_localizations ?? null,
required: current.required ?? null,
autocomplete: current.autocomplete ?? null,
choices: current.choices ?? null
},
...flat(current.options)
]
}
else
{
[
...previous,
{
name: current.name,
description: current.description,
descriptionLocalizations: current.description_localizations ?? null,
required: current.required ?? null,
autocomplete: current.autocomplete ?? null,
choices: current.choices ?? null
}
]
}
}, []);
}
Even I would say that's horrible
but readable
let flat = array => array.reduce((previous, current) => {
if(current.options) {
[
...previous,
{
name: current.name,
description: current.description,
descriptionLocalizations: current.description_localizations ?? null,
required: current.required ?? null,
autocomplete: current.autocomplete ?? null,
choices: current.choices ?? null
},
...flat(current.options)
]
}
else {
[
...previous,
{
name: current.name,
description: current.description,
descriptionLocalizations: current.description_localizations ?? null,
required: current.required ?? null,
autocomplete: current.autocomplete ?? null,
choices: current.choices ?? null
}
]
}
}, []);
}
Looks SO much better now
there even better
I see... we will never agree on that
the fact that I was doing something completelly different and ended up here is just funny
Has anyone yet actually worked with localizations for command names or descriptions?
The API seems to accept and save my registered/edited command as well as localizations object.
Running and testing the command by changing the language in my client works and returns the right language
But fetchรญng the command from the API always returns undefined for name and description localizations of the application comand
its possible that field when fetching is user account only
oh lemme check if it actually requires a fetch option
to fetch localizations
yikes
it does
didn't even notice
well ty for the tip
lmao
javascript/web dev is so nice
no segmentation faults
no unsafe memory access
no pointers
no structs
๐
imagine having to write 3 versions of a website
yeah you can actually distinguish between a 0 and null
that's why noscript exists, print fuck you and that's it
null in c/c++ is just a macro for 0
longer way to type 0 essentially
my internet is pooping rn
can i have some assistance on making a !name and response command, please.
what sort of issue do you have?
Just unqualified. I want to make a !link command that responds with a link
Ok? So ... you respond with a message including that link
That's it.
No matter it's a DM channel or text channel
Yup I want maybe a minor embed.
Were you looking for this?
Link
You wanna send an embed? Well which language do you use?
Yes embed.
So I'm assuming you're using discordjs
class Bot {
constructor(test){
this._test = test
}
async example(){
exemple2()
function exemple2(){
console.log(this._test)//not working how to do ?
}
}
}```
If you don't like to send a bare embed object, then you should take a look at the guide how to create embed
this inside your example2() is a different scope than inside your class
class Bot {
constructor(test){
this.test = test
}
async example(){
exemple2(this.test)
function exemple2(param1){
console.log(param1)
}
}
}
But this function inside a function inside a class somehow is very weird
example2 should be a method of your class bot when calling it from example()
or use an arrow function
class Bot {
constructor(test){
this.test = test
}
async example(){
this.exemple2()
}
exemple2(){
console.log(this.test)
}
}
that would work
5/7 indentation
wow discord fucked it up
also function keyword
this would work too as arrow functions dont have a this ```js
class Bot {
constructor(test){
this._test = test
}
async example(){
const exemple2 = () => {
console.log(this._test)
}
exemple2()
}
}
but yeah its weird to do it like that
oof that hurts my eyes
thx
how to get member object from user id (python)
what happens if u do null.getName()?
the universe will explode
i keep writing unsafe code and i cant stop
its because of my os
just like drugs on an impressionable mind
lol
fast or slow transition?
a thousand times fast
tyyy
I hate any kind of slow animations, unless it's a one-time epic intro
ig that's why w11 and iOS feels so weird to me
like, things used to be snappy, now you can notice the transitions
and ik iOS is famous for slowing down stuff for the sake of noticeable animations
samsung has slow ass animations by default
That's the reason you can disable all of those animations with one checkbox
bro the slow one look like a $50 android phone trying to render a simple animation
when internet was made in ActionScript and GIF
there's actually no stutter
ops ?
the button looks kinda out of place
very lonely
just like the average developer
very monotone
have you moved away from developing an OS to hosting a mail service?
how did you guess
the buttons give a Ditto vibe
yeah im not focusing on the css too much
like, the entire body is right, but the face... ._.
"yes i'm a fullstack developer how did you know"
Looks like an email service
tbh I'm also not really good when it comes to colors and design
motivation for doing so: none i just felt like using my database on something useful
actually just gave myself an idea
ima make sure everyone knows its powered by my database
https://www.youtube.com/watch?v=JCJUPJ_zDQ4 well that's nice timing
Native apps often feature transitions between states that both look great and help communicate the type of navigation to the user. The bad news: creating transitions between pages on the web is impossible. In-page transitions are possible, but complex. The good news: new APIs are coming to simplify this process, building on top of CSS animations...
2hrs ago
I like gray tones, too
I mean I have a dark mode
i added the "x new emails" just so people get depressed when they see 0 new emails
Damn
that's very intellij
speedy is this service live or is that being locally ran?
very what?
talking bout the theme
jetbrains, jetbrains
handcrafted, no theme
once i finish it i'll actually thow it onto the domain
although jetbrains has a slightly blue tint
I got some blue, too :D
some mf said hes gonna sign me up to email spam ๐
little do they know im gonna use a forum spam prevention service
oh you meant the background
well actually not a pallette but randomly picked colors I like in photoshop lol
tbh, it is closer to delphi's darcula
which fit good to the theme color
yeah I know what u mean but still just randomly picked
only gray without a blue touch in it looked weird
set the B value 1 or 2 points higher than the rest
makes it feel smoother for some reason
it has become so big and complex I'm aint touching anything anymore :D
actually, do the same for green so it pulls closer to cyan than deep blue
bold the text
i think it looks fine
took me a while to figure out the right color for dark and light mode you can see good enough on mobile and desktop
because a mobile screen usually doesn't 100% screen brightness
That blue doesn't work well with the background color. You can use the dev tools to check if the color has enough contrast with the background
oh fuck maybe I'm colorblind
huh what sort of dev tools?
chrome dev tools
not aware of something like what u mentioned
well im not using chrome
and never will
dayum thats really cool
firefox
yeah anyways, not really important tho
tbh I have no trouble reading it on desktop and mobile
made the blue a lot more brighter than before
This has helped me a lot
hmm firefox doesn't seem to have something like that
where is that from?
The select element button
huh, nah, has been just an example text
oh i didnt notice it has a hover box now
probably 10?
...the print clearly shows 12 tim
21
oh nvm firefox has that feature, too
I wonder why such arbitrary value instead of 0-100%
it's somehow disabled because of my privacy settings
wtf
i have literally no clue how to enable it, lmao
not even the faq tells me how to
honestly the feature set of dev tools never ceases to amaze me
its amazing how many super complex but super useful features it keeps dishing out
like the poor internet quality simulator?
i dont use it much, but yea their dev tools is also pretty good
it probably has almost everything chrome has
it's similar to chrome dev tools
Lighthouse is also great
what language?
discord.js
and php
djs and php??
separate php and djs
just call the endpoint, this is universal (requires no specialized lib at all)
...
because im a idiot
Ok so, for anyone using Firefox, you can enable it by changing the config manually
...
yk it's never too late to start learning how to use docs right?
then just don't be
my brother taught me he has a bot here but he doesn't teach me how to use dbl
you'll eventually reach a point where you have an issue so specific that noone except you can solve
there aren't examples for every use-case
do you know how to call apis?
like, by fetching
yeah I see, I'm getting a warning about the contrast
I know and I'm trying to learn to read docs but I don't know where to start. can you guide me
good to know that exists
idk
np
start here then
thank you
and here for php
๐
im know how to call api
bonk
but im dont call dbl api
then all you need is the top.gg url
it's the same thing for every single api in the internet
he wants to send a curl request in php? missing the context
you send a request, it answers you
context here
I want to do djs first, I'm training in php, php is not a problem.
just fetch the api in js
ah, that's webhooks then
webhooks
you want to check if someone voted? or you want to receive realtime vote events/notifications?
๐
:P
my brother has an approved boot i want to try on it
it will only work for his bot tho
the realtime vote notification system only works on one target at a time, if your brother already uses this system, you cannot use it without disabling his
you can use the endpoint to check if someone voted tho
You simply create a webhook listener (which is a webserver listening for post requests) and let topgg send these requests to your endpoint




