#development
1 messages · Page 2066 of 1
And then have all your locales loaded in memory unless specified otherwise
Then have like Locale.t('en', 'bot.message')
I’m probably missing something here but it feels wrong to need to await localization like that
I understand the ts being dummy thing but still
yes
Cause dot prop allows to go deeper than just 1 lookup
You could do some sort of syntax like Locale.get('en.message');
{
"bot": {
"message": "Hello, World",
"id": 1231313321,
"blah": {
"blah2": {
"something": "asomerasd"
},
"something": "somethingelse"
}
}
}
so you can nest
Oh localization uses objects too?
Nest what though?
I thought localization was just one string value to each key
the idea behind nesting is to organize your shit
Organize what
But localization is about translating phrases
I don’t see why you’d need nesting for that
{
"bot": {
"welcome": {
"mainMessage": "Hello, there blah",
"someOtherImportantMessage": "Something idfk",
},
"somethingImportant": "asdadsasd"
}
}
This is what I was idealing about
whatever though ig
I can do it like you guys suggest
Do what you want to do
ruining my fun hmph
I just don't see why nesting isn't a thing
like why not allow nesting?
It would make your localization files easier to read
It seems more complex to handle and you have to do that janky ts thing
(never)
{
"CLOUD:NAME": "ProductName",
"CLOUD:SIGNIN:USERNAME": "Username",
"CLOUD:SIGNIN:PASSWORD": "Password"
}```
Mmmm
I just feel like going by dot notation is easier for me to handle
I also gotta work on allowing them to have placeholders in their localization files
So here we could do
{
"WELCOME:MAIN_MESSAGE": "Hello World",
"WELCOME_SOME_OTHER_THING": "Something else",
}```
This is the i18n standard btw
which I could probably just do a .replace on
You might want to look at how mainstream localization is standardized
the language translation tool
Not saying you do I'm just saying this is i18n's
That's what we use at work
I imagine it's a little bit easier than object parsing.
Standards are good misty don’t go down this hole 🤬
no fuck you waffle
Standards make life easier for the developer
Misty breaks the norms 
I make my own standards
Based
I don't think it looks that bad...
I think that it would be smart to make sure you at least support the standard way of doing things, otherwise people probably won’t use it
I am treating this as if you are looking up stuff from actual objects dylan that is the only reason I say this
Then it goes to like this.translation("KEYHERE");
Most people that would use your package likely already have i18n built in
And therefore likely adhere to the standards
Yes but not all djs devs are dumb
is there a way to increase the size of the iframe tag?
https://top.gg/bot/895136993732878376
No
Waffle you really want me to cry more don't ya
No I’m just trying to help you
|| some dont even want to learn js||
okay fuck dot prop then
Make it how you want to make it, just be aware of standards
I at least know how to bypass dynamic imports transpiling to require now
so I learned something

Lol
Even bigger brain, make your own import function that just does that but in a function so you don’t have to see the jankiness
yea? isnt that basic json?
Okay and with this you'd this.translate("KEY:NAME")?
I am talking about how i18n standard is
I know it is just json
Right, and presumably you have a command that handles changing languages and loading the correct JSON file for each language so that it can key the right one
ok bye bye
bye person
I was planning just loading all of their json files into a map with the key being the locale

How many languages will a bot really support tho
True
I doubt some mf going to support all the languages in the world
There’s not really a good solution for that issue
Loading it into memory once is pretty much the best solution, if you’re supporting that much i18n then you’ve probably got a good enough vps to handle the damage
you're fine with maps as long as you have less than 8 million keys
Lol

