#development
1 messages · Page 1701 of 1
and definetely not when your code is bs
2+2 is 22
no that's 4
tho if they're string then you're korrekt
> What is code for mathematical expressions when trying to calculate user money???
> Yes this is (insert lib name here) related. I'm using it
mathjs without dot
what
there are two npm packages with the name mathjs
one is useless: npm.im/math.js
one is useful: npm.im/mathjs
I don't actually need a math lib btw
I can do advanced expressions with the built in methods already
if (!message.guild.me.hasPermission("EMBED_LINKS")) return message.author.send("I do not have permission to **Embed links ** in the guild!")
Is it wrong it doesn't sending any dm message just throwing erros missing perms
maybe the bot doesnt have permissions to send the DM
Should work fine just place it on top before it execute message.channel.send or smth
the author might have the bot blocked or the user has DMs turned off for shared servers
True also
what is this omg.
Upgrade your Discord.js version to latest. Stage Channels are not added in older versions
it doesn't seem like it because it's throwing type 13 for unknown channel
type 13 is Stage Channel
what is this 13
You need to npm install as well, then restart the bot
omg...
Do you have Windows Build Tools installed
You'll have to restart the terminal once it's installed
My bot was very easy when not used much, now there is another error every day.
I am getting bored
Maybe it's time for a rewrite
is that win8
errors help you understand what is flawed logic and what isn't. It's just to help you grow
12.5.3 fix tge stage channel, 12.5.1 still persist
what is going on here, why it returns undefined when channelId.profile clearly exists??????????? wtf
i even accessed channelId.ping and the others few lines above and it works just fine
morning all!
hi brain
I find it difficult to believe that a property called channelId is an object and not a string
also you can see that it's undefined lol
just use a debugger stop putting console.log everywhere
yeah ik. i don't know how it is possible for it to be undefined since it clearly appears in the console
yeah i should😅
why does discord instantly close the weebsocket connection for rate limits even tho i did nothing but CONNECT
no heartbeats
no identify
just connect
thats weird
and it's been two days since i last ran my test script
discord doesnt bean you from api for that long
it just closes instantly?
and doesnt send like an op hello code
IP addresses that make too many invalid HTTP requests are automatically and temporarily restricted from accessing the Discord API. Currently, this limit is 10,000 per 10 minutes. An invalid request is one that results in 401, 403, or 429 statuses.
@earnest phoenix maybe try use a vpn or something
how the fuck do you think i ran deno run --allow-all test.ts 10000 times in 10 minutes
idk
also i got multiple hello messages
is anyone here familiar with Twitter API ?
fine bro
then send an identify
the connection closes before i can
Привет всем
Im not English Im Russia
yeah that should work
#general-int for russia
#general-int for not so friendly northern country russian
Yes
As I understand Twitter API only counts "tweets" as the API usage so what If I retrieve the recent tweets of an user with "since_id" params and there are no newer tweets since that id then does my API usage increase ?
that is an awesome question that isn't about development but rather about specific limitations of an API that can be resolved by reading docs and, failing the docs answering it, asking Twitter about it. The chances of someone knowing the answer to that question here is gonna be pretty small
yea thats why I asked if anyone here is familiar with Twitter API at first but okay I might have to ask Twitter ig
assumed someone here did work with Twitter API
"im having problemo!"
"ye should read da docs"
da docs: reeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
is php a good option for making discord bots with
php is a good option to lose brain cells
i have very few brain cells left
u might just die if you use php
also my problemo got fixed by the great bois at official unofficial discord api
The API docs don't seem to mention anything about "tweets". https://developer.twitter.com/en/docs/twitter-api/rate-limits
it mentions ratelimits on specific endpoints but nothing about a number of tweets.
yep, thats why I wonder how it increases, I still assume the amount of tweets I retrieve = the amount of usage
are you sure because I only called 60 times and it increases more than that
or im trippin
are we talking about the same API here
because these are requests per 15 minutes
this is what i see when i hover on my api usage
ok and when you click on "learn more"?
im not talking about rate limit tho, its about the usage
when i click learn more it directs me to project overview
right, so what it's talking about here https://developer.twitter.com/en/docs/projects/overview#tweet-cap
ye that
Tweets received from the following endpoints count towards this monthly Tweet cap:
These pages are talking about 500k tweets / month and you're talking about 60 
yeah ok at this point it's clear that the question you're asking isn't going to be known by anyone here, this is really nitty-gritty stuff of a very specific usecase
people here make bots and can't even figure out webhooks usually, you're not going to find someone that's knowledgeable with bulk tweet parsing through special projects APIs.
hmm okay i tried to asked Twitter anyway, thank for helping

