#development
1 messages · Page 255 of 1
yes
check this out https://discordjs.guide/creating-your-bot/command-deployment.html#command-registration
alright, ill send u after
explains the difference between guild registration and global registration
Why not just prevent people from inviting it to other servers?
guild registration = only shows in your server
global registration = allows any guild the bot is in to see it
i think they are wanting the bot in other servers but only have certain commands accessible to their specific guild
i want a public bot but i just want a few commands that are only accessible in the support server
i gotcha!
this will give some helpful information on how to do that! https://discordjs.guide/creating-your-bot/command-deployment.html#command-registration
but post your code and i’ll take a look
ill dm u it in a lil. give me like 15-20
how do i make the ticket system
That's for you to decide!
i dont know how
if you can explain to yourself what a ticket sistem is and what its supposed to do, then you can also explain to yourself the steps you need to make it work
I got question for yall
has your bot been self restarting out of no where and you havent mess with it at all past few days
and there's no errors from self restarting
Uncaught exception maybe
that will pop up in my errors logs
but there's nothing
Are u sure u aren't muting any exception?
none muted
every 1 hour or something
Hm, that's very frequent
it started from discord api error from earlier today
Which error?
Well, did you shutdown the bot manually?
It might have been gotten into a restart loop
yea until i got home from school and no my vps hasnt been restarted automaticly
and yea
That's odd then, I've not noticed that latency issue at all today, might be something local
Try enabling debug level logs
And waiting till it restart
client.on("debug")?
It'll be a hella big log tho, probably some performance loss
No, debug level on node
idfk how to do that
Oh wait, is the process restarting or the connection itself?
process restarting
I suppose you use pm2 then
yup
thats where ive checking
Nothing there at all?
only
That's very weird, does it happen with any other pm2 process?
process.on
Try listening to unhandledRejection too
Also I'm unsure if js works the same, but in java Errors cannot be caught by catching exceptions
I have that too
yea that will never happened
Might want to put an onExit listener to print the exit code
Only way to know why it exited is by seeing the exit code
There oughta be a way to see it in node, otherwise u could have a script call node then printing the exit code of the process
I dont
It seems i fixed it but same time idk yet
I genuinely don't think the solution is to use a process monitor to restart things for you. I think the correct solution is to make more stable software
bro gave him the reality check
I use stable software

Not if there are errors killing your process 
Im using ubuntu
How does that relate to what I said
i'd say a mix of both
where the restart should be like the very last "solution" in case something goes horribly wrong
@lyric mountain @quartz kindle are constant pointers just pointers where you can't modify the value it's pointing to or pointers you can't modify the address itself?
gotta love these article titles
i think my teacher would've killed me for using , and and
if constant pointers are not pointers to constant, does that mean that ```c
const int year = 2024;
const int* ptr = &year;
i've always defined constant pointers as pointers to constant
but my lecturer interpreted them as literal constant pointers
my lecturer said that arrays are example of constant pointers, but which one? thisc int* array = { 0, 6, 7 }; array[2] = 3; // crash or this? ```c
int array[] = { 0, 5, 4 };
array = NULL;
I'm not fluent enough in low level languages
but I believe the const keyword protect the variable itself
I mean, it makes the variable a constant, so const int* would prevent it from being changed, not the value pointed at
Hello
but isn't that const int* const or int* const tho, not const int*

