#development
1 messages · Page 1956 of 1
i'll do what you said
and wouldnt it be easier to store data as
db.set('user id', {
trophies: 0,
arena: 0
});
db.get('user id').arena // -> 0
^^
yeah
you're defeating the whole point of objects if you're not going to use them
but I already made the bot with separated keys
Seems like your process of storing data is a little bit unorganized
¯_(ツ)_/¯
I want it to send a message every time it gets in a newer arena but it doesn't work
your code is very confusing
Yeah
it might not even be anything wrong with the code above
maybe something else
like storing the amount of messages
It’s difficult to tell what’s actually wrong because I don’t know what the point of half of these queries are lol
I started wrong lol I should've learned js properly from the start
leveling?
your whole code behind it
ok
an example for this to not repeat code you could just do something like
const user = db.get('user id');
if (user.trophies % 450 === 0) {
// some code to increase arena
message.channel.send(`Congratulations! You've got to the arena ${user.arena}! Use \`cc.arena\` to view it.`);
}
that way you are not repeating a lot of code
obviously just an example wont work properly
I don’t know if that would work even as a concept since his trophy count probably won’t be exactly a multiple of 450
Unless that’s how your system works
%?
yeah it's not multiple of it
But I can make it a multiple of it
this will send the message only one time?
oh but the trophies maybe are not multiple
because it gives random trophies and it removes random trophies
Not needed
at all
they can't ddos the bot
unless they miraculously got the bot's ip address
thats why its just an example
on ways he could optimise it
he could also have an array of trophies
well if the command is attached to a database
then you should
limit the user
Yeah
or an api
But DDOS protection is really not needed
That’s still spam prevention and has nothing to do with a dos attack
Setup an easy anti spam prevention by limiting command executions to users, channels and/or guilds
As I already told you yesterday…
DDoS'ing a bot is only impossible cuz discord is the one between both ends
so even if u get 1m users to run a command at the same time discord will put things in a queue before sending to the bot
I mean regarding some of the shared code in here, a denial of service sometimes happens if just one or a few commands are executed 
Oh right okey thanks
Or upon startup!
normal go is enough for an api or should use a framework?
normal any lang usually doesn't work
wdym
generally people advise not using raw go for an api
frameworks exist to make your life easier
Yeah or this
hello, can anyone help me to fix this problem?
^
TypeError [INVALID_ELEMENT]: Supplied Array fullPermissions includes an invalid element: [object Object]
at ApplicationCommandPermissionsManager.set (C:\Users\moyou\Documents\Alef\node_modules\discord.js\src\managers\ApplicationCommandPermissionsManager.js:180:51)
at C:\Users\moyou\Documents\Alef\Handlers\Commands.js:64:50
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
[Symbol(code)]: 'INVALID_ELEMENT'```
Show us line 64 of Commands.js
You probably didn't pass an array to some function/method
@sudden geyser
What's the value of fullPermissions?
idk how to code in this way i copied this video https://www.youtube.com/watch?v=rqRb8YJ4T5Q&list=PLQfxpktrTzhK-w4sdeIV6lNEdr-a1ke2Z&index=4&ab_channel=Lyxcode can u check it?
lol
I think I see what's wrong
Here specifically
The docs says it should be an array of permissions: https://discord.js.org/#/docs/discord.js/stable/typedef/GuildApplicationCommandPermissionData
I assume the video doesn't go over that, so it probably won't help you.
What you probably want to do is get rid of the : true after it.
Because you have the variable
But you're not using it.
oh
is there a way to make a event for onvote
so when a user votes i can give them a role and other perks
Thank You Very Much ❤️🔥
@sudden geyser I Got This Message :/
That doesn't correspond to the code block you showed me, so that's another issue.
Check the stacktrace for the locations of the error
You can then debug what went wrong
when i used the / command i got it
this is the code for: interactionCreate
Nice
Now you know it's throwing due to execute not being a function
So you'll want to check the value of command for an execute function/method
Which is probably missing
What you could do
Is check what value corresponds to the command you issued
and check the source code of that
its the same for the source code
ArgumentError: Expected `string choice value` to be of type `string` but received type `undefined`
error ^
.addStringOption((option) => option.setName('warranty')
.setDescription('Insert the type of warranty you can provide for this item.')
.addChoice('Till Claim')
.addChoice('Lifetime'),
),
the code^
Why’s there a , behind the addChoice method?
And why’s there another one behind addStrinngOption?
You remove both as that’s no valid syntax
because it's the end
It’s not an object or an array
if i remove that it leads to errors
data: new SlashCommandBuilder()
.setName('add')
.setDescription('Adds a item to the shop (Sellers Only)')
.addStringOption((option) => option.setName('url')
.setDescription('Insert the url of the item you are listing!')
.setRequired(true),
)
.addStringOption((option) => option.setName('price')
.setDescription('Insert the price of the item you are selling can go from 20 - 50 Cips!')
.setRequired(true),
)
.addStringOption((option) => option.setName('warranty')
.setDescription('Insert the type of warranty you can provide for this item.')
.addChoice('Till Claim')
.addChoice('Lifetime')
),
async execute(interaction) {
the top 2 ones work just fine
I see you removed the first one
the issue is on the third
There are also , behind the setRequired methods
Also an invalid syntax
…(method(),) is just wrong on many levels 
where is the , at
but those work just fine tho
the third one is the one not working
removed
still the same error
If code blocks wouldn’t be that horrible to watch on mobile 
Could you post the current code again incl the error?
Without indentation
.setName('add')
.setDescription('Adds a item to the shop (Sellers Only)')
.addStringOption((option) => option.setName('url')
.setDescription('Insert the url of the ')
.setRequired(true)
)
.addStringOption((option) => option.setName('price')
.setDescription('Insert the price of the')
.setRequired(true)
)
.addStringOption((option) => option.setName('warranty')
.setDescription('Insert the type of')
.addChoice('Till Claim')
.addChoice('Lifetime')
),
shortened desc so u can understand on mobile
i think the issue might be at
.addChoice
^
ArgumentError: Expected `string choice value` to be of type `string` but received type `undefined`
Expected string `string choice value` to have a minimum length of `1`, got `undefined`
Expected string `string choice value` to have a maximum length of `100`, got `undefined`
Is addChoice a valid method for string options?
looks like it
addChoice seems to require 2 parameters
uh
There we go
let me see what the sec par does
are you registering guild commands and global commands?
if so, all commands will show twice on the guild with guild commands.
This or the fact you’re registering commands multiple times
not sure abt that one
Well it’s your code, don’t u know how/where you register them?
ah i am registering them globaly
no i do
but i've been moving them from 1 pc to another
and the .env file messed up
Probably on any startup?
yup
Commands need to be registered once only
Anything else causes unexpected issues
You can always update or delete them but not register an already registered one again
try {
if (!TEST_GUILD_ID) {
await rest.put(
Routes.applicationCommands(CLIENT_ID), {
body: commands
},
);
console.log('Successfully registered application commands globally');
} else {
await rest.put(
Routes.applicationGuildCommands(CLIENT_ID, TEST_GUILD_ID), {
body: commands
},
);
console.log('Successfully registered application commands for development guild');
}
the dev guild id isn't on my .env anymore that's why it's messing up
just figured
That registers both global and guild commands but still a registration process is a one-time process
(at least in your test guild)
Alright I’m out… working
only running it when the bot goes online, and this does both registration processes, but it gives priority to global ones incase it doesn't find the dev guild id
Gotta love how the djs guide doesn’t properly show you how to register commands 
doing things properly? whats that?
Running it if the bot goes online is exactly what i mentioned above
You gonna register the commands over and over again
once means only a single time, not another startup registering them again
Also there’s no priority in terms your guild ID wasn’t found or not
Either you register a global command or guild command
Once the command has been pushed to the guild, a command being registered multiple times can pop up multiple times tho
And even worse one will always end up triggering an interaction failed response
It just shows how to register the commands one time.
That’s why the example requires your token as a client like in djs isn’t present to use the djs inbuilt methods
But for some reason people straight copy that guide bullshit into their bot code
Executing it every time they startup their bots
Because nobody actually reads what’s written down in the guide about the one time registration process
I wonder they provided a guide how to build a common handler but didn’t do so for slash commands as this would be more important
If I’m gonna search in this channel the issues about proper slash command registrations are countless
And this will probably get even more funny in April
Discord could get rid of that bullshit by throwing an API error if you try to register a command with the same name
Only the resource (PATCH) to update (all) commands should be capable or overwriting existing ones
I mean how can you fucking register something that already exists anyway?
What an useless shit and bad practice allowing it in my opinion
or PUT really
patch or put whatever it was
I swear I’m close to build a slash command handler package

how do i create a file on a github repo using the github api
will this delete the message for the interaction?
DELETE
/webhooks/{webhook.id}/{webhook.token}```
https://discord.com/developers/docs/resources/webhook#delete-webhook-with-token
are webhooks created each time the slash command is invoked?
Delete a webhook permanently. Requires the MANAGE_WEBHOOKS permission. Returns a 204 No Content response on success.
is it possible to delete this without first sending a message?
Isn’t “thinking” just the indication of a deferred response?
yeah, and i want to delete the thinking before giving the follow up response
probably not possible
i've tried using the delete webhook endpoint thingy and it failed
403
now i'm getting 429 errors with my test bot
i have 2 items in the array and it throws a 429 on the second call
i was doing it all in one Promise.all, but i changed it so now it's synchronous
but i still get 429 errors
Do you even defer it?
yeah
Hmm I think you can’t get rid of that then
Other than not deferring it and sending a channel message when your code is ready
Can you actually just acknowledge the interaction without sending a response?
To prevent it from failing?
the follow up message after the defer requires either context or embeds
i guess i could do a follow up message and then delete it after that
oh wait, i should be using this
https://discord.com/developers/docs/resources/webhook#execute-webhook
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
But I can't use that until I follow up with a message
Why do you even wanna remove that thinking placeholder?
Does your response takes that long?
The command is updating another message and having it return a response takes up too much space
I just want it to think and then be done thinking
Like how buttons work
Hmm actually without any response?
Yeah
I’m assuming that’s not the supposed use case 
Hello
Omg it’s a hacker
Are there any libraries which can keep track of invites and let me know who invited who?
I'm using discord. Py
No need for an additional library
But I think that’s a good question for the discord dev server tho
It’s possible with discord.py
But I assume the answer is the same
- Save current invites and their use count somewhere
- When member join, compare current invites with saves invites
- The one which was changed is the invite used
Will this work if there are people joining like over 1k at a same time?
@proven lantern After some investigation I’m sure it’s not possible.
Your only chance to not fill up the channel at least for anyone else is a ephemeral response, for example a simple content like just an OK emoji and to delete it right after it was sent
those ephemeral response only work for button interactions
No
and follow up messages after the initial message
You need to defer with the ephemeral option
Maybe it’s just too fast for my mobile client
But it looks like deferring with the ephemeral option makes the thinking text hidden too
At least for anybody else
Looks like there’s no other solution
i dont know if it's going to be ephemeral at the time im deferring.
You'll never have 1k joining at the same time, not even during a raid
But yeah, it'll work even at 1m joins per second
Never underestimate cpu speed
1ghz = 1 billion operations per second
That in a single threaded non-optimized runtime
Cpu speed is so fckin huge that we often forget 1 second is an eternity to a computer
light only travels about a foot in 1ns
light is slow as fuck
stupid light
want to talk to my friend at mars but have to wait 27 minutes
Imagine playing league on mars
By the time you exit the fountain the game already ended
"bro I lagged" will become a valid excuse
how can it do a billion operations in a second if light is so slow
it's a conspiracy
Imagine after they manage to reliably use quantum entanglement
matrix math is going to be big
infinite sized matrix
im not sure how to use that to solve many problems
Yeah I did exaggerated it, people are joining likely 5-10 members at a time
I'd like to see information-theoretical security become a thing
My estimate is that during a raid you have about 2-4 people joining per second
It looks like it does
no 5-10 is normal
the issue is that when i defer i dont know if it'll end up being an ephemeral message or not
i like to be complicated
Yeah I see 
i gave up on my idea of making each command it's own separate github project
that was a little too much
And like I said responding without deferring with an emoji for example and removing the webhook response immediately after sending it, isn’t an option?
that's what i'm going to do
like a delay
or maybe i can add a delete button
i'll make my own ephemeral message
that anyone can dismiss
yep, something like that should work
There we go
I will only calculate 2h as you have to make compromises
Support invoice is on its way