Why
You could but that seems like it would be up to the developer to do that
mmm true
Plus js already has string interpolation
I was going to hand hold em
😻
export interface ITranslatedText {
[k: string]: string;
}
function translate(key: string): string {
const myKeydPhrases: ITranslatedText = this.supportedLanguagesMap.get(someGuildConfig.locale);
const myPhrase = myKeydPhrases[key];
return myPhrase;
}``` Excuse my crude code example, but this should be fine
public t<T>(key: string): T | string {
const contents = this.locales.get(this.options.lng);
return contents[key] ?? 'Nothing was found there.'
}
literally all I did
this was for something before
I was going to let them set the type of the returned data
Makes sense.
;p
const { Localization } = require("locale");
(async () => {
const locale = new Localization({ lng: "en" });
await locale.addMultipleIn("locales");
console.log(locale.t("WELCOME:MAIN_MESSAG"));
})();
intentional misspelling of the localization key
but it works
😎
I wonder if people will have issues setting the lng though
standards 
well ig not
why do you need to set the lang in the constructor if you're adding all of the localization files in it already
cause that is what is used to query the map
but... why are you using addMultipleIn then
cause that reads all the data in their localization files and adds them to the map with the file name being the key of the map
Did Discord say a while back they're going to support language locale for slash commands?
Again, the problem being that you'll have to do this with many localization objects, no?
for the name and descriptions of options/choices yes
Wdym
Not sure I follow what you are saying waffle
Say I have localization for english and spanish, how would I access both of them
what
lng is the fall back language waffle
one that you'd use as default
t takes in 2 params locale being a optional one
Ah, okay
es

So then how are you setting the keys for each of the maps containing the localization
public t(key: string, locale?: string): any {
const contents = this.locales.get(locale ?? this.options.lng);
return contents[key] ?? 'Nothing was found there.'
}
so the t function looks like this
How do you know which one is en, es, etc
the key are the locales file name
so if you named your files like en.json, es.json
then en would be the key for english es would be the keys for spanish
Also, I'd throw an error if you can't find the localization text
Mmm alright
Since you wouldn't want it returning "Nothing was found there." because that could end up with bad results
Say someone mistypes a key and they don't realize there's something wrong until people start complaining about prod saying "Nothing was found there."
I thought Misty said this was for their bot
he's making a localization package
ah okay
not sure what the targeting part is, since it's just reading a file and translating
C:\Users\dyeaa\Documents\github\misty\price-check>node main.js
Error: WELCOME:MAIN_MESSAG does not exist in your en's file
at Localization.t (C:\Users\dyeaa\Documents\github\misty\locale\out\struct\Localization.js:15:37)
at C:\Users\dyeaa\Documents\github\misty\price-check\main.js:7:22
so like this?
i18n just returns the key itself if it's not found
I'd maybe make your own error class
yea I was thinking that as well
That's the standard?
Return the key and that tells the end user that it needs to be translated or needs to be fixed.
apparently so 😎
well it is going to hopefully be integrated into a friend of mines framework
to allow easy localization
If that's the standard then I guess go for it, that just seems like an error to me
why crash the program if it can be added later
what if a dev is working on a portion of code and has to wait a day for their translators to get back to them
Fair
Perhaps have a warnings option in your localization object options, and then log warnings when you can't get a localization for a certain language
So that users are still aware, but can turn it off if it's intentional
I feel if you're making a package for others to incorporate into their projects you should NOT be console logging as that area is for the user to do their own outputs.
WELCOME:MAIN_MESSAG was not found. Check your spelling/make sure you are looking in the right localization.
Hola
also checked making sure that getting from multiple localizations worked
so I can fetch from spanish localizations
How else would you alert users without throwing an error?
throwing an error is indeed not a good way
Again that's why you return the KEY back up. That's pretty noticeable when it's a VISUAL thing
you don't wanna stop the program
I'm in the school of thought that it should be very explicit in what's wrong
If I see this on my site or in discord
Then I know I messed up MY own translation file
And I can easily fix
up to you misty ¯_(ツ)_/¯
^^^^^ TRUE
if people don't like warnings, you can remove it; if users want warnings, you can add it
just depends on how you want to design it
I will make it output a java like error

super unhelpful 
Instead of what is wrong I will make it output the entire communist manifesto
do it
can i find a role by it's permission
I don't think so?
Lmao I guess
but no telling you will get the exact role you want
doesn't help if multiple have
it will likely end up giving you a collection of em if a lot of roles have that perm
im trying to make a log channel where everyone can't see it only admin can
permission overwrites is a thing
^
I don't remember exactly off the top of my head
but I know you can do something like
Then climb to the top of your head and think

<Channel>.permissionOverwrites.set([
{
id: roleYouWantToAllow,
allow: [PermissionsFlagsBit.ViewChannel, someOtherPermsIDK]
},
{
id: guildID, // this allows you to target everyone in the guild
deny: [PermissionsFlagsBit.ViewChannel, someOtherPermsIDK]
}
])
I found this cursed piece of shit from my detritus code: ```ts
export function createOverwritesAboveMinPermissionsSet(
minPermissions: bigint,
guild: Structures.Guild,
allowPermissions: bigint[],
denyPermissions: bigint[],
): RequestTypes.CreateChannelOverwrite[] {
const roles = guild.roles.filter(role => (role.permissions & minPermissions) == minPermissions);
const permOverwrites: Array<RequestTypes.CreateChannelOverwrite> = [];
for (const role of roles) {
permOverwrites.push({
allow: permissionsAsAny(allowPermissions),
deny: permissionsAsAny(denyPermissions),
type: OverwriteTypes.ROLE,
id: role.id,
});
}
return permOverwrites;
}
that is detritus shit
it won't be helpful here cause we can actually use arrays here waffle
message.guild.channels.create(channelName,{
type: 'text',
permissionOverwrites:[
{
id: everyoneRole.id,
deny: ['VIEW_CHANNEL']
},
{
id: guildAdminROle //How do i find
allow: ['VIEW_CHANNEL']
},
]
})
I have the same thing
aight i will change that
to find the role you want
you can filter through the guild's roles
<Guild>.roles.cache.find((r) => r.name === "SomeName")
which returns you the role object IF it exists if not you will have issues
ok thx
@round cove https://github.com/Mistyerious/locale :^)
for the guild id is this ok
{
id: message.guild.id,
deny:[PermissionsFlagsBit.ViewChannel, someOtherPermsIDK]
},
Hell yeah dude
ik
cool shit unironically proud
i'm not dumb
I JUST saw it lmfao
IT WAS NOT MY FAULT
I know 😔
read me formatted it weird no matter how I tried to do it
😩
ty man
I don't know what more I could do to make this package better
I think rn it is good how it is
Make a better read me and I will 100% use it 😉
def not pushing it off onto other people
https://stackedit.io/ pro tip
Full-featured, open-source Markdown editor based on PageDown, the Markdown library used by Stack Overflow and the other Stack Exchange sites.
ok but peep the readme https://github.com/Jwaffled/MathExpressionParsing
I tryharded that readme
@wheat mesa tf is this
it looked perfectly fine in the preview
😔
ok
3 commits just ot make the fucking readme look good
smh
Lmfao
back to djs after 8 months cuz old account got deleted lol
could someone please lmk what's wrong here? approved all intents and also has perms
403 usually means missing access/permission
when you make the invite link for the bot make sure to click application.commands alongside the normal bot option
does grabbing a guild's id trigger the discord API rate limit ?
Well fetching from the API x times and in a matter of n amount of time can cause a rate limit yes
Show your code and we can try and help to determine why you're being rate limited
am not getting rate limited, i just wanna know if that is a possibility when a lot of people use the bot
the limit probably gets higher if more guilds use the bot
thats what i thought
there's no way a bot with 100 guilds and 100000 guilds have the same limit
You can apply for it iirc unless they changed how they handle it
Best bet would be to email them about it and you'll get your answer another method of finding a possible answer is to ask in the dapi server
that's gateway rate limit
See the http one
there isn't much to do with gateway except changing status
i can't find http limits, ill have to look
Anyway
You can always check the X-RateLimit-Limit header value
It'll show the global limit
it's different for every user
*client
thank you
np
you made a lib?
I did yes
It isn't publicly out cause no one will use it
The repo's code is out dated
I find it rather nice
I could 100% make a dashboard now for a bot
But I don't know css that well
So the only thing holding me back is design
design is just pain
need to have a lot of patience
i'm stuck at a similar situation
Nah
Css is by far the hardest thing to me
I find making a lib easier than css
try using a framework for CSS like tailwind maybe? makes the job a bit easier in my opinion
I have chakra to carry me
that is if you know CSS to a decent level
I use mantine and tailwind.
Though I kinda wanna swap back to using angular over react ngl
Issue with css is I don't have the patience to sit down and use it
I can sit down and work on something like a library for hours though
Libs can't do everything for you
At least most of the annoying things can be done
I have to write 300 lines of css instead of 3000
I'ma probably just make a website without any css or component libs to begin with ngl
It'll force me to learn css
Using mantine I barely needed custom css
Most of the things that I needed with css was just basic
How can I stop node-gyp trying to use multiple visual studio versions? I have 2022 version installed, and both yarn and npm config are set to use the 2022 version.
haven't you been playing pokemon all the time?
No
ah
Spent the whole day cleaning today
Dang
I am probably moving soon
so i gotta clean as well
kek
So coming from a design pov, should the Client have access to application properties
talking bout my discord lib here
The second file is the one I was trying to keep from being uploaded
Don't mind my rage comment haha
I am wondering what that red is
probably not important
but hmmm lets see
So you added the gitignore, made it ignore the json file, ran git add . then ``git commit` and then pushed it right?
Yes
I've had to reset my bot token four times now because git seems to refuse to listen to .gitignore
I'll check it out now
Just fyi
Since you mentioned you committed before
You'll need to remove the remote file, it would otherwise still get pushed
Aka the gitignored file on the remote end
Tried to install react native and it gives this error anyone have any idea about this?
I might be wrong but just from reading it, looks like your dependencies require a different version of react then what you are trying to install
I didn't mentioned any version while downloading so i dont think it should be a problem
Infact its a on going project with package json file
And im just trying npm i
npm i on its own?
Seems like the other packages that rely on react don't support react v18
Again I could be wrong cause I suck at reading npm errors but just from a first glance that looks like it is what it is saying
Yup getting you
Please support I need tea https://www.patreon.com/tsoding
python 5?
Does someone have experience with discord auth2 like what topgg has login with discord and then it shows guild i am unable to find my way in it
you mean oauth2
Yeah
what was your problem again?
"it shows guild i am unable to find my way in it" what?
Uhmm....that isn't problem that i wanna do like i mean where to start from making it
There are lot less clear tutorial available on yt
you need a webserver
like a website or something
when people access your website, or a specific url in your website, you redirect them to discord's oauth2 url
discord's oauth2 has a callback system that redirects the user back to your website when they login
when the user is redirected back to your website, it will have extra stuff in the url, for example yourwebsite.com/url?code="39y9c82yn39c48y29384y9"
you have to read this code to access the user's information
the code will be there in your url
after the user is redirected
also there are two types of oauth2, explicit and implicit grant
the explicit type gives you a refresh token that you can use to keep the user's token valid
Oh
the implicit type only gives you temporary access, after which the user has to login again if you want to keep accessing their data
Ic
the implicit type is easier to use
both are described here
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Ah looks so complicated to put onto a website tho i will try
for example using the implicit grant
you redirect the user to https://discord.com/api/oauth2/authorize?response_type=token&client_id=290926444748734499&state=15773059ghq9183habn&scope=identify
the user will be taken to the discord login page
once they login, they will be redirected back to your website, in the url you specify in your discord application's redirect uri
after they are redirected, you will receive a request to your website like this
https://yourwebsitehere.com/#access_token=RTfP0OK99U3kbRtHOoKLmJbOn45PjL&token_type=Bearer&expires_in=604800&scope=identify&state=15773059ghq9183habn
these extra things after the # character is what you use to access their data
By redirect you mean like putting redirect url in bot invite and user authorises it and then the url got has token in it from which i can acees user info right?
And there are two types one temporary and one permanent
both are temporary but one can be refreshed every X time, the other cant
Oh
just adding a redirect url in the bot invite is not enough
the redirect url in bot invites only work if the user logs in with discord first
first you need to go to your bot's application dashboard, and setup its oauth2 links
This is from Spotify but the same works for discord
damn spotify's docs are better than tutorials

is there anyway to reload a voice connection on d.js?
hey, got a question. how can i use axios to search for a specific parm in the api?
for example i wanna search for https:\/\/howrare.is\/unfrgtnorbit\/482 and i wanna get the ranking of that so Rank 1
convert the response to json
and then? how can i search?
bruh but i want the find the rank
i have the link but not the rank, thats what i mean
that still doesn't make sense
if u request the api ur getting a single json no?
or does it return more than one?
1 json, but what i mean. in this json it shows the rank of specific ids. i got the ids and i wanna find the ranks using a command
ik its possible but i am doing smth wrong i guess
.find
Convert to json, do jsonRes.find(x => x.rank === 69)
I assume it’s an array of objects
will try
My compile command won't work, I have the full, long, error in this txt file below.
show your compile.js file
The entire file?
until line 17 (including line 17)
const config = require(`${process.cwd()}/config/config.json`)
var ee = require(`${process.cwd()}/config/embed.json`)
const fetch = require("node-fetch");
const { MessageEmbed } = require(`discord.js`);
module.exports = {
name: "compile",
category: "🛑 Others",
aliases: [""],
cooldown: 4,
usage: "compile <Code>",
description: "Compile code.",
run: async (client, message, args, cmduser, text, prefix) => {
thats only until line 14? you need to show 3 more lines
ok
const config = require(`${process.cwd()}/config/config.json`)
var ee = require(`${process.cwd()}/config/embed.json`)
const fetch = require("node-fetch");
const { MessageEmbed } = require(`discord.js`);
module.exports = {
name: "compile",
category: "🛑 Others",
aliases: [""],
cooldown: 4,
usage: "compile <Code>",
description: "Compile code.",
run: async (client, message, args, cmduser, text, prefix) => {
try {
const possiblecommands = {
cpp: "g++ main.cpp -pthread -pedantic -Wall -Wextra && ./a.out",
Just a fair warning if you didn’t already know, running code from unknown people will result in your VPS being absolutely fucked by everyone that can fuck it, especially with C++
Also, the error you have doesn’t make sense for the code you posted
I mean he's just compiling it
but like also just use an API which does this for you there are plenty
He’s also running it
&& ./a.out
I could imagine somebody abuses this though and compiles so much garbage it just locks your CPU at 100%
I’d lock this command to only you and whitelisted people
Either that or use an API designed for this
you can do a ton of compile time fuckery too
i still dont see a .get() anywhere, did you skip a line?
show more lines
run the script with an api or a docker container with no network access and user account privileges with limited execution time and you should be good
that's the least of the worries lmao
can't c++ directly access hardware?
u can literally brick the physical part no?
programs run under a level called ring 3
at that level any program if it malfunctions or is malicious should not be able to harm the hardware or read any other programs data
worst case scenario it can delete or read some files at best
feeling really short mood wise today
one too many idiots over on my own Discord
like, "help me or I'll hurt myself" really isn't something I can deal with any way except ban...smh
wtf
yeah ikr
Smh
you ever get one of those days where the fail seems constant
I'm gonna have to be stricter with spoon feeding I think
like you are here
i mean yeah
uhm what
good to know
spoonfeed but with one or more obvious errors so they have to at least read and understand the code 
/
What's webhook ratelimit again? 20messages every 5 seconds?
i want to give all this roles access to a channel i'm making how do i do that
find the role by name so you have the roleobject
then give the role permission to view the channel
and deny the everyone role (guild id) permission to view the channel
this is how i'm pushing all the roles from the guild
message.guild.roles.cache.forEach((roles)=>{
if(roles.permissions.has('ADMINISTRATOR')){
adminRoles.push(roles.name)
}
})
what
that's not what I said
also why do 5 different roles have the admin perm?
and if a role has admin perm you don't have to give them permission to view a channel
all you have to do then is just deny the everyone role (guild id) the permission to view the channel
ok thx
just found this is it older than you @quartz kindle
think they were a thing at around the 1970s
probably yes
In 1963, the GE-235 featured an "Auxiliary Arithmetic Unit" for floating point and double-precision calculations.[5]
does anyone know if according to the ABI if a functions stack frame is released does the function also release the parameters?
5/5
its 50/5 with all webhooks combined per ip
bro can i just comaplin
my laptop is so shit
imagine having 4gb ram in 2022
its enough to run a single chrome tab on windows without thrashing
let alone visual studio code with wsl and heavy c++ compiler tools
imagine using chrome
the performance increase of no thrashing will outweigh the performance decrease of operas performance
clang takes like 10 seconds to lint shit
20 sometimes
bro just because something doesnt use v8 doesnt mean ITS TERRIBLE
opera needs to swallow its pride and use v8
dont know what the ram differences are between them tho
get a pi 4b with 8gb ram, put the compiler and Linux environment elsewhere
and change to a different more lightweight editor

is there anyway to "restart" voice on d.js? cuz my internet sux the connection drops and come back meaning that the bot can join the chat but not play anything
it fixes when the bot is restarted but i dont want to have to do that like everyother day
is there any way to fix that
or am i just screwed
When you drop your connection to discord it’s likely you’ll get an unrecoverable error, or at least a bad state. When your bot disconnects from the gateway, it has to log in all over again
You need to find a solution to your internet, not a solution to reconnecting
If it happens often you’ll also likely hit your connection ratelimit if you’re automatically reconnecting somehow
session resumes dont have a ratelimit other than the standard sending 120 gateway messages a minute
bruh
welp we might get fibre at some point depends
half of it is just my internet being adsl
and the other half is just our 10 year old router
You probably shouldn’t be self hosting then
I’d say it’s probably more likely your computer is the issue with your connection dropping, some motherboards with built in wifi suck, and if you’re using a wifi card, sometimes those can break and cause issues like that
Personally I have had to replace my PCIE network card once so far
Had a similar issue where my ping would spike to 6000 and/or disconnect for a few seconds periodically
nah the router sometimes just reboots when im doing alot of stuff
also its ethernet
and the vc bot is just for my own server and doent affect my main bot so eh
what in gods name is that data structure
it is a working url that is what it is
hello, am trying to add the slash commands to my bot.
do i just remove the guild=discord.Object(id=MY_GUILD_ID)
to make available for all the servers ?
because i tried it but it doesn't work 😄 am i missing something ?
what lib?
looks like dpy
disgusting
yea discord.py
cant help you sorry, i use py-cord
oh i see
by the way, discord.py is getting updated again, its not shutdown anymore
they are all the same xd
you are in hell alone misty
those burning fire makes you hallucinate
i tried to switch to js, but i had trouble reading and writing to files using fs, python is just easy and quick with fewer lines
mainly the same, but not everything is the same
Hey I have a question
So I was trying to deploy my website with vercel. I have got mongodb on the website and stored it in process.env file
I got this error
When the environment variable starts with mongodb+srv://
How to get the total vote number ?
yea
The total number of votes should be possible to get sending a request to the api
People try to use api for vote notifs and webhooks for vote total
And/or by listening to the webhooks continuously and storing/counting them
Which might not be accurate sometimes since some webhooks may not make it to your endpoint
For various reasons
Request API on startup, keep count yourself after that. Maybe fetch from API every now and then (like 30 minutes or 2 hours or something like that) and correct your count
Uh anyone?
Log your env variable, vercel might have their own way of injecting envs into your program
Oki
{$pull: {inventory: {Name: "marriage ring"}}}``` can't pull when the string has space
any thoughts?
y
https://sourceb.in/0t9L61e9VM, How should I base on ms on database instead of cooldown in commands?
The cooldown is working fine
Issue: when the bot restarts, the ms ignored
all done
is this using sequelize?
Looks like you were storing data objects (so in memory) holding the cd information?
I've gotten like 30 missing permissions errors in my console then this dropped and my bot died even the PM didn't bring it back
ERROR Uncaught Exception: Error: WebSocket was closed before the connection was established
the fucking problem is it doesn't tell me which script / package the errors are coming from
xd so I'm stuck with them
Well what kind of error handling do you have set up?
log the debug event djs provides
Looks like maybe you have something like
process.on('unhandledRejection', (reason, promise) => {})
That won't be very helpful here
The error is being caused by something internally with djs
the debug event logs nearly everything that happens in djs from the first hello, to identifying and so on so forth
If you don't have a handler, it will normally show more information (traceback), at least it does for me
That's why I think they have a handler that doesn't log set up
Use the library/docs Top.gg has: https://docs.top.gg/
thanks...
What library are you using?
Im actually still looking into whats avilable rn
maybe python?
@forest cosmos Python examples: https://docs.top.gg/libraries/python/
I think they’re well explained and with a little adaption you should be good to go
Whenever the vote event fires, store the timestamp of it and then compare it with the next vote that comes in from the user ID
thanks
yeah..
I do, I've made a handler for almost everything including an error handler
which uses the unhandledRejection event
guys I wanna make a hangman game, but if I take the input from the chat anyone could play and it would really clog the chat the command is executed in
buttons won't work either
because I can't add buttons for the entire alphabet
:/
any ideas?
yeah but I want the game to be played with multiple people