idk, too confusing
const int* const would mean you cannot change the pointer’s location or the value stored, int* const would mean the pointer’s location cannot be changed, but the value can, and const int* means the pointer’s location can be changed but the value cannot
what about this? @wheat mesa
You cannot reassign the pointer location of an array iirc
So the second one would crash, the first one is fine I believe
oh yeah that’s right I forgot
For a compile time array that is true
(Why would you bother using pointers in a compile time array?)
For a dynamically allocated array, it wouldn’t crash
obviously
imagine actually using const
i use it once a year
i only use it for global variables but thats it
in javascript though i always use const unless i need to change it
any reason i can't create a JavaFX Project?
You don’t have a java installation path set
You need to set the JAVA_HOME env variable to point to your desired java binary location
I strongly recommend using intellij
java for vscode is cursed
what about constexpr?
xd
i use it but i have no idea what it does
Constexpr evaluates expressions at compile time
(In the context of variable declarations)
holy fuck @sharp geyser @quartz kindle
jetbrains now supports ai for query building
yea I saw that in data grip I think
just updated it, the features are quite good
wonder if the issues I opened last year were fixed in it
that thing doesn't work on my 3k lines database handler 😔
programs_that_have_ai_integrated_counter++;
also it's quite dumb for now ig. idk how is it on other's
is github being slow for anyone else 😦
it is very fast
is this worth the upgrade
i dont really need it tbh i only want the extra ram because i run vscode server and on 1gb ram it starts shitting itself when it runs for too long
5x more upload is helpful though
actually ill try adjusting my swap options to maybe remedy it
I've been on the standard 4g for a lonng time now
I love it
swap is a good idea first yeah
the out of memory killer starts kicking in and kills my vscode server for being too fat
5 minutes after my server becomes unresponsive first
that swap is utter misery
u can change it
i need to check if i have enough storage to spare first 💀
ah, right, 15 gb 💀
i have gotten unbelievable value out of this server but at a more annoying experience
and i do have the money to spare so might as well upgrade eventually
im just being frugal
maybe ill just upgrade
im sure i could probably clean it up to use less but not sure if its worth it
Chuck your referal link for gg on your profile
It pays off quite a lot.
Sometimes I'll get enough referrals in a month to pay for all my servers for a few months.'
Shoutout to the person who gave me $20 a month for a few months with my referral ❤️
That server is kind of not amazing for $3 a month, that’s like oracle free tier level perf
Then again, $3 a month to not have to deal with Oracle might be worth it

