#development
1 messages Ā· Page 1970 of 1
and that person either no longer contributes to top.gg or does not work on that lib anymore
shiv maintained it but now doesn't lol
If you really need it use python v3.9 ig
or don't use the lib and do all the stuff manually cuz thats not that hard either
if you really need or want to use v3.10
shouldn't be too hard to compile it yourself to 3.10 too
like, what could break in 0.1 versions
you never know
Norizon maintained it after that but now there's no maintainer afaik
No reason to really with slash commands
People just need to learn to do it themselves, there's nothing to it
For 3.10 specifically, not alot. 3.11 is quite breaking though as it removes the depreciated asyncio behavour marked in 3.8
Alsp python isnt semver
Python 4 will basically never happen
Each generation gets worse in terms of laziness and stupidity
let tup: (i8, &str, bool) = (3,"123",false);
``` why does rust make you have to use a reference when making a string type variable?
because a string literal can be stored on the stack as a reference
otherwise you have to use String::from() to dynamically allocate memory for a string on the heap afaik
for example, this compiles: ```rs
let tup: (i8, String, bool) = (5, String::from("test"), false);
Wth
I understood half of that
So essentially that is just making a reference to the string itself?
a string literal is a pointer to the stack
Ah
String::from() instead allocates it on the heap
there's some stuff about ownership and stuff too but I'm too stupid to explain it and understand it myself
let a = [3; 100];
I feel like creating an array like this is both useless and useful but I also can't think of any instances where you'd wanna create an array like this
strings are not primitives in low level langs, like they are in high level langs like js
in low level langs, strings are basically just an array of bytes
which require pointers
I think str in rust is basically just a buffer of u8's
yeah same in c/c++
when you work with strings, you're basically working with a pointer that points to the first byte of an array of bytes
there are two different "string" types in rust
there's &str which is just "some text" and there's String
u can't have a str that's not behind some sort of pointer like a & or Box
strs are sort of like an array of unsigned 8 bit integers [u8]
Ye, char array then
mhm
isnt that what waffle said lizard
he suggested using the String type tho š©
I didn't suggest, just explained why it was like that
aah ye mb
I'm by no means a rust expert or intermediate even
I just happen to know a little about rust strings
I just so happen to be learning rust as a side hobby
There's benefits and losses to using either type, I'm pretty sure there's some weird ownership and borrowing rules depending on which type you use
thankfully rust holds your hand with errors
ikr
if js could find a way to implement how rust handles errors I feel shit would be 100x easier ngl
Hey, while my bot is unverified, can people still invite it or will it have to wait until its verified?
ppl can still invite it but not through your bot page
ah alright
Is it risky to allow users to access Redis through custom commands?
They will have a limit of 500 bytes.
They also wonāt be able to access other keys.
Yes, never allow user access to db
Or cache, in this case
You can't know if there's an exploit somewhere that could allow someone to take control over ur data
Good point, I just want my users to make the most of my bot with all of its features.
If anything make a huge framework that abstracts anything regarding the database
And allow only functions that YOU created
No language features, no native methods, nothing, only things explicitly allowed by you
Most bots that allow custom commands do this to sandbox the user
They make their own language
So far, thatās what iāve been doing.
You need to abstract anything related to database, and sanitize all input
Itās very limited right now, so I donāt need to this. I will do this when Iām finished. Plus my bot isnāt released for the time being.
Just be careful, users can be creative
Remember someone discovered a way to hack into windows pcs by using notepad
When did this happen? Iāve never heard of that incident.
wtf is this website
digitaltrends
a good one
Damn
Daniel
Dana
Js
I have promise.allSettled to check all urls in db
fetching urls
Promise.all
Send status but when it get a error it stops
Now you just need a usb stick with windows media
aslong you don't have bitlocker,everybody can hack your pc in ease
I love how I forget to type return, so some other random code executes.
Javascript should just know wether or not to return. It should read our minds, shake my head.
smh programs are so lazy, i literally had to add the code myself to function. why cant they do it themselves
ai to automatically place return statements in ur code before u execute the code
why cant i make tables with html in description? I tried this but it shows weird ```html
<html><body>
<table>
<thead>
<th>
Name
</th>
<th>
Command Usage
</th>
<th>
Description
</th>
</thead>
<tbody>
<tr>
<td>/help</td>
<td><code>/help [command]</code></td>
<td>Shows all available bot commands.</td>
</tr>
<tr>
<td>/ping</td>
<td><code>/ping </code></td>
<td>returns websocket ping</td>
</tr>
<tr>
<td>/stats</td>
<td><code>/stats </code></td>
<td>Shows the bot's status and info.</td>
</tr>
</tbody>
</table>
</body></html>```
Hey, I just want to make command like if someone votes the bot then he can use the command and i got a issue help me..
Try to clear you cache, both are working fine for me

it should be Api, not api
nvm me failed
read the error
I fixed that error now. But what do I do to make this part work on manifest 3?
read docs
Okay
gimme link
Okay, one second
ohhh, i found it actually
it's under the manifest v3 section
bruh
lmao
just abt to say
xd
read the error and you didnt even send the full error
In Rust you just don't put a colon at the end of a statement to return a value
I think you mean you dont need to explicitly put return at the end of a block
a colon ins't really appart of that
tbh javascript should just write itself
Well, it looks like its trying to look for something but canāt find it.
Full error?
nvm i got it
Looks like it canāt find something related to xp.ha
Oh is it not
Js*
I just looked at the code: āMODULE_NOT_FOUNDā
xp.js
Y'all, where are the best sources for learning Javascript/Python advanced? If you know, pls let me know
what do you consider "advanced"?
there's not really a tutorial where things are considered "advanced"
and what about normal ones, you got any?
I mean, for c++ probably, but definitely not for ultra high level languages like js or python
you can only go so deep with them
after you learn the basic stuff (syntax, how code flow works, *async, etc) all that's left is learning new frameworks, libs and general optimization
I know a few programs that do full courses for those coding programs
- async might not apply in the literal sense for some languages
Well I guess it's learning new frameworks
Lmao, but there is 100% something basic about python I don't know 
Class attributes, had to look it up 
This confused me lmao
Whelp
that's basic OOP ain't it?
well, you could start there
run a couple OOP courses with python
I guess so
I sometimes wonder how I got a general purpose bot topgg-approved and discord-verified soonTM if I don't know some stuff that is basic after all

