#development
1 messages · Page 97 of 1
a normal for is the fastest
I always thought for of being faster
Well, no, but why?
well
Im wondering why you want to use setTImeout in a cron job
i have this issue i can't figure out
my cron jobs keep getting messed up
like they offsetting
it should do it x:05 but does it at x:06
etc
etc
Cron is usually extremely precise
and goes more and more offset
Perhaps your computer clock is off
at least node cron isn't duplicating my jobs like node schedule but this issue is very annoying
wew
how do i turn it on
Me when empty loop bodies are undefined behavior:
Perhaps because jit can't fiddle with it as freely as forof?
Since it’s a method call it’s probably not able to optimize as much I would assume
forEach invokes a callback on every iteration
something similar to for(const item of a) { (item => {})() }
Ah
I’m saying your clock is offset not literally off
Your local PC’s time probably isn’t as precise as the server’s time
then fucks up after a day or two
do u get a msg from discord?
What are u even doing inside the cron?
no
And at what rate is it scheduled?
every 5 minutes
is it really in 75 servers?
how do you create this cron job?
do you use a cron library?
:^)
that number is approximate, not exact
Wasn't it 76+?
its exact as long as its not over 100k no?
its not exact for me, and im on ~10k
sucks to suck /s
Try adding it to one more server
Also tim you have a bot in 10k servers?
inb4 he gets hit with the artificial growth slap in the face
imma wait till another server adds it
ah yes, create a server, add it, and get denied for unnatural growth :^)
yeah this
yet you wont finish your astrology api
ye

sooooooooooo
At this point ima just look at the stars myself
Astrology api? If tim adds a "what phase is the moon in" I'd use the hell out of it
my 10k bot uses the old version of the astrology api
since it still works
i just let it be
lmao
is there a alternative to node cron
I'd just have to go back to the jurassic era to not have any pollution in the sky to see the stars clear enough
pretty trivial to add
Issue ain't the library most likely
😵💫
Show how u created ur cronjob
tru
Honestly tim should just use chatgpt in his api
I do use a library for that currently, the calculations were too confusing to me
So what is updateTrackers
it could also be whatever is in that function
trackers
No shit sherlock
lemme
Show what ur doing inside it
My god this guy is as dumb as a box of nails
ill send the file
updateTrackers sounds like a very api-heavy task
You could be getting ratelimited to some extent if it uses a lot of api requests
no
nothing in my logs indicate that
or it could be taking so long to complete that it doesn't until 1 minute later than its scheduled time 
Heavy processing might hang cron yeah
thats the purpose of the setTimeout to prevent rate limiting
no way
well, an offline library is probably better for that than a rest api, although the api will be more precise
theres like 80 trackers
four per second
takes like 20 seconds
lemme just send
the code
one moment
Hence…why it gets slower every day…
I snapshot the phase once per day so... 
how
Just kidding btw, the library is enough for what I use it for
It's basically a quantity/rarity multiplier for cards and drops
haha cool
I wanted to make a tcg back in the day
then I gave up once canvas was too confusing and didn't wanna bother

can i send 60 lines of code here
sure
ok
in a pastebin
or some other kind of bin
one moment
I need to optimize my renderer, it's taking 2 seconds per frame
Tbh, the delay is kinda good because it prevents spam
But it bothers me
Actually, 1s per frame
The other second is packing and sending to discord
man will get it to render at .5s per frame
Lmao
here's the code of the updatetrackers function https://pastebin.com/6pcDHpFB
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.
My renderer works at 0.00007s per frame 🧌
prevent spam by using 100% cpu :^)
(It renders a rectangle at 14,000 FPS)
It's surprisingly not taking much cpu time, it's just slow
Plus it'd decrease by 10 fold if I could use jpeg instead of png
But oh well, transparency
if your idea was to add a 250ms delay between each tracker update, thats not how you do it
why not
you're currently waiting 250ms then updating all trackers at once anyway
how
setTimeout does not interrupt forEach
setTimeout only starts a timer, does not pause anything else
bruh
setTimeout just runs a callback after a certain amount of time has elapsed
a forEach cannot be delayed
There's the promise-based sleep
use a for(...of) with async await
😵💫
Wouldn’t go very well in a forEach
What'd happen?
Not entirely sure, I just know you’re not meant to make async callbacks to iterative functions like that for some reason
forEach encapsulates everything into a callback function
so if you have 100 items, you execute 100 functions
so even if you use async await, it will only affect the inside of the function scope
Ah
is this right for await (const tracker of trackers)
uh no
bruh
Btw, u don't need to declare a variable for each tracker value
for(const tracker of trackers) {
// do something
await new Promise(r => setTimeout(r, 250))
}
I see
ok
And if (something === undefined) can be translated to if (!something) in your case
there are also async timers in nodejs, which are already promisified for you
so if (!channel)?
Since ur just checking if the value exists
Oh wait, oh wait
How...how didn't I notice this?
notice what
is that bad
nah, just a tiny waste of resources
how many
microseconds
0
The code isn't the worst I saw around here, but most of it is redundant
Bae flashbacks
xD
🥰
If they’re redundant then they’re useless
all my code has comments
There's nothing wrong with it, it's just odd
Wonder how long your resolve will go
Your code will soon be between you and your religious (or lack thereof) figure of choice
I gave up even on git commits long time ago
🤨
most of my code has 0 comments lel
i will remove the comments
except jsdoc comments which im using quite a lot lately
No no, keep them
I comment something if I know I made the design for a reason
Nothing wrong with them
Just saying at some point we all get lazy lol
And/or write more understandable code from just looking at it
Wonder if the "commiter" job exists
Like, someone who's sole purpose is to write commits
does he have to read someone else's code to understand what it does ?
I guess, but that could be solved with pair programming
one codes, the other writes notes?
Yep
i've never actually had a job, so i have no idea how coding in teams looks like lol
and i have no idea what all those concepts like agile mean
In my workplace we just use github
Like, each programmer has its own module, whenever we go outside our modules we need to grab the latest file version with the other module's programmer
Usually ignoring git entirely cuz they didn't finish their part yet
xD
Surprisingly works, we rarely need to steer away from our modules
That said, I'm in a separate project, having to deal with an api made in delphi and an app made in react
Oh well
jesus
It'd not be half as bad if the former maintainer knew what "reusability" meant
All fucking screens are inside two-file folders, and every file is named index.js
Working with programming is nowhere as enjoyable as programming as hobby, but it has its perks
Namely money
It's pretty much this
This is pretty much how we work on Node.js, and other projects within the OpenJS Foundation, it's pretty fun and much simpler to go off of
Here's a better one
so i assume you can actually only verify your bot at 76 guilds, right?
Discord will only send you the verification system message when your bot surpasses the 75 guild count, so it's sent at 76 guilds
so, yes?
Yes 
Not exactly, the logical NOT operator (!) checks for all falsy values, which are false, null, undefined, 0, and ''
Basically it looks for more than just 0, it's better to just directly compare to the value you expect instead of shortening them
i see, thanks
also, if anyone knows, with better sqlite if I were to do database.prepare(`SELECT * FROM table WHERE id = '...';`).get(); and there were no results, is it suppose to return undefined.
The documentation should tell you that
true