i have oracle free tier but im not dealing with oracle
i do not associate oracle with reliability
just host at home smh
the cloud is where its at nowadays
depends
I can put 99% of projects on cf workers/pages so no need to worry about that
all my game servers, dev servers and lab vms are hosted at home and basically free (like 15€/month power)
and the rest is on a cheap hetzner dedi
galaxygate himself replied
3/10 upsell attempt
im pretty sure i have at least a 90% io cap by now
i might move to something cheaper tbh but not sure yet
my main concern is my email server and its built up a bit of an association with the vps's IP
i can't lie galaxygate fell of
their service goes offline every 1 week like waddafuck
lets not make it a habit now
Hetzner cloud if great if you’re willing to pay the min vps price
those ddos's were wild
I have been considering getting a digital ocean server for a bit just for webhooks.
thats overprise imo
pls don't
one of the providers i use
this is datalix
ddr3 tho
pls compare this to galaxygate lmao
oh yeah, I bought datalix
im moving from datalix because ddr3 is kinda slow and their vms are being so slow and unreliable for me atm
24gb vs 4gb of ddr4 tho
yeah but 16gb ddr4 vs 4gb ddr4
huh?
I litterally bought datalix and didnt use it because it performed so bad 👀
this one
owh wow that is awesome as well
im using it for my main server atm since my hetzner one finally died after 2 years (python upgrade broke the network)
imo galaxygate is literally nearing the end of the rat race, why are they not taking matters to make the cost lower and therefore the prices lower,?
everyone i know has switched away from that stupid provider
I think they just have good location
their ping to EU cant be outmatched because of location
yeah that's true
they're right next to an internet exchange for EU.
So its 1 or 2 hops
i can't lie sometimes datalix just starts tweaking.
I login to the vps and then out of nowhere the actual vps, not my ssh client, starts freezing lmao
owh damn i did not know
but i mean does that really even matter if their services are offline every week?
I havent had downtime since the last ddos
But yeah its not great :/
I dont get why they've been targeted so much
I did, 2x. They sent an email saying that my vps was affected by a server change or whatever
yeah
it's really strange.
The discord api is in a constant state of ping looping, so discord has made discord bots under 10k servers to restart ex amount a times per 2 hours.
thank god for high availability ^-^
wrong gif
I have not heard of this before
thats what ive been told
I don’t keep up with discord api stuff but that doesn’t sound right
Restart is the improper term here. You mean reidentify to the gateway. This absolutely does not require a process restart and negatively impacts you as it counts towards the identify limit of 1000 per day while resumes do not count
Yeah I was gonna say
yeah, thats what I was going to ask.
Your gateway library should already have resuming logic implemented and if not, switch immediately
im using djs
They definitely have resuming
Yeah if your process is restarting constantly, something is wrong with your code, that’s not a discord requirement.
Either that or your hardware is super unreliable
thats funny Oliver was on for a week and i never restarted it past week until the self restart happen
I don’t know what you mean by “self restart”
Probably pm2 restarting the script
You should never have to restart your app for anything to work unless you bump your dependencies or change core logic you can't hot reload with something like heatsync on npm
it been restarting itself past 24 hours
selfless plug
Respect
nah i already check that
no errors
or well voiding
but either way it hasnt restarted itself since 9am this morning
You sure your VPS is reliable?
using novonode
💀
No outages or anything reported?
no
imma fact check this guy right now
Are you lurking without saying hi??
And also are you actually checking the pm2 logs or are you just looking at the VPS
nah Its not your servers
Its weird to think about it
why tf is restart itself when its been up for a week
My bot ain't crashing also on novo so not novo probably
I'd be willing to bet it's crashing somehow somewhere
I was at school
Or that
💀
I didnt have my laptop
Go look at your pm2 logs
Thats when it started having erros
true
Those is the standard output tho
only errors ive been getting when shards die and it trys to post to topgg api
CD into the ~/.pm2/logs dir and do ls
I honestly don't think vanilla pm2 has a command to see only errors. It's a weird little thing
And better yet do ls -l
Would shards dying not be the interesting thing here?
pm2 logs ERR --lines 150
pm2 logs defaults to OUT iirc hence Webster's screenshot shoting bot-out.log
if he did ERR it might show error
or better again pm2 logs all --lines 150 will show all output
10 bucks says it’s a promise rejection
I don't think pm2 works like that
Oh shoot. Almost been 1 month since my last dependency bump update
It would yell at me that there's no program called "ERR"
he right Family
Wtf
Stg I tried that
Go to your logs directory and list the files
My money is on promise rejection
noonewillcare-log
We're betting?
y’all would rather trust pm2 commands to work properly than use a damn linux command 😠
idk why he's egoing you on the ls in the logs dir 😭
lowkey i trust Dylan more
bro 😭
Trust both
Brother
remember when you ran rm -rf because Tim said it in here
BROTHER he setup my server
shut
We don't interact with the raw system. We use wrappers like a boss 
The ls command has existed since the dawn of fucking OSes
fr
Don’t forget the --no-preserve-root
just happen to
too many requests 😭
Damn I was betting on a promise not a ratelimit
Ayyeeee unhandled promise! We win
How tf do you run into a ratelimit on a bot with less than 2k servers
magic
Ah shit it was handled
ill take a look wtf is goin on
jkkk
bully me whatever you want
but
at least we found damn problem
im takin a look of the code
You found the result of the problem, you haven’t found the actual problem yet 😉
wow
Does the error not show the line the error happened?
likly just voiding the error
Ah
this is why you dont void all errors
Honestly this is why you just let exceptions get thrown instead of having a catch all on the process
Yeah
Lmao
I ran into this issue recently. and it was so dumb of me
Not a big fan of how js does errors
yea its too much request
No, the line the error happened on
This doesn’t tell you anything anyways
ye
how many servers
i found the problem
190
ah nvm then 
bro did not find the problem
I had my bot status set to a min Woo said It might be a risk of ratelimiting so I changed that
thats only thing it could be it
status doesnt call gateway
how do i make a ticket system
ye
thats likely why
it calls /gateway/bot for sharding
@warm surge where do you host your bot
VPS or?
if you're using d.js
for every shard it called /gateway/bot
it's stupid and a flaw in d.js afaik
ik
its more common when on repl.it/glitch
im not entirely sure why you're getting that tbh
Hard to guess without seeing the source code or a wider context
its more likely d.js and a configuration issue
Good start might be to not force catch uncaught errors and just let it fail so you get the line the error happened on
Oh I see
discord.js auto retries on error
but then
idk if they're just logging ALL errors lol
regardless of handling
thats why they spawn shards on a timer
not all at once
but yeah, djs's sharding is pretty bad
considering they're subprocesses
they could you know
fetch it on the master shard and transmit to all the others