Then allow people to opt in
ye
oh I see maybe like a 30 second thing with a join button
should I make it minimum 3 people?
well I have an idea of how it could look like potentially...
well I'll start coding ig
gl
thank
man i cant find the motivation to design my portfolio on figma 😔
what's figma?
website/mobile and things designing software like adobe xd
but a bit better imo
sounds pretty useful I usually don't plan much when doing projects
just go with the flow 
💀
lmao
i just started using it too
but i suck at frontend and designing so practicing
I'm decent at frontend but I have to have a set idea of what I'm doing otherwise I'll be stuck
cause I'm not very imaginative
same
I can make a game with AAA graphics but no gameplay
lmao
😭
i really gotta practice frontend shit fr
backend developers ain't got any reputation fr
fr 💀
const challengeCheck = await msg2.awaitReactions({ filter, time: 30000, max: 5 });
``` any way I can execute some code each time someone reacts?
reactionAdd event?
I want to update the text to update who joined the game
how does it work?
idk never used it
oh wait I can't use a global event for a command
but there was an event
it would suck to integrate it
challengeCheck.on('collect', ({emoji}) => {
if (emoji.name === '👍') {
joinedCount++; whoJoined.push(...)
msg2.edit(`Hey peeps! ${message.member} started a game of Hangman. React to the message to join. You have 30 seconds.\n\nJoined ${joinedCount}/5`);
}
});
challengeCheck.on('end', (collected, reason) => {
if (collected.count < 5) {
msg2.edit("Not enough people joined the game. Cancelling the game.")
return false;
} else {
msg.delete();
return true;
}
});
I have a whoJoined array
I want to push there IDs of people who joined the game
how do I fetch them?
challengeCheck.on("collect", mf => console.log(mf.member))
prolly
challengeCheck.on('end', (collected, reason) => {
if (collected.count < 5) {
msg2.edit("Not enough people joined the game. Cancelling the game.");
return false;
} else {
msg2.delete(); whoJoined = collected.users;
return true;
}
});
}
// Now lets ask the mentioned member if they wanna play using the function we made above.
let validation = await validateUser(message);
// If it went through let's now start our game.
if (validation === true) {
return message.channel.send(`The game would normally start but I haven't coded that part yet. ${whoJoined.join(", ")}`);
}
``` the end event doesn't work
the count doesn't show up when it's less than 5 members
message does delete, butreturn message.channel.send(`The game would normally start but I haven't coded that part yet. ${whoJoined.join(", ")}`) doesn't send
any ideas?
so I'm making a collector to collect all the users who react and update the count on a previously sent message. The message sends and everyone can react to it and the count updates, but it doesn't end somehow when 5 people react, the message just deletes itself and the validation === "done" message doesn't send afterwards. It deletes itself even if there isn't enough people. I'm really confused. Any ideas?
let whoJoined = [], joinedCount = 1;
const validateUser = async function (message) {
const msg2 = await message.channel.send(`Hey peeps!\n${message.member} started a game of Hangman.\nYou can react to the message to join!\n\nJoined ${joinedCount}/5`);
msg2.react("👍");
const filter = (reaction, member) => "👍" === reaction.emoji.name && member.id != client.user.id;
const challengeCheck = await msg2.createReactionCollector({ filter, time: 30000, max: 5 })
challengeCheck.on('collect', ({emoji}) => {
if (emoji.name === '👍') {
joinedCount++;
msg2.edit(`Hey peeps!\n${message.member} started a game of Hangman.\nYou can react to the message to join!\n\nJoined ${joinedCount}/5`);
}
});
challengeCheck.on('end', (collected, reason) => {
if (collected.count > 5) {
return msg2.edit("Not enough people joined the game. Cancelling the game.");
} else {
msg2.delete(); whoJoined = collected.users;
return "done";
}
});
}
let validation = await validateUser(message);
if (validation === "done") {
return message.channel.send(`The game would normally start but I haven't coded that part yet. ${whoJoined.join(", ")}`);
}
Well your logic in the if statement is off
Shouldn't it be count < 5
Your code is very hard to read on mobile
you return from the function you're passing to challengeCheck.on("end", f) not from validateCheck
this is like async programming 101, you might wanna read up on callbacks and promises
my bad
I can't really format it better
yeah I get it now
// And create a end event when the timer finishes or the max of 5 people joined.
const endFunc = function(canStartGame, joinedUsers) {
if (canStartGame === true) {
msg2.delete(); whoJoined = joinedUsers.users;
return message.channel.send(`The game would normally start but I haven't coded that part yet. ${whoJoined}`);
// Define our hangman game.
const Hangman = require('../games/hangman.js'); const hangman = new Hangman();
// And start a new instance.
hangman.newGame(message);
} else {
msg2.reactions.remove();
return msg2.edit("Not enough people joined the game. Cancelling the game.");
}
}
challengeCheck.on('end', (collected, reason) => {
if (collected.size <= 3 || collected.size === 5) {
endFunc(true, collected);
} else {
endFunc(false, collected);
}
});
``` anyone know why whoJoined is undefined?
it works now but whoJoined is undefined. it's set using joinedUsers.users which derives from the collected variable in the end event of challengeCheck
any ideas how to fix that?
Could be joinedUsers.users is undefined
where are the users who reacted to the message stored?
the docs said it's collection.users
you're making this way more complicated than it has to be. Just return a promise
return new Promise(res => {
challengeCheck.on("end", (collected) => {
res(collected)
})
})
and then await your async function normally
I'm confused, how will that get the users out either way?
it just resolves the collection the end even emits
how will that help me get the users out of the collection though?
you await the promise 
what 😭
how does await collection get users out of it
I'm so confused even in the discord.js server they did that
how
do you get collection.users by awaiting collection?
how?
the reason why you can't do what you're trying to do is because the "end" event emits at an unpredictable time. Your function doesn't wait for that event. So you wrap it with a promise and only resolve it when it's done
const validateUser = async function(message) {
const filter = (reaction, member) => "👍" === reaction.emoji.name && member.id != client.user.id;
const challengeCheck = await msg2.createReactionCollector({
filter,
time: 30000,
max: 5
})
challengeCheck.on('collect', ({ emoji }) => {
// whatever
});
return new Promise(res => {
challengeCheck.on('end', (collected) => {
res(collected);
});
})
}
let collected = await validateUser(message);
if (collected.count > 5) {
return msg2.edit("Not enough people joined the game. Cancelling the game.");
} else {
msg2.delete();
return message.channel.send(`The game would normally start but I haven't coded that part yet. ${whoJoined.join(", ")}`);
}
validateUser doesn't resolve until challengeCheck ends
that makes a lot more sense now...
that's what I've had up until now
const validateUser = async function (message) {
const msg2 = await message.channel.send(`Hey peeps!\n${message.member} started a game of Hangman.\nYou can react to the message to join! (You have 30 seconds.)\n\nJoined ${joinedCount}/5`);
msg2.react("👍");
const filter = (reaction, member) => "👍" === reaction.emoji.name && member.id != client.user.id;
const challengeCheck = await msg2.createReactionCollector({ filter, time: 30000, max: 5 })
challengeCheck.on('collect', ({emoji}) => {
if (emoji.name === '👍') {
joinedCount++;
msg2.edit(`Hey peeps!\n${message.member} started a game of Hangman.\nYou can react to the message to join! (You have 30 seconds.)\n\nJoined ${joinedCount}/5`);
}
});
const endFunc = function(canStartGame, joinedUsers) {
if (canStartGame === true) {
msg2.delete();
return message.channel.send(`The game would normally start but I haven't coded that part yet. ${joinedUsers}`);
const Hangman = require('../games/hangman.js'); const hangman = new Hangman();
hangman.newGame(message);
} else {
msg2.reactions.removeAll();
return msg2.edit("Not enough people joined the game. Cancelling the game.");
}
}
challengeCheck.on('end', async (collected) => {
const collectedUsers = await collected;
if (collected.size >= 3 || collected.size === 5) {
endFunc(true, collectedUsers);
} else {
endFunc(false, collectedUsers);
}
});
}; await validateUser(message);
it actually worked
though it returns Object [map] as users
return new Promise(res => {
challengeCheck.on('end', async (collected) => {
//const collectedUsers = await collected;
if (collected.size <= 3 || collected.size === 5) {
endFunc(true, res(collected));
} else {
endFunc(false, res(collected));
}
});
});
``` so you can't do stuff like this? lol
I mean you can but this screams "I don't know how promises work"
creating random functions and passing around callbacks gets real painful
when i am viewing my server on gg it will not let anyone vote
says an error message #407
407 is proxy error
how many people did you check whether they can vote?
sorry 403
like, did you add the server?
The most basic and easy way imo is to call a function once it's done
join a programming server :p
^
Do you have any good ones?
Also I only want to help with discord bots and not web dev
they aren't programming web only
also if you want to help people from programming, go to stackoverflow 👹
stack overflow ogs when you ask for help
"k but you didnt format your question properly"
Stackoverflow needs an account and I dont wanna make one
discord needs one too
maybe people are just getting too smart
I know that's false though because I still see a lot of bad code

Tbh the general intelligence seems to be falling further with each generation
Especially logical thinking and common sense
।।
How do I create something like create-xyz-app and then it installs a couple of stuff I've choosen?
I was
Do you know a person with a sever
This is a channel for discussion about development, #general would be more fitting for that 
Old phone and working atm
But this channel is about other types of development in the likes of programming. General discussion happens in #general or #general-int
Your smart in your own way

Ok
I’ll put that in my cv
curriculum vitae or something like that
The heck
its the list of your education and work
lets talk about development
A document you send in when looking for work. Hpwever, this is not the place to discuss that
ping me if you need help making your discord bot (and you are kinda new at it)
Wow I believed
I know right
how do i remove a percentage from a number in js
i tried using the number and then - 10%
it's returning NaN
anyone has any knowledge on how to get roles from the person who used a slash command with discord.py ??
<string>.replace("%", "")?
or do u mean subtract a percentage?
@slender wagon forgot to ping
if u meant the latter, that's basic calculus, not really a language-specific problem (I doubt ANY language will have n - 10% as a valid operation)
looks like subtracting a percentage
n - n * 0.1 (10%)
which you would have to convert that percentage to a decimal and do that way
or that
or n * 0.9 (90%)
same diff
no need to convert anything, 1 is always equivalent to 100%, just think with 2 less zeroes
is there a way to check if a channel exists
Assuming the code is correct, it would find bots for just the one guild its ran in. But try it and see what happens 
do note, that "might" crash your bot if ran in a big enough server
I would do a progressive scan
like, fetch 100 users per pass
split the member count into chunks of N users, fetch those, count, repeat until you finish all chunks
about the exact implementation, I have no idea
fetching all members at once might cause a temporary spike in ram usage, and if your server isn't strong enough it'll go OOM and crash
🥴 shit i don't do maths
0.1 stands for the percentage?
yes
you could use 10/100 if u must, (% is actually 2 numbers separated by /, the circles represent their positions)
like 2⁄3
high af fee
let bots = 0
let members = guild.members.fetch()
for (let i = 0; i < members .length; i++) {
if (members[i].bot) bots++
}
höhö
that's what he did but worse
gonna work on it a lil bit and make it so the higher the price the lower the fee
Most basic implementation
for that you'll need rule of 3
loop >>> array function imo so
value | percentage
-------|------------
A | 100%
B | X
A being the maximum value, B being the desired value
X = B * 100 / A
You'll probably want to round the number after multiplying by 0.35
it is, but you're not only holding the array reference in memory until that scope ends, but also retrieving its size on each iteration
let sellerReward = Math.round(price * 0.35 )
right
thanks
ye gotta set a maximum before the fee goes to 0
just Math.max the value
since the value and the fee are inversely proportional, you reverse the value side
X = A * 100 / B
u can remove * 100 if u want to get a 0..1 range
(not necessarily clamped to 0 or 1)
65% fee!
lmao
is there a way to make category then make channels inside it
Creating the category will return a promise (your category channel) which you can use to create more channels inside
How do I create something like create-xyz-app and then it installs a couple of stuff I've choosen it to install?
what
well, if u mean running that on cmdline, you need to write a console application and add it to PATH (or equivalent)
now, if u mean ./create-xyz-app, you just need to write a script
yes like create-react-app and then it installs something. How do I build that? Any docs/articles for me?
sometimes I wonder why people don't start with console applications anymore
just pick your favourite language and hit build
the code itself needs to be written by you
it literally like making a discord bot, except you'll be working locally instead of discord
what you mean? 😅
when you're starting to learn a language, you usually (or used to) start with console applications
hello world, who am I, calculator, snake, etc
before you even think about doing UI or using external APIs
yeah kinda true 
who am I
calculator
for example, you build
console.log("Hello world")
into test.js
then node test.js
it'll print Hello world
well that's Python but aight xD
What
console.log("Hello world") :)
then u go more intricate, with conditionals, functions, classes, etc
import static System.out; and then out.println("Hello world"); 😉
a calculator is the perfect project to start, since it involves all of them
when u finish, just build it into and executable (or whatever u use to run a js file from PATH) and run it
u can also just run the script directly by setting an alias
well is there a way I get it to run with npx create-aqua-app ?
idk what npx is, but the concept is the same for all languages
build something executable and tell the machine where to find it
nvm I got it^^ thanks
unless u need a complex builder, just write a bash script
they're not that hard and work perfectly as buildscripts
true but I want to learn a bit more about it and try some stuff like options and checking etc. ^^
Well nowadays powershell tbh
I moved to, too
powershell can go to hell

even tho bash is also nice especially for beginners
it's nice for all skill ranges
yeah no questioning but for beginners to also learn the really basics and terminal stuff
ah yes
but yeah also for advances bash scripts can be very fun and also a challenge if you build a complex one
I always make at least one for all my projects that are going to run in a vps
to set envvars, update from git, check files, clear logs, etc
also nice and pretty helpful
well yeah but it's not that native as i know
Hmm just needs to be activated in the windows features
Shouldn’t even require an internet connection iirc
anything to do with binary compilation and programming on windows that isnt made by microsoft themselves is hell
@earnest phoenix do you happen to know what the approximate size of a js number type is in v8? I know there’s object overhead and such, but not sure of the actual size
too fucking big
this is why discord js's caching tactics are not best suited for javascript 💀
for c++ probably as proven by brain
caching everything yet the memory footprint is tiny
@green kestrel bet that makes you happy
In the internal side it's about 30 bytes or so, the main reason being that it's all mainly classes with internal slots and such
Jesus
But after some considerable optimization (on the fly of course), it usually settles on 8 bytes or less depending on the size of the number itself
Although the optimizations barely apply in some edge cases that usually never happen, or happen way less

Oh alright
You can't really expect much from an interpreted language, it's even bigger in Python's internal side
because even bigint stores stuff as a string
v8 is a fucking powerhouse to be fair
The language wasn’t even meant to be as performant as v8 has made it
Pretty incredible how fast it’s become
it was never meant to be for backend work, node is a crutch
I think it’s a great backend language if you don’t need incredible speed
at scale you often do need incredible speed
My uncle used to work in the industry in the 90s-2000s, he said that they would write their apps and such in Java, and anything that needed to be fast they would just write in C
yeah java is still more efficient than js
Not back then
java at least stores native types in a sane format in ram
(Compared to v8 now)
There’s big differences between the languages
sure, javas garbage collector was more garbage than collector back then ...
I’m sure that v8 now was way faster than the JVM then
but it was still pretty efficient at storage, it needed to map 1:1 with native types for jni
just the collector never freed stuff
Well when I said 30 bytes that's just an approximate, I haven't even checked the size in a while as they change often, but looking at it now, it would probably be around 15 bytes or less now
While even optimized to be way lower on the fly
it has to be the length of the value as a string plus \0 terminator or length count
so 18 is reasonable minimum
I’m sure it’s a complex system of optimizations
nope
you can see the source
there are optimisations on calculations done with it, and assignments
At runtime
V8 is designed to run fast not take small amount of ram