this should work
can we use tts in bots?
Why would mongodb be giving this type error? https://i.callumdev.xyz/vs54c.png
ayo ty 
(:
It's claiming usersOneCommand is type never?
@snow urchin
let warranty = await interaction.options.getString("warranty")
how do i check if warranty is null without making two big functions
i just wanna check if it is null and if yes it will give it a value
if(!warranty) {
// code
}```
that's exactly what i didn't want to do
if (warranty === null) warranty = "Till Claim"
went for this instead
saves alot of lines
there is something between you and awaits
Why wouldn't you want to do that?
because i would have to repeat the code 2 times
What?
and i couldn't just give another value to the warranty
i would have to use if else
What you want to do is
const warranty = interaction.options.getString("warranty") ?? 'Till Claim';```
nothing
What
That checks if it's null, if it is it gives it the value Till Claim
Is that not what you want?
Then don't use the if. Do the thing I showed.
did this instead
You should really use this instead.
okay i totally forgot about that
This the problem with non TS devs smh
oop that worked
collector.on('collect', async (i) => {
if (i.customId === 'cl') {
await i.message.delete()
if (price > 30 || price < 15){
i.channel.send(`Please avoid going higher than 30 CIPS or lower than 15 CIPS`);
}
try{
}
how do i define (i) inside the "try" block
You don't need to?
it no worki tho
oh shiut
nvm
i did a typo
await i.message.delete()
how do i prevent this shit from crashing my app
sometimes it works
sometimes it says unknown message
can i add a handler or smthn
is that crashing your app tho?
yes
wdym crashing
throw new DiscordAPIError(data, res.status, request);
^
DiscordAPIError: Unknown Message
it doesn't even warn it just crashes ffs
thats unfortunate, whats more unfortunate is that i dont know djs
F
catch it
it means you're trying to delete a message that was already deleted
how would i get the domains here to do a forloop
{
"ApiResponse": {
"$": {
"Status": "OK",
"xmlns": "http://api.namecheap.com/xml.response"
},
"Errors": [
""
],
"Warnings": [
""
],
"RequestedCommand": [
"namecheap.domains.getlist"
],
"CommandResponse": [
{
"$": {
"Type": "namecheap.domains.getList"
},
"DomainGetListResult": [
{
"Domain": [
{
"$": {
"ID": "47232901",
"Name": "benchurton.xyz",
"User": "oak8trading",
"Created": "12/31/2020",
"Expires": "12/31/2022",
"IsExpired": "false",
"IsLocked": "false",
"AutoRenew": "false",
"WhoisGuard": "ENABLED",
"IsPremium": "false",
"IsOurDNS": "false"
}
},```
yeah but it is weird since it deletes the message then throws it
(there are like 20 domains)
you have it in a collector, so for each collected interaction, it will try to delete it again
button interactions all have the same message
oh
so what can i try
in the beggining of each button i have it yeah
but it is inside the if blocks
for(const domain of obj.ApiResponse.CommandResponse[0].DomainGetListResult) { domain.Domain[0]["$"] }
something like that?
it would be a good idea to stop the collector when the message is deleted
okay
other than that you have to catch the delete anyway, becausw it can be deleted by other things
i'll try that
valid
where are these domains?
in the json output
so they are all in Domain, not in DomainGetListResult
ah
anyone explains why it returns null
Well, why are you doing it via regexes? You can achieve this with the .discriminator property, as the following: <user>.discriminator.
he want to get it from the text
Oh, I see.
im expecting it to return an array like
["hello#0804","epic#0001"]
but it just returns null
const regex = /\w+#[0-9]{4}/g;
const string = 'hello#0804 noob haha epic#0001';
const result = string.match(regex);
console.log(result) // [ "hello#0804", "epic#0001" ];
This is what it returns for me.
Anyone knows why when I upload a website folder from my domain, the image just disappears?
(Locally)
(On Domain)
have you considered checking your console?
OHH, now I know what you mean.
Although, why so, I'm not sure what I'm supposed to be doing to prevent this?
I mean, check your plesk logs ig
I checked the chrome log, check the above image.
It's a Get 500 error.
now my codes are human-readable I think and better organized
yes, so check your plesk logs
The error is there.
On my access_ssl_log?
OHH, I see why.
I appreciate it, I figured it out. 👍
Is there a way to name multiple variables using a array names? like instead of using let every time, you use function or something
Does this help?
One message removed from a suspended account.
okay I'm back lol
Having problems with starting my test bot. I updated Node.js and now it keeps loading (?) in the terminal. I already deleted all npm-modules and npm install, I tried npm init and I installed all my packages
Still not working
nvm I'm stupid
-> always make sure your ready event is working
Like a map?
I'm trying to update an object inside a array, but instead of updating the correct object it's updating the first in the array
The first is doing what i want but the second no
The function I use:
await equipItem("<user_id>","swords","iron","10000")
In the first sword instead of being true it should be false and in the second there should be a equiped value saying true
https://srcb.in/5Q0kbB1ERV
WHY doesnt this work and how can i make it work, why doesnt it mention the user js interaction.editReply({ content: `${data.value}\n${user}`, allowedMentions: { users: [user.id] } });
Log the variable item to see what it returns
Error?
no, it doesnt mention the user while i want it to mention the user, like it does have an @timber fractal but it doesnt actually give a mention
alright and?
Yes, but what are u getting?
U didn't show current output
@indigo cobalt ^
Give me a second
an unfunny joke and a mention that doesnt actually mention
[ { type: 'swords', quality: 'wood', exp: '0', equiped: true } ]
but the biggest problem is in the second call to the db
Welp, that's weird then
yeah and noone can help
is it cause i deferreplied it earlier?
Because if I get rid of the second call of the db it gets the first one equipped to false
@lyric mountain
Try checking the docs to see if you're declaring the allowed mentions correctly
no the docs say literally nothing and i tried to allow them in the deferreply but that didnt work but i removed the whole deferreply statement and now it works
dumb
Use under users, repliedUser and put it true
(don't mind unactivated windows)
but i dont want to mention the replied user right?
who do you want to mention?
What's better?
👍
horde is not as bad is it was before
but yeah i've always liked roundcube
its not that bad
outlook?
'user' that is defined from interaction.options.getuser()
Just realised I sent wrong screenshot lol
Meant to send that
The only trouble I'm facing is using my email from Gmail. :/
@feral aspen what framework you use for your website?
how can i make a file in a github repo using its api?
Despite considering myself a cryptographer, I have not found myself particularly drawn to “crypto.” I don’t think I’ve ever actually said the words “get off my lawn,” but I’m much more likely to click on Pepperidge Farm Remembers flavored memes about how “crypto” used to mean “cryptography” than ...
The first point and changing nft based on audience sounds interesting
web3 is a big pile of ass
for me, the biggest problem is not even listed there
its straight up just performance
web3 is stupidly slow in general, blockchains as stupid slow in general
you cannot build something like the common internet of today on top of blockchains without making everything much slower than it is today
Do you think it's a great idea to do this, and which? I don't seem to understand what's the huge difference between both of those.
I have no idea what the speed is. But the thing that got me was how centralized the "decentralized" thing is supposed to be and the amount of layers they make you go through, for something like the NFT, to not even SIGN the request and prove you're the owner.
web2 = client buys from business, client receives item. end of story
web3 = client buys from business, business checks the government, informs government that client bought item, government says ok, client receives item.
Damn, and NFTs are web3 based?
I have my same gripes with people wanting the metaverse lol.
i dont mean the literal government like the president of the united states, government as in the blockchains that control all transactions, just to be clear
cough topgg
Yeah lol
Metaverse is supposed to be a big open source project anyone can check, decentralized owned by all.
However, each big corporation is making their own non open source metaverse, centralized, get fucked.
It's literally doing the thing the book said lol
Damn.
big bad corpo
if you really want a true web3, start with ditching ISPs and creating your own open ended meshnets
Quickly, could anyone explain to me the difference.
until that happens, centralization will never be defeated because it simply outperforms everything
Silicon Valley. (The show)
There was a quote somewhere.
Web3 presents itself as a more secure design to stop these big governments from controlling and trying to make a dime. However, Web3 stands on the very foundation of a system make to make a quick dime ]
pretty much
Like the blog I sent above. Yeah lol.
i dont trust the current situation with NFTs at all
It's just for anyone wanting to make a quick buck.
it just feels like a fast money grab that will become forgotten and obsolete in no time
the entire concept of NTFs is just idiocracy
stealing money from idiots
web1 and web2: build
web3: buy
I think mee6 making NFTs is a good proof of the quick muni
That was so funny lol.
Top.gg with the DAO stuff is also just omega sad when the site hasn't finished its own bugs too.
^
Lmao.
:^)
so topgg is purposely creating bugs?? /hj
Look, a refresh button that should literally just be get bot info and update that's been broken for almost 2 months should get you fired ngl.
GOOD
but also not fixed
it refreshes
Is it a dice roll
but takes several hours to update
I mean, that's probably just how they cache.
true
But it shouldn't be.
their caching is shit
It should be a time limited button if that's the case.
It's okay refresh servers doesn't work either :^)

One button at a time.
top tip: don't release a site redesign if 90% of the features break
especially if its a popular service like top.gg
yeah
it's ok
basically
👏 Learn to cache correctly topgg
but also learn how to use a search system
👏
yes
mostly ok design, terrible caching and backend
me: accepts team invite
site: works
me: checks the team
site: not in team
api: shows me in team
https://capy-cdn.xyz/eVjhmfpA.png i am in the team tho 
😉 If you're watching and want me to fix the search and cache system my day rate is £1k
what the FUCK is that discord
Capitalist
changelog looking pretty poggers so far
well duh

what is this
by pressing one of the buttons on the left you can change page while staying in the same page so by pressing for example on the category fun there will be all the information of the fun orders which will be displayed without changing page same thing for the other categories and how can I do that? Please
give each button a unique id, and have all commands in a category in a div, and on click, hide the previous div and show the correct
like ben said, one option is to load the content of all pages at once, and hide them in invisible elements that are controlled with css and js
another option is to have the content of the pages available by ajax requests, so that when you click the button, it fetches the content of that page without reloading the page
why am i getting that
with gitlab
when alertmanager wasn't running (ip wasn't set in config), it gave me an error page
now I have fixed that, i'm now getting that
I've decided to swap from using express on itself and use nestjs with it
Since I couldn't be bothered to make everything nest already has.
So I am making a platform type thing, how should I generate user ids that will be unique per user?
oh?
then you can hash it, or convert it to base64, idk
Math.random for example
or crypto.randomBytes if you want extra safety
very simple way of generating guaranteed uniqueness
Mm I would prefer them to be numerical ids for readability
you want something like a snowflake id?
Yea
well you can still use the same method
if you want to create an actual snowflake conforming to the spec, its 41 bits of timestamp plus 10 bits of "instance", ie the worker/process id, plus 12 bits of "sequence", ie sequence++
Yea that is whatt people were telling me
But I didn't know exactly how to do that 
so in js terms, using bigints, that would be ((BigInt(Date.now()) << 22n) + (workerid << 12n) + sequence++
mmmm
for horizontal scaling
so you can have hundreds of workers generating snowflakes at the same time and never collide
My biggest confusion is between workerid and sequence
like what if sequence resets backs to 0 since you are incrementing it?
its supposed to
Ah
but by then the timestamp is way ahead
So for now i can just define a worker id in code?
true
54 bits instead of 64 bits
you can also reduce the size of the sequence
and fit everything in js ints
which are 53 bits
but for databases you still need 64 bit ints
so something like newUser.id = (BigInt(Date.now()) << 22n) + BigInt(seq++);
Oh hey that's a neat way to do that.
TypeError: Do not know how to serialize a BigInt 
I don't work with BigInts at all so I have no idea what this means
I think this is probably a typeorm error tho
Probably a backwards compatibility thing.
It can't.
that is an issue then
I might have to set the actual type to be bigint and let ts say its a string
@Column({ name: 'id', type: 'bigint', primary: true })
id: bigint;
to
@Column({ name: 'id', type: 'bigint', primary: true })
id: string;
Yea that worked
Thanks for the help Tim :)
json doesnt support bigint by default
if typeorm is using JSON.stringify behind the scenes, then it will cause that error
yea
btw that is still basically a 64 bit number
its still the same size as a snowflake, you just increased the sequence size
One message removed from a suspended account.
ill flake your snow
One message removed from a suspended account.
telepathy
ic
I am still storing it as a string tho
yeah it doesnt really matter if you're not worried about data size and stuff
it just changes the point at which the sequence should reset
your current setup should reset the sequence at 4194303
if(seq > 4194303) { seq = 0 }
to test it out I was just setting the sequence inside a function so it reset every function call
Ima change it now tho
So this will reset sequence to 0 if it is greater than that right
and I also assume it doesn't matter if it resets to 0 due to the backend going offline and back online
yeah it shouldnt matter
alrighty tyty
the functionality of the sequence is to prevent collisions caused by generating multiple snowflakes in the exact same millisecond
Should I replace Date.now() at some point with the timestamp of when the platform is released to the public like discord does or should I just not care
ah ic
discord basically did that to reduce a bit the size of the snowflake
ah
by setting an offset, you can count time from a closer date, and have smaller date numbers overall
I dont have to worry then
Mmm I just realized something
When I am fetching a user I obv don't want to display their password in the data returned that is something I want hidden.
How can I remove the password from the returned data?
what password?
the hashed password in the database
I dont wanna return that in the data from the GET /users/:id endpoint
then dont return it
But how
in your endpoint code?
Yes I know this but I am unsure of how to actually make it not return it
I wouldn't be asking if I knew
whats your code?
async findOne(identifier: string, relations?: Array<string>, cache: boolean = true) {
const user = relations
? await this.usersRepository.findOne({ where: { id: identifier }, relations, cache })
: await this.usersRepository.findOne({ where: { id: identifier }, cache });
if (!user) throw new BadRequestException('No user with the email exists.');
return user;
}
@Get('/:id')
async fetchUser(@Param('id') id: string, @Res() res: Response) {
return res.status(200).send({ ...(await this.usersService.findOne(id)) });
}
const user = await this.usersService.findOne(id));
delete user.password;
return res.status(200).send(user);
``` well thats one way
That's what I was thinking lol
otherwise theres also the opposite way, just build a new object with all the fields except the password
if you have many fields you can use a loop
I can't remember what my friend did but iirc he basically just deconstructed something and it left out whatever he grabbed from the end result
yikes.
my code
I haven't used nestjs in ages so I am trying to slowly get back into using it
this looks nice

Should i change what role is?
export enum Role {
ADMIN,
USER,
}
rn it is an enum so the values are 0-1
but should i give em string values instead like
export enum Role {
ADMIN = "Admin",
USER = "User",
}
Though in the end it probably doesn't matter cause what gets displayed wont even be what the enum's equal
const { password, ...rest } = user;
send(rest)
I plan on making badges or smth and displaying the appropriate badge depending on the value of role
Ah right that is it
i also forgot that was a thing, had to google it to remind myself
yeah its a cleaner approach
in terms of performance it should be the same as creating a new object with all keys except password
yea
it just looks cleaner which is what I like about it :p
@round cove also in case you care I recently figured out typeorm has its own caching system
You can cache whatever you fetch and typeorm will fetch from cache instead
you just need to pass in the cache option into find or findOne
Oh really?
That's pretty neat
I wonder if it's work looking into.
Or using.
I don't think my bot is something that would be able to use cache, it wouldn't make sense.
Or does it update the cache and DB at the same time? @earnest phoenix
Like I assume the cache is local in the entities and then it makes the call to the postgres db
I think it updates cache and db yes
Curious. I should google it.
If you find out I would like to know the answer too
But I am pretty sure it does
yea
My bot is based on if the server has react roles or not and if they deleted one and it was still cached then it kinda defeats the point?
I have no idea how to set the time not using a query builder
I am not using a query builder
:^)
TS2339: Property 'user' does not exist on type 'Request >'.
I know how to solve this but ffs
I wish shit was simpler sometimes
You're LITERALLY using TS for the type safety
The best part of it
but I know the feel
lmfao
yea pretty much
Type safety and decorators
literally the only thing I like about ts rn
lmao
Actually I dont think this is the best idea 🤔
declare module 'express' {
interface Request {
user: Partial<Users>;
}
}
yea
actually no
I want to
I want to override Request's types and add user to it like that so i can use it anywhere
Actually does it matter? 🤔
I am just setting req.user once they login so I can use it on the frontend side to get the user's data to display
Doesn't matter anyway, req.user is empty even after logging in

Wait wtf
Why am I doing this shit by myself I can use passport and passport-local

How do I have my bot check it's channel override permissions properly?
const msg = await message.channel.send({
embeds: [pingEmbed]
})
I'm toying around with v13+ after being on v12 of discord.js for a while and I wanted to ask since it has since changed...
how would I go about updating an embed with it being embeds: [pingEmbed]
I originally just did msg.edit(pingEmbed.setDescription("stuffhere")) however that wouldn't work anymore.
^
I know that feeling
https://scs.twilightgamez.net/d3mLQ.png ty again.
Curious, why would you edit it and not just sent an initial message that shows that info?
No need to edit.
local testing ignore the latency ;p
iirc editing is to get the ping
It's an old thing I did idk
${Math.floor(msg.createdAt - message.createdAt)}
Don't need to edit at least.
embed
.setTitle('General Info')
.setColor(COLOR.AQUA)
.setDescription(
`
Thanks for using RoleBot!
This servers shard ID: ${interaction.guild?.shardId}
Server count: ${size} servers.
Latency is ${
Date.now() - interaction.createdTimestamp
}ms. API Latency is ${Math.round(this.client.ws.ping)}ms.
[Click to Vote!](${VOTE_URL})
[Join the support server!](${SUPPORT_URL})
`
)
.setThumbnail(AVATAR_URL);```
I suppose Date.now() would also work ya
that might not be entirely accurate
yea
Which part?
you are relying on discord's time and your vps's time being in sync
which rarely happens, clocks can have several seconds of difference between computers
Hmm, I wouldn't be too worried when it reports ~26ms most off the time but yeah.
well you are showing 450ms
There aint no way people are worried about 30ms
30ms could make a difference 
not worried, just using the wrong math to get the same result, which works sometimes, and sometimes can be veeery off
gg

gonna hardcode 1ms
How so
better than those guys who hardcode math.random
Lmfao
It is saying I am unauthorized even when providing the correct jwt token
function randomNumber() {
return 4;
}```
some dude showing his ping code, and it literally had ping: ${Math.floor(Math.random() * 100)}
Clearly you're wrong lol
LOL???
Im not wrong tho
Wow
prove it
I literally copy and pasted the exact token returned
i also remember seeing some other guy post a code, and his ping command had an array like [150, 200, 145, 253, 120] and he would randomly pick one every time
lmfao
What's the point lmao
just to have a command?
nestjs/passport-jwt does that for me
yes
and one of them, i dont remember which one, legit thought thats how people did ping commands
he didnt even know what ping means
and how to measure it
As much as I wanna laugh at them I guess if they didn't know then you can't blame them.
Wait you don't pick a random number from a array to get the ping???
World is upside down now

Time to jump off a fucking bridge
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken to jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken() fixed the constant 401 Unauthorized

Lmao
So I want some help with thinking something through, basically I am going to be using sessions to persist logins, but heres the thing. I want to generate an api key that is unique to the user so that it can be used on certain api endpoints, like getting the user's data and such things like that (though if you guys have a better idea since I don't really plan on making the api public as of right now so it will be mostly internal use only to fetch user data, posts and things like that, that needs to be displayed on the frontend). My question is how should I generate these keys, store the keys so they can be verified/revoked and if I am using an api key system, should I attach the key to that users session or like what should I do.
client is undefined
what problem
client is not defined
how can i solve
You can define the client in the code
I recommend learning basic JS
For generating keys you can use crypto (built in to Node) and store keys in a database
Client is undefined, defined the your client
yeah me too
What is the best way to integrate a login system to express.js?
I would use Discord oauth like I usually do but the project is completely unrelated to Discord
you can use any other oauths out there
like google, facebook, etc
or if you want your own, just make a database and store users and passwords
plain text
I heard guilded used to store users' passwords in plain text
quite outstanding
lol
Unfortunately the sad truth
lmao
If you never ask yourself how websites could send you your forgotten password in plaintext in the past, you’re lost
sussy
thank god i've never seen that
MD5 totally save… no hash tables or related stuff exists
Bad things don’t exist!
megadrive5
Might look at magic.link
Looks really promising
While I’m gonna say my password encryption also ends up as MD5 string but using SHA with salt keys before and behind
I mean the fact it generates a 128 bit hash or 32 chars is perfect for a database tho
why not just bcrypt?
Because mixing multiple existing algorithms (combined with salt keys) is more save
i've always heard the opposite
that multi hashing does not really improve security
md5 hashing is basically just as bad as plain text
but yes it can cause issues because you're affecting how the algorithm ingests the data and performs the lossy operation
But too save is bad, if the NSA can’t read your shit tho you may will disappear
Did you remember the legendary cryptography group developing a new hashing method based on 3 different, very save hashing algorithms?
I can’t remember how the fucking project was called
It was basically “impossible” to decrypt it and the guys had the goal to improve the ‘net
nothing is ever impossible
But it never goes live and the developers mysteriously disappeared
SHA-256 and SHA-512 are already computationally impossible to reasonable bruteforce
That’s why I used quotes 
the issue is people making the passwords suck, and it only takes a few old websites to build a reasonable rainbowtable for the most common styles
Yeah but only works if you don’t use any salt keys or if they got leaked
And how knows how many (big) website out there are still thinking they’re save and relying on that old unsave shit
its impossible for a hashing algorithm to be 100% unbreakable, thats why we make the algorithm more expensive instead, to severly slow down any attempt at breaking it
there are rainbow tables in the Petabytes in size that can reasonably match your parent's passwords lol
any decent password hashing algo will be customizable in terms of computing complexity, so it will never go obsolete, you just increase the complexity at the same rate hardware power increases
Nope it doesn’t but as long as it’s not leaked it at least helps for rainbow tables and people using fucking passwords like 123456
what the fuck happened to faker.js
went to korea and started playing league of legends
Wut? Im still here
the entire source code is gone
No matter how save your system is, at least one fucking employee in a big company has a weak password and attackers then go the way to get your encryption source code other than trying to crack the passwords itself
it doesnt matter if they have the encryption source, thats the point
Not that it would be a big surprise employees have grant attackers access to their intranet by just opening a malicious email
you can know exactly how the hash was created, its still computationally too expensive to break it
fireship made a video on it
I think he didn't wanna work on it for free anymore
Yes but I doubt many companies are using more complex hash algorithms to protect their data
but apparently that marak dude used to be a maintainer for nodejs and he begs people to sponsor him on github
all these modern hashing functions are public and easily differentiable, take a bcrypt or argon2 hash and you know its made with bcrypt or argon2 just from looking at it
It mostly is the more cheap the better
also fireship had to reupload the video and strip a lot of important stuff
but you still wont be able to break it
pinned comment: "i haven't been harmed"
sounds a bit sus
lol yeah I’m aware but knowing the encryption algorithm helps at least if you really wanna crack stuff
if i steal a bcrypt/scrypt/argon2 hash from a database, i will give up on the spot
I’m fully aware of how it works as I’m running such a rainbow table myself for game IDs and stupid game developers think they can hide the Steam IDs
Yeah that’s what I mean
How knows if not even the administrator uses 123456 as password :)


what kind of important stuff
I didn't notice any
the name of the marak dude
the part about securedrop
and the uhhh self-rip of another guy whom marak thinks is related to aaron
Am I right that there's no way to obtain an id/timestamp of a type 5 reaction to an interaction?
please ping :)
anyone here use statsd? For some reason when I increment a value by 1, it doesnt actually do that. the most common increase seems to be 0.8, and i dont get why...
see? It somehow records 0.8 for the 'player' command usage, and then 0.2 on the following second
its like, it splits up the counters increase of 1? i dont get it.
another day of crying over css
i want the icons at the start of align to the left on mobile but it ain't working. I tried using css grid too.
.contact-ul li .button {
display: flex;
svg {
justify-self: flex-start;
}
}
@quartz kindle i summon thee
i haven't pinged tim for no reason since i stopped bot development
dont you want to justify the button content, not the button?
or i guess your trying to only justify the svg elements huh
imo, that will look wonky af, to have only the icons aligned with the text centered
true
those look like font awesome icons
but it's better than discord server expanding to the depths of left and right or worse justifying everything to the left
it's react-icons
ayo tim entered chat
do you need the word "server" there?
all our problems will now be gone
just remove it
yes, because usernames and servers are different things
what kinda site you making mr epic?
aughel's portfolio but with a <body> tag instead of <article class="markdown-body">
but do you offer both options there?
not yet
i should put aughel's username there too
you can always make it a sub-choice
wth is an 'aughel's portfolio' ? 😄
https://cringe.dev this is the original
click the discord button first, differentiating the service from other services, then in a second page/modal, display the distinction between user and server
or.... i can just not put aughel's username
oohh, thats not too bad ::)
it is
the best is clearly code913.devpage.me
should tell of projects
ok i removed the server part
it looks better tbh
ty
I also added target="_blank" to the links is that okay
pretty sure that guarantees you will go to hell.
lmfao
to ruin it further i underlined the text
it isn't dope af
it's doper than top.gg fixing a bug
top.gg has bugs? lies!
i actually realized top.gg had a hiring page the other day
i'd much rather just show off my skills and wait for a job offer than to apply tho 
anyone?
let skinss = await db.fetch(`skinss_${message.author.id}`);
^
TypeError: Cannot read properties of undefined (reading 'id')
at Object.run (/workspace/commands/useful/skin.js:14:54)
at Client.<anonymous> (/workspace/index.js:127:23)
at Client.emit (node:events:390:28)
at MessageCreateAction.handle (/workspace/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/workspace/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/workspace/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
at WebSocketShard.onPacket (/workspace/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
at WebSocketShard.onMessage (/workspace/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
at WebSocket.onMessage (/workspace/node_modules/ws/lib/event-target.js:132:16)
at WebSocket.emit (node:events:390:28)
why
Cannot read properties of undefined means you tried accessing a property on an undefined value.
x to doubt
it's a command so it should exist
That doesn't mean it can't be undefined.
oh

as interaction response and removing it 5s after sending it




salt does not make you invincible