but that would be too easy 
yeah thats what i used to do
d.js really go for the "simplest" solution huh
Touché
willing to try it if its better value
id probably buy for one month and migrate a few non-important services to see how it runs
it 100% is
and if its stable then sure
Ive been with hetzner for 2+ years
never had an issue
@frosty gale https://www.hetzner.com/cloud/
Cloud servers starting at € 3.79. A little money gets you lots of cloud. Our flexible billing model and clever interface make it easy to use our cloud servers for all your IT needs.
is your vps's server IP on any major blocklists?
https://mxtoolbox.com/blacklists.aspx
need a clean IP reputation as well ideally
not really
non afaik
that doesnt look promising https://www.reddit.com/r/hetzner/comments/1aqk2n6/ip_ranges_blocked/
want me to check any specifically
Uhm
that must be old
I have zero issues
all OK
hmm thats good then
same for my vps
i know galaxygate had similar issues with ip ranges being blocked but theyve started cracking down on abuse so theyre all unbanned now
maybe they did the same
my dblwebhook using shard to send message to my server when someone voted
sorry i was texting my cousin girlfiend
thats likely why then probably
if its only in 190 servers
dont shard
- use webhooks instead of an entire gateway
theres so many better ways to do it
isnt hetzner still blocked by discord's voice servers?
nope
old news afaik
i know the last update was like 4 years ago
but i've never seen any confirmation about the block being removed
eu or us servers?
EU
great.
ah yea
but afaik their US servers are newer than that
they do that
let me guess its the half assed ip thing that oracle does
indeed
Nah they actually verify your ID
they're fairly quick about it
lmao
I asked support why after the 4th
i guess i have european privilege
they stopped it happening again
i meant it probably detects youre potentially "untrusted" based on your ISP
yea more than likely
oracle does that too and they block you without telling you if your ip is blacklisted lmao
im guessing its not an issue for you?
if its ip based, then i have brazilian privilege
i only know because i tried on my work network and it let me register
i can verify my id i just dont like giving it away in strictly unnecessary situations
lmao
tbf, hetzner are fairly chill about it
generally unless you're me apparently its only done once
and they dont store it, simply just to verify you exist
is it also backed by stripe?
great because i signed my account up with the country that i am currently in it is saying my country is incorrect because my passport is not from that country 🤦
has hetzner never heard of immigration
driving license it is then
is it going to tell me to come in person to verify next
only did that cause the first one failed
dw too much
nice and were in
this is what happens when websites use terrible automatic heuristics
Yea
btw its worth mentioning
their VPS are usage based charges
so if its shutdown
you wont get charged for the time its OFF
thats good actually
azure/gcp/aws but cheaper
nice and secure
galaxygate still uses passwords by default lol
although i wont use it because i always disable the root account
ill add the key to my account later
ok
so basically
my click war bot
i have lots of games on there
and they’re all globally registered
but i have checks on certain games that only allows certain UID’s to invoke the command to start them
i’m wanting to implement those certain games as like premium features
best way to go about doing that with just the bot? i don’t have enough experience to create websites or dashboards or anything 😅
unless website and dashboard isn’t too hard to venture into?
@delicate zephyr i keep allocating new ips but theyre all blacklisted lmao
not by majority but mainly by one source
"baracuda"
so im just creating and deleting ips until i get a non-blacklisted one
i’m going to look into this 👀
ok update
so patreon will add users to your server and assign them tier roles
and i can have my bot check the roles for the premium games
another buddy of mine is doing that
he’s breaking it down for me
Yeah, the api responses are a mess with lots of redundant data and confusing structures
Also their cut is very high, best to search for a fairer option
any command ideas for my bible bot?
a command that lets you meet jesus
sorry it's against ToS and law
AI voice of Jesus reading the Bible 
Now with fancy error messages :^)
DID I HEAR RUST
Yes :>

Rust is really nice when you want to write a parser
Isn't this the 4th time you've posted this
No advertising pls
nah its like the 2nd time. i just added auto updates so shared again.
not advertising, its open source. and i only shared it like twice 
It's still advertising even if it's open source
kk gotcha
go to your discord applications dashboard and fill the verification form
i was expecting nothing useful from hetzner support but i was surprised
so this blacklist adds you on just because you dont have a valid reverse dns record?
so most of their ips arent blacklisted after all
it wont let me verify i think im too young
what does it say?
its just id verification im under the required age
wow
afaik you are allowed to ask a parent or family member to do it for you
how old do u have to be
13+ with a guardian
18+ otherwise
damn
ur lower than 13?
nope
oldest discord bot developer
omg 
yea but you can fix that