you wouldn't believe if I told you are a lesser critical case
I saw...cases...that one might wonder how they even turned on the pc
Lmfao
at least you're self aware (which is the first step to improve)
there are people who try to bend the language to their own will
I found some courses as we speak, I need to redo some stuff so they burn into my head
Not gonna succeed, instead 100 errors lmao
kekw
visual basic
Thatās advanced torture
I tried it and I really don't like it
talking about the excel variant (vba)
there's no continue statement in for loops, no easy way to return objects, subroutines/functions, vague errors, multiple weird ways of referencing/calling functions etc
the biggest shock is you don't need brackets to call a function
one thing I like though is you can make labels and easily jump to them kind of like assembly
how's that good
labels have no place in any high-level programming language like VB
ok community opinion time
uh oh
I'm making an anti botting server api (js) and module (py, soon js)
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
is that too sensitive?
I think the server icon being flagged is too harsh
True
well you can jump execution to anywhere you want without the need for a loop
I guess comes down to preference but I like that
i'll add a checker for things like "bot list" or "bots" in the name
It makes ur code less readable, and generally you'd never really have the need to use it
I think itās also too much to automatically report via the api
Just flag the guild with some info and review it manually
Ah
The API is mine and Scoopy's
Makes sense
its gonna have an api checker above it too to check that first
actually after probably
check without any api requests first, if it passes everything else then make an api request
I suppose that itās also a good idea to send a message to the guild saying why your bot is leaving btw
So people arenāt just confused
And leave a tag to be contacted if they believe itās a mistake
its a module
so i'll make it return a response
return {"flagPoints":flagPoints, "rulesBroken":rulesBroken} etc
I see
API: stores KNOWN bot farms
Module: checks for bot farms and also checks api for known bot farms
pug or ejs which 1 would u guys rather work with
ejs
ightys ty
react*
š§ ?
react angular
ejs
Little weirdchamp.
neither
same tbh
Why does borderRadius="50px" in charka-ui do nothing? š¤ I can only use values like lg, xl, md, etc.
using style also doesn't work which is even weirder
Actually, it's always set to md, even if I put 2xl
When I try to create an Invite for a server, it always works when I start the bot on my server. But when I start the SAME files on my PC, it always exits out with
Uncaught TypeError: Cannot read properties of undefined (reading 'createInvite')
why's that?
can you try showing some of your code..?
lucky guess: channel either isn't cached or the ID was passed as a number
that probably
but yes, show some code
Not to mention createInvite() isn't a method on a Guild or Channel object, so now I'm just more confused
Ah wait nevermind it's a thing on GuildChannel
Yeah
that's why
that smells privacy breach
also I'm like 95% sure that's not allowed
add +4% to that
unless you have specific permission from the guild owners
tos break is still tos break
private bot... added by other servers...
No
its on 4 servers
of mine
it's like saying that you stole a car but there was no cop nearby
regardless I don't think that you're allowed to create invites like that
hmjm
tbh sometimes I wonder why it's in the api
Okay yeah I can create the invites line by line
it's useful if the user is the one willingly creating it
I use invite generation on my on-site support command, but the user must agree with it before I even create the invite
opens up opportunities to turn normal bots into dm bots
like, there's a whole "I will create a one-time invite so I can bring my supports here, do you agree?"
ah yes, I'd say it's a grey zone
like, can be used for both good and bad
What framework should I make my website in
preferably a js/ts framework of some sort
(Just a general personal website, not a bot website/dashboard)
i would say javascript
ah yeah THaNk YOu
what about: english?
javascuriputooooo
tim you weeb
yamete kudasai
you ever just ngram bro
n gram or ng ram?
i always say n gram
ng ram sounds nice tho, next gen ram
sure but this is text XD
Java, TS, PYTHON or Golang?
java = old man
python = snake
ts = clusterfuck
go = weirdo
Is it possible to do optional chaining using brackets instead of dots?
x.?y
x[y]
Look at this magic.
console.log(adventurer.someNonExistentMethod?.())
obj.val?.[expr]
obj.arr?.[index]
obj.func?.(args)```
magick
wouldn't it be ?. before array/method variables?
like obj?.func(args)
And in-between the func and args
Theses
ops on fetch being integrated into node?
what
Ah
dont know how it differs performance wise though
@quartz kindle ?
youre the kind of person that would know
node fetch be gone die
afaik they were discussing integrating undici, and by extension undici-fetch
it think its a good idea, so people stop using crappy third part libs
looks cool
undici is an experimental replacement for node's http, and it has proven itself to be much better and faster than http
how well does nodejs handle incoming data like http anyways
its not the best, everything relies on its net and tls modules
but its what we have
functions must be delcared at the end of the code?
but i am happy crap http libs are being replaced like node fetch
since its not the best
very popular nevertheless
the problem with node's zlib is that its async
its good for large data, but terrible for small data
I mean that do be alot about compression
compressing tiny payloads will likely be larger overhead than not compressing it in the first place
compressing small data is amazing when usinn a shared context tho
should I use ts for my react website or js
discord packets can get up to 90% smaller with it
Can I create functions in a file only for them and call them wherever I want?
yes, you just need to export them
how exactly? I've never used funtions, but I want to improve myself
node.js or browser?
for a single function you can do this: ```js
// functions.js
function abc(a,b,c) {
return something;
}
module.exports = abc
js
// other file
const abc = require("./functions.js")
for multiple functions you can do this ```js
module.exports = {
abc,
xyz
}
or ```js
exports.abc = abc;
exports.xyz = xyz;
or even ```js
exports.abc = function(a,b,c) {
return smething;
}
and then import them like this js const { abc } = require("./functions.js") or ```js
const functions = require("./functions.js");
const abc = functions.abc;
in this case I want to start doing a Function in this file to create a profile inside mongodb
Is this possible?
I prefer doing stupid questions now lmao
functions can be void? without a return, like in this case where i dont Need a return
ty Tim and Dylan (I'm not gonna ping)
const addUser = sistemaMonete.create({
userID: interaction.user.id,
serverID: interaction.server.id,
coins: 0,
bank: 10,
tier: 0,
});
profile.save();
}
module.exports = { creaProfilo };
this can work?
Looks fine. Though I don't know why you gave it a parameter and don't use it. Also where's the interaction coming from?
I'm gonna do an userID = interaction.user.id; and pass it
oh
I got it
u right
I've copied it from an actual command
also shouldnt it be addUser.save()?
I'm working on it
the interaction.server.id works inside the function without passing it?
No.
const sistemaMonete = require("./models/profileSchema");
const addUser = sistemaMonete.create({
userID: idUtente,
serverID: idServer,
coins: 0,
bank: 10,
tier: 0,
});
addUser.save();
}
module.exports = { creaProfilo };```
That looks fine.
I would require it a single time outside the function.
its works yes, and its fine, but requires are usually put at the top of the file
it doesnt really affect performance since requires are cached, but its standard practice
Oh are they?
ye
TIL.
In this function.js I can require it at the top and then use it inside the functions?
Yes.
damn
Because it's in scope.
a new wonderfull world
anything that is outside the function can be used inside the function
unless they are inside something else
its like layers
and whats inside the functions cant be used outside
thanks to W3school lmao
I have a general doubt about NaN
I know that the return is a boolean, but how I check a numero
if(number.isNan)
if (number <= 0)
return interaction.followUp({
content: "Il numero inserito in questo comando non può essere negativo",
});
}```
And this can work with this type of return?
if (Number.isNaN(Number(number)))```
there are many ways to check
I don't think isNaN does implicit conversions.
each one has different edge cases
'cause I'm reading here : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN?retiredLocale=it
but I'm not understanding
typeof val === "number"
Number.isInteger(val)
Number.isFinite(val)
isNaN(val)
Number.isNaN(val)
Number(val)
all of those do slightly different things, but mostly the same thing
NaN is a special value that doesnt make much sense, but it exists for some reason
it represents a number that is not a number
its easier if you explain which numbers should be valid, instead of which numbers should be invalid
it easier to narrow it down that way
and how can I avoid using this for an Input String?
You should be smart and convert it to a number and check if it's a number or not.
And if it's above whatever value you want.
here says that interaction is not defined lol
Number(string) works for most cases, parseInt(string) if you want strictly integers (no decimals)
the NaN value is falsy, so you can "if" it
const number = Number(value);
if(!number) { not a valid number }

if(number < ++ number ) could also work?
< + + doesnt make sense
you mean if(number < ++number)?
yup
God that stack overflow is so good lol
while (0 <-- x) "I'm using the x goes to 0 operator..."
i mean, if(number < ++number) will always be true
because ++number will always be 1 more than number
I'm not
It validates the string.

š
which numbers do you want to be valid?
any number at all? including negtives and decimals?
Definetly I'm not
I'm asking for knowledge purpose
I dont need it
ah
because the best solution is different depending on the purpose
for example, if i want only whole numbers, no decimals, i would do this
const number = Number(value)
if(!Number.isInteger(number)) { invalid number }
crazy questions, if we talk about a double how can be the check?
Number.isInteger() checks if the value is an integer
if its not an integer, it can be a double or infinity
there is no Number.isFloat or Number.isDouble
so you have to combine both
i do it like this
Number.isFinite(value) && !Number.isInteger(value)
just like NaN is a special value, Infinity is also a special value
Number.isInteger(Infinity) returns false
its an extremely edge case tho
I hope never need this explanation lmao
back to my errors, how can I require the interaction inside the function file?
you have to pass it as an argument
potato-typing issues
what is potato-typing?
that's confusing
potato
lmao
js doesn't have types, it doesn't have anything at all
if you believe it exists it exists
everything in js is objects with labels for type
btw, parseInt(0.000005) == 5 is true
that's true
yes
no >:C
No it's not lol
who are you trying to gaslight here
what would be better?
use 1 byte to store numbers until 63, and 2 bytes to store numbers until 255, and 3 bytes to 64k?
or 1 byte to 31, 2 bytes to 4k, 3 bytes to 512k
const randomNumber = Math.floor(Math.random() * 50);
with this I get a number from 0 to 49?
yes
const randomNumber = Math.floor(Math.random() * 50) + 1;
1 - 50
yes
const random = Math.floor(Math.random() * max) + min;
return random;
}
// code use example
const number = randomNumber(mini, maxi);```
This assignment could give err?
It seems to me like I'm not a newbie anymore
finally thanks to you I've learned something
np
tysm, I'll do more questions if I need š
Damn, 1 more zero
also 0.1 + 0.2 does not equal 0.3
This is really funny or maybe not.
Function:function numberCheck(number, interaction) { if (number <= 0) return interaction.followUp({ content: ":x: Il numero inserito in questo comando non può essere negativo.", }); } module.exports = numberCheck;
code:``` numberCheck(somma, interaction);
err: ``` numberCheck(somma, interaction);
^
TypeError: numberCheck is not a function
at Object.run (C:\Users\Utente\Documents\Progetti Cri\NOVABOT\novabot update\SlashCommands\monete\newAzzardo.js:29:5)
at Client.<anonymous> (C:\Users\Utente\Documents\Progetti Cri\NOVABOT\novabot update\events\interactionCreate.js:31:9)
at processTicksAndRejections (node:internal/process/task_queues:96:5) ```
what
meaning NaN does not equal itself
alway or it is this way for err in memory?
always
did you require it in newAzzardo.js?
creaProfilo,
numberCheck,
netWorth,
randomNumber,
} = require("../../functions");
module.exports = numberCheck; can only export 1 thing
if you want to export multiple like you are importing, you have to use module.exports = { creaProfilo, numberCheck, etc }
or use exports.numberCheck = numberCheck; on each function
module.exports is the final value, you can only use it once, as it replaces all other exports every time you use it
I have something like module.exports = numberCheck; for every function :KEKW:
yeah, everytime you use it, it replaces the previous
ah
"Ba" + +"a" + "a"
yes banana
last question, then I go to sleep 'cause is 2.26 AM
err: ```const IDutente = interaction.user.id;
const IDServer = interaction.guild.id;
const ricerca = await sistemaMonete.findOne({
userID: interaction.user.id,
});
if (!ricerca) {
creaProfilo(IDutente, IDServer);
}
const valore = await sistemaMonete.findOne({
userID: interaction.user.id,
});
let valoreTotale = ricerca.coins + ricerca.bank;
console.log(valoreTotale);```
console.log:TypeError: Cannot read properties of null (reading 'coins') at Object.run (C:\Users\Utente\Documents\Progetti Cri\NOVABOT\novabot update\SlashCommands\monete\newAzzardo.js:62:34) at processTicksAndRejections (node:internal/process/task_queues:96:5) 10
the null came because data doesnt exist inside the database, and the '10' after the 2nd use of the command
Can I get directly the 10 without using a second time the command?
idk, maybe something like .then
what you probably want is something like this
let ricerca = await sistemaMonete.findOne({
userID: interaction.user.id,
});
if (!ricerca) {
ricerca = await creaProfilo(IDutente, IDServer);
}
but you need to modify creaProfilo to return it
dang what's that language
italian probably
italian :)
that's very patriotic of you to code in your native language (I assume)
now that I think of it it's pretty common for people to do that even in professional levels
also, you can remove the valore line, its not doing anything
i remember some russian guy that named his variables after vodka
that's Epic
what
what do it mean
Where did u learned it
āGo fuck yourselfā
You never heard about Italian blasphemy?
"go fuck yourself" is one word in Italian? that's pretty neat
Aye saves a lot of time
Hey, so I have this data, and im trying to print out them individually in a for loop, but it only prints the first number
{358670711109320705: Decimal('303576'), 383287544336613385: Decimal('135500')}```
```py
data = dict(data)
print(data)
for i in data:
print(i)```
it only prints 358670711109320705 or does it print 358670711109320705 and 383287544336613385?
it prints 358670711109320705 and 383287544336613385
The object keys
yup
Dunno about the syntax in py
for something in dict iterates over the dict's keys
ah
you can do this instead:
for i in data.items()
that should iterate over its entries, in key value pairs
oh yeah that works, ty 
you can't do for e of data?
for of isn't a thing
your excuses Sir, no no
i dont have any ex named cuses
Tim googling stuff to prevent others from googling stuff 
smh
ok
Can anyone help me on this?
https://stackoverflow.com/questions/70945800/upload-attachments-using-clickup-api
I'm having a hard time dealing with it. I try uploading the attachment with Every possible way I know but it doesn't show up on clickup
shot in the dark here, but try this:
files={"attachment": open("attachment.png", "rb"), "filename": "example.png"}
Alr in a min
nope doesn't do the trick
might just give it a try with their provided example code first
multipart is complicated because there are multiple "file names"
each entry counts as a file, and each file needs its own file name as well
so its confusing which one they are talking about
according to the requests docs, the files option basically works like this:
files={entryname: (filename, data, type, headers), ...}
you can try this lol```js
files={"attachment": ("attachment", open("attachment.png", "rb")), "filename": ("filename", "example.png")}
just tried their given code example
I think the problem lies in this particular thing
open("attachment.png", "rb")
cs
Doesn't work
values = f"""
attachment: {(open("attachment.png", "rb")).read()}
filename: example.png (string)""".encode("utf-8")
Doesn't work either
values = f"""
attachment: {(open("attachment.png", "rb"))}
filename: example.png (string)""".encode("utf-8")
the attachment should be raw data, it cant be utf8 encoded
well I tried without utf-8 encoding
but it showed error saying it should be bytes
TypeError: POST data should be bytes, an iterable of bytes, or a file object. It cannot be of type str.
this is what it said
yeah that example just feels wrong
doesnt look like urllib2.Request handles multipart separators and headers, which is required
error:0308010C:digital envelope routines::unsupported hmmm
Apparently on stackoverflow I was supposed to do --openssl-legacy-provider on NODE_OPTIONS but that didn't work so idk
Anyone know how to get the total guild member with shards in discord.js
is it possible to display the bots server count on a html page?
not without javascript
Well. Actually, it is possible if you make an image and then link an api to generate that image and display it
either way you'll need a HTTP server
so transfer my website scripts to my bot script
You can communicate with your website via a websocket
just request a guild count from all shards then combine the result.
You'd need too look into thread base replying since the same operation could be sent at the same time and lead to result precision errors
you'll still need an HTTP server
where
just before </body>
can you show the whole code?
ah i've fixed it
it was me being retarded and spelling script wrong on the bottom tag
Are you using typescript? and what do you need ejs / pug for?
i am using js
yeah well gl
wat
theres a pug to html converter
from there turn into ej
s
oh
<!-- include ./header.pug-->
<div class="container">
<section class="slider">
<div class="row">
<div class="col-md-4">
<!-- each val, i in highlighted
if i < 2
each articleVal, i in articles
if articleVal._id == val.article_id
a(href=`/article/${articleVal.num}`)
.article
each catVal, i in category
each subcat, i in subCategory
if articleVal.category_id == subcat._id
p.category-label= subcat.name
if articleVal.category_id == catVal._id
p.category-label= catVal.name
img.img-thumbnail(src= `/uploads/${articleVal.image}` alt='image')
h5= `${articleVal.title.substring(0, 60)}...`
p= `${new Date(articleVal.date).getDate()}, ${new Date(articleVal.date).getMonth()+1}, ${new Date(articleVal.date).getFullYear()} `
span.fa.fa-clock
-->
</div>
<div class="col-md-4">
i've currently comented the js
and the includes
the includes part is easy
the issue is with the js
const IDServer = interaction.guild.id;
let ricerca = await sistemaMonete.findOne({
userID: interaction.user.id,
});
if (!ricerca) {
creaProfilo(IDutente, IDServer);
}
let valoreTotale = await ricerca.coins + ricerca.bank;
console.log(valoreTotale);```
problem: If there is no user profile inside the database, the conole.log gives err 'cause doesnt find the user profile in the database. How can I make the valoreTotale be executed after the creation of the profile?
You need to await your createProfile() function, not the calculation of your total coins
the funciont Is already async
Just do it and see the magic
Also remove the await within your valoreTotale, it doesnāt make sense here
You need to consider that after creating your profile, your var ricerca is still null
Either you send a request to the database again (after creating the profile) or manually declare the var ricerca
You can also return your database user when executing your creaProfilo() function
That would be the easiest solution
try alt-tab twice, sometimes some programs get stuck in an "alt mode" where u can't select anything
somma = somma.parseInt();
call function(argument1, argument2, ...)
Yes
ty
only: parseInt(somma);
Sure
i used to think python was bad for intentional indentation
but this... i want to die
Is it possible to call functions inside other functions?
well yeah otherwise it wouldn't be very good
After that when I call It in another file, I must call both?
Huh
If youāre calling a function that calls a function, you donāt need to call the other function too
function doSomething() {
console.log('did something');
doSomething2();
}
function doSomething2() {
console.log('did something 2');
}
doSomething();
it'd not even make sense the other way
If I have a negative const and a positive one, for example: const name = -10 const name2 = 20; There is a fast way to move from the second 10 for getting 0 in the first one?
In this case I assume I know both the numbers, but I wont ever know the numbers, so I need an univoque way
There is a fast way to move from the second 10 for getting 0 in the first one?
Wut?
The first one is -10, the second 20. I want in the end that the negative one becomes 0 and the second one decreasy by the second number
and in the end have two variables with 0 and 10
It's hard to explain with my english knowledge
lmao
I'll try better
start: let name = - 10; let name2 = 20;
Objective: //NO NEGATIVE NUMBER name; //contains 0 name2; //contains 10
I need an english course lmao
nope idk
just do
name3 = name2 + name
this is for explanation purpose declared
I'll try explaining the context.
In my economy system there is a command that can send your balance under 0.
And there is bank and wallet
So I want to move from bank to wallet and vice versa
const ricerca = await sistemaMonete.findOne({ userID: idUtente });
if (ricerca.coins < 0) {
if (ricerca.banca > 0) {
let pareggioN = ricerca.coins;
let pareggioP = pareggioN * -1;
if (ricerca.bank > pareggioP) {
variazioneMonetePortafoglio(idUtente, pareggioP);
variazioneMoneteBanca(idUtente, pareggioN);
}
}
}
if (ricerca.bank < 0) {
if (ricerca.coins > 0) {
let pareggioN = ricerca.bank;
let pareggioP = pareggioN * -1;
if (ricerca.coins > pareggioP) {
variazioneMonetePortafoglio(idUtente, pareggioP);
variazioneMoneteBanca(idUtente, pareggioN);
}
}
}
} ```
This is the function that I did
if(wallet < 0) {
bank += wallet;
wallet = 0;
}
technically you need to know how much you want to pay first
if you need to pay 20, you need to check if both wallet and bank combined have enough to pay 20
How this code seems to u?
I'm checking if bank + wallet Is enough for the sum u have to pay
where is the sum you have to pay?
already decreased the wallet above that Function
bot for example if I have 2 in wallet and 20 in bank and I pay 5, I have -3 in wallet
and for this I want to move that 3 from bank ti wallet
and what do you do if in the end you have negative in the bank?
debt
actually nothing
u have to use the earn command
nope, cause if u have to pay 20 and bank + wallet Is less than 20, send a message where says that the user Is too broke for the action
and where do you do that check?
let valoreTotale = ricerca.coins + ricerca.bank;
if (somma > valoreTotale)
return interaction.followUp({
content: `${frasiSoldiInsufficienti[sceltaFrase]}`,
});
ok, so all you need to do after that, is just ```js
ricerca.coins -= valoreTotale;
if(ricerca.coins < 0) {
ricerca.banca += ricerca.coins;
ricerca.coins = 0;
}
I dont know If this works with mongoDB
you probably just need to do ricerca.save() at the end
is this mongoose?
No this is #development
let re;
if(status1.status.yes === 'no'){
async function startLunar(){
// some embeds etc etc
re = Math.floor(Math.random() * 5000) + 10000;
//some other unimportant info
}
ps = setTimeout(startLunar, re);
} else {clearTimeout(ps) };
``` why is this function only running once?
So Iām stuck with making my status in my bot showing up. Any help?
Idk if I did anything wrong
Do I need to add something
what library is this?
Looks like python.
Python
fuck off Dylan :)
(:
Sheesh so any ideas
so the library is python. what's the programming language?
cya
flaz you are good with js ain't you?
:,((
I'm ok at it
dang fate makes us cross each other on this beautiful wednesday.
Yer
it runs once because it's a timeout?
Wait omg
So it should be an interval
wtf am i doing
with the setTimeout nested right
If I have a token which expires after some time, how can I like iterate over the table and delete all of the expired ones? I mean I can do like an automation but let's say you have 10k data records.. to iterate over all of them would be absolutely trash
I mean...
most of them you can just invalidate when you ned check them if they're over
and then just occasionally do a purge
true š¤ thanks :)
let re;
if(status1.status.yes === 'no'){
async function startLunar(){
console.log("test")
re = Math.floor(Math.random() * 5000) + 10000;
//some other unimportant info
}
ps = setInterval(startLunar, re);
} else {clearInterval(ps) };```new issue lmao. Why is this code not setting the interval named re?
it just sends a fuckton of "test" logs
re is a number
ps is an interval that runs every re milliseconds, and that value is the first evaluated value, not the one you modified inside the interval
cringe
do I have to put my Server's IP with the port in here?
I'm using top.gg's official sdk with the webhook server
yes
Update: ditched Scaleway, Backblaze and google cloud storage, using DigitalOcean spaces as it speedy as fuck
And cdn included
Plus fast to upload and easy to use with Nodejs
š
did someone say speedy
yes
I'm generating tokens for login and I want that you have different tokens on every device so if you use my thing on the computer often it can re-set the expiration date of the token but f.e. on the mobile device it expires after some time because you don't use it anymore... I was thinking about using ip adress of the device but that's quite complicated... idk
Quite complicated especially for mobile devices as the IP can change each standby-wake up cycle or each time the device changes its connection point
If this login is about a website then your best choice are cookies
As you can also set expiration dates and change/expand/revoke them if needed
Also as those are essential cookies you wonāt have to bother with a privacy policy
but let's say if there's no token, I will create one and send it to the client side. Now when I login on an other device I either need to create a new token or send it the current one which won't expire if you login on any device where the token is in the cookies
Well you can store the cookie hash in your database associated with the IP if you like to identify different devices in the same network
Once one device is logged in another one automatically receives the cookie
But this is a huge security gab
As Publix networks also exist
In your login flow, you should have the device send its cookies and you check if the token exists. If not, create a new one and send a Set-Cookie and then proceed with login. It's not uncommon for a "per device basis" website to do this
no need to store IP
Just store the relation between the cookie and the user
persistent IP based logic can fall apart pretty easily and require re-logins quite frequently considering EU most commonly does not have static IPs
I donāt know which country has either
I don't exactly get it... if 2 devices have the same token it means that if the token get's extended you stay loggedin on both devices
Why do both devices need the same token?
Technically, the way I'm describing it is per browser
You associate your cookie with an unique user
there is no real per device unless its a native app
In your case multiple cookies are associated with one user then
so the browser has a cookie which will validate the browser or some sort of "device"?
The cookie is always locally set on the clients device
Each browser has its own cookie jar
and what if you paste the "browser-cookie" into the cookie of an other device manually? Then it counts as 1 "device" again
I don't think you can tamper with cookies, but I may be wrong
It technically would but you could at least detect the user agent and notice itās different
sure you can just open DevTools, go to Applications and edit the cookies
Of course you can copy your cookie and recreate it in a different browser
how?
I don't see why a unique token per device is desirable
there's nothing at all preventing the user from fudging with everything on their client-side
Thatās why you never store user associated informations in cookies but instead using hashed or anon IDs
The question is how you want to detect it. If you have a token it get's extended, so if you login on 1 and create the token and after that login on 2 it will send you the created token because there already exists one. Otherwise you just create a new token each login