do you actually expect twitter to help you
When trying to respond to an interaction I'm getting a 404 error
I'm sending the request using this:
let endpoint = `${client.endpoint}/interactions/${data.id}/${data.token}/callback`;
fetch(endpoint, {
method: "POST",
body: JSON.stringify({
type: 4,
data: {
content: "poggers"
}
})
})
.then(resp => resp.json())
.then(console.log);
example url: (the token expired btw)
https://discord.com/api/v8/applications/829698249991782432/interactions/831129199309488149/aW50ZXJhY3Rpb246ODMxMTI5MTk5MzA5NDg4MTQ5OjNEMUF6VTdTODlhQmNiWHNzS1lLalRyOW5JVGxNcE1BdTQwVnY3WXJQWko4cjZiZ1U0c2tXWnpMdnY2VFd4UTRLcEdXUTZkelRHcnBLOWtsYUQ3R3d6VUJGQzhvTU9QYk9SQUhhTkEzVnFWdVZYYXZuR2RQWlFwV2VLUDd4V3Nm/callback
so i have this code to delete blacklisted word but it doesnt only delete the blacklisted words, it deletes everything, how can i fix it?
if(blacklistWords.words.some(word => message.content.toLowerCase().includes(word))){
message.delete();
message.channel.send(`${message.author}, watch your language`);
}```
someone?
you cant edit someone elses message
you have to delete the entire thing
it doesnt edit
it does message.delete();
yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyeah
wtf my computer is drunk
anyways if you only want to delete the blacklisted word part youll have to edit the guys message, which you cant
i dont want that i want it to delete messages that contain blacklisted words but it deletes everything so how can i fix it?
i mean every message that is sent
it deletes every messages somebody sends
what
automoderation, u know how that works right?
yeah
thats what i want
i dunno how arrays work
umm
includes on a string?
i didnt made the code
.has
its from stormbeatz dev
.includes is an array method
i asked help to him and he sent this
try message.stuff.morestuff.match(new RegExp(word, "i"))
no

okay i will try
He's trying to help you
i will try this
also can ye guys help me with interactions api
When trying to respond to an interaction I'm getting a 404 error
I'm sending the request using this:
let endpoint = `${client.endpoint}/interactions/${data.id}/${data.token}/callback`;
fetch(endpoint, {
method: "POST",
body: JSON.stringify({
type: 4,
data: {
content: "poggers"
}
})
})
.then(resp => resp.json())
.then(console.log);
example url: (the token expired btw)
https://discord.com/api/v8/applications/829698249991782432/interactions/831129199309488149/aW50ZXJhY3Rpb246ODMxMTI5MTk5MzA5NDg4MTQ5OjNEMUF6VTdTODlhQmNiWHNzS1lLalRyOW5JVGxNcE1BdTQwVnY3WXJQWko4cjZiZ1U0c2tXWnpMdnY2VFd4UTRLcEdXUTZkelRHcnBLOWtsYUQ3R3d6VUJGQzhvTU9QYk9SQUhhTkEzVnFWdVZYYXZuR2RQWlFwV2VLUDd4V3Nm/callback
dont ask how i typed all that so fast
copy paste

when i tried that it said "(node:22512) UnhandledPromiseRejectionWarning: SyntaxError: Invalid flags supplied to RegExp constructor 'test'" when i said the word
hmm
Hi guys somebody can help me
(node:7092) UnhandledPromiseRejectionWarning: #<Response>
(Use node --trace-warnings ... to show where the warning was created)
(node:7092) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:7092) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
that is not the actual error
you're showing us the deprecation warning part of the error
Hmm
When trying to respond to an interaction I'm getting a 404 error
I'm sending the request using this:
let endpoint = `${client.endpoint}/interactions/${data.id}/${data.token}/callback`;
fetch(endpoint, {
method: "POST",
body: JSON.stringify({
type: 4,
data: {
content: "poggers"
}
})
})
.then(resp => resp.json())
.then(console.log);
example url: (the token expired btw)
https://discord.com/api/v8/applications/829698249991782432/interactions/831129199309488149/aW50ZXJhY3Rpb246ODMxMTI5MTk5MzA5NDg4MTQ5OjNEMUF6VTdTODlhQmNiWHNzS1lLalRyOW5JVGxNcE1BdTQwVnY3WXJQWko4cjZiZ1U0c2tXWnpMdnY2VFd4UTRLcEdXUTZkelRHcnBLOWtsYUQ3R3d6VUJGQzhvTU9QYk9SQUhhTkEzVnFWdVZYYXZuR2RQWlFwV2VLUDd4V3Nm/callback
@quartz kindle when in doubt ping tim
or erwin
ye
who is typing now
@opal plank
@opal plank
I would recommend installing ts and setting it to lax. It would be js with intellisence
Oh god wtd
how did you not notice us when typing that really long message
do you know why this aint working
I havent used slash commands
noob ok
lol
string and array
Ah
WHO POSTED MEMES ON GENERAL?
you
does anyone know how to do this, im trying to execute a function from a file by clicking a button, but it gets executed only when reloading
ejs
-Hey man, I'm gonna eat your GrIlFrIeNd
@narrow roost you're setting the button to the action of the output of x()
i didnt see..
anyone knows how bots like carl-bot, can maintain messages with that wait for on_reaction_add for a long time? For me, the hosting service i use, has to restart the application every 24h. and so bot is restarted, there fore on_reaction_add stops working which makes sense. But i see many other bots that has same feature but keep functioning. Is it just they dont restart for a long time?
you mean like reaction roles?
yeah for example, if i have a command that opens a menu, and you can navigate it through reactions
defok
what i have in mind, is an attendance system, where who react to a certain message, will be added to the message as "attending" but what if the bot restarts. therefore reacting to the message wont work anymore
what language you use?
python
Rewrites in it does

😶
after you the bot sent the "react role msg" you save the id of it and later when a messageReactionAdd event triggers you can check the msg id and do what you want
thats what im doing
👀
in my bot, I save this:
{
"buttons": [
{
"channelId": "123456789",
"buttons": [
{"messageId": "987654321", "button": "😩", "role": "2545167152"},
{"messageId": "987654321", "button": "😙", "role": "2545167152"},
...
]
}
]
}
then after I restart her I just iterate over the buttons and re-create them
If u wanna remove html put this in .htaccess
RewriteEngine on RewriteCond %{THE_REQUEST} /([^.]+)\.html [NC]RewriteRule ^ /%1 [NC,L,R] RewriteCond %{REQUEST_FILENAME}.html -fRewriteRule ^ %{REQUEST_URI}.html [NC,L]
although there are multiple ways of approaching that issue
ok, thanks a lot ^^
Np
I can use that for bot command
What you all use ?
For coding ?
What? Thats to remove .html from a link
You can also just make the desired slug a folder and put index.html in the folder
But can get messy quick
Np
Rewrite cond is better
Yah
Who wants to get Demonetized?
why is this happening
is it even possible to call functions from ejs
or to pass a function with .render
no
<%= %> essentially passes the string
it doesnt run on your backend
so forms then
wait it might work
nvm, back to cs
does replit allow socket connections?
like, can i connect with external app to it
net
weeb socket
const net = require("net");
const server = new net.Server();
server.listen(6661, "localhost");
server.on("connection", (client) => {
console.log("pog");
})
const express = require('express')
const app = express()
app.get('/', (req, res) => {
res.send('fuck you')
})
app.listen(8080, () => {
console.log(`aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`)
})
wait maybe im just dum
what the fuck is that code
its ujst test
you're missing the port
where
in the url
i tried even with ws://url:6661
so what do i put in
First question: why are you making a TCP server
tcp
the hostname isn't created by the express server
it will auto-assign the first one most likely
You cant use multiple ports
all others will be ignored
man i cant open ports on my router, this is hell
cough get an actual vps
i am trying to make a welcome message but its not working
one for each webapp
can some one help me?
or you can use almighty glitch
i was hosting on my own server but changing isp fkd it all up
we dont speak python
ping shivaco if you need help with py
what about it is not working?
did you check if you are receiving the event at all by printing something in it?
if you're not receiving anything, you need to enable the SERVER MEMBERS intent
if you are reciving, then print the channel variable to see if it actually found a channel
can ports be opened on a mobile broadband 💩
Yup
discord.utils.find takes a predicate and a sequence. Just make a function that takes a channel and returns whether or not the name attribute is in that list you made. You can even make a lambda function, that function or lambda will be the predicate. The sequence would be <Guild>.text_channels
ohhh
huh?
nvm
can anyone explain me wtf is going on in https://github.com/Major-Thrust/alexa-bot-api/blob/main/src/ai.js
what is that
plagiarize
verb
past tense: plagiarised; past participle: plagiarised
take (the work or an idea of someone else) and pass it off as one's own.
"he was fined $6,000 for having plagiarized the song"
take the work or an idea of (someone) and pass it off as one's own.
"the author claims she was plagiarized"
I am doubting this guy for claiming ai chatbot api to be his own
the previous version just used cleverbot's api
and he just outta no where said he rewrote it
but I think he did some clever thing which still uses something else
That definitely makes a request to something
so he most likely didn't make the API, no
I mean, he could have made the api and he's making requests to it
Maybe the URL is so obfuscated so it's private, even though it can be figured out
This guy claimes that Cleverbot's team gave him perm
to use their api
which I doubt
Maybe they bought api calls
and that's why they're obfuscating the code which makes the call
that do makes sense
but why would cleverbot allow this guy to make it into npm package with 100k downloads
wouldn't this cause a loss to them?
I highly doubt cleverbot gave them api calls for free. They most likely brought them
npm link?
or are scraping the cleverbot site which isn't very hard to do either
which by the way is against their ToS
yes that's what I think
he refuses
the website is ugly :C
and he says that Cleverbot gave him perm for free
check the source?
the code is quite small
obfuscated api call
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
this is simplified
version
encoded
file in utils folder :
name: "utilsPanel",
category: "Utils"
}```
help.js :
```client.commands.filter((command) => command.category === "Utils").map((command) => `\`${command.name}\``).join(', ')```
but my bot send empty field.. why?
they said this :Bruh: I never paid, i emailed them sayin I'm a student like an year ago, they gave me a free premium cookie that i can use to get unlimited calls i don't wanna disclose the cookie that's the reason i obfuscated it
This seems fully suspicious
command.help.name
Since it's exports.help
lol
Well they are definitely making a request to the official api
seeing obfuscated code makes me cringe
yes they are
but i want to check if command is in a category: 'utils' @umbral zealot
but, I think he is not doing it the legal way
This npm package gets calls about 100k times every day
Why would cleverbot want to be in loss
command.help.category , command.help.name
you're exporting an object called help so when you export it you have to use the help object first
ok i test
(node:11505) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'category' of undefined
Should I complaint it to Cleverbot?
then now it maybe
.setDescription(client.commands.filter((command) => command.help.category === "Utils").map((command) => `\`${command.name}\``).join(', '))
@umbral zealot
(node:11505) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'category' of undefined
Do you hate that guy or something
well clearly one of your command doesn't have a help object exported
yes, I do
I was just asking him if this is legal just in a friendly way and he cussed the heck out at me
and just kept saying I suck
but I still didn't cuss back
and maintained my same tone
go through the files in your commands folder, and make sure you have a exports.help = { ... blah blah blah here } on every file.
your code doesn't allow for files that dont' have it
if that's his response then it's likely that he's not supposed to do that
If it's paid then I don't think it would be a problem, but if they gave it to him for free, for PERSONAL use
he's not using it very personally
js cringe
A light weight [asynchronous / promise] based Neural Network [Artificial Intelligence] in the github repo description... when all he's doing is a request to a service... cringe
here's a partially decoded version 😉
https://text.evie.codes/radacaxomu.js
exactly
Let's steal that token :d
I wouldn't even be mad if it he was agreeing to use cleverbot api
but instead he bluntly claims that he coded everything
lol, I saved source code on my local PC :hehe:
he can probably change it any time though
then that's kinda pointless
but still
what if he is reading this rn 😳
not even in this server
I downloaded whole source code and tested it yesterday
it works fine 
ehem... he IS in this discord server
wtf is even happening here
eh
just sniff traffic via wireshark
doesn't matter whether the code is obfuscated
the http request won't be
true
heres a more partially decoded version
basically they do ```js
await superagent.post("https://www.cleverbot.com/webservicemin?uc=UseOfficialCleverbotAPI").set(_0x47f9[22], cookies).type("text/plain").send(hash);
cookies is "XVIS=TEI939AFFIAGAYQZ;Path=/;Max-Age=31536000"
hash is
and to get cookies they do ```js
const _0x8d36x12 = await superagent.get("https://www.cleverbot.com/");
cookies = _0x8d36x12.header["set-cookie"];
so basically, they are scraping
is tim legit manually decoding obfuscated code? or are my eyes decieving me?
it's not hard
it's basically just a bunch of numbers in hex form
js-obfuscator can only do so much
I see
I wouldn't call that scraping, but knowing how the cleverbot website works, he must've done his research
well they are setting cookies to pretend they are a browser
then requesting the page as text/plain
pretty sure thats considered scraping
i need help
ask2ask
I'm pretty sure the XVIS cookie is something like an API token which can be used
and they're getting that then using it
they are getting that just from vising the main page tho
i dont know the command to translate the language
yeah, seems like cleverbot sends the cookie when a user visits the main page
cause the chatbot thing is on the main page
those kinds of cookies are basically sessions cookies to prevent usage from non-browsers
yeah well... doesn't look like they're working
everything can be spoofed
its just a layer of protection
not perfect but works for a lot of stuff like generalized scrapper bots
What the writer of the npm package did is pretty clever though, gotta give em that
clever but not that special, but the fact they're hiding it does make them look shady
this kind of obfuscated code in an npm package caused serious issues before
remember that story when malicious code was injected into a crypto currency module by doing exactly this to one of its dependencies?
oh yeah definitely... I don't get the point of the obfuscation... just say that it uses the cleverbot api for free
does this break cleverbot's ToS?
It does use the official API
if (subcommand === 'ban'){
let targetMember = message.mentions.members.first();
console.log(targetMember.id)
let test = JSON.parse(fs.readFileSync("./banned.json", "utf8"));
config.userids.push(targetMember.id);
fs.writeFileSync("./banned.json", JSON.stringify(test))
}``` Hey why is thjs not writing anything to userids?
because you're modifying config and not test
owh
but config is saved to require banned.json
man's still using the same json db
ok but you're not modifying test which is the updated value
and config isn't being updated, probably because you're requiring it?
This is what you get for sticking with a shitty-ass json database, mate.
how would i then use instead of require
You'd already be done dealing with this shit if you were using a real db
let test = JSON.parse(fs.readFileSync("./banned.json", "utf8")); <----- what about this line? why not just use that?
you literally know how, just use that
What's crazy is that this guy's been asking questions regarding the json database for a few months already...
I know right
"But it's easier"
It's been months
and you still can't read/write to one file!
August 2010. 6 months. SIX MONTH
how are you still sticking with "it's easier" ?
2010
Imagine
Trying to figure out how to make your json database to work for a whole decade
rewrite everyting to wasm perf™️
you'll barely get any performance out of that but ok
When are you going to admit your idea of sticking to JSON is the wrong choice?
there are way too many masochists in the dev world. It's scary.
Is there a way to store a java hashmap in mariaDB?
dude this is #development
lmao
entirely out of the loop, but isnt that basically just mongodb xd
yes you can but i doubt there is a way to directly translate it. you 'll likely need to iterate over it and insert
dyi homescrapped mongodb
like I have multiple groups and each group has a hashmap
or serialize it
whats serializing
convert it to a string of key-value
like json
could also serialize to a binary format
hmm
sql is based on tables and relational data, so you need to see how to best fit your hashmaps to it
since hashmaps are key-value only
if each of your groups is a row in your db, then serialize and insert in a column
just for you, i am completely switching to mongodb.
if each of your groups is a table, then you could make rows for each entry in the hashmap
Will be back within like 4 hours once everything is set
You should be doing that for your own sanity, not just for me
I mean if you switched to quick.db or enmap you would actually be done in like 4 hours
in a longtext column?
like actually, truly
if your data is that big sure
but if your data is that big, you might wanna consider making a separate table for it
like im writing a minecraft permission plugin
also depends how you want to access it
because you cannot independently access the keys and values of a serialized hashmap, you have to parse the entire thing before
if its very large it will be costly
hmm
a typical strategy for relational databases would be to make a new table and store keys and values there, along with a group id to connect it with the other tables
for example
a public one, at that
why did I think this said hashbrowns
honestly I agree
NO BITING
hmm like then i would have like
groups:
groupId, other data, other data
123, data, data
456, data, data
groupMap:
groupdId, key, val
123, 1, abc
123, 2, abcd
hmm
yes
welcome to relational databases
that would be the most performant method
fast insert and read
but slightly more disk space consuming
if you only using it for that why not use redis with keydb?
set the entry group as the key, and the hashes have their own values
so you would shrink all that under 1 "table"
i have 10gb free space that should be enoguht i think
even though redis doesnt work with tables
Hset and Hget would be better imo
but i have 20k rows and use like 20mb
// groupId, hash 1, hash1 value, hash 2, hash 2 value
redis.hset('123'/*key (aka your group)*/, '1', 'abc' , '2', 'abcd' /*, etc...*/);
redis.hset('456'/*key (aka your group)*/, '3', 'efg' , '4', 'efgh' /*, etc...*/);
redis.hgetall('456'); // returns {3: 'efg', 4: 'efgh};
redis.hget('456', '3') // returns 'efg'
this would be far more efficient in my opinion
hello I have a problem. when I do the join command or a command that wants to join the bot in my channel I have an error
Sounds like your hosting is too slow for a music bot and is timing out.
What is that, repl?
far more efficient yes, but it will still hog your ram, while offloading it to a db wont
you can set redis to unload on disk instead of keeping it all on memory, along with clustering
or i could have hashmap<groupdId, hashmap<key, value>>
keydb
this is exactly what im saying with redis and keydb
here
redis with hashes
@quartz kindle
what the website of keydb
which is still a good alternative
the entire dataset is kept in memory at all times
Syntax Error
Adkdynet
File "E:\lib\runpy.py", line 267, in run_path
code, fname = _get_code_from_file(run_name, path_name)
File "E:\lib\runpy.py", line 242, in _get_code_from_file
code = compile(f.read(), fname, 'exec')
File "c:\Users\User\Desktop\Banking Bot Main File\mainFile.py", line 22
async def ban(ctx,member : discord.Member,*,reason = "No Reason has been provided"):
^
SyntaxError: invalid syntax
PS C:\Users\User\Desktop\Banking Bot Main File>
trying to see where thats at, but im not finding it https://docs.keydb.dev/docs/memory-optimization/
or what would happen if it hits maximum memory allocated
it will use swap if possible, and then crash with OOM
The previous point means that you need to provision memory based on your peak memory usage. If your workload from time to time requires 10GB, even if most of the times 5GB could do, you need to provision for 10GB.
yeah i read that part
though the question becomes, how many entries do you need to allocate that much
since they only have 10GB space, i assume they would have a good 4GB ram to abuse
and possibly a swap with the disk
If swap is possible its more of a win than anything
Normal dbs should also be reading from disk, so i dont assume it would be that much worse
You would gain from speed from the entries in ram, and not lose much with the ones in disk compared to others
But you would gain overall in size possibly
From 10gb to 10gb + some ram
swap is slower than regular databases tho
at least it should be
there is a lot more work involved
If it is that voids my other argument
redis has a thing on that
Using as little memory as possible
An interesting setup to turn Redis into an on-disk DB with just keys in memory is setting vm-max-memory to 0. If you don't mind some latency more and poorer performance but want to use very little memory for very big values, this is a good setup.In this setup you should first try setting the VM as blocking (vm-max-threads 0) as with this configuration and high traffic the number of swap in and swap out operations will be huge, and threading will consume a lot of resources compared to a simple blocking implementation.
Is it possible to import a module in a html tag?
a module like mongoose
for ex
not exactly
modules for browsers are different than modules for node.js
you can load them with script tags or import them from js using es6 imports
but they must be compatible with browsers
so
many modules out there are node.js-only unless they specifically state it works on browsers too
and i doubt mongoose is one of them
can you give me an example how could i import them?
furthermore, you should never use a database module on the client side
db connections shouldn't be available to clients anyways
9GB. Feels bad
lol yeah
its a profiler
so i got 600,000 users, 270,000 roles, and 7600 guilds in 325mb ram
but its flapping back and forth between 0 and 3.5% cpu
i want to check if thats acceptable or not, so profiler time
still a ton less CPU than the aegis lib, though
not bad :)
325MB seems a bit excessive for such a low size considering I was able to squish ~3.7k into 80MB or so
Anyone have template of webhook receiver?
but were you caching everything?
and does that include the program code for the bot? ive never seen a node app take only 80mb in htop
Okay no, not everything returned by socket, but I was caching all of the properties available to certain resources
stateless bots are cool :)
nah, node itself takes more than 80mb just to boot doesnt it?
nah
after you load all the node_modules and stuff to make it do something
Node can be pretty optimized depending on what modules you install and your own logic
such is the case with any language though
these are the figures im really proud of though
can someone help me with a nickname command
guild_member: 72
user: 72
channel: 160
role: 80
emoji: 64```
these are the sizes per item, in bytes, for cached objects 🙂
these are my node apps:
do you cache all properties for resources
there's overhead the minute you store them in an unordered_map though 😦
i cache all those types
what have you tried?
i'll look into it for other stuff
its a header-only dep, but alright
storing messages seems like a security concern regardless 👀
`module.exports = {
name: 'nick',
group: 'Moderation',
description: 'Sets a users nickname.',
userPermissions: [
'MANAGE_NICKNAMES',
'CHANGE_NICKNAME'
],
clientPermissions: [
'MANAGE_NICKNAMES',
'CHANGE_NICKNAME',
],
argsType: 'multiple'
}
run: async = (message, args) => {
const target = message.mentions.users.first()
const member = message.guild.members.cache.get(target.id)
args.shift()
const nickname = args.join(' ')
member.setNickname(nickname)
message.reply('You changed the nickname!')
}`
header only, the bane of C++
xD
how to bulk up your compile times in one easy step lol
i made a pre-compiler to reduce build time
it simply copy pastes the contents of all files into a single file before build
xD
ask the node.js devs? iirc by default it caches the last ten of every channel? maybe more?
this would make it a ton slower for me, because that one file can only be compiled on one core, rather than splitting workload across multiple cores
storing in-memory doesnt count as a security concern i believe since its part of the program's operations
e.g. make -j8 is nerfed
`module.exports = {
name: 'nick',
group: 'Moderation',
description: 'Sets a users nickname.',
userPermissions: [
'MANAGE_NICKNAMES',
'CHANGE_NICKNAME'
],
clientPermissions: [
'MANAGE_NICKNAMES',
'CHANGE_NICKNAME',
],
argsType: 'multiple'
}
run: async = (message, args) => {
const target = message.mentions.users.first()
const member = message.guild.members.cache.get(target.id)
args.shift()
const nickname = args.join(' ')
member.setNickname(nickname)
message.reply('You changed the nickname!')
}`
this is my nickname command what is wrong with it
storing it off-memory would be another thing
makes it 20 times faster for me haha
but my workload is waaay different
its about 90 files, and every single file needs a header which needs the full C library it requires
the old C lib i told you about, thats like 60k+ lines
ive been doing my best to do away with header only deps
thought it was detritus for a second
so i can compile my entire lib from clean in 4.5 mins
compiling triviabot from clean with aegis takes 22 mins 🤮
thats kid of a lot
?
my dev box has old slow xeon
my lib's compile time is like 20 seconds
lol
a js library for discord, better than disocrd.js
well, only tested on my pc
Ah shit here we go again
mines the acid test of if your process really is efficient 😉
an i5 laptop
was about to say, Erwin's at it again
but well, its a completely different library
vendor_id : GenuineIntel
cpu family : 6
model : 30
model name : Intel(R) Xeon(R) CPU X3450 @ 2.67GHz
stepping : 5
microcode : 0x4
cpu MHz : 2660.130
cache size : 8192 KB
its really fast for db stuff
but really really slow for compilation
my production box is like 4x as fast
look up the X3450
`module.exports = {
name: 'nick',
group: 'Moderation',
description: 'Sets a users nickname.',
userPermissions: [
'MANAGE_NICKNAMES',
'CHANGE_NICKNAME'
],
clientPermissions: [
'MANAGE_NICKNAMES',
'CHANGE_NICKNAME',
],
argsType: 'multiple'
}
run: async = (message, args) => {
const target = message.mentions.users.first()
const member = message.guild.members.cache.get(target.id)
args.shift()
const nickname = args.join(' ')
member.setNickname(nickname)
message.reply('You changed the nickname!')
}`
this is my nickname command. when i run it it doesnt work! please help!
The error i get is: node:946) UnhandledPromiseRejectionWarning: TypeError: command.run is not a function
(node:946) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:946) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
its a good ten years old iirc
AAAAAAAAAAAAH
jesus stop pasting your entire code
use a pastebin like normal people
or at least do this
i5-7300HQ
module.exports = {
name: 'nick',
group: 'Moderation',
description: 'Sets a users nickname.',
userPermissions: [
'MANAGE_NICKNAMES',
'CHANGE_NICKNAME'
],
clientPermissions: [
'MANAGE_NICKNAMES',
'CHANGE_NICKNAME',
],
argsType: 'multiple'
}
run: async = (message, args) => {
const target = message.mentions.users.first()
const member = message.guild.members.cache.get(target.id)
args.shift()
const nickname = args.join(' ')
member.setNickname(nickname)
message.reply('You changed the nickname!')
}```
thats my cpu lul
wish there was an option to collapse code blocks similar to *.txt embedding
it still beats my dev server
look here @lament rock
oh wow
hell, my AMD FX-6300 desktop beats my dev server
thats a really old xeon
yup
you will have a recommendation in host for bot radio and music?
it was refurb enterprise server
@earnest phoenix theres plenty of issues in ur code btw
help me then plz
isn't that embedding a js file as suggested by the file name
cammy
yes
what s your error
?
The error i get is: node:946) UnhandledPromiseRejectionWarning: TypeError: command.run is not a function
(node:946) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:946) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
first, you dont check if you have a target, you might try to cache.get(undefined.id) which will error
second, nickname can be empty
third, member might be null/undefined
fourth, you dont check for 32 max size thats allowed to edit nicknames
theres plenty of errors here in a 6 line code on ur run() function
My ban command is having a syntax error (discord.py)
@client.command(aliases = ["b"])
@commands.has_permissions(ban_members = True)
async def ban(ctx,member : discord.Member,*,reason = "No Reason Provided"):
await ctx.send(member.name + "Has been banned")
await member.ban(reason = reason)
What's the error?
@unique panther check your dms
module.exports = {
name: 'nickname',
description: "nickname",
async run(message, args, client){
const target = message.mentions.users.first()
const member = message.guild.members.cache.get(target.id)
args.shift()
const nickname = args.join(' ')
console.log(nickname)
message.reply('You changed the nickname!')
}
}
try it like that
ok\
literally t33o
idk what s your command handler
did you bother reading what i sent?
amazing
tbh
noted
Im having a syntax error
@client.command(aliases = ["b"])
@commands.has_permissions(ban_members = True)
async def ban(ctx,member : discord.Member,*,reason = "No Reason Provided"):
await ctx.send(member.name + "Has been banned")
await member.ban(reason = reason)
whats best is that cammy is likely trying to ask electro for js help in dms
mhm
Yes you said that already
no
But what error?
but y?
@earnest phoenix
wdym why
even if his function works
it'll likely error
that code is as stable as a cards tower
ik
one wrong blow and it all falls
So can anyone help it shows syntax error in this line
async def ban(ctx,member : discord.Member,*,reason = "No Reason Provided"):
but yeah, his error is what you said, he's not including the function inside the exports module
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'users' of undefined
at Object.run (/home/runner/CAMS-bOT/commands/Moderation/nickname.js:5:41)
at Client.<anonymous> (/home/runner/CAMS-bOT/index.js:44:25)
at Client.emit (events.js:314:20)
at Client.EventEmitter.emit (domain.js:483:12)
at MessageCreateAction.handle (/home/runner/CAMS-bOT/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/home/runner/CAMS-bOT/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/home/runner/CAMS-bOT/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
at WebSocketShard.onPacket (/home/runner/CAMS-bOT/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
at WebSocketShard.onMessage (/home/runner/CAMS-bOT/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
at WebSocket.onMessage (/home/runner/CAMS-bOT/node_modules/ws/lib/event-target.js:132:16)
(node:1018) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1018) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit cod
thats my error
Does it literally just say syntax error?
AAAAH
and nothing else?
@earnest phoenix stop asking and read this #development message
idk what that means
File "E:\lib\runpy.py", line 267, in run_path
code, fname = _get_code_from_file(run_name, path_name)
File "E:\lib\runpy.py", line 242, in _get_code_from_file
code = compile(f.read(), fname, 'exec')
File "c:\Users\User\Desktop\Banking Bot Main File\mainFile.py", line 22
async def ban(ctx,member : discord.Member,*,reason = "No Reason Provided"):
^
SyntaxError: invalid syntax
PS C:\Users\User\Desktop\Banking Bot Main File>
then learn js
@earnest phoenix Before you make a Discord Bot, you should have a good understanding of JavaScript. This means you should have a basic understanding of the following topics:
- proper syntax
- debuging code
- basic features (vars, arrays, objects, functions)
- read and understand docs
- nodejs module system
As much as we d like to assist everyone with making their bots, we rarely have the time and/or patience to handhold beginners through learning javascript. We highly recommend understanding the basics before trying to make bots, which use advanced programming concepts.
Here are good resources to learn both Javascript and NodeJS:
Javascriptinfo: https://javascript.info/
Codecademy: https://www.codecademy.com/learn/javascript
FreeCodeCamp: https://www.freecodecamp.org/
Udemy: https://www.udemy.com/javascript-essentials/
Eloquent JavaScript, free book: http://eloquentjavascript.net/
You-Dont-Know-JS: https://github.com/getify/You-Dont-Know-JS
NodeSchool: https://nodeschool.io/
CodeSchool: https://www.codeschool.com/courses/real-time-web-with-node-js
Evie s Accelerated JS: https://js.evie.dev/
Please take a couple of weeks/months to get acquainted with the language before trying to make bots!
ik java
Remove *, before reason
with what command did you test it?
ok
just asking
?nickname
if you know java, that should give you a decent head-start
that s why u got this error
at this point you just copy pasting random stuff
i have 8 commands
again
u didn t mention anybody
learn javascript
oh
you shouldnt be coding a bot with 0 knownledge of code
im willing to bet you took that command from someone
no i did ?nickname @someoneinmyserver test
yea try that
oh
oops
srry
Same error
File "E:\lib\runpy.py", line 267, in run_path
code, fname = _get_code_from_file(run_name, path_name)
File "E:\lib\runpy.py", line 242, in _get_code_from_file
code = compile(f.read(), fname, 'exec')
File "c:\Users\User\Desktop\Banking Bot Main File\mainFile.py", line 22
async def ban(ctx,member : discord.Member,reason = "No Reason Provided"):
^
SyntaxError: invalid syntax
PS C:\Users\User\Desktop\Banking Bot Main File>
i m blind
my showroles command is bust idk why i cant get it to pick up the name err TypeError: Cannot read property 'name' of undefined
const Discord = require("discord.js");
exports.run = async (client, message) => {
var guildRoles = message.guild
for (var i = 0; i < guildRoles.length; i++) {
var nowRole = guildRoles[i];
}
let embed = new Discord.MessageEmbed()
.setTitle("ROLES")
.setColor("GREEN")
.setDescription("Name" + `${nowRole.name}` + "\nPosition: " + `${nowRole.position}` + "\nMentionable: " + `${nowRole.mentionable}` + "\nColor: " + `${nowRole.color}`)
.setFooter("Server Roles")
message.channel.sendEmbed(embed);
}
thx
avoid using var in js anymore
do you want to move this conv in dm?
yes sure!
also that code wont work
is there a shorter way i can grab a servers role list
guild is an object, not an array
Hey @pale vessel it shows same error\
also also
you're trying to access newRole where it doesn't exist
newRole only exists in the for loop
nowRole*
Show your code
message.reply({embed: {title: "ROLES", color: 'GREEN',, footer:{ text: 'Server Roles'}, description: [...message.guild.roles.cache.values()].map((role) => `Name: ${role.name}\nPosition: ${role.position}\nMentionable:${role.mentionable}\nColor:${role.color}`).join('\n').slice(0, 1990),},})
i cant think of a safer way than this

nor smaller
Is the discord TestFlight full
@client.command(aliases = ["b"])
@commands.has_permissions(ban_members = True)
async def ban(ctx,member : discord.Member,reason = "No Reason Provided"):
await ctx.send(member.name + "Has been banned")
await member.ban(reason = reason)
@onyx hare im feeling charitable, enjoy
and the full error?
Traceback (most recent call last):
File "E:\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "E:\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "c:\Users\Sameer Khan.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\lib\python\debugpy_main.py", line 45, in <module>
cli.main()
File "c:\Users\Sameer Khan.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 444, in main
run()
File "c:\Users\Sameer Khan.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 285, in run_file
runpy.run_path(target_as_str, run_name=compat.force_str("main"))
File "E:\lib\runpy.py", line 267, in run_path
code, fname = _get_code_from_file(run_name, path_name)
File "E:\lib\runpy.py", line 242, in _get_code_from_file
code = compile(f.read(), fname, 'exec')
File "c:\Users\Sameer Khan\Desktop\Banking Bot Main File\mainFile.py", line 22
async def ban(ctx,member : discord.Member,*,reason = "No Reason Provided"):
^
SyntaxError: invalid syntax
PS C:\Users\Sameer Khan\Desktop\Banking Bot Main File>

doesn't seem like you saved the code
No thanks
That's not even a valid invite link 5head
dont work like that my dude
anyways let's continue our python rant
I tried in debug section
idk what that is, but its fancy and i like it
its profiler output
on the left hand side is a relative chart of how long the processor spent in each part of the code
the boxes within boxes is a graphical representation of the same
clicking the chart lets you drill down
so you can see what parts of your code are computationally expensive
and which bits to work on
rather than just clutching at straws and optimising needless things
i give up
get hold of something called qcachegrind then @opal plank
what python version are you using by the way?
dont know if node can output a callgrind.out file though that it needs
@green kestrel
Chrome's Heap inspector is not beginner friendly
oh please dont say drill ive had enough pain from #memes-and-media
I've gotten my app to the point where strings of imported modules are the Objects which occupy the most memory
drill.
why does axios have to be so chomk
in the good way, right
no
axios pog tho
I moved all my libs to centra because I dislike axios
i love axios
the one i've yet to try is GOT
ew got
also, i saw that
have you tried it?
tim talked about it quite a few times, but i've never tried it myself
WTF WHY
yeah. Kinda bad imo. Tried it while I was trying other http libs for my rest only lib
😢
now shut
cpp-httplib for life
you want basic shit?
wish I knew cpp
cpp-httplib isnt basic 😄
lol ew
what's the difference between a full virtual machine and a container
- makes a module that wraps curl cli
- puts it in production bot
- comes to top.gg #development and asks "why my bot so slow"
i've had the brilliant idea of doing something similar before
Next thing you know: out of memory because of how many child processes are being spawned
a container doesnt emulate the cpu, in short
or the hardware
a container is basically like an advanced chroot with some other stuff on top
to contain the network portions
how would i make a global cooldown instead of just for that one person
unless youre running a linux container on windows, in which case yes... theres really no difference between the two terms under the hood 😄
at least on docker
with wsl2 containers
@onyx hare key the cooldown to the guild id
in a dict
brain
here
import {exec};
let output= await exec('CURL https://google.com'), parsed;
if(output) parsed = JSON.parse(output);
gg ez
just require promisify and make exec await/async

big brain
parsing stdout from exec
The lateste python 3
That's fucking cursed
I thought exec didn't return a Promise
well
me neither, but it does
name the second error as stderr
ignore that
time to look at child_process's api docs
tfw devs talk about masters and slaves
thats the terminology i still use
fuck everyone else who dislikes it
not my problem

execution 
Damn. Thought we were closer than that 
didnt block you, just referring that theres a block button
ik. I'm memeing
its quite hard to piss me off to the point of blocking
but i still use that terminology
okay
there might be some false positivies here
but gives you an idea

I still do as well even for git branches, but if I made a new branch and intended it to be the default branch, I would still probably call it main since all new repos are having that enforced
or I'd just meme and name the branch index
i'll literally host my shit on hastebin if they dont allow my repos to use master terminology
You can still make a branch with the name master then set it as default and delete main
well fair
How can I make the bot ask to repeat the value of the variable arg but leave two letters of error
string.repeat is a method
if you're trying to output something multiple times to a string that is
I think they're talking about fuzzy string matching, but it's unclear what they're saying
ah
I don’t want this, im french sorry…
Basically I want the user to write a word, but if they are 3 letters wrong (for example), it is still accepted
fuzzy string search
fuzzyset, fuse or some other module for it
or you can use some pre-made algorithms
hello! can u help me with reaction collector discord?js
'🟢' => <ref *1> MessageReaction {```
how do i use this array ?
ah yes sry