they literally told you how
love hetzner support
Hi - I’m looking for discord that will give me notifications to my phone when a specific user posts. Any help?
dont know any bot that does that
in fact that'd be quite unsustainable given how many messages a user send
Trying to receive notifications from a specific user when they post on discord
yes, I answered that
discord isn't like reddit or twitter where people post ever so often, people in discord often send dozens of messages per minute
a public bot would easily hit message ratelimit with a single subscribed user
Yes makes sense.. but the people in tracking don’t post that often.
I’ve heard of bots that do this
well, then get those bots
Just trying to figure out where to get it
Came here first to ask
Is there anyone here that could make one
make one no, you'll need to hire someone for that
you can try searching those bots you mentioned on top.gg, just type on the search bar there
but I'm very certain they aren't public, and are constrained to a single channel
And you must remember that you can "track" a user only on the servers where this bot is
I see.. so if it’s not your server, and you can’t get your bot in. It won’t work
Exactly, all "services" that can offer something like this are violating Discord's ToS afaik
dude really wants to spy on someone lmao
is it just me or is github dieing for anyone else?
keep getting rate limit timers and 429 codes
I had issues last night.
I wasnt doing much on github, just checking some files for refrences.
So I'm not sure what was going on.
I was just searching stuff but its basically unusable
I ended up just downloading the repo locally to refer to it.
whats some commands i can add to my bible bot

smite command
invokes the power of jesus to smite someone
...
sorry, that was a bad joke
I mean, there's not much you can add to such a bot
theres bots with it
all i have is /info /verse and /random
idk what to add
Bots with it what?
I said there's not much YOU can add to such a bot, it's literally a book lookup bot
Those 3 cmds are pretty much all you can add without going off the rails
its not necessarily js about the bible ig
christianity relatted
Sorry but christianity is kinda all about the book
Ig you could add a holiday tracker maybe?
Aside from that idk, use a payment service and donate 100% of it to charity?
You'll eventually reach a plateau of features, that's the destiny of all single-focus bots
At that point you just maintain it, basically a finished product
Your bot's users are your best source of feature ideas
i just have on ideas
no*
i added a support feature for suggestions
but my server is empty
besides a bible bot i dont have any ideas for bots
One message removed from a suspended account.
One message removed from a suspended account.
if you're using slash commands, you deploy them to a guild id
for example if you're using discord.js, instead of application.commands, you use guild.commands
i use a different js for each command i just dont know how to make it like this
if you're using discord.js rest, then its Routes.applicationGuildCommands
instead of Routes.applicationCommands
did you follow a specific guide?
i dont get how to do it
i would update my index.js correct?
i just dont get it
hm?
how did you register your existing commands?
did you use Routes.applicationCommands?
sure, post it here if you dont mind
can i send it in dms?
alright
sent
yeah
instead of client.application.commands.set
you can do client.guilds.cache.get(GUILD_ID_HERE).commands.set
that will register a command only for that specific guild
i only want a specific command to do this though
and instead of commandsData you would use the specific command you want to set
so how do i do this
first you need to use a filter to not add that command everywhere
then you can use a find to get only that command
this is what i was showing you in the docs i sent
register your command for the guild instead of globally
you put all your commands inside client.commands
so for each command in client.commands, either add it to the application, or add it to the guild
for example
const globalCommands = [];
const guildCommands = [];
client.commands.forEach(cmd => {
if(command.name === "abc") {
guildCommands.push(cmd);
} else {
globalCommands.push(cmd);
}
});
client.application.commands.set(globalCommands);
client.guilds.cache.get(GUILD_ID_HERE).commands.set(guildCommands);
instead of command.name you can use something else
like add a category to all your commands, or something else
@earnest phoenix
hola!
tim’s helping you out with your command registrations
wait a sec
i wanna be top gg verified!!!
this is why I hate JavaScript 🔥
it's so easy to do that on Python with Discord.py or Nextcord
like where do i even put this
how do i set it up
To start with, I recommend using files, to manage commands, I have a simple template on GitHub to maybe help somehow, it makes it easier to manage commands
You may have the bot, but do you have code already?
If you do, maybe I could incorporate your commands into my template for you
yup!
i already have most of it done
its one thing to fix
Then make a functional bot, and submit it
i do, it’s in 100 servers but for some reason i thought it had to be a verified app to be top gg verified
It doesn't, top.gg is for growing your bot
ah, well let’s get this show on the road.