If the statement was successful but found no data, undefined is returned. If execution of the statement fails, an Error is thrown.
found the answer 😵💫 z
Just a tip, always use explicit columns instead of *
Unless u absolutely need all columns
For sqlite it might not matter much since it's fast, but it's a good habit to have
so, would that be like database.prepare(`SELECT (column1, column2, ...) FROM table WHERE id = '...';`).get();
Without the parentheses
where
Run it and the error will tell you where
id = '...';?
don't u need to have them if it's a string
oh parentheses
i'm stupid ☠️
i see
why though
how can I add a property to process with typescript?
I mean intellisense, not literally a property
you'd have to cast it
Dont think there are any libraries as they require a virtual driver maybe try a virtual usb device
No idea
Maybe this repo can help https://github.com/lcgamboa/USBIP-Virtual-USB-Device
Seems really outdated tho
If you ask a question someone might be able to help
i was writing
today after 14 the slash command of my bot no longer work
I tried hard to fixare, as long as trying it on my pc I got these errors
my bot never had problems like this
I also tried to put back an old backup and update configs but it gives me the same thing
That should help
thanks
You're welcome
I’m trying to fix it but it won’t work, maybe this error can help you
But this has nothing to do with the previous error
The previous one was related to the database and here is just a bad webhook token
this essentially means mongoose is not connected properly
i have no idea why mongoose even lets you run stuff without being connected, but for some reason it does
this is only a test
this one means your webhook token is invalid, as it says in the error
it still says invalid webhook token tho
What is this webhook?
now it doesn't
👍
i don't know, i have so many webhooks
this one is coming from your interactionCreate.js line 18
yes
Is it possible that this is related to not responding to the interaction within 3 seconds?
Because after 3 seconds the token is deleted, that would explain why it is inavlid
i don't know
now i will check with my devs team
usually in that case the error is "unknown interaction"
no
Could you show the code of the command that could cause such an error?
anyone know any good and free ChatBot API ? 👀
OpenAI isn't free
Quality = price I guess although I've never understood this interest in AI
You can have paid but good or free but not so good
This rule probably applies to most things
Yes and I wont pay for a free feature in my bot
then you wont get the feature ¯_(ツ)_/¯
there are plenty of free AIs out there but you are likely to need to train them yourself in many cases
yeah
chatbots are very resource intensive, nobody will give u a free pre-trained bot with unlimited calls
except training your own AI will take thousands of GPU hours which will in turn cost you thousands of dollars
is running a GPU for 10 thousand hours really free
if you assume the GPU uses 400 W = 0.400 kW • 10 000 h = 4 000 kWh • 0.10 ¢/kWh = $400
and chances are you're using your 200 W gaming GPU
oowhhhh now i understand
that was late
so for example this.size will give me the size of the current object i used the method on, but super(size) will give me the size of the superclass object?
i had lectures all day, my bad and i completely forgot about it
no
super(...) is calling the superclass constructor
what's a constructor?
the same way that this(...) will call the current class' constructor
public TheClass() {
...
}
the constructor is the method called when u do new TheClass()
so anything inside the constructor is called on instantiation time
meaning u can assign final constants or do some setup
huh wait hold on, isn't this super, and this exactly what i said here?
like super.size would give us the size of the superclass object right
^
is that like the way to use super when handling with multiple variables?
the same way u can do new TheClass("steve", 12, true)
when you extend a class you need to call its constructor if it doesn't have a zero-arg constructor
public class ClassA {
public ClassA(String name) {
}
}
public class ClassB extends ClassA {
public ClassB() {
super("default"); // <-- required because parent class has no zero-arg constructor
}
}
this isn't a java thing btw, all languages that support inheritance also require calling superclass constructor
it's just that whatever-typed languages like js simply default the arguments to undefined
owh i see so for example this constructor:
if we now create a new object of type parent and we for example use new Parent(1) it will system.out?
and this will basically create a new object of type Super, with the given variables?
then the class belonging to super prob also has a custom constructor that already sets the data of the object? Like:
Bike(frameMaterial, size, color, speed){
this.framematerial = ...
...
}```
no, you're never creating any super
you're just deferring the call to super constructor
but a constructor is the same as the classes' new class() right?
no
new TheClass() CALLS the constructor
because it's constructing an object
imagine it as an object initializer
an automatically called method basically
no object can ever be created without going first through the constructor
ah i see okay, thank you!
I will read more about it online because i still don't get the super() tbh, like the this. and super. were clear but those fucking () are hard to understand tbh
sigh
you're confusing it because you're thinking it's any different to a function
void doStuffA(String name) {
...
}
void doStuffB() {
doStuffA("default");
}
doStuffB(); // automatically calls doStuffA("default")
@eternal osprey
this is LITERALLY what it's doing
So if we call doStuffB() it will in fact perform the method of doStuffA?
for example:
public void method1(int size, int weight){
super(size,weight);
will actually perform the function of super?
}
oowhh wait is it a thing to seperate methods from a superclass and subclass?
Imagine i have 2 classes with the same method name: setSize()
public class ClassA {
public ClassA(String name) {
System.out.println(name);
}
}
public class ClassB extends ClassA {
public ClassB() {
super("default"); // <-- required because parent class has no zero-arg constructor
}
}
new ClassB()
will print "default"
even tho ClassB doesn't print it, its parent does
hold on, so basically super() allows us to actually perform a method of the superclass, while invoking our own method?
i think i get it now!
]
and with the super keyword we can actually perform methods on a superclasse's object!
The super keyword is literally just a pointer to the extended class, calling super() will call the extended class' constructor, meanwhile super.foo() will call the extended class' foo() method
yeah, the thing is... i don't know what a constructor is, or does when we use super()
like do we create a new superclass object or..?
A constructor is the function that initializes a value, for example:
public class Foo {
public Foo(String bar) { // the constructor
System.out.println(bar);
}
}
You see a class named Foo, but it has a method named the exact same as the class, that's the constructor, which is what sets up the class when you do new Foo()
Though it differs on how constructors are declared in other programming languages, that example I showed is Java, but here's the same thing in JavaScript:
class Foo {
constructor(bar) { // the constructor, obviously
console.log(bar);
}
}
owhhhhh
When you call super(), it calls the extended class' constructor, which is required to initialize the class you've made as well
so imagine we have
2 classes, one subclass, other one is superclass.|
class superclass{
public superclass(int size, int weigt){
this.size = size;
this.weight = weight;
}
}
class subclass extends superclass{
int type;
public subclass(int size, int weight, int idk){
super(size, weight);
this.type = 1;
}
}```
Use a codeblock
so if we use new subclass() we will create a new object subclass and assign it's type to 1, and we will simultaneously also create a new superclass object with the given size and weight?
am i correct?
You can't even use the super keyword in subclass because it doesn't extend a class
owh yeah i know
forgot that
but would the idea/reasoning of my explanation be correct?
The extended class (superclass) is initialized before your class (subclass), but the explanation is correct
Though I'm saying this because you're calling super() first
The extended class won't be initialized until you call super()
owh where should i put the super() then?
Wherever you need to initialize the extended class, putting it right at the first is absolutely fine
But you can of course do stuff before initializing the extended class, for example:
public class Foo extends Bar {
public Foo(String bar) {
// Do stuff before initializing the extended class
String something = getStringFromSomeFunction() + bar;
super(something); // Initialize the extended class (`Bar`) by calling it's constructor and passing a String to it (`something`)
// Do other stuff after initializing the extended class
}
}
ahh i see, so the extended class will be created first, and then the subclass will follow? Makes sense!
tho, the super() is clear now, but the this() would that be the opposite?
so in a superclass if the constructor is called, we can use this() to also call the constructor of the subclass?
Now now, not this
In java you're obligated to have super in the first line of the constructor
It'll refuse to compile otherwise
It's used for deferring the constructor to another constructor
public AClass() {
this("default");
}
public AClass(String name) {
this.name = name;
}
It's mostly used when you want to have more than one constructor
Same works for methods (having many of the same method but with different arguments)
void doStuff(String a, int b, boolean c) {
...
}
void doStuff(String a, int b) {
doStuff(a, b, false);
}
void doStuff(String a) {
doStuff(a, 0);
}
owhh so it's bullshit what i said here
That's the stupidest thing I've seen all day
Not really, it guarantees you respect the hierarchy
Many weird bugs could happen otherwise
That's not the compiler's job, it's not up to the compiler to decide what should be done before extended class initialization
Pretty much no other compiler fails like this
Java usually doesn't allow you to do unsafe operations or things that'd break inheritance
oowh so this() is just used to make sure that when we use new Aclass() with no arguments for example, it will only run this constructor and not the others?
Weird Java semantic, there's usually a very good use for operations before extended class initialization, but eh ¯_(ツ)_/¯
It'll run the arg-less constructor, which will run the other constructor
Like a chain
Super doesn't instantiate the class, it just supplies the required params
The object will only be created when the constructor finishes
I very well know that, doesn't change my point
I've seen people do a lot of stuff before passing things to the super() call
That's why sometimes you see static constructors in java
static TheClass of(BasicParams a) {
// do some processing to get ComplexParams
return new TheClass(params);
}
TheClass(ComplexParams p) {
super(p);
}
Then u do var abc = TheClass.of(...)
Yeah seen that pattern before, though extra steps, but Java so be extra worried about inheritance considering pretty much everything is a class 
Gotta respect the elderly (superclasses) 
Modern JavaScript users seeing var in other programming languages: 😱
I wonder if one day they'll finally put var to rest
Damn browsers not staying up to date smh my head
so i have a message with button,
i want the first one to click get the loot
i have an interaction create event
what i tried:
when clicked remove button
but it dont work like if 2 or more users click it at same time
We most likely won't ever remove var considering the tons of programs using it
any solution?
Why doesn't it work if 2 press?
Same case as the non-strict equality/inequality operators (==/!=)
Any error?
nope
The why doesn't it work?
it gives loot to both
Just filter
Yes, but the important part is that it's doing something else
The prevent both from collecting it you need something to lock it on first click
Like a mutex
Are u storing the drop somewhere?
Like, before collecting
Better to show the code instead
code ^
Don't store which loots were claimed
Store which loots are up to claim
Them right after someone claims it remove from the list
Tho it'll not work if two people click the exact same time
oh
For that you'd need to synchronize the block, which idk if it's possible in js
oh i see thank you
Why did you delete the codeblock I was reading 😠
(Also just don’t do that, it could potentially help someone else in the future with a similar problem even if you don’t realize it)
Love to see people delete their questions
Still don't understand the purpose of doing that but yeah
Seen it quite a lot 
Does js support atomic operations btw?
I don’t see why it would given it’s a single threaded language
js has atomics yes
but they only really have one use case
sharedArrayBuffers
atomic i/o is OS-dependent mostly, but node does expose low level fs operations via fs.open
hey i am back... i had a quick question about overloading, hiding and overriding?
overriding is simply, we have the same method name, parameters but a different body right?
superclass:
public void name(int a){
this.size = a;
}
subclass:
@override
public void name(int a){
System.out.println("heey " + a);
}
overloading is that we have the same name, but a different body and parameters right?
public void name(int a){
this.size = a
}
public void name(int a, int b){
this.size = a;
this.size = b;
}```
Yes
yeye gottem thanks!
overload doesnt mean different bodies
it means different signatures
meaning the function accepts different sets of parameters and may return different values
but the body of the function is just one
Yeah
The body doesn’t matter, just the signature of the function itself
The compiler just needs a way to differentiate between two functions of the same name
🤨 why is trackerName returning as null
What’s that linebreak in your code between the else statement and the console.log
that doesnt look like nothing
not on my server
^^
it looks like you're covering something up
Seems like the only reasonable explanation as to why it’s null
what are you so afraid of, you conspiracy theorist
Also I highly suggest using the curly brackets in else blocks the same way you do with if blocks, since it’s much easier to read
I used to use bracket-less if clauses a lot before, until I had to solve a bug that caused by me not realising it didn't have a body
now I put brackets even in one-liners
same
You didn’t show us the line you blanked out
???
theres no blacked out line
thats just what my visual studio code does when on a line
it makes it dark
That looks very weird
Looked like it was edited
Try putting your else statement in a block
will that do anything tho?
That’s very dark compared to mine, that’s why I was confused
Potentially. The way you wrote that statement is very unconventional so I don’t know what it could cause
Even though I suspect there’s nothing wrong with it
well i'll try that i guess
is this a block {
}
Yes
ok
can you console.log tracker.name?
thats what i thought
tracker.name is "null", not null
its a string
so !== null wont work
it would possibly be a better idea to test for the existance of {data}, depending on what exactly is your goal
yeah
alright
woahhhh part 1 of my issue is fixed
now, what would cause a for of loop to end?
from what i can see, it's stopping after looping over only 4 items.
An unhandled error within the loop body or a break statement
(Or reaching the end of your loop obviously)
Then your collection you’re looping over only has 4 items
no
Would also help if you provided a little code
this is .length on the array
what code would be helpful?
The code related to your problem?
😵💫
getting the array from the db
const trackers = database.prepare('SELECT * FROM trackers').all();```
looping over it
```js
for (const tracker of trackers) {
...
};```
What are you doing inside of the loop
well
h
Also, log the trackers variable
why
Because it’s relevant to your issue…
how do i make a bot
well, ok 🫡
In simplified form,
Learn a programming language of your choice
Pick a discord bot library of your choice for said language after you’ve learned most of the fundamentals
Follow the examples for that library and try to make your own stuff until you get the hang of it
Yes
well i made i made it but how do i get it aproved
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.
submit
they review
you approved
🎉
Submit it to top.gg by going to their website and that link battleless just posted
so, your saying return will end the entire loop, correct?
Yes
ok
It will end the method in fact
i'll look into something else
It transfers control back from the callee to the caller
Aka when you use return in a function, it continues back from wherever it was called
with continue is there anyway to do js if (!channel) return database.prepare(`DELETE FROM trackers WHERE id = '${tracker.id}';`).run(); or would i have to do js if (!channel) { database.prepare(`DELETE FROM trackers WHERE id = '${tracker.id}';`).run(); continue; }
You’d do the latter
what does that mean
The 2nd one
More readable
thank you waffle and tim i appreciate your help 🇼
how to create a bot for my server
did you read what waffle said above?
i did submit it
how are you asking "how to create a bot for my server" but you've already created a bot
⁉️
ok 👌
thats how i got to this server
why are you asking how to create a bot for your server though that has nothing to do with being approved
what would cause the missing access error when editing a voice channel if my bot has the Manage Channels + Connect permissions
The instructions were not clear
no longer being in that guild
ie, the bot was kicked
besides that
maybe not having view channel permission
hmmm, will test that out
That was a terrible question
Are u trying to use image recognition or u already have one running?
Opencv
Never used it, but ik people use opencv
Just note that the "open" family is extremely low level
Can't u just ask for the link and scrap it?
Besides, why don't u simply use valorant api?
All riot games have an api
so you want them to send an image and read the text in the image to get the rank?
If there are sites for global rank there's definitely an api u can use
Also, u can request api keys
If nothing works I'd still recommend scrapping
Leave image recog for the last option
even if you need image recognition, if it has text, use OCR, no need for ai
That's why I suggested opencv
I'm sure there's a better way to do this
Aka using their API instead of image recognition
have you thought about the "opt in" thing being there for a reason...
Honest question regarding #discord-news
What difference does 4 fucking bytes make lol
It actually makes a considerable difference because it expands the amount of information that can be sent, and considering the incredible amount of packets being sent so many times, it gradually helps to optimize and reduce the amount of packets needed to send
But that's if they're trying to optimize, they could also be requiring more information on every packet to properly work
can you access
interaction.message
without messageIntent?
in discord.js
interaction given by interactionCreate event
my bot is taking so much memory, how can I have a control on this 
shut it down
😂
Depends on what your bot needs in order to function. If you don’t need caching of members or messages for example, you can disable those and save on tons of memory
umm, like for some commands it's needed
It also depends on what is actually causing the high memory usage
How many guilds is the bot in and how many members (estimated) does it serve in total? How much RAM is it using?
3k guilds, and it has around 3657704 members (568930 in cache), and it has used 3.8gb ram within the uptime of 46h
That’s quite a lot of cached users so I can see why it’s using that much
Do you cache messages as well? Do you need to have messages cached?
I don't think so there's any need of old messages
If your bot can function entirely on slash commands, you can save a considerable amount of memory without caching any messages (assuming you’re using message intent already)
Member cache is where most of your memory usage is probably going to reside, I’m not sure if there’s a way to change it in djs but in the library I used there was a way to set how long it took before items were removed from the cache
that's the issue, my bot isn't used in slash cmds, 96% is the usage of normal prefix commands
memory sweeper?
like what I can do is, that I can clear the cache, and if I need the details of a member, then I can just fetch it from the client
You can also use chrome’s devtools heap snapshot to look at what’s taking a majority of your memory, or some other memory profiler
Well the whole point of a cache is to reduce the number of API requests you have to make so you avoid ratelimits and reduce latency
the <Client>.users.fetch("id") fetches directly from API, right?
The best way to get rid of excessive ram usage in a bot is to find a way to cache less or ideally not need to cache at all. If your bot needs member data and message data frequently then that’s not really an option, so you might have to deal with some higher memory usage
Yes
(Technically it checks the cache first and then goes to the api if there’s no key match)
ahh
Ideally you’d want to probably convert to interactions, but if that isn’t an option then unfortunately messages will eat a lot of ram
const avatar = await Canvas.loadImage(int.user.displayAvatarURL({
format: "png"
}))
ctx.drawImage(avatar, 1000, 500, 50, 50)
error: unsupported image type
int = interaction given by interactionCreate event
The format option was renamed to extension
oh ty
@lyric mountain hey i had a question, we had to do this for class and I wanted some confirmation before i'll spend a lot of time designing this. I thought about creating an abstract class with the given methods, uninitialized, and then create a new class named newQuestion, extending this abstract class?
but we actually also had to save the objects, could i somehow do that in the abstract class?
like, newQuestion[] test = ...
or am i tripping
Yes u can
As long as the classes have a common ancestry you can always put them together
I'm trying to make a role all command, which will provide the specified role to all the users of the server.
My bot will be ratelimited if I don't make a time gap between every member getting the role, so how much time should I gap in between, so that it doesn't ratelimit my bot
Check discords docs
can't find there 
i believe 1.5 seconds is fine
umm, okay
Hey, How do I fix this footer when the screen size is changing?
this is the normal size
you can just use relative size
like 100% of body
instead of a fixed size
to set a limit on size you can grow / shrink, you can check out clamp
In where?
on media query class?
or non media query class?
non-media
oh still not working
Also just saying it’s A friendly not an friendly
show your current css
CSS Code
.footer{
border-top: 1px black solid;
border-bottom: 1px black solid;
background: rgb(14,0,255);
background: linear-gradient(90deg, rgba(14,0,255,1) 0%, rgba(30,30,143,1) 47%, rgba(21,140,164,1) 100%);
color: white;
font-family: Arial, Helvetica, sans-serif;
padding: 30px;
bottom: 0px;
margin-top: 1000px;
position: relative;
}
footer .contents{
display: flex;
}
footer .contents .left-content{
width: 500px;
margin: 20px;
}
footer .contents .left-content .title{
font-size: 20px;
}
footer .contents .right-content .title{
font-size: 20px;
}
footer .contents .center-content .title{
font-size: 20px;
}
footer .contents .center-content{
width: 500px;
margin: 20px;
display: flex;
flex-direction: column;
}
footer .contents .right-content{
width: 500px;
margin: 20px;
display: flex;
flex-direction: column;
flex-wrap: wrap;
}
footer .contents .right-content .ul{
text-decoration: none;
}
footer .contents .center-content .links{
position: relative;
text-decoration: none;
color: white;
padding: 2px;
transition: 0.5s;
line-height: 25px;
}
footer .contents .center-content .links:hover{
background-color: aqua;
border-radius: 10px;
position: relative;
}
HTML Code
<footer class="footer" id="footer-section">
<div class="contents">
<div class="left-content">
<span class="title">ABOUT US</span>
<br>
<br>
<hr>
<br>
<p style="line-height: 25px;">An Friendly, Powerful, And Discord Bot Dev Comminuty Since Started On <b>01/05/2023</b>. So What are you Waiting For? Come On
And Join With Us And Test Our Discord Bots How There are Good</p>
</div>
<div class="center-content">
<span class="title">LINKS</span>
<br>
<hr style="margin-bottom: 15px;">
<ul class="ul" style="list-style: none; text-align: center; line-height: 29px;">
<li class="links"><a href="" class="links" ><span>Home</span></a></li>
<li class="links"><a href="" class="links" ><span>About</span></a></li>
<li class="links"><a href="" class="links" ><span>News</span></a></li>
<li class="links"><a href="" class="links" ><span>Contact</span></a></li>
</ul>
</div>
<div class="right-content">
<span class="title">CONTACT US</span>
<br>
<div class="contact-info">
<hr style="margin-bottom: 15px;">
<i class="fa-solid fa-house"></i> | Location: Nugegoda, Colombo, Sri Lanka <br><br>
<i class="fa-solid fa-envelope"></i> | kevinbandara0000@gmail.com <br><br>
<i class="fa-solid fa-phone"></i> | 078996770
</div>
</div>
</div>
</footer>
no
Tim the walking and breathing documation
@_@
and your media queries?
does that mean the channels role/member permissions or editing the channel, because those require two different permissions (manage roles and manage channels)
I want to check if my bot can edit the channels name, however, just checking if the bot has Manage Channels doesn’t seem to be enough
because im getting missing access errors
Okay
wanted to know if channel.manageable would be a solution for that ❓
@media screen and (max-width: 600px) {
.topnav a:not(:first-child) {display: none;}
.topnav a.icon {
float: right;
display: block;
}
.footer{
width: 500px;
display: flex;
flex-direction: column;
}
.bottom{
width: 450px;
}
}
@media screen and (max-width: 600px) {
.topnav.responsive {position: relative;}
.topnav.responsive .icon {
position: absolute;
right: 0;
top: 0;
}
.topnav.responsive a {
float: none;
display: block;
text-align: left;
}
}
@media screen and (max-width: 600px) {
footer .contents{
display: flex;
flex-direction: column;
text-align: center;
}
}
Here's the media query
remove the 500px from both the regular footer and the media query footer, instead leave it at width: 100%
wrong message
then you can control the flexbox from footer .contents, for example using justify-content: space-around;
wtf
lol
i swear i clicked on this message
its not the first time, wtf is going on with discord
waiting since 12 days for verification how much more
Should get reviewed soon, it's like 13-14 days waiting time
how can i ignore if a value is null in a if statement
if(!value)
no?
no
i want to ignore if the value is null
in an if statement
so i don't get the typeerror
that's what they showed
no
null is falsy, the inverse of false is true
show some code
why?
LMAO
because you want help, and we cant help if you dont give the slightest context
You won't get help if you don't share your code
whats funny Krypton
You expect to get help, yet don't want to share code
Is it maybe copy pastaed code 
If I were to run if (variable.property.includes('...')) and that property's value is null I would the above error.
I'm asking if it's possible to ignore if it's null so i don't get the error.
use ?.
no
i coded this myself
Minecraft
minecraft?
as huuhaku said, if you use ?. the entire expression is converted to undefined in case of null or undefined.
for example
variable.property?.includes() will return undefined if property is null or undefined, and not proceed with reading includes
i just said how
tell me you don't understand what the error means without saying it
i do
let variable = {};
let a = variable.property.something // error
let b = variable.property?.something // undefined
(slightly)
and would undefined error with .includes?
anything after ?. is canceled
bruh
its a short circuit, its exactly the same as doing this
let a
if(variable.property) { a = variable.property.something }
else { a = undefined }
using your example of if (variable.property.includes('...')) it would be like this:
let a;
if(variable.property) { a = variable.property.includes("...") }
else { a = undefined }
if (a)
the above is shortened to: ```js
if (variable.property?.includes('...'))
or using ternary:
timdocs
timgoat
timotei
if (variable.property?.includes('...'))
is equal to
if (variable.property ? variable.property.includes('...') : undefined)
if only i got paid for this
lmao
so if I had this and it was null
if (variable.property?.includes('...')) {
...
} else {
...
}
it would do the else, right
yes
because it would shortcircuit to undefined, and if(undefined) is falsey
hey guys when you're all rich and famous company owners consider hiring me :^)
🤞
Tim Javascript course when?
how can I prevent this access error? right now i'm using <Channel>.manageable which it seems to get pass / bypass.
I am catching the error, so it really does nothing, but i want to know if there's anyway to check if my bot has access to the channel or not.
is this still about the voice channel thing? what permissions does your bot have?
yes it's related to that
i'm not exactly sure what permissions it has. this is a public bot, which is why i don't really know how to reproduce it.
though, i can check the permissions, give me a second.
try channel.manageable && channel.viewable
🤦
how did i not see that in the docs
thank you again, tim
that'll probably solve it
👍
If I had a user-set variable which the application would enter into the database, how would I go about preventing possible SQL injections?
prepared statements
each lib does them differently, for example better-sqlite3 does them like this db.prepare("... ? ...").get(variable)
yes
sql injections can only happen when you mix variables directly into the sql query, for example using string concatenation
when the lib has functions that separate the query from the variables, it means they are probably using prepared statements internally and should be protected by default
no
ok thx
is the "first row" the entry nearest to the top of the database?
Node version: Undefined
const { Client, Events, GatewayIntentBits } = require("discord.js");
const packageJSON = require("./package.json");
const discordJSVersion = packageJSON.dependencies["discord.js"];
const { token } = require("./config.json");
const clc = require("cli-color")
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
client.once(Events.ClientReady, c => {
console.log(clc.blue("[INFO]"), clc.green("-"), clc.yellow(`Logged in as ${c.user.tag}`));
});
client.once(Events.ClientReady, c => {
console.log(clc.blue("[INFO]"), clc.green("-"), clc.yellow("Server Logged in."));
console.log(clc.blue("[INFO]"), clc.green("-"), clc.yellow(`User ID: ${c.user.id}`))
});
client.once(Events.ClientReady, c => {
console.log(clc.blue("[INFO]"), clc.green("-"), clc.yellow(`Guilds: ${client.guilds.cache.size}`));
console.log(clc.blue("[INFO]"), clc.green("-"), clc.yellow(`Channels: ${client.channels.cache.size}`));
console.log(clc.blue("[INFO]"), clc.green("-"), clc.yellow(`DJS Version: ${discordJSVersion}`));
console.log(clc.blue("[INFO]"), clc.green("-"), clc.yellow(`Node Version: ${process.Version}`));
});
client.login(token);```
It's process.version, not process.Version
why do you have multiple listeners of the same event right next to each other
that is so useless
const { Permissions } = require('discord.js');
const channel = message.channel;
const botPermissions = channel.permissionsFor(message.guild.me);
if (!botPermissions.has(Permissions.FLAGS.SEND_MESSAGES) || !botPermissions.has(Permissions.FLAGS.EMBED_LINKS)) {
message.author.send('I do not have permission to send messages or embeds in this channel/server!');
return;
}
My discord.js-v13 code for logic "if the bot can't send message / embed in a channel (don't care it is missing the server permissions or channel permissions), the bot will DMS a user to announce "
Is my logic and my code right?
Just as small optimization has() can take an array of permissions as you check for both permissions at any time anyways
Also send() is a promise you neither await nor catch
wdym?
So my logic is oke right? It should work and nothing I need to fix right?
Thanks bro for helping me 💖.
Technically yes, except the fact that the method permissionsFor() doesn't exist for DM channels
So once it's DM you can skip the entire check
Will this code work?
> Proceeds to dump the entire source code base for Discord
Short answer would be no
Would be funny if people sent whole ass zips of their projects just to ask if it would work
why not
Does Discord work for you?
yes
stop kidding yourself, it's a buggy and broken mess
lmao
Whenever I'm in a call on mobile and a timer goes off, my mic breaks and I have to restart
people do that sadly
Oh if any change possible, you can suggest it to me :))
Thanks again :))
This kinda reminded me of the guy who was accidentally uploading their entire drive to the npm registry
npm-c:
didnt something like that happen on the node repo? lmao
invalid PRs are funny af
I don't remember something like that happening on the node repo but yeah, the invalid PRs are hilarious
I sometimes read through them
Anyone having problems with when your bot synces app comnands it kicks him offline?
nope, likely something is causing your bot to crash
do you have any error?
Nope, no error, it just goes offline, 2 bots go off, 1 is still on somehow
And this happens when i sync tree on on_ready event
and if you dont sync it, it doesnt go off?
Figured out what it was
It was crashing due to one api being offline and task crashed the whole bot
👍
hi I have a problem with my bot
i want to create a private voice chat when a user enter in a vocal chat
this is my code:
client.on("voiceStateUpdate", (oldMember, newMember) => {
if (newMember.channelId === "1081190849255321680") {
const member = newMember.id
const CChannel = client.guild.channels.create({
name: `🔊 ${member.user.username}'s private'`,
type: ChannelType.GuildVoice,
parent: client.config.privateCategory,
});
member.voice.setChannel(CChannel.id)
client.member.voice.setChannel(CChannel.id)
setInterval(() => {
client.on("voiceStateUpdate", (oldMember, newMember) => {
try {
if(CChannel.members.size === 0){CChannel.delete()};
} catch (err) {return}
return;
})
}, 2000)
}
})
and this is the error:
Uncaught Exception: TypeError: Cannot read properties of undefined (reading 'channels')
oh ok
i have another error when i define guild
Uncaught Exception: TypeError: Cannot read properties of undefined (reading 'channels')
how are u defining guild?
i resolve all the problem, it's not client.guild, but guild
read the docs™️
I have another problem, whit member.voice.setChannel(CChannel.id) it don't move me
i have this error
(Use `node --trace-warnings ...` to show where the warning was created)```
so for this it cannot move me?
no they don't have any connection
the error (that isn't an error, but a warning) is just saying ur using way too many listeners (and should be fixed asap)
ah ok, so why it don't move me? it don't have error
what is CChannel?
name: `🔊 ${member.user.username}'s private`,
type: ChannelType.GuildVoice,
parent: client.config.privateCategory,
});```
don't u need to await that?
anyway, it'd error if u needed
are you sure, 100% sure there's no error in the log?
yes
how can i use await? i don't know how to use it ver well
Oh boi
show the whole code please
then you really need to learn js before attempting a bot
like, I know making a bot is cool and all, but you're shooting in the dark if you have no experience with the language you're using
client.on("voiceStateUpdate", (oldMember, newMember) => {
if (newMember.channelId === "1081190849255321680") {
let guild = client.guilds.cache.get(client.config.guildID);
const id = newMember.id
const member = guild.members.cache.get(id)
const CChannel = guild.channels.create({
name: `🔊 ${member.user.username}'s private`,
type: ChannelType.GuildVoice,
parent: client.config.privateCategory,
});
member.voice.setChannel(CChannel.id)
setInterval(() => {
client.on("voiceStateUpdate", (oldMember, newMember) => {
try {
if(CChannel.members.size === 0){CChannel.delete()};
} catch (err) {return}
return;
})
}, 2000)
}
})
you shouldn't be creating a channel inside a voiceStateUpdate
also, u don't need to get the guild from the cache since any of the params will have the guild as a property, nor member since u already have the member as a param
and this alone will destroy your bot in a matter of minutes
how can i fix?
i don't have any idea how to delete the channel when all the user left
I didn't see this line at first, so it's fine to create a channel if ur creating it only if a member joins a specific vc
that line is also the answer to your original question, probably
you can store the created channels to watch their member count afterwards, and delete when they reach zero
and no, I won't tell you how, you seriously lack programming knowledge, and I advise you to do a few crashcourses to get yourself familiar with it first
Ok, thanks
@lyric mountain how could i go through the source code of an electron .exe
i got a scammers .exe
look at the size of this thing
read from here #general message for extra context
and remember, if ur gonna do it, do in an offline vm
any
you'll be deleting it afterwards anyway
I used windows 10 for mine since it's easy to find
just make sure you isolate the vm, so no matter what malwares won't be able to escape
tho I doubt it'll have any malware to begin with
install 7zip and the plugin I mention there before you lock the vm, else you'll need to reopen connection, which u shouldn't
after ur done fiddling with the source files, simply delete the vm
always was
it's faster, smaller, free (and open-source) and has a ton more compatibility than winrar
can i make .exe's with it like winrar
i make extracting tools
i need it for some projects
the only advantage winrar has is that their proprietary format allows fixing corrupted files sometimes
like auto extracting
exe is a compiled format, not a compressed file
ah, u mean self-extracting exe, not exe as in compiled code
go to settings and disable the connection driver
only for a certain os?
it isn't inside the vm
right now i am downloading some sort of windows 10 light since i got little space on my ssd
it's before you open it (in virtualbox vm settings for example)
should i do that after i install the required tools?
^
thanks.
organization
consider using functions then
instead of creating 3 listeners
You only need one listener, then use a function
const channel = message.channel;
const botPermissions = channel.permissionsFor(message.guild.me);
if (!botPermissions.has(Permissions.FLAGS.SEND_MESSAGES) || !botPermissions.has(Permissions.FLAGS.EMBED_LINKS)) {
message.author.send({
embeds: [
new MessageEmbed()
...
],
});
return;
}
I have test this code, it only work for one time, in the next time of request the log still showing, how do I can solve it
I turn off and restart the bot, the same problem still happening