you just tell the client to set the token already created as a cookie
every device can share the same token
Do you wanna associate different cookies - devices - to one account?
yes also thought about that but that means that if you extend the lifetime of the token this gets adjusted to all devices
Or can each be login unique?
yeah some sort
what you mean with that?
I somehow feel like he wants to auth a client on one device and wants to detect the same client on a different device
That doesnāt work or letās say itās not really accurate
You have to track every small detail you possibly can and check for differences
Quick side question. Let's say you login f.e. at GitHub. If I copy every single cookie of you, would I get access to your account? Like technically..
You would get access, but in most sites, tokens expire
But they might also check the last user agent as it could be associated with the cookie
yeah that's what I mean... so it's impossible to completely hide a way to the user data for others. (Doesn't even make sense xD)
I'm still lost at what you're trying to get at
Dito
Pikachu, I choose you

Oh wait that's Ditto
https://uwu.solutions/ZsVxzpmp for anyone good at s3 lib
const file = await fs.readFileSync(`${adID}.png`);
await s3.putObject({Bucket: "vertexnodes", Key: `${adID}.png`, Body: file, ACL: "public"}, (err, data) => {
if (err) return console.log(err);
console.log("Your file has been uploaded successfully!", data);
});```
Yeah auto correct has fucked me once again
no. The PokƩmon's name is Ditto
smh


Let me try to explain it with an example:
Device 1:
Login -> Create token if doesn't exist, otherwise send it to you -> Access
Device 2:
Login -> Create token if doesn't exist, otherwise send it to you -> Access
Both devices loggedin with the same account so that means:
Device 1:
Creates token xy
Device 2:
Get's created token
In this case both have the same token. If I create a new token on every login there would be many many tokens which only expire after 7 day. This means even if you got a new token the old one is still active.
(If I think about it now, I could just generate a new one every time and delete the old one completely because I just found out that it get's sent with it too xD oh man)
Wait nvm it doesn't get sent with it on login...
fixed, its public-read not public
You somehow mix tokens, cookies and actual account data
I donāt get your term token here at all
You basically create a simple login system, e.g. username and password and save an associated hash in a cookie on the clients device
That allows the client to enter the site without a new login
Once the client uses a different device he needs to login again using your login system, which will also save a cookie on his device with the associated account
You can control all cookies however you want
Set a max lifetime, expand it, revoke it etc
yes sure but if you then revoke the old token and create new one and send it to the new device. You need to relogin on the first device too and then you're in a cycle xD
The hash of my user cookie I place are stored in my database
So Once a client enters the site the database is being queried to check if the cookie ID (hash) is still valid or if for example I revoked the access
Since I canāt manipulate the clients cookie if heās not on my site, this system makes sure I can revoke access at any time
const bodyParser = require("body-parser")
app.use(bodyParser.urlencoded({ extended: true}));
app.use(bodyParser.json());
app.use(bodyParser.raw());
app.post('/approveAd', checkAuth, async function(req, res) {
const ad = await ads.find({adID:req.body.adID}).toArray()
if (!ad.length > 0) { return res.json({error: "true"}) }
const msg = new webhook.MessageBuilder()
.setName("VertexNodes | Ads")
.setColor("#aabbcc")
.setTitle('Ad Approved!')
.setDescription(`Approved by ${req.user.username}#${req.user.discriminator} (${req.user.id})`)
.addField(`Ad ID`, `${req.body.adID} (${ad[0].name})`)
Hook.send(msg);
await ads.updateOne({adID:req.body.adID}, { $set: {state:"approved"} })
res.json({ error: "false" })
})``` why does this return undefined
well req.body.adID
$.ajax({
url: "/approveAd",
type: "post",
dataType: 'application/json',
data: JSON.stringify({adID:ad}),
success: (res) => {
console.log(res.error)
if (res.error == "true") return Swal.fire('Error!', `Invalid ad`, 'error');
Swal.fire({
title: 'Ad approved!',
text:`You approved "${ad}"`,
icon: "success"
})
}
})```
No stop talking about tokens, thatās wrong here
Youāre simply said saving your user accounts ID hash in your cookie to identify the account
This one does never change
oh wait I think we might misunderstand the "token". It's just a generated, unique string like the discord's access_token
In very simple words, you save the username of the account in your cookie once you logged in to identify the client and itās account
Dude thatās a completely different thing
my token is like your hash
You also receive specific account informations from Discord based on an access token exactly like you would identify a client based on his saved cookie
gtg anyways
thanks man
hello developers
i have returned
basically,
async function declineAd(ad) {
const { value: reason } = await Swal.fire({
title: 'Enter your reason',
input: 'text',
inputLabel: 'Decline reason',
showCancelButton: true,
inputValidator: (value) => {
if (!value) {
return 'You need to write something!'
}
}
})
if (reason) {
$.ajax({
url: "/declineAd",
type: "post",
dataType: 'json',
data: {adID:ad, reason:reason},
success: (res) => {
console.log(res.error)
if (res.error == "true") return Swal.fire('Error!', `Invalid ad`, 'error');
Swal.fire({
title: 'Ad declined!',
text:`You declined "${ad}" for "${reason}"`,
icon: "success"
})
}
})
}
}```
when doing `console.log(req.body)` returns `{ '{"adID":"7jJ6WnzI","reason":"test"}': '' }`
why not {adID:"7jJ6WnzI", reason:"test"}
anyone know how I can make code that invites a person to a random 2 servers with the bot in it, done with a command and not by random choice in discord.py?
I have a command that invites me to all guilds but I want it changed for users
and only looking for 2 servers to be invited to
Have the two servers agreed to you creating invites for you to join?
It is a massive privacy concern if you are creating and logging invites for you to use as a backdoor to invite yourself onto servers.
Any bot with that type of functionality will get declined on Top.gg, unless the server opts into that functionality or is given clear warning
Just wanted to ask before someone is helping you with privacy breaching functionality
nono
it would be done by the user not by me
wait I didnt read your message right
yes I asked the people with my bot in it a very long time ago when I took more action lol, but now I thought of a concept of a user running a command and joining servers while other people can run the command and join servers
just not sure how I could do random servers with the bot in it instead of certain servers everytime
I am not familiar with discord.py so I'll let someone else answer
But as mentioned before, make sure all servers agree and that there is a clear disclaimer that when someone use the bot random people may join or have it as opt-in
yes no worries I was thinking about making a whole new bot with it for no confusion lol
seemed like a cool idea im just not experienced enough for it lol my friend prolly gonna end up helpin anyways
index.ts:28:3 - error TS2531: Object is possibly 'null'.
28 bot.user.setActivity("Use {help for more info");
~~~~~~~~
index.ts:29:3 - error TS2531: Object is possibly 'null'.
29 bot.user.setStatus("dnd")
~~~~~~~~
Found 2 errors.```
wtf is this error?
ok
Is { in front of help a typo or your actual command prefix?
is a command prefix
works
smh
commands/timeout.ts:14:63 - error TS2554: Expected 1 arguments, but got 2.
14 e.message.reply("Do you want add or remove the timeout?", {embeds: [embed]})
~~~~~~~~~~~~~~~~~
Found 1 error.``` @wheat mesa
help here
pls
?
seems to me like that's not a typescript issue
you're passing in 2 parameters into the reply function when it's only expecting one
look at the docs for whatever lib you're using
yeah
i saw
someone helped me
You can only reply without arguments in an object if you just wanna reply with the content only
reply("content");
Hello, I was wondering what you all thought about the design of my API's documentation. Is it too cluttered, and is there anything I could improve on?
commands/timeout.ts:12:29 - error TS2769: No overload matches this call.
Overload 1 of 2, '(value: number, options?: { long: boolean; } | undefined): string', gave the following error.
Argument of type 'string[]' is not assignable to parameter of type 'number'.
Overload 2 of 2, '(value: string): number', gave the following error.
Argument of type 'string[]' is not assignable to parameter of type 'string'.
12 member.timeout(Number(ms(e.args.slice(1))), "Timeouted by " + message.member)
~~~~~~~~~~~~~~~
Found 1 error.```
What is wrong?
@boreal iron
@wheat mesa
It seems like you are giving ms a string[] and not a string
Lol really dude?
You are giving it something it can't use
Ok... And?
Omg
(:
Ok
slice returns a new array with that element missing btw
If what you were trying to do was get something from the array then this is basic js arr[index]
you should probably learn more about statically typed languages before moving on with typescript
that'll help you with a lot of the errors that come with typescript
I hate C# !
no
C# is an amazing language
it's like java except it has none of the flaws of java
Oh yeah? Riddle me this batman
Program does not contain a static 'Main' method suitable for an entry point
in .NET 6 you don't even need a main method
told ya to use py
You out, now!!1!
FakE is temporarily not available. Please hold the line!
py sucks, never use py
unless you're doing machine learning
that's about the only thing I condone
but even then
he's using ts
which is much better
py sucks balls imo
everything is so counterintuitive
js was thrown together in a week but python feels like it was thrown together in an hour
turns out I needed to define the lang version in my infrastructure csproj but the error made it so fucking hard to know that lmao
and yeah I'm using .net 6
How do I get the current shard no. that my guild is currently in?
hey guys please tell me some free hosting sites , because replit keep on getting me temp banned ;-;
There really is no free hosting for a discord bot
You really just gotta suck it up and either buy a vps or use an old laptop and run the bot on it. But you gotta make sure it is constantly connected to wifi and doesn't go to sleep
if you say There is nothing like that on internet, I can't believe it
even replit is not free but we can make it free by cheating it š
people will jump through a million hoops in order to not pay for products they want to use lol
also nice mentionable name
thanks
replit allows 24/7 hosting from what I remember. If you're getting banned you must be doing something else shady
nah pretty sure its replit issue tho
replit is just that shitty
a scaleway Starburst instance costs $2/month. Just pay for things you need to use jesus
coder rule 1: coders never pay for online stuff
no you're dumb
there is actually a lot of free hosting but its not as good and free as the paid ones
people pay for things they use
that's how the world works
you're trying to abuse products, that's not a coder thing that's a you wanting to abuse stuff thing
me using all mod apps in my phone not paying for anything and still using there premiums
good for you
if you don't need premium you don't pay for it. Clearly what you need here is a VPS so go pay for it
This deserves a star.
Whats up with the bot getting banned temporarily from accessing the api...?
I searched it up on the internet and it says, the problem may be with error messages that flood up the api and trigger the limit..?
Any idea, this happen everytime i go to sleep smh, at the morning, there is just a error messge saying bot is temp banned from api bcz it hit the limit many times...
@pulsar bone #development message
replit?
the only legitimate free host I've seen is oracles free tier
or what api
nope
discord api or what api?
discord api
well its in your code
just give me any site that doesn't get me temp ban again and again
I was taking care of low storage by using a text file in replit for database so doesn't care about storage beside my bot doesn't use much of database
database.txt
database.json
yeah, i mean, it says that, but what could be that thing...
yes
it says someting like errors are flooding up the api
Unfortunately, I cannot help. As Wendy has mentioned earlier, the only legitimate free host I've seen is oracles free tier.
you're abusing the api, for everything that you do you must search google for its rate limit
dont know what you are abusing and dont want to know
yeah, that is obvious from the error message
someone told me before but I forgot

Can confirm. I've been running my replit 24/7 for free and it still works just fine
and you need cc
Unfortunately, I'm not sure what that is.
credit card
pretty sure if your code is ultra shitty and runs on near 100% cpu usage on a free tier instance replit will ban you to kill bitcoin miners
though I doubt that'd be the case

replit is super buggy thats just how it is
you may get ratelimited easily and you may not
depends on your container
true
replit is actually great for its real purpose
its free but this
true which is not for bots
just say they don't have temp ban problems
š„ŗ how can I abuse a service without facing consequences
me
well if you can abuse it without facing consequences then that is great
but likely not gonna happen