Why does that give a discord embed
so
look at it and compare it with your own code, and see what you need to change. its basically like building something with lego, its all building blocks that you put together in a logical way. if you still have trouble understanding, it would be wise to learn a bit more about how javascript itself works
The first thing I made in JavaScript and Python was a discord bot, fun fact, I had no prior knowledge beforehand, and now I know both quite well
like if you dont know what .forEach does, and what .push() does, you need to learn about it
yeah its a good experience, but it requires some drive to learn
I learned Python completely on mobile, then JavaScript I used PC for
js is not much different from lua, many concepts are shared accross programming languages
my excuse is im too young!
whenever you see something you dont know what it means or what it does, look it up and try to understand what its going on
age doesnt matter, its the motivation to figure it out that matters
motivation to understand what you dont understand yet
like whne you are in school, you are very good at subjects you like and have interest in
but if you dont like a particular subject and have no motivation to learn it, then you wont be very good at it
You're never too young to learn
Within reason.
im 6
because that motivation drives you to look up and study on your own, not only when someone tells you
You wanna hope that's a joke, or that is a discord ToS issue
its a joke...
well, you never know these days, people lie
i needa figure out this
I could maybe help a little bit, if you need some assistance or guidance with it
im so lost
what could be causing this api latency to be this high?
how can i put that script into mine
this one
please
WAIT
I GOT IT
could u teach me how to implement a database to it
I think u skipped some few too many steps when making ur bot
...
do u wanna see my bot?
I'll pass
k
But try to go back to the fundamentals, you're missing a lot of core concepts
Mozilla has pretty good courses for js
Also codecademy
my bot is done
..
it just needs a database
and ill continue to add on cmds
DM me, I shall help
nop
I tried ¯\_(ツ)_/¯
discord api is wack sometimes
u don even know what my bot is
idc what it is, I'm trying to help you out
its a database to save a ticket number...
also i need to make another command to display a panel
whick idk how to sync with my support cmd
no
To have a "panel" look into using discord buttons
@solemn latch
u realise i have it done already
nvm
Okay ^-^
i need a command to send that panel to a channel for a support channel
sorry for the ping, just suspected spam
So, you wanna run a command, that sends a panel, to a channel?
the same exact panel as a seperate command
which syncs the ticket numbers since there is a ticket maker with the command
or wtv
I'm confused with what you're trying to make
can i send u the link to my server to show u
Are you wanting to save tickets IDs for future reference?
that too
i was thinking that but that is unusually high, especially with no outages
join my support server so i can show u
It's Discord, expect high ping lmao
u can leave after
Send me it in dms
And this is where your programming adventure ends?
no
For what?
Adding a database without need will only waste resources
Then do the courses, improve upon your projects and eventually you'll be proficient in programming
Hey guys i am in need of some help.
I have a bunch of videos and need to use an ai model to categorise the videos.
Creating an ai model capable of that can cost a lot of time training etc.
Suppose that i do want to use that, what models would be the best?
Not only that, but i came with a solution.
What if i transcribe the video (aka extract the text from the video) and use that in a more simple model.
That's how summaries of videos are done cheaply (using subtitles)
enjoy using 16 terawatts of electricity each video you feed it lmao
hire a company in silicon valley to train rats to be able to identify video categories through reinforcement learning
youve already got a good idea
thats about as good as it can get without going overkill
but transcribing audio even on half decent gpu hardware is still quite expensive computationally
i see
Thank you very much
I think that is indeed the best
I could use chatgpt for sure
and just parse strings to it asking to clasify it
But would rather want to use my own implementation
is there a node module i can install to create a translator command? or is that an api thing?
api thing
you can technically use google translate module, but it's just a wrapper to gtranslate api
there's also yandex, in case you want to avoid google
both are paid btw
I think bing has a free API module, of some sort, doesn't require a URL or key and it's 100% free
bing can barely get correct results, I doubt they'd properly translate slightly long sentences
hm
looks ok only piece of advice is to avoid using tokio async mutexes if youre not going to be holding a lock across awaits/overly blocking code
they have a bit of a performance penalty and a standard mutex would be faster but wouldnt bother fixing that
oh right yeah
its probably because of this
still holds the lock as you call db.query and rust native mutex no no like working across threads
looks pretty good! but rs let queue = app.queue.clone(); let db = app.influxdb.clone(); let hourly = tokio_schedule::every(1).minute().perform(move || { let queue = queue.clone(); let db = db.clone(); i believe you can just pass app as it's already an Arc here, so you don't have to pass two Arcs across threads
true although that will probably be optimized out anyways
unnecessary clones are common in rust so i would imagine thats on a focus list of things to optimize
hey guys
i am learning about stacks and memory in c
suppose i have this:
int main(){
function_call():
return 0;
}
how can i know an estimate of how much memory function_call uses on the stack?
cuz some ppl told me to print a variable pointer before and right after the function call, but it does not make any sense?
all local variables of main are added to the stack BEFORE we call function_call..
here's an AI response.
You're right to question that method - printing variable pointers before and after the function call won't give you an accurate measure of the stack usage for function_call(). Let me explain why and provide a better approach.
The stack grows downwards in memory on most systems. When you enter main(), space for its local variables is allocated on the stack. Then, when you call function_call(), additional space is allocated on the stack for this function's frame.
To estimate the stack usage of function_call(), you need to measure the difference in the stack pointer before and after the function call. Here's a way to do this in C:
#include <stdio.h>
void function_call() {
// Your function implementation here
}
int main() {
void* stack_pointer_before;
void* stack_pointer_after;
// Get stack pointer before function call
asm volatile ("mov %%rsp, %0" : "=r" (stack_pointer_before));
function_call();
// Get stack pointer after function call
asm volatile ("mov %%rsp, %0" : "=r" (stack_pointer_after));
// Calculate and print the difference
printf("Approximate stack usage: %ld bytes\n",
(char*)stack_pointer_before - (char*)stack_pointer_after);
return 0;
}```
ehh thanks..
i instead used this.
i knew what the code looked like, so i continously decreased the pointer in memory untill i reached the last local variable of the 2nd function
Assuming a stack looks like this
chatgpt and c+assembly do not go well
it has poopoo training on both
unsafe code detected
do you want the maximum stack memory a function will use? stack use will fluctuate as the function runs
in general the compiler will allocate space on the stack for variables that will live during the entire function call on the top and from there other variables are allocated and freed as the compiler sees as the most optimized approach
the only way i can really see you getting a half decent estimate is to output the function as assembly and then count the stack increments/decrements
hahahha
yeah
it is supposed t be unsafe in this code tho
the best person to ask this question is the compiler but there generally isnt a good use case for this
i need help with an error
i have lots of errors i need help with too its ok
I don't have errors I have "Uncaught fatal exception"
i have my commands in seperate js files. if i use one to fetch a channel or role how can i save it for use in other commands
Most libraries operate on cache, i.e. informations such as channels, users, roles and so on are stored in memory until restart
So you fetch a given channel once and it is available in the cache without having to fetch it a second time
like i use a select menu to fetch a chanel and im using a seperate command to send an embed to that channel
how would i do that
You probably need a database
why u fetch instead of get? (if fetched already)
Fetch (at least in discord.js) checks the cache first
why?
I'm not entirely sure what you want to do, but a database is a good idea in 99% of situations (unless you want to store everything in memory and lose it after a restart)
i was just planning in saying on mmemory
are you fine with your bot forgetting that channel whenever you restart it?
in my bot it shows a slash command that was deleted. how do i remove?
help
sync
@solemn latch
slash commands are saved inside discord's servers
you create one by running a piece of code that sends it and stores it in there, to remove it from there you must run another piece of code to request for deletion
for example client.commands.delete(commandID)
can i send u my scripts for some help
it just shows a command that doesnt exist
and when u type it it shows an erorr
error
so idk whats up
as i said, you need to run the delete code to remove it
slash commands are independent from the bot program, they are stored inside discord's servers, even if your bot is turned off
im so confused
discord has a database of commands
when you create a command, it will be stored in discord's database
tim is right
even if your bot is off, the command is still in discord's database, and will still show up for people
of course, when peple run the command, the bot has to be on, or the command will fail
at some point you added that command
once added, it will stay there forever, until you remove it
sometimes you need restart or clear cache on discord to see the command ^
how do i remove it then
by running a code to request deletion from discord's database
like client.commands.delete(commandID)
how do i get the command id
you only need to run that code once, you dont need to keep it in your bot's code
you can see all command ids by console.log(client.commands)
you can run it in node's repl
for example, if you type node without any file.js, it will enter repl mode
where you can run code by typing in real time
where do i put console.log(client.commands)
for example inside the ready event
if you're not gonna use repl mode
the ids should be inside the object
so you need to map
ah
im so confused
put console.log(client.commands) in your ready.js
index.js?
ok
wait do you have ready.js?
^
i dont
@earnest phoenix
can i send u my script to fix this
im just lost
nani
const replayed = shard.sessionInfo.sequence - shard.closeSequence; will work for replays events when shard is Resume?
@quartz kindle
Logged in as Xorvian#8654!
Collection(1) [Map] {
'host' => {
data: SlashCommandBuilder {
options: [Array],
name: 'host',
name_localizations: undefined,
description: 'Start a Mag Game or Lob Game',
description_localizations: undefined,
contexts: undefined,
default_permission: undefined,
default_member_permissions: undefined,
dm_permission: undefined,
integration_types: undefined,
nsfw: undefined
},
execute: [AsyncFunction: execute],
buttonHandler: [AsyncFunction: buttonHandler]
}
}
this is what shows
i dont know where the other command is from
it shows this
perhaps you added it as a guild command?
i dont believe so
if so it should show up in client.guilds.cache.get(YOURGUILDID).commands
what do i do
not sure, afaik the sequence is reset when resuming, but i dont remember
i looked at my code and the way i do it is to count the number of events in between hello and resumed
@quartz kindle check dms
alright, Ill check when it resumes might take while so ill slide in dms to let you know
you see where you have this:
client.once(Events.ClientReady, () => {
console.log(`Logged in as ${client.user.tag}!`);
});
in there put the code that deletes all commands
what code
for example
client.once(Events.ClientReady, () => {
console.log(`Logged in as ${client.user.tag}!`);
client.guilds.cache.get(YOURGUILDID).commands.set([]) // delete all guild commands
});
run the bot once with that, then close the bot, and remove that line again
that code only needs to be run once
ReferenceError: YOURGUILDID is not defined
at Client.<anonymous> (/home/runner/Xorvian-Bot/index.js:34:29)
at Object.onceWrapper (node:events:634:26)
at Client.emit (node:events:519:28)
at WebSocketManager.triggerClientReady (/home/runner/Xorvian-Bot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:381:17)
at WebSocketManager.checkShardsReady (/home/runner/Xorvian-Bot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:364:10)
at WebSocketShard.<anonymous> (/home/runner/Xorvian-Bot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:194:16)
at WebSocketShard.emit (node:events:519:28)
at WebSocketShard.checkReady (/home/runner/Xorvian-Bot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:184:12)
at WebSocketShard.gotGuild (/home/runner/Xorvian-Bot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:158:10)
at WebSocketManager.<anonymous> (/home/runner/Xorvian-Bot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:234:15)
Node.js v20.16.0
i dont have a guild id in the bot
i know
you have a guild that is your support server right? and you created a guild command there
i dont
1
and you're sure you never created a guild command?
i havent
in any case run that code anyway
i might just remake the bot
Btw why we call it guild instead of server?
thats how the api calls them lol
true but discord could use client.servers.cache.get
you could if you wanna make your own lib
but the api itself will always call them guilds
so lib devs prefer to keep the same nomenclature

whenever i do the extra command it says this
No command matching setup was found.
bro
what is wrong with my bot
restart/update your discord app
well you could always try fetching the commands from discord's database
and see if it shows up
await client.commands.fetch() for global commands
await client.guilds.cache.get(YOUR GUILD ID HERE).commands.fetch() for guild-only commands
console.log() each of those inside your Ready event
how can i host a replit bot 24/7
Replit has been blocking any means of hosting bots 24/7 on its platform for a very long time
They really don't like it and that's not the purpose of this platform I guess
is there any way to download it and host it for free
You can probably download the code or you can simply copy it. As for free hosting, there are services that offer such a thing but they have quite significant disadvantages
I've never used replit but they probably thought about the option to download the code
like whar
what
What disadvantages or what services?
In the dijkstra algorithm, is it still possible to change the distance of a certain vertex if it had already been dequeud (so explored)?
Dijkstra involves exploring every possible path at some point or another, so you will likely pass over the vertex more than once iirc
(So I think that means yes?)
Hi is there any website or application which I code node js canvas there and it shows the output live?
i see, why do people say that negative edges don't work with dijkstra then?
these mfs say that dijkstra doesn't reconsider a node once it marks it as visited?
I’d have to look back in my discrete math notes to tell you for sure
there are many
although its browser canvas, not node canvas, but they are 99% the same
tnx also how can I set a custom font in canvas?
https://i.imgur.com/tnaIwF9.png I register new fonts
https://i.imgur.com/lSw4j1V.png I use the fonts
https://i.imgur.com/XIddRzC.png but result still dont use them
registerFont must be used before creating any canvas

